Commit 3d6f4c29 authored by ysawant's avatar ysawant

*Added SUN related changes in PerkClaimCancelProcess component

PerkClaimCancelProcess.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@212940 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ba99818d
......@@ -53,8 +53,11 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
Connection conn = null;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
//Added by Yashwant on 29-11-12 [START]
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Added by Yashwant on 29-11-12 [END]
conn.setAutoCommit(false);
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
......@@ -212,6 +215,10 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
int noRowInst = 0;
/* START >> Added by vinay c 11/11/2019 */
boolean checkCancelStatus=false;
/* END >> Added by vinay c 11/11/2019 */
try
{
......@@ -282,15 +289,23 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
//ADDED BY AMIT SHRIVASTAVA ON[A15ISUN003] 30/11/18 TO CONVERT TRAN DATE INTO TIMSTAMP [END].
claimDate = sdf.parse(tranDate);
System.out.println("claimDate >> "+claimDate);
/* START >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
checkCancelStatus=checkCancelStatus(tranId,conn);
/* END >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
if((confirmed.trim().length() >0 && confirmed.trim().equalsIgnoreCase("Y"))
&& (loanAdjamount != null && loanAdjamount >0.0d))
{
errorString = itmDBAccess.getErrorString("", "VPPERKAD1", "");
return errorString;
}
else if(checkCancelStatus) /* START >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
{
errorString = itmDBAccess.getErrorString("", "VTCHKCANC1", "");
return errorString;
} /* END >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
else
{
/* START >> Commented by vinay c 11/11/2019
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
sql="select amt_bal from allowdedn_bal where ad_code = ? for update ";
......@@ -303,19 +318,25 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
{
sql="select amt_bal from allowdedn_bal where ad_code = ? for update nowait ";
}
End */
/* START >> Commented by vinay c 11/11/2019
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, adCode);
rs2 = pstmt.executeQuery();
End*/
/* START >> Commented by vinay c 11/11/2019
if(rs2.next())
{
End */
//Added By Amit Shrivastava on 20/02/19 for declair amtBal variable [start]
/*String amtBal = rs2.getString("amt_bal");*/
amtBal = rs2.getDouble("amt_bal");
//amtBal = rs2.getDouble("amt_bal");// Commented by vinay c 11/11/2019
//Added By Amit Shrivastava on 20/02/19 for declair amtBal variable [end]
/* START >> Commented by vinay c 11/11/2019
System.out.println("@S@ amtBal ["+amtBal+"]");
}
close(pstmt, rs2);
End */
/**If Payroll voucher type is payroll
* will inserted records into tables
* */
......@@ -382,8 +403,26 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
close(pstmt,rs);
System.out.println("count"+count);
/* START >> Added by vinay c 13/11/2019 To validate accounting year */
sql = "select FN_CHECK_ACCOUNTING_YEAR(?,?,?,?,?) as err_code from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, tranId);
pstmt.setString(3, userId);
pstmt.setTimestamp(4, tranDateTimpstamp);
pstmt.setString(5,"PERK_CLAIM_CAN");
rs = pstmt.executeQuery();
if (rs.next())
{
errorString = rs.getString("err_code");
}
close(pstmt, rs);
if(errorString!=null && errorString.trim().length()>0)
{
errString = itmDBAccess.getErrorString("", errorString, "");
return errString;
}
/* END >> Added by vinay c 13/11/2019 To validate accounting year */
if(count > 0)
{
/* START >> Commented by vinay c 03102019
......@@ -392,7 +431,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
END*/
/* START >> Added by vinay c 03102019 To Update change date,change user and change term */
sql = "update employee_mthad set amount = amount + ? ,chg_date=?,chg_user=?,chg_term=? " +
" where emp_code = ? and eff_date = ? and exp_date = ? ";
" where emp_code = ? and eff_date = ? and exp_date = ? and ad_code = ? ";//Added by vinay c 11/11/2019 to add ad_code
System.out.println("@vinay:sql>>"+sql);
/* END >> Added by vinay c 03102019 */
......@@ -411,6 +450,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
pstmt.setString(5,empCode);
pstmt.setTimestamp(6,java.sql.Timestamp.valueOf(fromDate));
pstmt.setTimestamp(7,java.sql.Timestamp.valueOf(toDate));
pstmt.setString(8,pyrlAdclaim);//Added by vinay c 11/11/2019 to add ad_code.
/* END >> Added by vinay c 03102019 */
updateCnt = pstmt.executeUpdate();
if(updateCnt >0)
......@@ -639,25 +679,28 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
payrollPrdValue =checkNull(rs.getString("PRD_CODE__PAYROLL"));
tranDateNew =rs.getDate("TRAN_DATE");
System.out.println("@amit tranDateNew inside without eff>>"+tranDateNew);
sqlUpdateEmpAdClaim = "insert into EMP_ADCLAIM (TRAN_ID,EMP_CODE,AD_CODE,EFF_DATE,BAL_AMT,CLAIM_AMT,LOAN_ADJAMT,PAYROLL_VOUCHER,PRD_CODE__PAYROLL,CHG_DATE,CHG_USER,CHG_TERM,TRAN_DATE)"
+ " Values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
// Added By Amit Shrivastava on 20/02/19 for replace BAL_AMT value with amt_bal[end]
adClaimUpdate = conn.prepareStatement(sqlUpdateEmpAdClaim);
/* START >> Commented by vinay c 14/11/2019
adClaimUpdate.setString(1,checkNull(tranIdNew));
adClaimUpdate.setString(2,checkNull(employeeCode));
adClaimUpdate.setString(3,checkNull(adCodeValue));
adClaimUpdate.setDate(4,(java.sql.Date) effDate);
End */
// Added By Amit Shrivastava on 20/02/19 for replace BAL_AMT value with amt_bal[start]
/*adClaimUpdate.setDouble(5,balAmountValue);*/
/* START >> Commented by vinay c 14/11/2019
adClaimUpdate.setDouble(5,amtBal);
System.out.println("@Amit amtBal>>"+amtBal);
System.out.println("@Amit claimAmountValue Value>>"+claimAmountValue);
adClaimUpdate.setDouble(6,claimAmountValue*(-1));
System.out.println("claimAmountValue*"+claimAmountValue*(-1));
End */
//Added By Amit Shrivastava on 190219 end for change claimAmountValue value into negative calim amount
/* START >> Commented by vinay c 14/11/2019
adClaimUpdate.setDouble(7,loanAdjamountValue);
adClaimUpdate.setString(8,checkNull(payrollVoucherValue));
adClaimUpdate.setString(9,checkNull(payrollPrdValue));
......@@ -665,8 +708,9 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
adClaimUpdate.setString(11,checkNull(userId));
adClaimUpdate.setString(12,checkNull(chgTerm));
adClaimUpdate.setDate(13,tranDateNew);
End */
//Added By Amit Shrivastava on 02/04/19 [end ] for changes for pstmt
/* START >> Commented by vinay c 14/11/2019
updateCnt = adClaimUpdate.executeUpdate();
if(adClaimUpdate != null)
{
......@@ -678,7 +722,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
msgType.append("adclaim");
System.out.println("insert EMP_ADCLAIM with tran Id >> "+ tranIdNew);
}
End */
/**added and modified by vinay chaurasiya for insert new record instead
* of updating the adclaim table for perk claim cancel process date 29/10/18. end*/
sql ="";
......@@ -701,7 +745,51 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
}
System.out.println("Count --["+allWCnt+"]");
close(adAllowBalPstmt,rsAllBal);
/* START >> Added by vinay c 14/11/2019 To get current bal amount from allow deduction balance table */
sql ="";
sql=" select amt_bal from allowdedn_bal where emp_code = ? and ad_code = ? and start_date = ? and end_date = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, adCode);
pstmt.setDate(3, (java.sql.Date) startDate);
pstmt.setDate(4, (java.sql.Date) endDate);
ResultSet vrs=pstmt.executeQuery();
if(vrs.next())
{
amtBal=vrs.getDouble("amt_bal");
System.out.println("@vinay::amtBal >>"+amtBal);
}
close(pstmt,vrs);
/* END >> Added by vinay c 14/11/2019 To get current bal amount from allow deduction balance table */
/* START >> Added by vinay c 14/11/2019 To set parameters */
adClaimUpdate.setString(1,checkNull(tranIdNew));
adClaimUpdate.setString(2,checkNull(employeeCode));
adClaimUpdate.setString(3,checkNull(adCodeValue));
adClaimUpdate.setDate(4,(java.sql.Date) effDate);
adClaimUpdate.setDouble(5,amtBal);
adClaimUpdate.setDouble(6,claimAmountValue*(-1));
adClaimUpdate.setDouble(7,loanAdjamountValue);
adClaimUpdate.setString(8,checkNull(payrollVoucherValue));
adClaimUpdate.setString(9,checkNull(payrollPrdValue));
adClaimUpdate.setTimestamp(10, new java.sql.Timestamp(System.currentTimeMillis()));
adClaimUpdate.setString(11,checkNull(userId));
adClaimUpdate.setString(12,checkNull(chgTerm));
adClaimUpdate.setDate(13,tranDateNew);
updateCnt = adClaimUpdate.executeUpdate();
System.out.println("@vinay::amtBal>>"+amtBal);
System.out.println("@vinay::claimAmountValue Value>>"+claimAmountValue);
System.out.println("claimAmountValue*"+claimAmountValue*(-1));
if(adClaimUpdate != null)
{
adClaimUpdate.close();
adClaimUpdate = null;
}
if(updateCnt >0)
{
msgType.append("adclaim");
System.out.println("insert EMP_ADCLAIM with tran Id >> "+ tranIdNew);
}
/* END >> Added by vinay c 14/11/2019 To set parameters */
if(allWCnt > 0)
{
sql = "UPDATE ALLOWDEDN_BAL SET AMT_BAL = AMT_BAL + ?, AMT_ADJ = AMT_ADJ - ? WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
......@@ -886,7 +974,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
/* Commented by vinay c 01/11/2019
pstmtPayroll.setString(2, claimPrd);
End */
/* Added by vinay c 01/11/2019 To set payroll period instead of claim period */
/* Added by vinay c 01/11/2019 */
pstmtPayroll.setString(2,payrollPrd);
/* */
rsPayroll = pstmtPayroll.executeQuery();
......@@ -911,7 +999,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
/* Commented by vinay c 01/11/2019
retString = admCommon.payarrToProcUpdation(claimPrd, claimPrd, empCode, empCode, "AR", "w_perkclaim_cancel_load", "", adCode,claimAmount*-1 , frDateStr, toDateStr, xtraParams, conn);
End */
/* Added by vinay c 01/11/2019 To set payroll period instead of claim period */
/* Added by vinay c 01/11/2019 */
System.out.println("@vinay c::payrollPrd>>"+payrollPrd);
retString = admCommon.payarrToProcUpdation(payrollPrd,payrollPrd, empCode, empCode, "AR", "w_perkclaim_cancel_load", "", adCode,claimAmount*-1 , frDateStr, toDateStr, xtraParams, conn);
/* End */
......@@ -926,7 +1014,7 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
//Added By Amit Shrivastava on 26/02/19 for update reversal claim amount [End]
}
else
else if(payrollVoucher.equalsIgnoreCase("V")) //Modify else to else if by vinay 20/11/2019
{
/**If Payroll voucher type is Voucher
* will inserted records into tables
......@@ -1142,18 +1230,30 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
sqlUpdateEmpAdClaim = "insert into EMP_ADCLAIM (TRAN_ID,EMP_CODE,AD_CODE,EFF_DATE,BAL_AMT,CLAIM_AMT,LOAN_ADJAMT,PAYROLL_VOUCHER,PRD_CODE__PAYROLL,CHG_DATE,CHG_USER,CHG_TERM,TRAN_DATE)"
+ " Values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
adClaimUpdate = conn.prepareStatement(sqlUpdateEmpAdClaim);
/* START >> Commented by vinay c 14/11/2019
adClaimUpdate.setString(1,checkNull(tranIdNew));
adClaimUpdate.setString(2,checkNull(employeeCode));
adClaimUpdate.setString(3,checkNull(adCodeValue));
adClaimUpdate.setDate(4,(java.sql.Date) effDate);
END */
/* START >> Commented by vinay c 11/11/2019.
adClaimUpdate.setDouble(5,balAmountValue);
END */
/* START >> Commented by vinay c 11/11/2019 [ to insert current bal amount from allowdedn_bal table] */
/* START >> Commented by vinay c 14/11/2019
System.out.println("@vinay:amtBal>>"+amtBal);
adClaimUpdate.setDouble(5,amtBal);
END */
/* END */
//Added By Amit Shrivastava on 19/02/19 start for change claimAmountValue value into negative calim amount
/*adClaimUpdate.setDouble(6,claimAmountValue);*/
/* START >> Commented by vinay c 14/11/2019
System.out.println("@Amit claimAmountValue>>"+claimAmountValue);
adClaimUpdate.setDouble(6,claimAmountValue*(-1));
System.out.println("claimAmountValue*"+claimAmountValue*(-1));
END */
//Added By Amit Shrivastava on 19/02/19 start for change claimAmountValue value into negative calim amount
/* START >> Commented by vinay c 14/11/2019
adClaimUpdate.setDouble(7,loanAdjamountValue);
adClaimUpdate.setString(8,checkNull(payrollVoucherValue));
adClaimUpdate.setString(9,checkNull(payrollPrdValue));
......@@ -1185,6 +1285,8 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
adAllowBalPstmt.setDate(3,(java.sql.Date) effDate);
ResultSet rsAllBal = null;
rsAllBal = adAllowBalPstmt.executeQuery();
END */
/* START >> Commented by vinay c 14/11/2019
while(rsAllBal.next())
{
allWCnt = rsAllBal.getInt("cnt");
......@@ -1220,6 +1322,96 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
close(adAllowBalPstmt,rsAllBal);
System.out.println("startDate >> "+ startDate +" "+ "endDate >> "+ endDate);
END */
/* START >> Added by vinay c 14/11/2019 To get current bal amount from allow deduction balance table and inserted into emp_adclaim */
sql ="";
int allWCnt = 0;
sql = "select count(*) as cnt,start_date,end_date from ALLOWDEDN_BAL where emp_code = ?"
+ " and ad_code = ? and start_date = ? group by start_date, end_date";
adAllowBalPstmt = conn.prepareStatement(sql);
adAllowBalPstmt.setString(1,empCode);
adAllowBalPstmt.setString(2,adCode);
adAllowBalPstmt.setDate(3,(java.sql.Date) effDate);
ResultSet rsAllBal = null;
rsAllBal = adAllowBalPstmt.executeQuery();
if(rsAllBal.next())
{
allWCnt = rsAllBal.getInt("cnt");
startDate = rsAllBal.getDate("start_date");
endDate = rsAllBal.getDate("end_date");
}
System.out.println("Count --["+allWCnt+"]");
close(adAllowBalPstmt,rsAllBal);
sql ="";
sql=" select amt_bal from allowdedn_bal where emp_code = ? and ad_code = ? and start_date = ? and end_date = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, adCode);
pstmt.setDate(3, (java.sql.Date) startDate);
pstmt.setDate(4, (java.sql.Date) endDate);
ResultSet vrs=pstmt.executeQuery();
if(vrs.next())
{
amtBal=vrs.getDouble("amt_bal");
System.out.println("@vinay::amtBal >>"+amtBal);
}
close(pstmt,vrs);
adClaimUpdate.setString(1,checkNull(tranIdNew));
adClaimUpdate.setString(2,checkNull(employeeCode));
adClaimUpdate.setString(3,checkNull(adCodeValue));
adClaimUpdate.setDate(4,(java.sql.Date) effDate);
adClaimUpdate.setDouble(5,amtBal);
adClaimUpdate.setDouble(6,claimAmountValue*(-1));
adClaimUpdate.setDouble(7,loanAdjamountValue);
adClaimUpdate.setString(8,checkNull(payrollVoucherValue));
adClaimUpdate.setString(9,checkNull(payrollPrdValue));
adClaimUpdate.setTimestamp(10, new java.sql.Timestamp(System.currentTimeMillis()));
adClaimUpdate.setString(11,checkNull(userId));
adClaimUpdate.setString(12,checkNull(chgTerm));
adClaimUpdate.setDate(13,tranDateNew);
updateCnt = adClaimUpdate.executeUpdate();
System.out.println("@vinay::claimAmountValue>>"+claimAmountValue);
System.out.println("@vinay::claimAmountValue*"+claimAmountValue*(-1));
if(adClaimUpdate != null)
{
adClaimUpdate.close();
adClaimUpdate = null;
}
if(updateCnt >0)
{
msgType.append("adclaim");
System.out.println("insert EMP_ADCLAIM with tran Id >> "+ tranIdNew);
}
if(allWCnt > 0)
{
sql ="";
sql="UPDATE ALLOWDEDN_BAL SET AMT_BAL = AMT_BAL + ?, AMT_ADJ = AMT_ADJ - ? , CHG_DATE= ?, CHG_USER= ? ,CHG_TERM= ? "
+ " WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
allowdednbalPstmt = conn.prepareStatement(sql);
allowdednbalPstmt.setDouble(1 , claimAmountValue);
allowdednbalPstmt.setDouble(2 , claimAmountValue);
allowdednbalPstmt.setTimestamp(3, new java.sql.Timestamp(System.currentTimeMillis()));
allowdednbalPstmt.setString(4,checkNull(userId));
allowdednbalPstmt.setString(5,checkNull(chgTerm));
allowdednbalPstmt.setString(6 , empCode);
allowdednbalPstmt.setString(7 , adCode);
allowdednbalPstmt.setDate( 8,new java.sql.Date(startDate.getTime()));
allowdednbalPstmt.setDate( 9, new java.sql.Date(endDate.getTime()));
int up = allowdednbalPstmt.executeUpdate();
if(allowdednbalPstmt != null)
{
allowdednbalPstmt.close();
allowdednbalPstmt = null;
}
if(up > 0)
{
System.out.println("ALLOWDEDN_BAL updated for >> "+empCode);
}
}
}
close(adClaimPstmt,rs);
......@@ -1450,8 +1642,233 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
}
System.out.println("return String >> "+ errString);
} /* START >> Added by vinay c 20/11/2019 When Payroll Voucher Type is Lapse */
else
{
/**If Payroll voucher type is Lapse
* will inserted records into tables
* */
sql = "select FN_CHECK_ACCOUNTING_YEAR(?,?,?,?,?) as err_code from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, tranId);
pstmt.setString(3, userId);
pstmt.setTimestamp(4, tranDateTimpstamp);
pstmt.setString(5, "PERK_CLAIM_CAN");
rs = pstmt.executeQuery();
if (rs.next())
{
errorString = rs.getString("err_code");
}
close(pstmt, rs);
if(errorString!=null && errorString.trim().length()>0)
{
errString = itmDBAccess.getErrorString("", errorString, "");
return errString;
}
int cntHDR = 0,cnt = 0;
tranIdNew=checkNull(generateTranId(tranDate,paySite,conn));
System.out.println("tranIdNew >> "+ tranIdNew);
sql = "select count(*) as cnt from EMP_ADCLAIMHDR where tran_id = ?";
adClaimPstmthdr = conn.prepareStatement(sql);
adClaimPstmthdr.setString(1,tranId);
rs = adClaimPstmthdr.executeQuery();
if(rs.next())
{
cntHDR = rs.getInt("cnt");
}
System.out.println("Count --["+cntHDR+"]");
System.out.println(this.getClass().getName()+"713["+userId+"]");
System.out.println("--new train id voucher--"+tranIdNew);
close(adClaimPstmthdr,rs);
if(cntHDR > 0)
{
sqlUpdateEmpAdClaimHDR = "UPDATE EMP_ADCLAIMHDR SET REF_STATUS =? ,REF_ID__REV = ?"
+ " WHERE TRAN_ID = ?";
adclaimhdrPstmt = conn.prepareStatement(sqlUpdateEmpAdClaimHDR);
adclaimhdrPstmt.setString(1,"Y");
adclaimhdrPstmt.setString(2,tranIdNew);
adclaimhdrPstmt.setString(3,tranId);
updateCnt = adclaimhdrPstmt.executeUpdate();
if(updateCnt >0)
{
System.out.println("EMP_ADCLAIMHDR Updated with tran Id >> "+ tranId);
System.out.println("EMP_ADCLAIMHDR Updated with tran Id >> "+ tranIdNew);
}
}
close(adclaimhdrPstmt,rs);
sql="SELECT tran_date,emp_code,claim_amt,loan_adjamt,payroll_voucher,prd_code__payroll,"
+ " ad_code,confirmed,udf_type FROM EMP_ADCLAIMHDR where tran_id=? ";
adClaimPstmthdr = conn.prepareStatement(sql);
adClaimPstmthdr.setString(1,tranId);
rs = adClaimPstmthdr.executeQuery();
if(rs.next())
{
tranDateNew=rs.getDate("tran_date");
employeeCode=rs.getString("emp_code");
claimAmountValue=rs.getDouble("claim_amt");
loanAdjamountValue=rs.getDouble("loan_adjamt");
payrollVoucherValue=rs.getString("payroll_voucher");
payrollPrdValue=rs.getString("prd_code__payroll");
adCodeValue=rs.getString("ad_code");
confirmedValue=rs.getString("confirmed");
udfType = rs.getString("udf_type");
}
System.out.println("Count --["+tranId+"]");
close(pstmt,rs);
sqlUpdateEmpAdClaimHDR="insert into EMP_ADCLAIMHDR "
+ " (tran_id,tran_date,emp_code,claim_amt,loan_adjamt,payroll_voucher,prd_code__payroll,chg_date,chg_user,chg_term,ad_code,confirmed,udf_type) "
+ " Values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
adclaimhdrPstmt=conn.prepareStatement(sqlUpdateEmpAdClaimHDR);
adclaimhdrPstmt.setString(1,checkNull(tranIdNew));
adclaimhdrPstmt.setDate(2,date);
adclaimhdrPstmt.setString(3,checkNull(employeeCode));
adclaimhdrPstmt.setDouble(4,claimAmountValue*(-1));
adclaimhdrPstmt.setDouble(5,loanAdjamountValue);
adclaimhdrPstmt.setString(6,checkNull(payrollVoucherValue));
adclaimhdrPstmt.setString(7,checkNull(payrollPrdValue));
adclaimhdrPstmt.setTimestamp(8, new java.sql.Timestamp(System.currentTimeMillis()));
adclaimhdrPstmt.setString(9,checkNull(userId));
adclaimhdrPstmt.setString(10,checkNull(chgTerm));
adclaimhdrPstmt.setString(11,checkNull(adCodeValue));
adclaimhdrPstmt.setString(12,checkNull(confirmed));
adclaimhdrPstmt.setString(13,checkNull(udfType));
System.out.println("@vinay::lapse::claimAmountValue >>"+claimAmountValue*(-1));
int insert=adclaimhdrPstmt.executeUpdate();
if(insert >0)
{
msgType.append("adclaimhdr");
System.out.println("EMP_ADCLAIMHDR inserted with new tran Id >> "+ tranIdNew);
}
employeeCode="";payrollVoucherValue="";payrollPrdValue="";
adCodeValue="";confirmedValue = "";udfType = "";
claimAmountValue=0.0d;loanAdjamountValue=0.0d;
tranDateNew = null;
empAdclaimSql= "SELECT EMP_CODE,AD_CODE,EFF_DATE,BAL_AMT,CLAIM_AMT,LOAN_ADJAMT,"
+ " PAYROLL_VOUCHER,PRD_CODE__PAYROLL, TRAN_DATE FROM EMP_ADCLAIM WHERE TRAN_ID = ? ";
adClaimPstmt = conn.prepareStatement(empAdclaimSql);
adClaimPstmt.setString(1,tranId);
rs = adClaimPstmt.executeQuery();
while(rs.next())
{
employeeCode = checkNull(rs.getString("EMP_CODE"));
adCodeValue = checkNull(rs.getString("AD_CODE"));
effDate = rs.getDate("EFF_DATE");
balAmountValue = rs.getDouble("BAL_AMT");
claimAmountValue =rs.getDouble("CLAIM_AMT");
loanAdjamountValue =rs.getDouble("LOAN_ADJAMT");
payrollVoucherValue =checkNull(rs.getString("PAYROLL_VOUCHER"));
payrollPrdValue =checkNull(rs.getString("PRD_CODE__PAYROLL"));
tranDateNew =rs.getDate("TRAN_DATE");
System.out.println("@vinay:: tranDateNew value EFF_DATE>>"+tranDateNew);
System.out.println("@vinay::EFF_DATE"+effDate);
sqlUpdateEmpAdClaim = "insert into EMP_ADCLAIM (TRAN_ID,EMP_CODE,AD_CODE,EFF_DATE,BAL_AMT,CLAIM_AMT,LOAN_ADJAMT,PAYROLL_VOUCHER,PRD_CODE__PAYROLL,CHG_DATE,CHG_USER,CHG_TERM,TRAN_DATE)"
+ " Values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
adClaimUpdate = conn.prepareStatement(sqlUpdateEmpAdClaim);
sql ="";
int allWCnt = 0;
sql = "select count(*) as cnt,start_date,end_date from ALLOWDEDN_BAL where emp_code = ?"
+ " and ad_code = ? and start_date = ? group by start_date, end_date";
adAllowBalPstmt = conn.prepareStatement(sql);
adAllowBalPstmt.setString(1,empCode);
adAllowBalPstmt.setString(2,adCode);
adAllowBalPstmt.setDate(3,(java.sql.Date) effDate);
ResultSet rsAllBal = null;
rsAllBal = adAllowBalPstmt.executeQuery();
if(rsAllBal.next())
{
allWCnt = rsAllBal.getInt("cnt");
startDate = rsAllBal.getDate("start_date");
endDate = rsAllBal.getDate("end_date");
}
System.out.println("Count --["+allWCnt+"]");
close(adAllowBalPstmt,rsAllBal);
sql ="";
sql=" select amt_bal from allowdedn_bal where emp_code = ? and ad_code = ? and start_date = ? and end_date = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, adCode);
pstmt.setDate(3, (java.sql.Date) startDate);
pstmt.setDate(4, (java.sql.Date) endDate);
ResultSet vrs=pstmt.executeQuery();
if(vrs.next())
{
amtBal=vrs.getDouble("amt_bal");
System.out.println("@vinay::amtBal >>"+amtBal);
}
close(pstmt,vrs);
adClaimUpdate.setString(1,checkNull(tranIdNew));
adClaimUpdate.setString(2,checkNull(employeeCode));
adClaimUpdate.setString(3,checkNull(adCodeValue));
adClaimUpdate.setDate(4,(java.sql.Date) effDate);
adClaimUpdate.setDouble(5,amtBal);
adClaimUpdate.setDouble(6,claimAmountValue*(-1));
adClaimUpdate.setDouble(7,loanAdjamountValue);
adClaimUpdate.setString(8,checkNull(payrollVoucherValue));
adClaimUpdate.setString(9,checkNull(payrollPrdValue));
adClaimUpdate.setTimestamp(10, new java.sql.Timestamp(System.currentTimeMillis()));
adClaimUpdate.setString(11,checkNull(userId));
adClaimUpdate.setString(12,checkNull(chgTerm));
adClaimUpdate.setDate(13,tranDateNew);
updateCnt = adClaimUpdate.executeUpdate();
System.out.println("@vinay::claimAmountValue>>"+claimAmountValue);
System.out.println("@vinay::claimAmountValue*"+claimAmountValue*(-1));
if(adClaimUpdate != null)
{
adClaimUpdate.close();
adClaimUpdate = null;
}
if(updateCnt >0)
{
msgType.append("adclaim");
System.out.println("insert EMP_ADCLAIM with tran Id >> "+ tranIdNew);
}
if(allWCnt > 0)
{
sql ="";
sql="UPDATE ALLOWDEDN_BAL SET AMT_BAL = AMT_BAL + ?, AMT_ADJ = AMT_ADJ - ? , CHG_DATE= ?, CHG_USER= ? ,CHG_TERM= ? "
+ " WHERE EMP_CODE = ? AND AD_CODE = ? AND START_DATE = ? AND END_DATE = ?";
allowdednbalPstmt = conn.prepareStatement(sql);
allowdednbalPstmt.setDouble(1 , claimAmountValue);
allowdednbalPstmt.setDouble(2 , claimAmountValue);
allowdednbalPstmt.setTimestamp(3, new java.sql.Timestamp(System.currentTimeMillis()));
allowdednbalPstmt.setString(4,checkNull(userId));
allowdednbalPstmt.setString(5,checkNull(chgTerm));
allowdednbalPstmt.setString(6 , empCode);
allowdednbalPstmt.setString(7 , adCode);
allowdednbalPstmt.setDate( 8,new java.sql.Date(startDate.getTime()));
allowdednbalPstmt.setDate( 9, new java.sql.Date(endDate.getTime()));
int up = allowdednbalPstmt.executeUpdate();
if(allowdednbalPstmt != null)
{
allowdednbalPstmt.close();
allowdednbalPstmt = null;
}
if(up > 0)
{
System.out.println("ALLOWDEDN_BAL updated for >> "+empCode);
}
}
}
close(adClaimPstmt,rs);
}
/* END >> Added by vinay c 20/11/2019 When Payroll Voucher Type is Lapse */
}
}
catch(Exception e)
{
......@@ -1731,4 +2148,41 @@ public class PerkClaimCancelProcess extends ProcessEJB implements PerkClaimCance
return tranId;
}
/* START >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
private boolean checkCancelStatus(String tranIdValue,Connection conn)
{
boolean status=false;
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql="",refStatus="",refIdRev="";
System.out.println("@vinay::inside checkCancelStatus method");
System.out.println("@vinay::tranIdValue>>"+tranIdValue);
try
{
sql =" select ref_status,ref_id__rev from emp_adclaimhdr where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdValue);
rs = pstmt.executeQuery();
if(rs.next())
{
refStatus=checkNull(rs.getString("ref_status"));
refIdRev=checkNull(rs.getString("ref_id__rev"));
System.out.println("@vinay::refStatus>>"+refStatus+"\trefIdRev>>"+refIdRev);
if((refStatus!=null && refStatus.trim().length()>0 && refStatus.equals("Y")) && (refIdRev!=null && refIdRev.trim().length()>0 ))
{
status=true;
}
}
close(pstmt, rs);
}
catch(Exception er)
{
er.printStackTrace();
System.out.println("Exception in "+this.getClass().getSimpleName()+" >>"+er.getMessage());
}
return status;
}
/* END >> Added by vinay c 11/11/2019 [ To check in Perk Claim Load tran id is already cancelled ] */
}
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