Commit 96219690 authored by arawankar's avatar arawankar

*Changes made in Leave confirmation and leave Cancellation as per pb code.( pb...

*Changes made in Leave confirmation and leave Cancellation as per pb code.( pb changes incorporated done upto 28th of june)

EmpLeaveCancel.java
EmpLeaveConf.java

*Leave Encashment Confirmation component as per pb code migrated .( pb changes incorporated done upto 28th of june)
LeaveEncashmentConfirmation.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@204061 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0e8f1c27
...@@ -528,7 +528,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -528,7 +528,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(status.equals("C")) //Modified by Anjali R. on [18/07/2019][Start]
//if(status.equals("C"))
if(status.equalsIgnoreCase("C"))
//Modified by Anjali R. on [18/07/2019][End]
{ {
errCode = "VTEMPLVE13"; errCode = "VTEMPLVE13";
break; break;
...@@ -813,16 +816,23 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -813,16 +816,23 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(status.equals("C")) //Modified by Anjali R. on [18/07/2019][Start]
//if(status.equals("C"))
if(status.equalsIgnoreCase("C"))
//Modified by Anjali R. on [18/07/2019][End]
{ {
errCode = "VTEMPLVE13"; errCode = "VTEMPLVE13";
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
break; break;
} }
else if(useFlag.equals("E")) //Modified by Anjali R. on [18/07/2019][Start]
//else if(useFlag.equals("E"))
else if("E".equalsIgnoreCase(useFlag))
{ {
if(status.equals("A")) //if(status.equals("A"))
if("A".equalsIgnoreCase(status))
//Modified by Anjali R. on [18/07/2019][End]
{ {
//Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][Start] //Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][Start]
errCode = "VTEMPLVE21"; errCode = "VTEMPLVE21";
...@@ -926,14 +936,20 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -926,14 +936,20 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][End] //Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][End]
} }
} }
else if(useFlag.equals("L")) //Modified by Anjali R. on [18/07/2019][Start]
//else if(useFlag.equals("L"))
else if(useFlag.equalsIgnoreCase("L"))
//Modified by Anjali R. on [18/07/2019][End]
{ {
errCode = "VTLVE16"; errCode = "VTLVE16";
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
break; break;
} }
else if(useFlag.equals("V") && status.equals("A")) //Modified by Anjali R. on [18/07/2019][Start]
//else if(useFlag.equals("V") && status.equals("A"))
else if(useFlag.equalsIgnoreCase("V") && status.equalsIgnoreCase("A"))
//Modified by Anjali R. on [18/07/2019][End]
{ {
errCode ="VTLVE16"; errCode ="VTLVE16";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -944,7 +960,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -944,7 +960,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt = connectionObject.prepareStatement(sql); pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,empCode); pstmt.setString(1,empCode);
resultSet = pstmt.executeQuery(); resultSet = pstmt.executeQuery();
while(resultSet.next()) //Modified by Anjali r. on [18/07/2019][Start]
//while(resultSet.next())
if(resultSet.next())
//Modified by Anjali r. on [18/07/2019][End]
{ {
empStatus = checkNull(resultSet.getString("status")); empStatus = checkNull(resultSet.getString("status"));
} }
...@@ -958,7 +977,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -958,7 +977,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(empStatus.equals("S")) //Modified by Anjali R. on [18/07/2019][Start]
//if(empStatus.equals("S"))
if(empStatus.equalsIgnoreCase("S"))
//Modified by Anjali R. on [18/07/2019][end]
{ {
errCode = "VTEMPSEP1"; errCode = "VTEMPSEP1";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -1110,14 +1132,18 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -1110,14 +1132,18 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
} }
if(rowsUpdate > 0) if(rowsUpdate > 0)
{ {
//Modified by Anjali R. on [18/07/2019][Start]
if(status.equals("A")) //if(status.equals("A"))
if(status.equalsIgnoreCase("A"))
//Modified by Anjali R. on [18/07/2019][End]
{ {
hmap = cancelLve(tranId , 2 , connectionObject); hmap = cancelLve(tranId , 2 , connectionObject);
if(errCode != null && errCode.trim().length() > 0 &&utilMethod.pos(errCode , "<Errors>") > 0) if(errCode != null && errCode.trim().length() > 0 &&utilMethod.pos(errCode , "<Errors>") > 0)
{ {
break; break;
} }
//Modified by Anjali R.on [03/06/2019][Start]
/*
else else
{ {
noRows = 0; noRows = 0;
...@@ -1146,14 +1172,14 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -1146,14 +1172,14 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
break; break;
}*/ }
if(ediOption > 0 ) if(ediOption > 0 )
{ {
empLveCancel = new StringBuffer(); empLveCancel = new StringBuffer();
/*empLveCancel.dataobject = "d_empleave_cancel_edit"; /*empLveCancel.dataobject = "d_empleave_cancel_edit";
empLveCancel.settransobject(sqlca); empLveCancel.settransobject(sqlca);
empLveCancel.retrieve(tranId); empLveCancel.retrieve(tranId);
*/
if(ediOption == 2) if(ediOption == 2)
{ {
//To be done later on //To be done later on
...@@ -1165,6 +1191,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL ...@@ -1165,6 +1191,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//functionsAdv.nf_create_edi_multi("w_empleave_cancel",empLveCancel.describe("datawindow.syntax") +"\r"+empLveCancel.describe("datawindow.syntax.data"),'E',ediOption, 1, "","","","","",""); //functionsAdv.nf_create_edi_multi("w_empleave_cancel",empLveCancel.describe("datawindow.syntax") +"\r"+empLveCancel.describe("datawindow.syntax.data"),'E',ediOption, 1, "","","","","","");
} }
} }
}*/
//Modified by Anjali R.on [03/06/2019][End]
} }
} }
else if(status.equals("R")) else if(status.equals("R"))
......
...@@ -98,6 +98,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -98,6 +98,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
try try
{ {
retString = confirm( tranId, xtraParams, forcedFlag, 2, conn); retString = confirm( tranId, xtraParams, forcedFlag, 2, conn);
System.out.println("confirm---["+retString+"]");
//Added by varsha V on 03-08-18 for Commit statement //Added by varsha V on 03-08-18 for Commit statement
if(retString.contains("VTSUCC1")) if(retString.contains("VTSUCC1"))
{ {
...@@ -184,9 +185,22 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -184,9 +185,22 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
System.out.println("Calling Post Logic "); System.out.println("Calling Post Logic ");
//retString = postLogic(tranId, tranId, 2, xtraParams, conn); commented and added by Varsha V on 24-Jul-18 //retString = postLogic(tranId, tranId, 2, xtraParams, conn); commented and added by Varsha V on 24-Jul-18
retString = postLogic(tranId, tranId, commitFlag, xtraParams, conn); retString = postLogic(tranId, tranId, commitFlag, xtraParams, conn);
System.out.println("retString--["+retString+"]");
System.out.println("return Error List of Post Logic :: "+this.errList); System.out.println("return Error List of Post Logic ::["+this.errList+"]===this.fldList["+this.fldList+"]");
//Modified by Anjali R. on [03/06/2019][Start]
if (retString != null && retString.trim().length() > 0)
{
if(retString.indexOf("<") > -1)
{
return retString;
}
else
{
errString = itmDBAccess.getErrorString("",retString,this.userId,"",conn);
return errString;
}
}
//Modified by Anjali R. on [03/06/2019][End]
int cnt =0; int cnt =0;
String errorCode = ""; String errorCode = "";
String errFldName = null, errorType = ""; String errFldName = null, errorType = "";
...@@ -196,7 +210,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -196,7 +210,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
for (cnt = 0; cnt < this.errList.size(); cnt++ ) for (cnt = 0; cnt < this.errList.size(); cnt++ )
{ {
errCode = (String)this.errList.get(cnt); errCode = (String)this.errList.get(cnt);
errFldName = (String)this.fldList.get(cnt); if(this.fldList.size() > 0)
{
errFldName = (String)this.fldList.get(cnt);
}
System.out.println("errCode .........."+errCode); System.out.println("errCode .........."+errCode);
/*Modified by Anjali Rawankar on[22/08/2017][Start] /*Modified by Anjali Rawankar on[22/08/2017][Start]
...@@ -373,7 +390,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -373,7 +390,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
break; break;
} }
//else if(leaveApplStatus.equals("C")) //else if(leaveApplStatus.equals("C"))
else if("C".equals(leaveApplStatus)) if("C".equalsIgnoreCase(leaveApplStatus))
{ {
errCode = "VTLVEX1"; errCode = "VTLVEX1";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -382,7 +399,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -382,7 +399,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
break; break;
} }
//else if(leaveApplStatus.equals("A")) //else if(leaveApplStatus.equals("A"))
else if("A".equals(leaveApplStatus)) else if("A".equalsIgnoreCase(leaveApplStatus))
{ {
errCode = "VTEMPLVE3"; errCode = "VTEMPLVE3";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -421,7 +438,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -421,7 +438,8 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
break; break;
} }
noRows = 0; noRows = 0;
if(ruleValidation.equalsIgnoreCase("Y")) //if(ruleValidation.equalsIgnoreCase("Y"))
if("Y".equalsIgnoreCase(ruleValidation))
{ {
errCode = leaveChkGeneral(empCode,lveCode,prdCode,noDays,lveDateFr,lveDateTo,useFlag,tranId,connectionObject); errCode = leaveChkGeneral(empCode,lveCode,prdCode,noDays,lveDateFr,lveDateTo,useFlag,tranId,connectionObject);
isError = false; isError = false;
...@@ -471,7 +489,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -471,7 +489,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
if (balOpt.equalsIgnoreCase("Y")) if ("Y".equalsIgnoreCase(balOpt))//need to change 08042019
{ {
returnValue = 0; returnValue = 0;
allowAdvLeave = "N"; allowAdvLeave = "N";
...@@ -552,6 +570,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -552,6 +570,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
if(noRows == 0) if(noRows == 0)
{ {
System.out.println("VTLVE15---["+256+"]");
errCode= "VTLVE15"; errCode= "VTLVE15";
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
...@@ -575,7 +594,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -575,7 +594,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
returnValue = 0; returnValue = 0;
} }
if ("E".equals(useFlag)) if ("E".equalsIgnoreCase(useFlag))
{ {
if(payrollOrVoucher == null || payrollOrVoucher.trim().length() == 0 || (!("P".equals(payrollOrVoucher)) && !("V".equals(payrollOrVoucher)))) if(payrollOrVoucher == null || payrollOrVoucher.trim().length() == 0 || (!("P".equals(payrollOrVoucher)) && !("V".equals(payrollOrVoucher))))
{ {
...@@ -585,7 +604,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -585,7 +604,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
else if("P".equals(payrollOrVoucher)) else if("P".equalsIgnoreCase(payrollOrVoucher))
{ {
if(payrollPeriod == null || payrollPeriod.trim().length() == 0) if(payrollPeriod == null || payrollPeriod.trim().length() == 0)
{ {
...@@ -636,6 +655,100 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -636,6 +655,100 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
isError = true; isError = true;
} }
//Modified by Anjali R. on [03/06/2019][Start]
if ("P".equalsIgnoreCase(payrollOrVoucher))
{
String lsEncPrd = "";
if(payrollPeriod == null ||payrollPeriod.trim().length() == 0 )
{
sql = "select max(prd_code) from payroll where emp_code = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsEncPrd = rs.getString(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lsEncPrd != null && lsEncPrd.trim().length() > 0)
{
sql = "select to_date from period where code = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, lsEncPrd);
rs = pstmt.executeQuery();
if(rs.next())
{
sysDate = rs.getTimestamp("to_date");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(sysDate != null)
{
sysDate = utilMethod.dateTime(utilMethod.RelativeDate(utilMethod.date(sysDate) , 1),utilMethod.stringToTime("00:00"));
}
}
else
{
sysDate = utilMethod.dateTime(utilMethod.today() , utilMethod.stringToTime("00:00"));
}
sql = "select code from period where ? between fr_date and to_date";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate);
rs = pstmt.executeQuery();
if(rs.next())
{
lsEncPrd = rs.getString("code");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lsEncPrd == null || lsEncPrd.trim().length() == 0)
{
errCode = "VTPRDNDF";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
payrollPeriod = lsEncPrd;
}
}
LeaveEncashmentConfirmation leaveEncConf = new LeaveEncashmentConfirmation();
errCode = leaveEncConf.leavesApprove(tranId, 2, payrollOrVoucher, payrollPeriod, xtraParams, "",connectionObject);
System.out.println("Returning from LeaveEncashmentConfirmation--["+errCode+"]");
if (errCode != null && errCode.trim().length() > 0)
{
isError = true;
}
//Modified by Anjali R. on [03/06/2019][End]
} }
else else
{ {
...@@ -653,11 +766,11 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -653,11 +766,11 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
errCode = ""; errCode = "";
} }
else /*else
{ {
errCode = "ERROR"; errCode = "ERROR";
}*/
} }
}
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -707,7 +820,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -707,7 +820,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
boEmpleave.this.lveRuleList.put("check_max_time_allow",(boolean)this.lveRuleList.get("check_max_time_allow")) ; boEmpleave.this.lveRuleList.put("check_max_time_allow",(boolean)this.lveRuleList.get("check_max_time_allow")) ;
boEmpleave.this.lveRuleList.put("allow_update_negative_leave",(boolean)this.lveRuleList.get("allow_update_negative_leave")) ; boEmpleave.this.lveRuleList.put("allow_update_negative_leave",(boolean)this.lveRuleList.get("allow_update_negative_leave")) ;
*/ */
returnValue = boEmpleave.checkNegAdvLveRules(leaveDom, allowAdvleave, workSite,cadre,grade,lveTable, "C",this.lveRuleList, conn); //Modified by Anjali R. on [03/06/2019][Start]
//returnValue = boEmpleave.checkNegAdvLveRules(leaveDom, allowAdvleave, workSite,cadre,grade,lveTable, "C",this.lveRuleList, conn);
returnValue = boEmpleave.checkNegAdvLveRules(allowAdvleave, workSite,cadre,grade,lveTable, "C",this.lveRuleList, conn);
//Modified by Anjali R. on [03/06/2019][End]
HashMap retHMap = boEmpleave.getClassVariables(); HashMap retHMap = boEmpleave.getClassVariables();
if( returnValue == -9 ) if( returnValue == -9 )
{ {
...@@ -918,6 +1034,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -918,6 +1034,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
if(noRows == 0) if(noRows == 0)
{ {
System.out.println("VTLVE15---["+135456+"]");
errCode = "VTLVE15"; errCode = "VTLVE15";
fldName = "emp_code"; fldName = "emp_code";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -948,6 +1065,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -948,6 +1065,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
if(noRows == 0) if(noRows == 0)
{ {
System.out.println("VTLVE15---["+197797+"]");
errCode = "VTLVE15"; errCode = "VTLVE15";
fldName = "emp_code"; fldName = "emp_code";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -1215,6 +1333,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -1215,6 +1333,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
}
else if(utilMethod.left(lveFrMth , 4).equals("ERR~t")) else if(utilMethod.left(lveFrMth , 4).equals("ERR~t"))
{ {
errCode = utilMethod.mid(lveFrMth , 5); errCode = utilMethod.mid(lveFrMth , 5);
...@@ -1223,7 +1342,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -1223,7 +1342,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
}
lveToMth = admCommon.getAdmEnv(workSite ,cadre ,grade ,"LVE_TOMTH" , mlveDt,connectionObject); lveToMth = admCommon.getAdmEnv(workSite ,cadre ,grade ,"LVE_TOMTH" , mlveDt,connectionObject);
if(lveToMth == null || lveToMth.trim().length() == 0 || lveToMth.indexOf("NULLFOUND") > 0) if(lveToMth == null || lveToMth.trim().length() == 0 || lveToMth.indexOf("NULLFOUND") > 0)
{ {
...@@ -3364,7 +3483,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3364,7 +3483,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
private String leavesRule11(String confOrProbe,String empCode,String lveCode,double noDays,double noDaysInMonth,java.sql.Timestamp lvedtFr,java.sql.Timestamp lvedtTo, Connection connectionObject) throws RemoteException,ITMException private String leavesRule11(String confOrProbe,String empCode,String lveCode,double noDays,double noDaysInMonth,java.sql.Timestamp lvedtFr,java.sql.Timestamp lvedtTo, Connection connectionObject) throws RemoteException,ITMException
{ {
System.out.println("=================Inside leavesRule11 Method============");
String errCode = "",period = ""; String errCode = "",period = "";
double noDays1 = 0,days = 0; double noDays1 = 0,days = 0;
boolean isError = false; boolean isError = false;
...@@ -3388,8 +3507,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3388,8 +3507,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
resultSet = pstmt.executeQuery(); resultSet = pstmt.executeQuery();
while(resultSet.next()) while(resultSet.next())
{ {
period = resultSet.getString(""); //Modified by Anjali R. on [18/07/2019][Start]
//period = resultSet.getString("");
period = resultSet.getString("CODE");
//Modified by Anjali R. on [18/07/2019][End]
toDate = resultSet.getTimestamp("TO_DATE"); toDate = resultSet.getTimestamp("TO_DATE");
} }
...@@ -3411,7 +3532,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3411,7 +3532,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
else else
{ {
days = days - utilMethod.DaysAfter(lvedtTo, toDate); //Modified by Anjali R. on [25/05/2019][Start]
//days = days - utilMethod.DaysAfter(lvedtTo, toDate);
days = days - utilMethod.DaysAfter(utilMethod.date(lvedtTo), utilMethod.date(toDate));
//Modified by Anjali R. on [25/05/2019][End]
} }
do do
{ {
...@@ -3455,7 +3579,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3455,7 +3579,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
break; break;
} }
tempDate = utilMethod.dateTime(utilMethod.RelativeDate(toDate, 1)); //Modified by Anjali R. on [25/05/2019][Start]
//tempDate = utilMethod.dateTime(utilMethod.RelativeDate(toDate, 1));
tempDate = utilMethod.dateTime(utilMethod.RelativeDate(utilMethod.date(toDate), 1));
//Modified by Anjali R. on [25/05/2019][End]
} }
while((tempDate.before(lvedtTo)) || (tempDate.equals(lvedtTo))); while((tempDate.before(lvedtTo)) || (tempDate.equals(lvedtTo)));
} }
...@@ -3489,6 +3616,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3489,6 +3616,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
errCode = ""; errCode = "";
} }
System.out.println("=================Returning from leavesRule11 Method============["+errCode+"]");
return errCode; return errCode;
} }
...@@ -3534,8 +3662,20 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3534,8 +3662,20 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
//$$$$$$$$$$$$$$$$$$$$$ END $$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$ END $$$$$$$$$$$$$$$$$$$$$$$$$$
Timestamp detFrDate = null, detToDate = null; Timestamp detFrDate = null, detToDate = null;
// Modified by Piyush on 12/01/2018 [To update no of days considering weekly off/holidays as perleave rules. Sun CCF No: IT2016-073 - Request ID: A16ISUN003].Start
double lihwdays = 0;
String lsstarttemp = "B" , lsendtemp = "E";
EmpLeaveIC empLeave = null;
// Modified by Piyush on 12/01/2018 [To update no of days considering weekly off/holidays as perleave rules. Sun CCF No: IT2016-073 - Request ID: A16ISUN003].End
// Modified by Anjali R. on 11/06/2019 [To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][Start]
double lcLveSumTotdays = 0.0;
// Modified by Anjali R. on 11/06/2019 [To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][End]
try try
{ {
empLeave = new EmpLeaveIC();
System.out.println("================Inside Leaves approve=============="); System.out.println("================Inside Leaves approve==============");
//connectionObject = getConnection(); //connectionObject = getConnection();
chgTime = utilMethod.dateTime(utilMethod.todaySqlDate(),utilMethod.now()); chgTime = utilMethod.dateTime(utilMethod.todaySqlDate(),utilMethod.now());
...@@ -3690,8 +3830,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3690,8 +3830,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
break; break;
} }
} }
System.out.println("========errCd=====["+errCd+"]");
noRows = 0; noRows = 0;
if(errCd.trim().length() > 0) if(errCd !=null && errCd.trim().length() > 0)
{ {
errCode = "VTDATE5"; errCode = "VTDATE5";
this.errList.add(errCode); this.errList.add(errCode);
...@@ -3730,7 +3872,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -3730,7 +3872,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
//Modified by Anjali Rawankar on[20/09/2017][Start] //Modified by Anjali Rawankar on[20/09/2017][Start]
//if(balOpt.equals("Y")) //if(balOpt.equals("Y"))
if(balOpt.equalsIgnoreCase("Y")) if("Y".equalsIgnoreCase(balOpt))
//Modified by Anjali Rawankar on[20/09/2017][End] //Modified by Anjali Rawankar on[20/09/2017][End]
{ {
boolean allowUpdateNegLeave = (Boolean)this.lveRuleList.get("allow_update_negative_leave"); boolean allowUpdateNegLeave = (Boolean)this.lveRuleList.get("allow_update_negative_leave");
...@@ -4193,6 +4335,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4193,6 +4335,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
else else
{ {
System.out.println("Inside ==[4318]");
errCode = "VTEMPLVE4"; errCode = "VTEMPLVE4";
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
...@@ -4202,6 +4345,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4202,6 +4345,7 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
} }
else else
{ {
System.out.println("Inside ==[4328]");
errCode = "VTEMPLVE4"; errCode = "VTEMPLVE4";
this.errList.add(errCode); this.errList.add(errCode);
this.fldList.add(""); this.fldList.add("");
...@@ -4264,7 +4408,12 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4264,7 +4408,12 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
noDays = noDays - 0.5; noDays = noDays - 0.5;
} }
days = days + noDays; //Modified by Anjali R. on [03/06/2019][Start]
if(mDate.equals(mDate2) && "M".equalsIgnoreCase(lveEnd))
{
noDays = noDays - 0.5;
}
/*days = days + noDays;
if(days > mDays) if(days > mDays)
{ {
noDays = noDays - (days - mDays); noDays = noDays - (days - mDays);
...@@ -4272,8 +4421,36 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4272,8 +4421,36 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
noDays = 0; noDays = 0;
} }
}*/
lihwdays = 0;
lsstarttemp = lveStart;
lsendtemp = lveEnd;
if(mDate.after(mDate1))
{
lsstarttemp = "B";
}
if(tempToDt.before(mDate2))
{
lsendtemp = "E";
}
lihwdays = Double.parseDouble( empLeave.gbfGetHwDay(mEmp, mDate, tempToDt, mLveCode, lsstarttemp, lsendtemp, mDate1, mDate2, connectionObject));
System.out.println("lihwdays===["+lihwdays+"]");
if(lihwdays < 0)
{
errCode = "VTLVEHW001";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
noDays = noDays - lihwdays;
if(noDays < 0)
{
noDays = 0;
} }
} }
//Modified by Anjali R. on [03/06/2019][End]
else else
{ {
mDate2 = mDate1; mDate2 = mDate1;
...@@ -4312,6 +4489,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4312,6 +4489,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
isError = true; isError = true;
break; break;
} }
//Modified by Anjali R. on [28/06/2019][To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][Start]
lcLveSumTotdays = lcLveSumTotdays + noDays;
//Modified by Anjali R. on [28/06/2019][To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][End]
if (utilMethod.pos("ELVA" , museFlag) > 0) if (utilMethod.pos("ELVA" , museFlag) > 0)
{ {
break; break;
...@@ -4330,7 +4511,62 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4330,7 +4511,62 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
{ {
break; break;
} }
if(museFlag.equals("V")) //Modified by Anjali R. on [28/06/2019][To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][Start]
if( utilMethod.pos("ELVA" , museFlag) == 0)
{
if (lcLveSumTotdays < mDays)
{
lcLveSumTotdays = mDays - lcLveSumTotdays;
period = "";
sql = "select max(prd_code) as max_period from empleave_summary where tran_id = ? and emp_code = ? and lve_code = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, mEmp);
pstmt.setString(3, mLveCode);
resultSet = pstmt.executeQuery();
if(resultSet.next())
{
period = checkNull(resultSet.getString("max_period"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(period == null || period.trim().length() == 0)
{
errCode = "DS000";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
sql = "update empleave_summary set no_days = no_days + ? where tran_id = ? and emp_code = ? and prd_code = ? and lve_code = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setDouble(1, noDays);
pstmt.setString(2, tranId);
pstmt.setString(3, mEmp);
pstmt.setString(4, period);
pstmt.setString(5, mLveCode);
int cnt = pstmt.executeUpdate();
if(cnt != 1)
{
errCode = "DS000NR";
this.errList.add(errCode);
this.fldList.add("");
isError = true;
break;
}
}
}
//Modified by Anjali R. on [28/06/2019][To track no of days adjusted in summary and balance days to be adjusted as some time weekly offs get changed afterwords][End]
if(museFlag.equalsIgnoreCase("V"))
{ {
sql = ""; sql = "";
sql = "SELECT LVE_CODE__CONVERT FROM LEAVES WHERE LVE_CODE = ?"; sql = "SELECT LVE_CODE__CONVERT FROM LEAVES WHERE LVE_CODE = ?";
...@@ -4578,17 +4814,17 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4578,17 +4814,17 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
if (isError) if (isError)
{ {
System.out.println("If err is true"); System.out.println("If err is true");
errCode = "ERROR"; //errCode = "ERROR";
if (commit == 2) if (commit == 2)
{ {
connectionObject.rollback(); connectionObject.rollback();
} }
} }
else if (commit == 2) /*else if (commit == 2)
{ {
connectionObject.commit(); connectionObject.commit();
errCode = ""; errCode = "";
} }*/
/******************To be done after migrating all component*****************/ /******************To be done after migrating all component*****************/
/*noRows = 0; /*noRows = 0;
sql = ""; sql = "";
...@@ -4664,10 +4900,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4664,10 +4900,10 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
End if End if
destroy nvo_attd_proc destroy nvo_attd_proc
End if End if
End if End if*/
// end for attendance processing // end for attendance processing
// for EDI option // for EDI option
If isnull(ls_errcode) or len(trim(ls_errcode)) = 0 then /*If isnull(ls_errcode) or len(trim(ls_errcode)) = 0 then
select edi_option into :ls_edi_option select edi_option into :ls_edi_option
from transetup from transetup
where tran_window = 'w_empleave'; where tran_window = 'w_empleave';
...@@ -4696,13 +4932,9 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -4696,13 +4932,9 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
'E', ls_edi_option, 1, '', '', '', '', '', '') 'E', ls_edi_option, 1, '', '', '', '', '', '')
End if End if
End if End if
End If End If*/
// end edi // end edi
ls_errcode = gbf_insert_err( ls_errcode , '' )
destroy nvo_aed_functions_adv
*/
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -5085,13 +5317,12 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -5085,13 +5317,12 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
availFrom = dateConf; availFrom = dateConf;
process = confirmed; process = confirmed;
} }
if(availOn.equals("P")) else if(availOn.equals("P"))
{ {
availFrom = probationDate; availFrom = probationDate;
process = probation; process = probation;
} }
else if(availOn.equals("J"))
if(availOn.equals("J"))
{ {
availFrom = dateJoin; availFrom = dateJoin;
process = "Y"; process = "Y";
...@@ -5147,7 +5378,22 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -5147,7 +5378,22 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
lveFrDt1 = utilMethod.dateTime(lveFrDate1); lveFrDt1 = utilMethod.dateTime(lveFrDate1);
lveToDt1 = utilMethod.dateTime(lveToDate1); lveToDt1 = utilMethod.dateTime(lveToDate1);
if(accumulate.equals("Y"))
// Modified by Anjali R on 02/02/2019 [To restrict expiry date till '2034' because of no of months can be more then this].Start
int litempyear = 0;
litempyear = utilMethod.year(utilMethod.date(lveToDt1));
if (litempyear < 100)
{
litempyear = 2000 + litempyear;
}
litempyear = (litempyear * 12);
if(litempyear + accumulateMonths > 24408 )
{
accumulateMonths = 24408 - litempyear;
}
// Modified by Anjali R on 02/02/2019 [To restrict expiry date till '2036' because of no of months can be more then this].End
if("Y".equalsIgnoreCase(accumulate))
{ {
if (accumulateMonths > 0) if (accumulateMonths > 0)
{ {
...@@ -5206,10 +5452,16 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal, ...@@ -5206,10 +5452,16 @@ public class EmpLeaveConf extends ActionHandlerEJB implements EmpLeaveConfLocal,
break; break;
} }
noRows = 0; noRows = 0;
//Modified by Anjali R. on[18/07/2019][Start]
/*sql = "INSERT INTO LEAVEBAL"+
"(EMP_CODE,LVE_CODE,EFF_DATE,UPTO_DATE,EXP_DATE,EDIT_FLAG,AVAIL_DAYS, CONS_DAYS,"+
"ENCH_DAYS,BAL_DAYS,PREV_BAL,ENCASHABLE,ACCT_PRD,CHG_DATE,CHG_USER,CHG_TERM,CONV_DAYS)"+
"VALUES(?,?,?,?,?,'A',0,0,0,0,0,?,?,SYSDATE,?,?,0)";*/
sql = "INSERT INTO LEAVEBAL"+ sql = "INSERT INTO LEAVEBAL"+
"(EMP_CODE,LVE_CODE,EFF_DATE,UPTO_DATE,EXP_DATE,EDIT_FLAG,AVAIL_DAYS, CONS_DAYS,"+ "(EMP_CODE,LVE_CODE,EFF_DATE,UPTO_DATE,EXP_DATE,EDIT_FLAG,AVAIL_DAYS, CONS_DAYS,"+
"ENCH_DAYS,BAL_DAYS,PREV_BAL,ENCASHABLE,ACCT_PRD,CHG_DATE,CHG_USER,CHG_TERM,CONV_DAYS)"+ "ENCH_DAYS,BAL_DAYS,PREV_BAL,ENCASHABLE,ACCT_PRD,CHG_DATE,CHG_USER,CHG_TERM,CONV_DAYS)"+
"VALUES(?,?,?,?,?,'A',0,0,0,0,0,?,?,SYSDATE,?,?,0)"; "VALUES(?,?,?,?,?,'P',0,0,0,0,0,?,?,SYSDATE,?,?,0)";
//Modified by Anjali R. on[18/07/2019][End]
pstmt = connectionObject.prepareStatement(sql); pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,empCode); pstmt.setString(1,empCode);
pstmt.setString(2,lveCode); pstmt.setString(2,lveCode);
......
package ibase.webitm.ejb.adm.adv;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import ibase.planner.utility.ITMException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.TransIDGenerator;
public class LeaveEncashmentConfirmation extends ActionHandlerEJB
{
String userid = "";
String termid = "";
double acenchamt = 0.0;
public String confirm(String tranId, String xtraParams, String forcedFlag)
{
String retString = "";
Connection conn = null;
E12GenericUtility genericUtility = null;
try
{
conn = getConnection();
genericUtility = new E12GenericUtility();
userid = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
termid = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
retString = confirm(tranId,xtraParams,forcedFlag,conn);
if(retString != null && retString.trim().length() > 0)
{
conn.rollback();
}
else
{
conn.commit();
//retString = success string need to be define
}
}
catch(Exception e)
{
}
finally
{
}
return retString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag,Connection conn)
{
String retString = "";
try
{
conn = getConnection();
//retString = leavesApprove(tranId,xtraParams,forcedFlag,conn);
}
catch(Exception e)
{
}
finally
{
}
return retString;
}
public String leavesApprove(String tranId,int aiSaveFlag ,String aspayrollorvoucher ,String aspayrollperiod,String xtraParams, String forcedFlag,Connection conn) throws SQLException, ITMException
{
String retString = "";
String museflag = "", fval1 = "", fval2 = "", mstatus = "", mprd = "", lsbalopt = "", lssite = "", lsperiod = "";
String lsrefno = "" ,lsadcode = "" ,lserrcode = "" , memp = "", mlvecode = "";
String lspayable = "", lsdept = "", lsledgpostconf = "" ,lsedioption = "",lsedioption1 = "";
String lsvar3 = "",lsvar13 = "", lsvar5 = "",lsvar11 = "",lsvar12 = "",lsvar6 = "",lsvar7 = "";
String lsvar14 = "",lsvar9 = "",lsvar10 = "",lsnull = "";
double mbasic = 0.0, mgross = 0.0;
Timestamp fval3 = null, fval4 = null, fval5 = null, mdate3 = null, ldfrdate = null,ldtodate = null;
Timestamp ldvar2 = null,ldvar6 = null , mdate1 = null , mdate2 = null;
Timestamp ldchgtime = null,ldto = null,ldfr = null,mdate= null, lddate = null, ldaprvdate = null,ldconfdate = null;
double lcnvar1 = 0.0, mdays = 0.0, mamt =0.0;
double mcondays = 0.0, menchdays = 0.0, fval6 = 0.0, updbal = 0.0, nextbal = 0.0;
int mcnt = 0 ,litimes = 0;
boolean advflag = false;
double lcnodays = 0.0 , lcdays = 0.0 ,llnodays = 0.0;
Date lddt = null,ldpmdate1 = null, ldpmdate2 = null;
String lsplstart = "", lsplend = "", lserrcd = "",lsleavestart = "", lsleaveend = "" , lsmonthcode = "";
Timestamp ldcfdate = null, ldcfdatelist[] = null, ldeffdate = null;
long llrow = 0;
double lcbaseamt = 0.0;
String lsextraarg = "" ;
Timestamp ldrelieve = null;
String lsempccsal = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql1 = "";
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
String sql2 = "";
PreparedStatement pstmt2 = null;
ResultSet rs2 = null;
String sql3 = "";
PreparedStatement pstmt3 = null;
ResultSet rs3 = null;
String sql4 = "";
PreparedStatement pstmt4 = null;
ResultSet rs4 = null;
String sql5 = "";
PreparedStatement pstmt5 = null;
ResultSet rs5 = null;
UtilMethods utilMethods = null;
ITMDBAccessEJB itmDbAccess = null;
ValidatorEJB validatorEjb = null;
AdmCommon admCommon = null;
HashMap lsvouchData = null;
String entryBy = "";
try
{
utilMethods = new UtilMethods();
itmDbAccess = new ITMDBAccessEJB();
validatorEjb = new ValidatorEJB();
admCommon = new AdmCommon();
ldchgtime = utilMethods.dateTime(utilMethods.today());
mdate3 = utilMethods.dateTime(utilMethods.today());
ldconfdate = utilMethods.dateTime(utilMethods.today());
mamt = 0;
ldcfdate = null;
E12GenericUtility genericUtility = new E12GenericUtility();
userid = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
termid = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
System.out.println("xtraParams-----["+xtraParams+"]");
do
{
System.out.println("150=============================================================================================================");
sql = "select emp_code,lve_code,lve_date_fr,lve_date_to,status, no_days, use_flag, ench_amt, prd_code, aprv_date, case when entry_by is null then 'O' else entry_by end as entry_by from empleave " +
" where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
memp = checkNull(rs.getString("emp_code"));
mlvecode = checkNull(rs.getString("lve_code"));
mdate1 = rs.getTimestamp("lve_date_fr");
mdate2 = rs.getTimestamp("lve_date_to");
mstatus = checkNull(rs.getString("status"));
mdays = rs.getDouble("no_days");
museflag = checkNull(rs.getString("use_flag"));
mamt = rs.getDouble("ench_amt");
mprd = rs.getString("prd_code");
ldaprvdate = rs.getTimestamp("aprv_date");
entryBy = checkNull(rs.getString("entry_by"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("mstatus---["+mstatus+"]");
if("A".equalsIgnoreCase(mstatus))
{
retString = itmDbAccess.getErrorString("", "VTEMPLVE3", "","",conn);
return retString;
}
else if("C".equalsIgnoreCase(mstatus))
{
retString = itmDbAccess.getErrorString("", "VTSTATUS", "","",conn);
return retString;
}
else if(!("E").equalsIgnoreCase(museflag))
{
retString = itmDbAccess.getErrorString("", "VTSTATUS", "","",conn);//wrong method call
return retString;
}
System.out.println("194");
sql = "select payable, bal_opt from leaves where lve_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mlvecode);
rs = pstmt.executeQuery();
if(rs.next())
{
lspayable = checkNull(rs.getString("payable"));
lsbalopt = checkNull(rs.getString("bal_opt"));
}
else
{
retString = itmDbAccess.getErrorString("", "VMLVECD1", "","",conn);
return retString;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on [28/06/2019][Start]
double lcEncashAmt = 0.0;
double lcEncashBaseamt = 0.0;
if( aiSaveFlag == 2)
{
sql = "select code from period where fr_date <= ? and to_date >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, mdate1);
pstmt.setTimestamp(2, mdate1);
rs = pstmt.executeQuery();
if(rs.next())
{
lsperiod = checkNull(rs.getString("code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
String tranIdTemp = "";
tranIdTemp = lsperiod.trim() + ":" + memp.trim() + ":" + mlvecode + ":" + mdays;
/*
PayrollProjEnc payrollProjEnc = new PayrollProjEnc();
retString = payrollProjEnc.confirm(tranIdTemp, xtraParams, forcedFlag,conn);
System.out.println("payrollProjEnc===retString==["+retString+"]");*/
if(entryBy == null || entryBy.trim().length() == 0)
{
PayrollProjEnc payrollProjEnc = new PayrollProjEnc();
retString = payrollProjEnc.confirm(tranIdTemp, xtraParams, forcedFlag,conn);
System.out.println("payrollProjEnc===retString==["+retString+"]");
}
else
{
retString = gbfCalcEnchamt(memp, lsperiod, mlvecode, mdays, conn);
System.out.println("retString=======["+retString+"]");
}
if(retString == null || retString.trim().length() == 0)
{
//if(utilMethods.pos(retString, "<ench_amt>") > 0)
//{
/*retString = utilMethods.mid(retString , utilMethods.pos(retString , "<ench_amt>") + 10);
retString = utilMethods.mid(retString , 1 , utilMethods.pos(retString , "</ench_amt>") - 1);
lcEncashAmt = Double.parseDouble(retString);*/
lcEncashAmt = acenchamt;
System.out.println("lcEncashAmt==["+lcEncashAmt+"]");
if(lcEncashAmt <= 0)
{
retString = itmDbAccess.getErrorString("", "VTLVENCH", "","",conn);
return retString;
}
else
{
if(utilMethods.pos(retString, "<base_amt>") > 0)
{
retString = utilMethods.mid(retString , utilMethods.pos(retString , "<base_amt>") + 10);
retString = utilMethods.mid(retString , 1 , utilMethods.pos(retString , "</base_amt>") - 1);
lcEncashBaseamt = Double.parseDouble(retString);
if(lcEncashBaseamt <= 0)
{
retString = itmDbAccess.getErrorString("", "VTLVENCH", "","",conn);
return retString;
}
else
{
retString = "";
}
}
}
/*}
else
{
return retString;
}*/
}
else
{
System.out.println("Inside Else condition..................");
retString = itmDbAccess.getErrorString("", "VTLVENCH", "","",conn);
return retString;
}
}
//Modified by Anjali R. on [28/06/2019][End]
System.out.println("lsbalopt---["+lsbalopt+"]");
if("Y".equalsIgnoreCase(lsbalopt))
{
nextbal = mdays;
sql = "Select emp_code, lve_code,eff_date, upto_date,exp_date, bal_days from leavebal where emp_code = ? " +
"and lve_code = ? and exp_date >= ? order by exp_date";
pstmt = conn.prepareStatement(sql);
sql1 = "select relieve_date from employee where emp_code = ?";
pstmt1 = conn.prepareStatement(sql1);
sql2 = "Update leavebal set bal_days = bal_days - ?, cons_days = cons_days + ?," +
" ench_days = ench_days + ? where emp_code = ? " +
" and lve_code = ? and eff_date = ? and upto_date = ?";
pstmt2 = conn.prepareStatement(sql2);
sql3 = "select count(*) from emplve_trace where tran_id = ? and "
+ " eff_date = ? and upto_date = ? ";
pstmt3 = conn.prepareStatement(sql3);
sql4 = "insert into emplve_trace (tran_id , emp_code, lve_date_fr, lve_date_to, lve_code, eff_date, upto_date, lves_alloc) " +
"values (?, ?, ?, ?, ?, ?, ?, ?) ";
pstmt4 = conn.prepareStatement(sql4);
sql5 = "update emplve_trace set lves_alloc = ? where tran_id = ? and eff_date = ? and upto_date = ?";
pstmt5 = conn.prepareStatement(sql5);
pstmt.setString(1, memp);
pstmt.setString(2, mlvecode);
pstmt.setTimestamp(3, mdate1);
rs = pstmt.executeQuery();
while(rs.next())
{
fval1 = checkNull(rs.getString("emp_code"));
fval2 = checkNull(rs.getString("lve_code"));
fval3 = rs.getTimestamp("eff_date");
fval4 = rs.getTimestamp("upto_date");
fval5 = rs.getTimestamp("exp_date");
fval6 = rs.getDouble("bal_days");
if( fval6 == 0 && (fval3.equals( mdate1 ) || fval3.before( mdate1 )))
{
System.out.println("continue");
continue;
}
pstmt1.setString(1, fval1);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
ldrelieve = rs1.getTimestamp("relieve_date");
}
pstmt1.clearParameters();
if(ldrelieve != null && "E".equalsIgnoreCase(museflag))
{
System.out.println("==========================277========================================");
}
else
{
if( fval3.after(mdate1))
{
break;
}
}
if (fval6 < nextbal )
{
updbal = fval6;
}
else
{
updbal = nextbal;
}
switch(museflag)
{
case "E":
mcondays = 0;
menchdays = updbal;
case "C":
mcondays = updbal;
menchdays = 0;
}
pstmt2.setDouble(1, updbal);
pstmt2.setDouble(2,mcondays);
pstmt2.setDouble(3, menchdays);
pstmt2.setString(4, fval1);
pstmt2.setString(5, fval2);
pstmt2.setTimestamp(6, fval3);
pstmt2.setTimestamp(7, fval4);
int cnt = pstmt2.executeUpdate();
System.out.println("Updated cnt--["+cnt+"]");
pstmt2.clearParameters();
if(cnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
pstmt3.setString(1, tranId);
pstmt3.setTimestamp(2, fval3);
pstmt3.setTimestamp(3, fval4);
rs3 = pstmt3.executeQuery();
if(rs3.next())
{
mcnt = rs3.getInt(1);
}
pstmt3.clearParameters();
if(ldcfdate == null )
{
ldcfdate = fval3;
}
if(mcnt == 0)
{
mcnt = 0;
pstmt4.setString(1, tranId);
pstmt4.setString(2, memp);
pstmt4.setTimestamp(3, mdate1);
pstmt4.setTimestamp(4, mdate2);
pstmt4.setString(5, mlvecode);
pstmt4.setTimestamp(6, fval3);
pstmt4.setTimestamp(7, fval4);
pstmt4.setDouble(8, updbal);
mcnt = pstmt4.executeUpdate();
System.out.println("mcnt-inserted emplve_trace--["+mcnt+"]");
pstmt4.clearParameters();
if(cnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
}
else
{
mcnt = 0;
pstmt5.setDouble(1, updbal);
pstmt5.setString(2, tranId);
pstmt5.setTimestamp(3, fval3);
pstmt5.setTimestamp(4, fval4);
mcnt = pstmt5.executeUpdate();
System.out.println("mcnt-updated emplve_trace--["+mcnt+"]");
pstmt5.clearParameters();
if(cnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
}
nextbal = nextbal - updbal;
if (nextbal == 0 )
{
break;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if(rs3 != null)
{
rs3.close();
rs3 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(pstmt4 != null)
{
pstmt4.close();
pstmt4 = null;
}
if(pstmt5 != null)
{
pstmt5.close();
pstmt5 = null;
}
if(retString != null && retString.trim().length() > 0)
{
break;
}
else if( nextbal > 0 )
{
retString = itmDbAccess.getErrorString("", "VTEMPLVE4", "","",conn);
return retString;
}
}
if(retString != null && retString.trim().length() > 0)
{
break;
}
mdate = mdate1;
lcdays = 0;
do
{
sql1 = "select code, fr_date, to_date from period where fr_date <= ? and to_date >= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1, mdate);
pstmt1.setTimestamp(2, mdate);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsperiod = checkNull(rs1.getString("code"));
ldfr = rs1.getTimestamp("fr_date");
ldto = rs1.getTimestamp("to_date");
}
else
{
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
retString = itmDbAccess.getErrorString("", "VTPRD1", "","",conn);
return retString;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
mdate2 = mdate1;
mcnt = 0;
sql1 = "insert into empleave_summary (tran_id , emp_code, lve_date_fr, lve_date_to, lve_code, no_days, prd_code,use_flag ) " +
"values(?,?,?,?,?,?,?,?)";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setString(2, memp);
pstmt1.setTimestamp(3, mdate1);
pstmt1.setTimestamp(4, mdate2);
pstmt1.setString(5, mlvecode);
pstmt1.setDouble(6, lcnodays);
pstmt1.setString(7, lsperiod);
pstmt1.setString(8, museflag);
mcnt = pstmt1.executeUpdate();
System.out.println("mcnt inserted empleave_summary --["+ mcnt +"]");
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(mcnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
mdate = utilMethods.dateTime(utilMethods.RelativeDate(utilMethods.date(ldto),1));
break;
}
while(mdate.equals(mdate2) ||mdate.before(mdate2));
System.out.println("retString--["+retString+"]");
if(retString != null && retString.trim().length() > 0)
{
break;
}
if(aiSaveFlag == 2)
{
sql1 = "select code from period where fr_date <= ? and to_date >= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1, mdate1);
pstmt1.setTimestamp(2, mdate1);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsperiod = checkNull(rs1.getString("code"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
int licnttemp = 0;
String lstranidtemp = "";
lstranidtemp = checkNull(lsperiod) + ":" + checkNull(memp) + ":" + mlvecode + ":" + checkNull(String.valueOf(mdays));
sql1 = "select count(1) from Payroll_projdet where prd_code = ? and emp_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, lsperiod);
pstmt1.setString(2, memp);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
licnttemp = rs1.getInt(1);
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(licnttemp == 0)
{
//Projection part migrated to be later
/*nvo_bo_pay_proj_enc lo_nvo_bo_pay_proj_enc
lo_nvo_bo_pay_proj_enc = create nvo_bo_pay_proj_enc
ls_errcode = lo_nvo_bo_pay_proj_enc.gbf_post_logic(ls_tran_id_temp , ls_tran_id_temp , 1 , is_extra_arg)
destroy lo_nvo_bo_pay_proj_enc;
if not isnull(ls_errcode) and len(trim(ls_errcode)) > 0 then
if pos(ls_errcode , "<ench_amt>") > 0 then
ls_errcode = mid(ls_errcode , pos(ls_errcode , "<ench_amt>") + 10)
ls_errcode = mid(ls_errcode , 1 , pos(ls_errcode , "</ench_amt>") - 1)
mamt = dec(ls_errcode)
if mamt <= 0 then
ls_errcode = "VTLVENCH~t Amount returned from nvo_bo_pay_proj_enc : " + string(mamt)
else
ls_errcode = ""
end if
end if
else
ls_errcode = "VTLVENCH~t Amount not returned from nvo_bo_pay_proj_enc"
end if*/
PayrollProjEnc payrollProjEnc = new PayrollProjEnc();
retString = payrollProjEnc.confirm(lstranidtemp, xtraParams, forcedFlag,conn);
if(retString != null && retString.trim().length() > 0)
{
if(utilMethods.pos(retString, "<ench_amt>") > 0)
{
retString = utilMethods.mid(retString, utilMethods.pos(retString , "<ench_amt>") + 10);
retString = utilMethods.mid(retString, utilMethods.pos(retString , "</ench_amt>") - 1);
mamt = Double.parseDouble(retString);
if(mamt <= 0)
{
retString = itmDbAccess.getErrorString("", "VTLVENCH", "","",conn);
return retString;
}
else
{
retString = "";
return retString;
}
}
}
else
{
retString = itmDbAccess.getErrorString("", "VTLVENCH", "","",conn);
return retString;
}
}
else
{
retString = gbfCalcEnchamt(memp , lsperiod , mlvecode , mdays , mamt, conn);
System.out.println("retString--["+retString+"]");
}
if(retString != null && retString.trim().length() > 0)
{
break;
}
mamt = lcEncashAmt ;
lcbaseamt = lcEncashBaseamt;
sql1 = "select ad_code__ench from leaves where lve_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, mlvecode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsadcode = checkNull(rs1.getString("ad_code__ench"));
}
else
{
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
retString = itmDbAccess.getErrorString("", "VMLVECD1", "","",conn);
return retString;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(lsadcode == null || lsadcode.trim().length() == 0)
{
retString = itmDbAccess.getErrorString("", "VTENCADN1", "","",conn);
return retString;
}
sql1 = "select acct_code__sal,cctr_code__sal from allwdedn where ad_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, lsadcode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsvar11 = checkNull(rs1.getString("acct_code__sal"));
lsvar12 = checkNull(rs1.getString("cctr_code__sal"));
}
else
{
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
retString = itmDbAccess.getErrorString("", "VTENCADN1", "","",conn);
return retString;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
System.out.println("aspayrollorvoucher---["+aspayrollorvoucher+"]");
if("P".equalsIgnoreCase(aspayrollorvoucher))
{
//lstr_func_return.ls_tranid = "PRD_" + as_payroll_period
lsmonthcode = utilMethods.mid(checkNull(aspayrollperiod),5,2);
sql1 = "select fr_date, to_date from period where code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, aspayrollperiod);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
ldfrdate = rs1.getTimestamp("fr_date");
ldtodate = rs1.getTimestamp("to_date");
}
else
{
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
retString = itmDbAccess.getErrorString("", "VTPRD1", "","",conn);
return retString;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
lsrefno = new SimpleDateFormat ("dd/MM/yyyy").format(ldfrdate) + mlvecode;
System.out.println("lsrefno--["+lsrefno+"]");
sql1 = "select count(*) from employee_mthad where emp_code = ? and month_code = ? "+
"and ad_code = ? and eff_date = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, memp);
pstmt1.setString(2, lsmonthcode);
pstmt1.setString(3, lsadcode);
pstmt1.setTimestamp(4, ldfrdate);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
mcnt = rs1.getInt(1);
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(mcnt == 0)
{
mcnt = 0;
sql1 = "insert into employee_mthad (emp_code,month_code,ad_code,eff_date,exp_date,type,amount,chg_date,chg_user,chg_term,ref_type,ref_no)\n" +
"values(?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, memp);
pstmt1.setString(2, lsmonthcode);
pstmt1.setString(3, lsadcode);
pstmt1.setTimestamp(4, ldfrdate);
pstmt1.setTimestamp(5, ldtodate);
pstmt1.setString(6, "F");
pstmt1.setDouble(7, mamt);
pstmt1.setTimestamp(8, ldchgtime);
pstmt1.setString(9, userid);
//pstmt1.setString(10, termid);
pstmt1.setString(10, userid);
pstmt1.setString(11, "E");
pstmt1.setString(12, lsrefno);
mcnt = pstmt1.executeUpdate();
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
System.out.println("Inserted ["+ mcnt +"] rows in employee_mthad table.");
if(mcnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
}
else
{
sql = "update employee_mthad set ref_type = 'E' , ref_no = :ls_ref_no,type = 'F', amount = amount + :mamt " +
"where emp_code = :memp and month_code = :ls_monthcode and ad_code = :ls_ad_code and eff_date = :ld_fr_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsrefno);
pstmt.setDouble(2, mamt);
pstmt.setString(3, memp);
pstmt.setString(4, lsmonthcode);
pstmt.setString(5, lsadcode);
pstmt.setTimestamp(6, ldfrdate);
mcnt = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Inserted ["+ mcnt +"] rows in employee_mthad table.");
if(mcnt != 1)
{
retString = itmDbAccess.getErrorString("", "DS000NR", "","",conn);
return retString;
}
}
}
else if("V".equalsIgnoreCase(aspayrollorvoucher))
{
ldvar2 = mdate3;
sql1 = "select ledg_post_conf from transetup where upper(tran_window) = 'W_EMPLEAVE'";
pstmt1 = conn.prepareStatement(sql1);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsledgpostconf = checkNull(rs1.getString("ledg_post_conf"));
}
else
{
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
retString = itmDbAccess.getErrorString("", "VTSEQ", "","",conn);
return retString;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
String lsErrorCode = "";
mcnt = 0;
sql1 = "select work_site from employee where emp_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, memp);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
mcnt++;
lssite = checkNull(rs1.getString("work_site"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(mcnt > 0)
{
lsErrorCode = validatorEjb.nfCheckPeriod("ADM", ldvar2, lssite, conn);
if(lsErrorCode == null || lsErrorCode.trim().length() == 0)
{
sql1 = "select site_code__acct from site where site_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, lssite);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lssite = checkNull(rs1.getString("site_code__acct"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
lsErrorCode = validatorEjb.nfCheckPeriod("FIN", ldvar2, lssite ,conn);
}
if(lsErrorCode != null && lsErrorCode.trim().length() > 0)
{
retString = itmDbAccess.getErrorString("", lsErrorCode, "","",conn);
return retString;
}
}
ldvar6 = ldvar2;
lsvar3 = memp;
lcnvar1 = mamt;
lsvar13 =lsadcode;
lsvar5 = "";
sql1 = "select employee.pay_site, site.fin_entity, dept_code , employee.bank_code, employee.pay_mode,employee.cctr_code__sal " +
" from employee, site where employee.emp_code = ? and employee.pay_site = site.site_code";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, memp);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsvar6 = checkNull(rs1.getString("pay_site"));
lsvar7 = checkNull(rs1.getString("fin_entity"));
lsdept = checkNull(rs1.getString("dept_code"));
lsvar5 = checkNull(rs1.getString("bank_code"));
lsvar14 = checkNull(rs1.getString("pay_mode"));
lsempccsal = checkNull(rs1.getString("cctr_code__sal"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(lsvar5 == null || lsvar5.trim().length() == 0)
{
lsvar5 = admCommon.getEnv("999999","BANKCODE",conn);
if ((lsvar5 != null && lsvar5.trim().length() > 0) || "NULLFOUND".equalsIgnoreCase(lsvar5))
{
retString = itmDbAccess.getErrorString("", "VSENVVAR1", "","",conn);
return retString;
}
}
if(lsempccsal != null && lsempccsal.trim().length() > 0)
{
lsvar12 = lsempccsal;
}
sql1 = "select acct_code, cctr_code from department where dept_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, lsdept);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
lsvar9 = checkNull(rs1.getString("acct_code"));
lsvar10 = checkNull(rs1.getString("cctr_code"));
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
lsvouchData = new HashMap();
lsvouchData.put("dvar2", ldvar2);
lsvouchData.put("dvar6", ldvar6);
lsvouchData.put("svar2", "LEN");
lsvouchData.put("svar3", lsvar3);
lsvouchData.put("svar4", tranId);
lsvouchData.put("svar5", lsvar5);
lsvouchData.put("svar6", lsvar6);
lsvouchData.put("svar7", lsvar7);
lsvouchData.put("nvar1", lcnvar1);
lsvouchData.put("svar9", lsvar9);
lsvouchData.put("svar10", lsvar10);
lsvouchData.put("svar11", lsvar11);
lsvouchData.put("svar12", lsvar12);
lsvouchData.put("svar13", lsvar13);
lsvouchData.put("svar14", lsvar14);
retString = gbfPayrVouch(lsvouchData,forcedFlag,xtraParams, conn);
if(retString != null && retString.trim().length() > 0)
{
break;
}
}
else
{
lserrcode = "No Processing Done";
System.out.println("No Processing Done");
break;
}
mcnt = 0;
sql1 = "update empleave set status = 'A', ench_amt = ? , status_date = ?,emp_code__aprv = ?, tran_id__payr = ?," +
"aprv_date = ?, base_amt = ? where tran_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setDouble(1, mamt);
pstmt1.setTimestamp(2, mdate3);
pstmt1.setString(3, userid);
pstmt1.setString(4, tranId);
pstmt1.setTimestamp(5, ldchgtime);
pstmt1.setDouble(6, lcbaseamt);
pstmt1.setString(7, tranId);
mcnt = pstmt1.executeUpdate();
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
System.out.println("updated ["+mcnt+"] rows in empleave.");
if(mcnt != 1)
{
retString = itmDbAccess.getErrorString("", "VTPRD1", "","",conn);
return retString;
}
}
else
{
mcnt = 0;
sql1 = "update empleave set status = 'A' where tran_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
mcnt = pstmt1.executeUpdate();
System.out.println("mcnt empleave--["+mcnt+"]");
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(mcnt != 1)
{
retString = itmDbAccess.getErrorString("", "VTPRD1", "","",conn);
return retString;
}
}
break;
}
while(true);
}
catch(Exception e)
{
System.out.println("Exception from leavesApprove --["+e.getMessage()+"]");
throw new ITMException(e);
}
finally
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if(rs3 != null)
{
rs3.close();
rs3 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(pstmt4 != null)
{
pstmt4.close();
pstmt4 = null;
}
if(pstmt5 != null)
{
pstmt5.close();
pstmt5 = null;
}
}
System.out.println("retString FROM LEAVESAPPROVE ENCASHMENT CONFIRMATION--["+retString+"]");
return retString;
}
public String gbfPayrVouch(HashMap payrollVoucherData,String forcedFlag,String xtraParams ,Connection conn) throws ITMException
{
String retString = "";
String mtranid = "", mtrantype = "", mempcode = "", mrefno = "", mbankcode = "",mautopay = "", msitecode = "", mfinentity = "", manalcode = "", mconfirmed = ""
, lssite = "", mpaid = "", macctcodepay = "", mcctrcodepay = "", lssiteac = "", mkeystr = "", lsbatchno = "",
mlineno = "", macctcode = "", mcctrcode = "", madcode = "", lscurr = "", mpaymode = "", lsautopost = "", lserrcode = "";
Timestamp mtrandate = null, meffdate = null, mrefdate = null, mchgdate = null;
double mtotamt = 0.0, lcexch = 0.0, mtotamtbc = 0.0;
String lscadre = "", lsgrade = "" ;
String lsempsite = "" , lspaysite = "" , lsworksite = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
UtilMethods utilMethos = null;
AdmCommon admCommon = null;
ITMDBAccessEJB itmDbAccess = null;
PayrollVoucherConf payrollVoucherConf = null;
try
{
utilMethos = new UtilMethods();
admCommon = new AdmCommon();
itmDbAccess = new ITMDBAccessEJB();
payrollVoucherConf = new PayrollVoucherConf();
sql = "select key_string from transetup where upper(tran_window) = 'W_PAYR_VOUCHER'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mkeystr = checkNull(rs.getString("key_string"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
mtrandate = utilMethos.dateTime(utilMethos.today());
mtrantype = "LEN";
mempcode = " ";
mrefno = " ";
mbankcode = " ";
mautopay = "Y" ;
msitecode = " ";
mfinentity = " ";
mtotamt = 0.00;
mconfirmed = "N";
mpaid = "N";
macctcodepay = " ";
mcctrcodepay = " ";
mlineno = " 1";
macctcode = " ";
mcctrcode = " ";
madcode = " ";
mchgdate = utilMethos.dateTime(utilMethos.today());
E12GenericUtility genericUtility = new E12GenericUtility();
mtrandate = (Timestamp) payrollVoucherData.get("dvar2");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysdatestr = sdf.format(mtrandate);
mtrantype = (String) payrollVoucherData.get("svar2");
meffdate = (Timestamp) payrollVoucherData.get("dvar6");
mempcode = (String) payrollVoucherData.get("svar3");
mrefno = (String) payrollVoucherData.get("svar4");
mrefdate = (Timestamp) payrollVoucherData.get("dvar2");
mbankcode = (String) payrollVoucherData.get("svar5");
mautopay = "Y";
msitecode = (String) payrollVoucherData.get("svar6");
mfinentity = (String) payrollVoucherData.get("svar7");
mtotamt = (double) payrollVoucherData.get("nvar1");
mconfirmed = "N";
mpaid = "N";
macctcodepay = (String) payrollVoucherData.get("svar9");
mcctrcodepay = (String) payrollVoucherData.get("svar10");
mlineno = " 1";
macctcode = (String) payrollVoucherData.get("svar11");
mcctrcode = (String) payrollVoucherData.get("svar12");
madcode = (String) payrollVoucherData.get("svar13");
mpaymode = (String) payrollVoucherData.get("svar14");
lsbatchno = " ";
do
{
sql = "select cadre, grade , emp_site , work_site, pay_site from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mempcode);
rs = pstmt.executeQuery();
if(rs.next())
{
lscadre = checkNull(rs.getString("cadre"));
lsgrade = checkNull(rs.getString("grade"));
lsempsite = checkNull(rs.getString("emp_site"));
lsworksite = checkNull(rs.getString("work_site"));
lspaysite = checkNull(rs.getString("pay_site"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
lsautopost = admCommon.getAdmEnv(msitecode , lscadre , lsgrade , "AUTO_POST" , mtrandate,conn);
if(lsautopost == null || lsautopost.trim().length() == 0 || "NULLFOUND".equalsIgnoreCase(lsautopost))
{
lsautopost = admCommon.getEnv("999999","AUTO_POST",conn);
if(lsautopost == null || lsautopost.trim().length() == 0 || "NULLFOUND".equalsIgnoreCase(lsautopost))
{
lserrcode = itmDbAccess.getErrorString("", "VSENVAR1", "","",conn);
break;
}
}
else if ("ERR".equalsIgnoreCase(utilMethos.left(lsautopost , 4)))
{
lserrcode = utilMethos.mid(lsautopost , 5);
lserrcode = itmDbAccess.getErrorString("", lserrcode, "","",conn);
break;
}
sql = "select site_code__acct from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, msitecode);
rs = pstmt.executeQuery();
if(rs.next())
{
lssiteac = checkNull(rs.getString("site_code__acct"));
}
else
{
lserrcode = itmDbAccess.getErrorString("", "VMPAYSITE", "","",conn);
break;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
mtranid = generateTranId("w_payr_voucher", lssiteac, sysdatestr,lsempsite,conn);
sql = "select curr_code from finent where fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mfinentity);
rs = pstmt.executeQuery();
if(rs.next())
{
lscurr = checkNull(rs.getString("curr_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
sql = "select std_exrt from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lscurr);
rs = pstmt.executeQuery();
if(rs.next())
{
lcexch = rs.getDouble("std_exrt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
mtotamtbc = mtotamt * lcexch;
int cnt = 0;
sql = "insert into payr_voucher (tran_id, tran_date, tran_type, eff_date, " +
" emp_code, ref_no, ref_date, bank_code, auto_pay, pay_mode, " +
" chg_date, chg_user, chg_term, site_code, fin_entity, " +
" anal_code, confirmed, paid, acct_code__pay, cctr_code__pay, " +
" tot_amt, entry_batch_no, vouch_type, curr_code, exch_rate, tot_amt__bc )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'O',?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mtranid);
pstmt.setTimestamp(2, mtrandate);
pstmt.setString(3, mtrantype);
pstmt.setTimestamp(4, meffdate);
pstmt.setString(5, mempcode);
pstmt.setString(6, mrefno);
pstmt.setTimestamp(7, mrefdate);
pstmt.setString(8, mbankcode);
pstmt.setString(9, mautopay);
pstmt.setString(10, mpaymode);
pstmt.setTimestamp(11, mchgdate);
pstmt.setString(12, userid);
//pstmt.setString(13, termid);
pstmt.setString(13, userid);
pstmt.setString(14, lssiteac);
pstmt.setString(15, mfinentity);
pstmt.setString(16, manalcode);
pstmt.setString(17, mconfirmed);
pstmt.setString(18, mpaid);
pstmt.setString(19, macctcodepay);
pstmt.setString(20, mcctrcodepay);
pstmt.setDouble(21, mtotamt);
pstmt.setString(22, lsbatchno);
pstmt.setString(23, lscurr);
pstmt.setDouble(24, lcexch);
pstmt.setDouble(25, mtotamtbc);
cnt = pstmt.executeUpdate();
System.out.println("inserted ["+cnt+"] rows in payr_voucher.");
if(cnt == 1)
{
cnt =0;
sql = "insert into payr_vouchdet (tran_id, line_no, acct_code,cctr_code, amount, ad_code )" +
"values (?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mtranid);
pstmt.setString(2, mlineno);
pstmt.setString(3, macctcode);
pstmt.setString(4, mcctrcode);
pstmt.setDouble(5, mtotamt);
pstmt.setString(6, madcode);
cnt = pstmt.executeUpdate();
System.out.println("inserted ["+cnt+"] rows in payr_vouchdet.");
if(cnt == 1)
{
}
else
{
lserrcode = itmDbAccess.getErrorString("", "DS000", "","",conn);
break;
}
}
else
{
lserrcode = itmDbAccess.getErrorString("", "DS000", "","",conn);
break;
}
if(lserrcode == null || lserrcode.trim().length() == 0 || "Y".equalsIgnoreCase(lsautopost))
{
lserrcode = checkNull(payrollVoucherConf.confirm(mtranid, forcedFlag, xtraParams, conn));
}
}while(true);
}
catch(Exception e)
{
System.out.println("Exception from gbfPayrVouch--["+ e.getMessage() +"]");
throw new ITMException(e);
}
finally
{
}
return lserrcode;
}
public String checkNull(String inputStr) throws ITMException
{
String outputStr = "";
try
{
if(inputStr == null || inputStr.trim().length() == 0)
{
outputStr = "";
}
else
{
outputStr = inputStr.trim();
}
}
catch(Exception e)
{
throw new ITMException(e);
}
return outputStr;
}
public String gbfCalcEnchamt (String asempcode, String asprdcode, String aslvecode, double acnodays, double acench_amt,Connection conn) throws ITMException, SQLException
{
System.out.println("===============================gbfCalcEnchamt=====================================================");
System.out.println("asempcode==["+asempcode+"]asprdcode==["+asprdcode+"]aslvecode==["+aslvecode+"]acnodays==["+acnodays+"]acench_amt===["+acench_amt+"]");
String retString = "";
String lsadcode = "", lsadcode1 = "" , lserrcode = "" , lssite = "", lsgrade = "" , lscadre , lslvetblno = "";
String lsencashable = "", lspropdays = "", lsrndoff = "";
int licnt = 0 , lipropdays = 0;
double lcbaseamt = 0.0 ,lcbase_amt = 0.0, lcrndto = 0.0;
Timestamp lddate = null;
String lslvecon = "";
acenchamt = 0.00;
licnt = 0;
lipropdays = 0;
UtilMethods utilMethod = null;
ITMDBAccessEJB itmdbAccess = null;
AdmCommon admCommon = null;
DistCommon disCommon = null;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean isRecordExist = false;
try
{
utilMethod = new UtilMethods();
itmdbAccess = new ITMDBAccessEJB();
admCommon = new AdmCommon();
disCommon = new DistCommon();
lddate = utilMethod.dateTime(utilMethod.today());
sql = "select work_site , grade , cadre from employee where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, asempcode);
rs = pstmt.executeQuery();
if(rs.next())
{
lssite = checkNull(rs.getString("work_site"));
lsgrade = checkNull(rs.getString("grade"));
lscadre = checkNull(rs.getString("cadre"));
}
else
{
lserrcode = itmdbAccess.getErrorString("", "VTLEVENC01", "","",conn);//Data not found for this employee
return lserrcode;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("lssite==["+lssite+"]lsgrade==["+lsgrade+"]lscadre==["+lscadre+"]");
sql = "select lve_tblno from grade_site_lvetbl where site_code = ? and grade_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lssite);
pstmt.setString(2, lsgrade);
rs = pstmt.executeQuery();
if(rs.next())
{
isRecordExist = true;
lslvetblno = checkNull(rs.getString("lve_tblno"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("lslvetblno==["+lslvetblno+"]isRecordExist==["+isRecordExist+"]");
if(!isRecordExist)
{
isRecordExist = false;
if(lslvetblno == null || lslvetblno.trim().length() == 0)
{
sql = "select lve_tblno from cadre_site_lvetbl where site_code = ? and cadre_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lssite);
pstmt.setString(2, lscadre);
rs = pstmt.executeQuery();
if(rs.next())
{
isRecordExist = true;
lslvetblno = checkNull(rs.getString("lve_tblno"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(!isRecordExist)
{
lserrcode = itmdbAccess.getErrorString("", "VTLEVENC02", "","",conn);//Leave Tale not found for this employee
return lserrcode;
}
System.out.println("1619:isRecordExist==["+isRecordExist+"]lslvetblno==["+lslvetblno+"]");
}
}
sql = "select encashable from lvetable where lve_tblno = ? and lve_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lslvetblno);
pstmt.setString(2, aslvecode);
rs = pstmt.executeQuery();
if(rs.next())
{
lsencashable = checkNull(rs.getString("encashable"));
}
else
{
lserrcode = itmdbAccess.getErrorString("", "VTLEVENC03", "","",conn);//Leave code not defined in leave table
return lserrcode;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("lsencashable===["+lsencashable+"]");
if((lsencashable != null && lsencashable.trim().length() > 0 ) && !"Y".equalsIgnoreCase(lsencashable))
{
lserrcode = itmdbAccess.getErrorString("", "VELVE3", "","",conn);//Leave is not encashable
return lserrcode;
}
lslvecon = checkNull(aslvecode) +"_ENCON";
lsadcode = admCommon.getAdmEnv(lssite , lscadre , lsgrade ,lslvecon ,lddate ,conn);
if(utilMethod.pos(lsadcode, "ERR") > 0 || utilMethod.pos(lsadcode, "NULL") > 0 || lsadcode == null || lsadcode.trim().length() == 0)
{
lsadcode = admCommon.getEnv( "999999" , lslvecon ,conn);
if(lsadcode != null && lsadcode.trim().length() > 0 && "NULLFOUND".equalsIgnoreCase(lsadcode))
{
lsadcode = admCommon.getAdmEnv(lssite , lscadre , lsgrade , "PL_ENCON" ,lddate,conn );
if(utilMethod.pos(lsadcode, "ERR") > 0 || utilMethod.pos(lsadcode, "NULL") > 0 || lsadcode == null || lsadcode.trim().length() == 0)
{
lsadcode = admCommon.getEnv( "999999" , "PL_ENCON" ,conn);
}
}
}
System.out.println("lsadcode==["+lsadcode+"]");
if(lsadcode == null || lsadcode.trim().length() == 0 || "NULLFOUND".equalsIgnoreCase(lsadcode))
{
lserrcode = itmdbAccess.getErrorString("", "VSENVVAL1", "","",conn);//No ad code defined in payroll variable : PL_ENCON/'+as_lvecode +"_ENCON"
return lserrcode;
}
sql = "select count(*) from allwdedn where ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsadcode);
rs = pstmt.executeQuery();
if(rs.next())
{
licnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("licnt==["+licnt+"]");
if(licnt == 0)
{
lserrcode = itmdbAccess.getErrorString("", "VSENVVAL1", "","",conn);//Wrong ad defined in payroll variable: PL_ENCON/"+as_lvecode +"_ENCON
return lserrcode;
}
lslvecon = checkNull(aslvecode) +"_ENC";
lsadcode1 = admCommon.getAdmEnv(lssite , lscadre , lsgrade , lslvecon , lddate , conn);
if(utilMethod.pos(lsadcode1, "ERR") > 0 || utilMethod.pos(lsadcode1, "NULL") > 0 || lsadcode1 == null || lsadcode1.trim().length() == 0)
{
lsadcode1 = admCommon.getEnv( "999999" , lslvecon ,conn);
if(lsadcode1 != null && lsadcode1.trim().length() > 0 && "NULLFOUND".equalsIgnoreCase(lsadcode1))
{
lsadcode1 = admCommon.getAdmEnv(lssite , lscadre , lsgrade , "_ENC" ,lddate,conn );
if(utilMethod.pos(lsadcode1, "ERR") > 0 || utilMethod.pos(lsadcode1, "NULL") > 0 || lsadcode1 == null || lsadcode1.trim().length() == 0)
{
lsadcode1 = admCommon.getEnv( "999999" , "PL_ENC" ,conn);
}
}
}
if(lsadcode1 == null || lsadcode1.trim().length() == 0 || "NULLFOUND".equalsIgnoreCase(lsadcode1))
{
lserrcode = itmdbAccess.getErrorString("", "VSENVVAL1", "","",conn);//No ad code defined in payroll variable : PL_ENCON/'+as_lvecode +"_ENCON"
return lserrcode;
}
sql = "select count(*) from allwdedn where ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsadcode1);
rs = pstmt.executeQuery();
if(rs.next())
{
licnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(licnt == 0)
{
lserrcode = itmdbAccess.getErrorString("", "VSENVVAL1", "","",conn);//Wrong ad defined in payroll variable: PL_ENCON/"+as_lvecode +"_ENCON
return lserrcode;
}
lslvecon = checkNull(aslvecode) +"_PROP";
lspropdays = admCommon.getAdmEnv(lssite , lscadre , lsgrade , lslvecon , lddate , conn);
if(utilMethod.pos(lspropdays, "ERR") > 0 || utilMethod.pos(lspropdays, "NULL") > 0 || lspropdays == null || lspropdays.trim().length() == 0)
{
lspropdays = admCommon.getEnv( "999999" , lslvecon ,conn);
if(lspropdays != null && lspropdays.trim().length() > 0 && "NULLFOUND".equalsIgnoreCase(lspropdays))
{
lspropdays = admCommon.getAdmEnv(lssite , lscadre , lsgrade , "PL_PROP" ,lddate,conn );
if(utilMethod.pos(lspropdays, "ERR") > 0 || utilMethod.pos(lspropdays, "NULL") > 0 || lspropdays == null || lspropdays.trim().length() == 0)
{
lspropdays = admCommon.getEnv( "999999" , "PL_PROP" ,conn);
}
}
}
if(lspropdays == null || lspropdays.trim().length() == 0 || "NULLFOUND".equalsIgnoreCase(lspropdays))
{
lserrcode = itmdbAccess.getErrorString("", "VSENVVAL1", "","",conn);//No ad code defined in payroll variable : PL_ENCON/'+as_lvecode +"_ENCON"
return lserrcode;
}
lipropdays = Integer.parseInt(lspropdays );
sql = "select amount,base_amt from Payroll_projdet"
+ " where prd_code = ? and emp_code = ? and ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, asprdcode);
pstmt.setString(2, asempcode);
pstmt.setString(3, lsadcode);
rs = pstmt.executeQuery();
if(rs.next())
{
lcbaseamt = rs.getDouble("amount");
lcbase_amt = rs.getDouble("base_amt");
}
else
{
lserrcode = itmdbAccess.getErrorString("", "VTLVEENC04", "","",conn);//Payroll Projection not done form Employee code :
return lserrcode;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("lcbaseamt==["+lcbaseamt+"]lcbase_amt==["+lcbase_amt+"]");
if(lcbaseamt <= 0.0)
{
lserrcode = itmdbAccess.getErrorString("", "VTLVENCH", "","",conn);//Calculation is not proper for ad code
return lserrcode;
}
System.out.println("lcbaseamt["+lcbaseamt+"]====acnodays["+acnodays+"]====lipropdays["+lipropdays+"]");
acenchamt = ( lcbaseamt * acnodays ) / lipropdays;
System.out.println("acenchamt==["+acenchamt+"]");
sql = "select rnd_off , rnd_to from allwdedn where ad_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsadcode1);
rs = pstmt.executeQuery();
if(rs.next())
{
lsrndoff = rs.getString("rnd_off");
lcrndto = rs.getDouble("rnd_to");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
System.out.println("lsrndoff==["+lsrndoff+"]lcrndto==["+lcrndto+"]");
acenchamt = getRndamt(acenchamt , lsrndoff , lcrndto);
System.out.println("acenchamt====["+acenchamt+"]");
}
catch(Exception e)
{
System.out.println("Exception from gbfCalcEnchamt--["+e.getMessage()+"]");
throw new ITMException(e);
}
finally
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
System.out.println("retString==::::::1840::::["+retString+"]");
return retString;
}
private String generateTranId( String windowName, String siteCode, String tranDateStr,String empCode ,Connection conn) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
String paySite = "";
String workSite = "";
String empSite = "";
try
{
System.out.println("generateTranId() called...");
selSql = "select emp_site,work_site,pay_site from employee where emp_code = ?";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, empCode );
rs = pstmt.executeQuery();
if (rs.next())
{
empSite = rs.getString("emp_site");
workSite = rs.getString("work_site");
paySite = rs.getString("pay_site");
}
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
if(rs != null)
{
rs.close();
rs=null;
}
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>";
xmlValues = xmlValues + "<emp_site>" + empSite + "</emp_site>";
xmlValues = xmlValues + "<work_site>" + workSite + "</work_site>";
xmlValues = xmlValues + "<pay_site>" + paySite + "</pay_site>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator transIDGenerator = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = transIDGenerator.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception :LeaveEncashmentConfirmation:generateTranId :generateTranId :SQLException ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception :LeaveEncashmentConfirmation:generateTranId :Exception ::" + e.getMessage() + ":");
//Modified by Anjali R. on[19/09/2018][Start]
try
{
conn.rollback();
}
catch (Exception e1)
{
e1.printStackTrace();
System.out.println("Exception from generateTranId class--["+e1.getMessage()+"]");
throw new ITMException(e1);
}
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return tranId;
}
//Modified by Anjali R. on [28/06/2019][][Start]
public String gbfCalcEnchamt (String asEmpCode, String asPrdCode, String asLveCode, double acNodays,Connection conn) throws ITMException
{
System.out.println("=============gbfCalcEnchamt=======================================");
String lsErrcode = "";
double lcBaseAmt = 0.00 ;
double lcEncashAmt = 0.00;
try
{
lsErrcode = gbfCalcEnchamt(asEmpCode, asPrdCode, asLveCode, acNodays, lcEncashAmt,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
lsErrcode = "<?xml version='1.0'?>";
lsErrcode = lsErrcode + "<Detail><ench_amt>" + lcEncashAmt + "</ench_amt>";
lsErrcode = lsErrcode + "<base_amt>" + lcBaseAmt + "</base_amt></Detail></Root>";
}
}
catch(Exception e )
{
throw new ITMException(e);
}
System.out.println("lsErrcode======================================================1977["+lsErrcode+"]");
return lsErrcode;
}
public double getRndamt(double newQty, String round, double roundTo)
{
System.out.println("======================================Inside getRndamt==========================================");
System.out.println("newQty==["+newQty+"]round["+round+"]roundTo=["+roundTo+"]");
double lcMultiply = 1;
try
{
System.out.println("Inside try block19999");
round = round.toUpperCase();
if (newQty < 0)
{
lcMultiply = -1;
newQty = Math.abs(newQty);
}
else if (newQty == 0)
{
System.out.println("Inside 20008");
return newQty;
}
else if (round.trim().equalsIgnoreCase("N"))
{
System.out.println("Inside 2013");
return newQty;
}
else if (roundTo == 0)
{
System.out.println("Inside 2018");
return newQty;
}
if (round.trim().equalsIgnoreCase("X"))
{
newQty = (newQty - (newQty % roundTo) + roundTo);
}
if (round.trim().equalsIgnoreCase("P"))
{
newQty = (newQty - (newQty % roundTo));
}
if (round.trim().equalsIgnoreCase("R"))
{
if ((newQty % roundTo) < (roundTo / 2))
{
newQty = (newQty - (newQty % roundTo));
}
else
{
newQty = (newQty - (newQty % roundTo) + roundTo);
}
}
System.out.println("newQty[" + newQty + "]");
System.out.println("lcMultiply[" + lcMultiply + "]");
newQty = newQty * lcMultiply;
System.out.println("newQty * lcMultiply[" + newQty + "]");
return newQty;
} catch (Exception e) {
System.out.println("Exception :Conversion Qty ::" + e.getMessage()
+ ":");
}
if (roundTo == 1)
{
newQty = getRequiredDecimal(newQty, 0);
}
else if (roundTo == .1)
{
newQty = getRequiredDecimal(newQty, 1);
}
else if (roundTo == .01)
{
newQty = getRequiredDecimal(newQty, 2);
}
else if (roundTo == .001)
{
newQty = getRequiredDecimal(newQty, 3);
}
else if (roundTo == .0001)
{
newQty = getRequiredDecimal(newQty, 4);
}
System.out.println("newQty==["+newQty+"]");
return newQty;
}
public double getRequiredDecimal(double actVal, int prec)
{
System.out.println("==============getRequiredDecimal=======================");
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
Double DoubleValue = new Double(actVal);
numberFormat.setMaximumFractionDigits(3);
String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",", "");
double reqVal = Double.parseDouble(strValue);
System.out.println("reqVal==["+reqVal+"]");
return reqVal;
}
//Modified by Anjali R. on [28/06/2019][][End]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment