Commit 356150a8 authored by pbhosale's avatar pbhosale

Updated on[21/11/2019] changes done as suggested by Piyush Sir

AllowDednSalComp.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@212542 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 99dd032f
......@@ -3,12 +3,17 @@ AllowDednSalComp.java
HashMap adCompsInfo = new HashMap();
HashMap payCompInfo = new HashMap();
*/
*/
package ibase.webitm.ejb.adm;
import java.lang.reflect.Array;
import java.sql.*;
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.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
......@@ -25,6 +30,60 @@ public class AllowDednSalComp
{
AdmCommon admCommon = new AdmCommon();
UtilMethods utilMethods = new UtilMethods();
//Modified By Poonam B[20/11/2019][START][New methods created to convert formula in java syntax with dynamic concept].Start
ArrayList<String> pbSyntaxKeyList = new ArrayList<String>();
ArrayList<String> pbToJavaSyntaxKeyList = new ArrayList<String>();
int pbToJavaSyntaxKeySize = 0;
private String convertFormulaInJava(String input, Connection conn) throws ITMException
{
try
{
if (pbToJavaSyntaxKeySize == 0)
{
String varValue = admCommon.getEnv("999999", "ADFORMULA_PB2JAVA", conn);
pbToJavaSyntaxKeySize = -1;
if(varValue != null && varValue.trim().length() > 0 && varValue.indexOf("[") > 0 && varValue.indexOf("]") > 0)
{
String[] syntaxStr = varValue.split("[");
int syntaxStrSize = syntaxStr.length;
for(int i = 0;i < syntaxStrSize; i++)
{
syntaxStr[i].replace("[", "");
syntaxStr[i].replace("]", "");
String[] syntaxKeyStr = ((String)syntaxStr[i]).split("{");
if(syntaxKeyStr.length != 2)
{
continue;
}
syntaxKeyStr[0].replace("{", "");
syntaxKeyStr[0].replace("}", "");
syntaxKeyStr[1].replace("{", "");
syntaxKeyStr[1].replace("}", "");
pbSyntaxKeyList.add(syntaxKeyStr[0]);
pbToJavaSyntaxKeyList.add(syntaxKeyStr[1]);
pbToJavaSyntaxKeySize = pbSyntaxKeyList.size();
}
}
}
if(pbToJavaSyntaxKeySize > 0)
{
for (int i = 0; i < pbToJavaSyntaxKeySize; i++)
{
String pbKeyStr = (String) pbSyntaxKeyList.get(i);
String javaKeyStr = (String) pbToJavaSyntaxKeyList.get(i);
input = input.replace(pbKeyStr, javaKeyStr);
}
}
}
catch(Exception e)
{
throw new ITMException(e);
}
return input;
}
//Modified By Poonam B[20/11/2019][START][New methods created to convert formula in java syntax with dynamic concept].End
private String replaceIF(String input) throws ITMException
{
try
......@@ -51,6 +110,7 @@ public class AllowDednSalComp
}
return input;
}
//Modified by Rohini T on [09/08/19][Start]
public LinkedHashMap getAdCompInfo(String processType, Connection conn) throws ITMException
{
......@@ -72,7 +132,7 @@ public class AllowDednSalComp
//Modified by Rohini T on [09/08/19][End]
public LinkedHashMap getAdCompInfo(String processType, String seqNo, Connection conn) throws ITMException
{
String sdCodesSql = "";
//HashMap adCompsInfo = new HashMap();
LinkedHashMap adCompsInfo = new LinkedHashMap<>();
......@@ -82,13 +142,13 @@ public class AllowDednSalComp
System.out.println("Inside getAdCompInfo(String processType, String seqNo, Connection conn) ::::s");
try
{
double rndTo = 0d;
System.out.println("seqNo::::"+seqNo);//need to chnage below sql
//Modified by Poonam B[14/11/2019][START][As suggested by Sir to remove APPLICABLE_TO from sql query]
sdCodesSql = /*"SELECT AD_CODE,SH_DESCR,DESCR,TYPE,SEQ_NO,RND_OFF,RND_TO,PROP_YN,PROP_ON,PAYABLE,POST_YN,SLAB_OPTION,BASE_FORMULA,SLAB_FORMULA,RES_FORMULA,BAL_OPT,FOR_CONDN,SQL_EXPR,SQL_INPUT,MIN_VAL,MAX_VAL,IT_PROJ,IT_SECTION,PRT_SEQ,DROP_YN,COST_COMPANY,SPLIT_YN,ACCT_CODE__SAL,CCTR_CODE__SAL,CHG_DATE,CHG_USER,CHG_TERM,PAY_TAX,TAUTH_CODE,DIRECT_VOUCHER,DELETE_ARR,BAL_FROM,BAL_TO,DROP_OPT,DROP_SEQ,FREQUENCY,IT_PROOF_REQ,PRINT_OPT,GEN_NEGT_ARR,UDF_TYPE,APPLICABLE_IN_FFS,INPUT_TYPE,APPLICABLE_TO FROM ALLWDEDN WHERE NVL(SEQ_NO , ' ') < ?"*/
"SELECT AD_CODE,SH_DESCR,DESCR,TYPE,SEQ_NO,RND_OFF,RND_TO,PROP_YN,PROP_ON,PAYABLE,POST_YN,SLAB_OPTION,BASE_FORMULA,SLAB_FORMULA,RES_FORMULA,BAL_OPT,FOR_CONDN,SQL_EXPR,SQL_INPUT,MIN_VAL,MAX_VAL,IT_PROJ,IT_SECTION,PRT_SEQ,DROP_YN,COST_COMPANY,SPLIT_YN,ACCT_CODE__SAL,CCTR_CODE__SAL,CHG_DATE,CHG_USER,CHG_TERM,PAY_TAX,TAUTH_CODE,DIRECT_VOUCHER,DELETE_ARR,BAL_FROM,BAL_TO,DROP_OPT,DROP_SEQ,FREQUENCY,IT_PROOF_REQ,PRINT_OPT,GEN_NEGT_ARR,UDF_TYPE,APPLICABLE_IN_FFS FROM ALLWDEDN WHERE NVL(SEQ_NO , ' ') < ?"
//Modified by Poonam B[14/11/2019][END][As suggested by Sir to remove APPLICABLE_TO from sql query]
//Modified by Poonam B[14/11/2019][END][As suggested by Sir to remove APPLICABLE_TO from sql query]
//+" AND ad_code in('DW008','DW002','DW009','CW005','DW009_S','D0005','DW005','DW006','DW001','DW010''DW015','CW001')"
+ " ORDER BY CASE WHEN SEQ_NO IS NULL THEN ' ' ELSE SEQ_NO END, AD_CODE";
//sdCodesSql = "SELECT AD_CODE,SH_DESCR,DESCR,TYPE,SEQ_NO,RND_OFF,RND_TO,PROP_YN,PROP_ON,PAYABLE,POST_YN,SLAB_OPTION,BASE_FORMULA,SLAB_FORMULA,RES_FORMULA,BAL_OPT,FOR_CONDN,SQL_EXPR,SQL_INPUT,MIN_VAL,MAX_VAL,IT_PROJ,IT_SECTION,PRT_SEQ,DROP_YN,COST_COMPANY,SPLIT_YN,ACCT_CODE__SAL,CCTR_CODE__SAL,CHG_DATE,CHG_USER,CHG_TERM,PAY_TAX,TAUTH_CODE,DIRECT_VOUCHER,DELETE_ARR,BAL_FROM,BAL_TO,DROP_OPT,DROP_SEQ,FREQUENCY,IT_PROOF_REQ,PRINT_OPT,GEN_NEGT_ARR,UDF_TYPE,APPLICABLE_IN_FFS,INPUT_TYPE,APPLICABLE_TO FROM ALLWDEDN WHERE NVL(SEQ_NO , ' ') < ? and rownum <100 ORDER BY CASE WHEN SEQ_NO IS NULL THEN ' ' ELSE SEQ_NO END, AD_CODE";
......@@ -112,30 +172,61 @@ public class AllowDednSalComp
String strBaseFormula = rstAdCodes.getString("BASE_FORMULA");
//Added By Varsha V on 19-07-19 to replace IF with IIF
System.out.println("strBaseFormula::::inside getAdCompInfo before"+strBaseFormula);
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].Start
/*
if(strBaseFormula != null && strBaseFormula.trim().length() > 0)
{
strBaseFormula = replaceIF(strBaseFormula.trim().toUpperCase());
System.out.println("strBaseFormula::::inside getAdCompInfo after"+strBaseFormula);
}
*/
if(strBaseFormula != null && strBaseFormula.trim().length() > 0 && !strBaseFormula.startsWith("SELECT "))
{
strBaseFormula = convertFormulaInJava(strBaseFormula.trim().toUpperCase(),conn);
System.out.println("strBaseFormula::::inside getAdCompInfo after"+strBaseFormula);
}
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].End
//Ended By Varsha V on 19-07-19 to replace IF with IIF
String strSlabFormula = rstAdCodes.getString("SLAB_FORMULA");
System.out.println("strSlabFormula::::inside getAdCompInfo before"+strSlabFormula);
//Added By Varsha V on 19-07-19 to replace IF with IIF
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].Start
/*
if(strSlabFormula != null && strSlabFormula.trim().length() > 0)
{
strSlabFormula = replaceIF(strSlabFormula.trim().toUpperCase());
System.out.println("strSlabFormula::::inside getAdCompInfo after"+strSlabFormula);
}
*/
if(strSlabFormula != null && strSlabFormula.trim().length() > 0 && !strSlabFormula.startsWith("SELECT "))
{
strSlabFormula = convertFormulaInJava(strSlabFormula.trim().toUpperCase(),conn);
System.out.println("strSlabFormula::::inside getAdCompInfo after"+strSlabFormula);
}
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].End
//Ended By Varsha V on 19-07-19 to replace IF with IIF
String strResFormula = rstAdCodes.getString("RES_FORMULA");
System.out.println("strResFormula::::inside getAdCompInfo before"+strResFormula);
//Added By Varsha V on 19-07-19 to replace IF with IIF
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].Start
/*
if(strResFormula != null && strResFormula.trim().length() > 0)
{
strResFormula = replaceIF(strResFormula.trim().toUpperCase());
System.out.println("strResFormula::::inside getAdCompInfo after"+strResFormula);
}
*/
if(strResFormula != null && strResFormula.trim().length() > 0 && ! strResFormula.startsWith("SELECT "))
{
strResFormula = convertFormulaInJava(strResFormula.trim().toUpperCase(),conn);
System.out.println("strResFormula::::inside getAdCompInfo after"+strResFormula);
}
//Modified By Poonam B[20/11/2019][method name is renamed and replace in other select statement].End
//Ended By Varsha V on 19-07-19 to replace IF with IIF
String strBalOpt = rstAdCodes.getString("BAL_OPT");
String strForCondn = rstAdCodes.getString("FOR_CONDN");
String strSqlExpr = rstAdCodes.getString("SQL_EXPR");
......@@ -221,7 +312,7 @@ public class AllowDednSalComp
adCompsInfo.put(strAdCode , adCompMap);
}
//System.out.println("adCompsInfo:::::"+adCompsInfo);
if (rstAdCodes != null)
......@@ -269,7 +360,7 @@ public class AllowDednSalComp
{
LinkedHashMap payAdMap = new LinkedHashMap();
LinkedHashMap payAdMapOrg = new LinkedHashMap(); // Modified by Piyush on 07/09/2019[To allow multiple rows from payb structures]
LinkedHashMap retPayCompMap = new LinkedHashMap();
String sdCodesSql = "";
......@@ -283,14 +374,14 @@ public class AllowDednSalComp
// Modified by Piyush on 07/09/2019[To allow multiple rows from payb structures].End
try
{
double rndTo = 0d;
double payAmount = 0d;
double minBasic = 0d;
double maxBasic = 0d;
double minAmount = 0d;
double maxAmount = 0d;
java.sql.Timestamp effDate = null;
java.sql.Timestamp expDate = null;
payCompMap = (LinkedHashMap) payCompMapAll.get("PAYMAP");
......@@ -453,9 +544,9 @@ public class AllowDednSalComp
{
isSplit = "Y";
}
adCompMap = (LinkedHashMap) adCompsInfo.get(strAdCode);
String strType = (String) adCompMap.get("TYPE");
String strRndOff = (String) adCompMap.get("RND_OFF");
String strPropYn = (String) adCompMap.get("PROP_YN");
......@@ -523,7 +614,7 @@ public class AllowDednSalComp
{
payCompMap.put(strAdCode , payAdMap);
}
*/
*/
ArrayList payCompRows = new ArrayList();
if(payCompMap.containsKey(strAdCode))
{
......@@ -543,7 +634,7 @@ public class AllowDednSalComp
}
payCompMap.put(strAdCode , payCompRows);
// Modified by Piyush on 07/09/2019[To allow duplicate keys - First find in original map, if existing then replace else add].End
//adCompMap.clear();
}
if (rstAdCodes != null)
......@@ -591,7 +682,7 @@ public class AllowDednSalComp
}
return retPayCompMap;
}
public String checkNull(String argStr)
{
if(argStr == null)
......@@ -642,7 +733,7 @@ public class AllowDednSalComp
String prdCodeArr = "";
String addescr = "";
String nAdCode = "";
Timestamp ldEffDate = null;
Timestamp ldExpDate = null;
Timestamp tsFrDateOfRunPrd = null;
......@@ -650,32 +741,32 @@ public class AllowDednSalComp
Timestamp joinDateTm = null;
Timestamp relieveDateTm = null;
Timestamp retirementDateTm = null;
Timestamp ldFrDate = null;
Timestamp ldToDate = null;
LinkedHashMap retMap = new LinkedHashMap();
LinkedHashMap adMap = new LinkedHashMap();
LinkedHashMap payAdMap = new LinkedHashMap();
LinkedHashMap payrollDetDataMap = null;
LinkedHashMap payrollDetDataMapAll = new LinkedHashMap();
LinkedHashMap calcPropAmtMap = null;
Timestamp ldFrDate = null;
Timestamp ldToDate = null;
LinkedHashMap retMap = new LinkedHashMap();
LinkedHashMap adMap = new LinkedHashMap();
LinkedHashMap payAdMap = new LinkedHashMap();
LinkedHashMap payrollDetDataMap = null;
LinkedHashMap payrollDetDataMapAll = new LinkedHashMap();
LinkedHashMap calcPropAmtMap = null;
Object[] keyArray = null;
Object[] keyArray1 = null;
ScriptEngineManager manager = new ScriptEngineManager();
// ScriptEngine exprsEngine = manager.getEngineByName("js");
ScriptEngine exprsEngine = manager.getEngineByName("JavaScript");
//Added by Varsha V on 22-07-19
exprsEngine.eval("function IIF(a,b,c) {return a?b:c}");
exprsEngine.eval("function ISNULL(a) {return a==null?true:false}");
//Ended by Varsha V on 22-07-19
AdmCommon admCommon = new AdmCommon();
PayrollSplitgenAccPrc payrollPrc = new PayrollSplitgenAccPrc();
// ScriptEngine exprsEngine = manager.getEngineByName("js");
ScriptEngine exprsEngine = manager.getEngineByName("JavaScript");
//Added by Varsha V on 22-07-19
exprsEngine.eval("function IIF(a,b,c) {return a?b:c}");
exprsEngine.eval("function ISNULL(a) {return a==null?true:false}");
//Ended by Varsha V on 22-07-19
AdmCommon admCommon = new AdmCommon();
PayrollSplitgenAccPrc payrollPrc = new PayrollSplitgenAccPrc();
UtilMethods utilMethods = new UtilMethods();
//PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
DecimalFormat format = new DecimalFormat("##.00");
//PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null;
DecimalFormat format = new DecimalFormat("##.00");
int detCount = 0;
//Modified by Rohini T on [08/08/19][Start]
E12GenericUtility genericUtility = new E12GenericUtility();
......@@ -688,7 +779,7 @@ public class AllowDednSalComp
System.out.println("argStrDate"+argStrDate);
System.out.println("argDblVars"+argDblVars);
System.out.println("::argXtraParms::"+argXtraParms);
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula]
LinkedHashMap allInputMap = new LinkedHashMap();
ArrayList payAdList = null;
......@@ -696,7 +787,7 @@ public class AllowDednSalComp
{
/*sql = "select date_join, relieve_date, retirement_date from employee where emp_code = ? ";
pstmt = argConn.prepareStatement(sql);*/
/*sql = "select descr from allwdedn where ad_code = ?";
pstmt1 = argConn.prepareStatement(sql);*/
keyArray = argEmpDataMap.keySet().toArray();
......@@ -741,7 +832,7 @@ public class AllowDednSalComp
//tsToDateOfRunPrd = (Timestamp) argEmpDataMap.get("TO_DATE");
//Modified by Rohini T on [08/08/19][End]
prdCodeArr = (String) argEmpDataMap.get("PRD_CODE__ACC");
for (int i = 0; i < noOfKeys; i++)
{
String dataKey = Array.get(keyArray,i).toString();
......@@ -780,7 +871,7 @@ public class AllowDednSalComp
//Added by Varsha V
addescr = (String) adMap.get("DESCR");
System.out.println("strCompCode::"+strCompCode);
//payAdMap = (LinkedHashMap) argPayCompMap.get(strCompCode);
//System.out.println("payAdMap::::"+payAdMap);
//if(payAdMap == null)
......@@ -805,7 +896,7 @@ public class AllowDednSalComp
payAdMap = null;
payAdMap = (LinkedHashMap) payAdList.get(rNo);
System.out.println("payAdMap::::"+payAdMap);
//Modified by Piyush on 07/09/2019[Access Arraylist].End
String strAdType = checkNull((String) payAdMap.get("TYPE_S"));
String strBaseFormula = checkNull((String) adMap.get("BASE_FORMULA"));
......@@ -818,12 +909,12 @@ public class AllowDednSalComp
dPayMaxAmt = Double.parseDouble(setNullToZero(payAdMap.get("MAX_AMT").toString()));
dPayMinBaseAmt = Double.parseDouble(setNullToZero(payAdMap.get("MIN_BASIC").toString()));
dPayMaxBaseAmt = Double.parseDouble(setNullToZero(payAdMap.get("MAX_BASIC").toString()));
// dPayAmt = (double) payAdMap.get("AMOUNT");
// dPayMinAmt = (double) payAdMap.get("MIN_AMT");
// dPayMaxAmt = (double) payAdMap.get("MAX_AMT");
// dPayMinBaseAmt = (double) payAdMap.get("MIN_BASIC");
// dPayMaxBaseAmt = (double) payAdMap.get("MAX_BASIC");
// //Modified by Rohini T on [09/08/19][End]
// dPayAmt = (double) payAdMap.get("AMOUNT");
// dPayMinAmt = (double) payAdMap.get("MIN_AMT");
// dPayMaxAmt = (double) payAdMap.get("MAX_AMT");
// dPayMinBaseAmt = (double) payAdMap.get("MIN_BASIC");
// dPayMaxBaseAmt = (double) payAdMap.get("MAX_BASIC");
// //Modified by Rohini T on [09/08/19][End]
String strSlabOption = checkNull((String) adMap.get("SLAB_OPTION"));
System.out.println("strBaseFormula::"+strBaseFormula+"strSlabFormula::"+strSlabFormula+"strResFormula::"+strResFormula);
dBaseAmt = 0d;
......@@ -864,8 +955,8 @@ public class AllowDednSalComp
}
catch(Exception bEvalEx)
{
errorCode = "VPPAYPRC01\tException in base formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
errorCode = "VPPAYPRC01\tException in base formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
}
System.out.println("Evaluated values for BASE "+strCompCode+"_B is "+dBaseAmt);
......@@ -873,7 +964,7 @@ public class AllowDednSalComp
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].Start
allInputMap.put(strCompCode + "_B", dBaseAmt);
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].End
dSlabAmt = 0d;
if("C".equalsIgnoreCase(strSlabOption) || "D".equalsIgnoreCase(strSlabOption))
{
......@@ -911,8 +1002,8 @@ public class AllowDednSalComp
}
catch(Exception bEvalEx)
{
errorCode = "VPPAYPRC01\tException in slab formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
errorCode = "VPPAYPRC01\tException in slab formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
}
}
......@@ -921,30 +1012,30 @@ public class AllowDednSalComp
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].Start
allInputMap.put(strCompCode + "_S", dSlabAmt);
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].End
dResAmt = 0d;
dprop = "";
dpropon = "";
retVal = 0d; // Modified by Piyush on 07/09/2019 [To initialize the variable]
dprop = "";
dpropon = "";
retVal = 0d; // Modified by Piyush on 07/09/2019 [To initialize the variable]
//if("F".equalsIgnoreCase(strAdType) ) changed by Varsha V as per nvo on 24-07-19
if("F".equalsIgnoreCase(strAdType) || ("P".equalsIgnoreCase(strAdType) && dPayAmt != 0))
if("F".equalsIgnoreCase(strAdType) || ("P".equalsIgnoreCase(strAdType) && dPayAmt != 0))
{
System.out.println("Inside strAdType if.....");
dprop = checkNull((String) payAdMap.get("PROP_YN_S"));
dpropon = checkNull((String) payAdMap.get("PROP_ON"));
//Added By Varsha V on 24-07-19
while(true)
{
if(dPayMinBaseAmt != 0 || dPayMaxBaseAmt != 0)
{
System.out.println("Inside strAdType if.....");
dprop = checkNull((String) payAdMap.get("PROP_YN_S"));
dpropon = checkNull((String) payAdMap.get("PROP_ON"));
//Added By Varsha V on 24-07-19
while(true)
{
if(dPayMinBaseAmt != 0 || dPayMaxBaseAmt != 0)
{
// Modified by Piyush on 07/09/2019[Wrong condition. Should be or not &]
// if(dSlabAmt < dPayMinBaseAmt && dSlabAmt >= dPayMaxBaseAmt)
if(dSlabAmt < dPayMinBaseAmt || dSlabAmt >= dPayMaxBaseAmt)
{
break;
}
}
//Ended By Varsha V on 24-07-19
// if(dSlabAmt < dPayMinBaseAmt && dSlabAmt >= dPayMaxBaseAmt)
if(dSlabAmt < dPayMinBaseAmt || dSlabAmt >= dPayMaxBaseAmt)
{
break;
}
}
//Ended By Varsha V on 24-07-19
dResAmt = dPayAmt;
if("P".equalsIgnoreCase(strAdType))
{
......@@ -964,11 +1055,11 @@ public class AllowDednSalComp
{
ldExpDate = Timestamp.valueOf(ldExpDateStr);
}
*/
*/
ldEffDate = (Timestamp) payAdMap.get("EFF_DATE");
ldExpDate = (Timestamp) payAdMap.get("EXP_DATE");
// Modifid by Piyush on 07/09/2019 [The dates are timestamp only and are in dbformat in map, so no need to bellow codes].End
//Modify by Varsha V on 10-09-2019 to call common method --[START]
/*if(ldEffDate != null && ldExpDate != null)
{
......@@ -1047,7 +1138,7 @@ public class AllowDednSalComp
else
{
try {
dResAmt = Double.parseDouble(calcPropAmtMap.get("AMOUNT").toString());
}
catch(Exception e) {
......@@ -1057,12 +1148,12 @@ public class AllowDednSalComp
//Modify by Varsha V on 10-09-2019 to call common method --[END]
}
break;
}
if(errorCode != null && errorCode.trim().length() > 0) {
break;
}
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].Start
/*
}
if(errorCode != null && errorCode.trim().length() > 0) {
break;
}
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].Start
/*
try
{
String strResult = String.valueOf(exprsEngine.eval(dResAmt+""));
......@@ -1096,18 +1187,18 @@ public class AllowDednSalComp
errorCode = "VPPAYPRC01\tException in of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
*/
System.out.println("Evaluated values for RESULT 1 "+strCompCode+" is "+dResAmt);
*/
System.out.println("Evaluated values for RESULT 1 "+strCompCode+" is "+dResAmt);
exprsEngine.put(strCompCode , dResAmt);
allInputMap.put(strCompCode , dResAmt);
retVal = dResAmt;
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].End
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].End
}
else if(strResFormula != null && strResFormula.trim().length() > 0)
{
System.out.println("Inside strResFormula if.....");
dprop = checkNull((String) payAdMap.get("PROP_YN_S"));
dpropon = checkNull((String) payAdMap.get("PROP_ON"));
dpropon = checkNull((String) payAdMap.get("PROP_ON"));
if(strResFormula.startsWith("SELECT "))
{
retMap = null;
......@@ -1169,7 +1260,7 @@ public class AllowDednSalComp
errorCode = "VPPAYPRC01\tException in of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
*/
*/
exprsEngine.put(strCompCode , retVal);
allInputMap.put(strCompCode , retVal);
dResAmt = retVal;
......@@ -1217,8 +1308,8 @@ public class AllowDednSalComp
}
catch(Exception bEvalEx)
{
errorCode = "VPPAYPRC01\tException in result formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
errorCode = "VPPAYPRC01\tException in result formula of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].Start
exprsEngine.put(strCompCode , dResAmt);
......@@ -1282,7 +1373,7 @@ public class AllowDednSalComp
errorCode = "VPPAYPRC01\tException in gbfGetPropAmt of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
*/
*/
exprsEngine.put(strCompCode , retVal);
allInputMap.put(strCompCode , retVal);
dResAmt = retVal;
......@@ -1314,7 +1405,7 @@ public class AllowDednSalComp
olvesTaken = 0;
//dResAmt = calcPropAmt(dpropon, opaidDays, oworkDays, ldFrDate, ldToDate, ldFrDate, ldToDate, mTotDays, dResAmt, runMode, considerAttd);
dResAmt = gbfGetPropAmt(dpropon, opaidDays, oworkDays, ldFrDate, ldToDate, ldFrDate, ldToDate, mTotDays, dResAmt, runMode, considerAttd);
*/
*/
calcPropAmtMap = calcPropAmt(payAdMap, argEmpDataMap, mTotDays, dResAmt, dpropon, lsSplit, runMode, considerAttd, logConn);
errorCode = calcPropAmtMap.get("ERRORCODE").toString();
if(errorCode != null && errorCode.trim().length() > 0)
......@@ -1327,7 +1418,7 @@ public class AllowDednSalComp
{
ototDays = utilMethods.DaysAfter(ldEffDate, ldExpDate)+1;
try {
dResAmt = Double.parseDouble(calcPropAmtMap.get("AMOUNT").toString());
}
catch(Exception e) {
......@@ -1370,7 +1461,7 @@ public class AllowDednSalComp
errorCode = "VPPAYPRC01\tException in gbfGetPropAmt of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
*/
*/
exprsEngine.put(strCompCode , dResAmt);
allInputMap.put(strCompCode , dResAmt);
retVal = dResAmt;
......@@ -1394,7 +1485,7 @@ public class AllowDednSalComp
{
ldExpDate = Timestamp.valueOf(ldExpDateStr);
}
*/
*/
ldEffDate = (Timestamp) payAdMap.get("EFF_DATE");
ldExpDate = (Timestamp) payAdMap.get("EXP_DATE");
// Modifid by Piyush on 07/09/2019 [The dates are timestamp only and are in dbformat in map, so no need to bellow codes].End
......@@ -1430,7 +1521,7 @@ public class AllowDednSalComp
hrLogWriter.gbfErrWrite(strRunPrd, strEmpCode, argProcType, errorCode, "E", 2, logConn);
break;
}*/
calcPropAmtMap = calcPropAmt(payAdMap, argEmpDataMap, mTotDays, dResAmt, dpropon, lsSplit, runMode, considerAttd, logConn);
errorCode = calcPropAmtMap.get("ERRORCODE").toString();
if(errorCode != null && errorCode.trim().length() > 0)
......@@ -1443,7 +1534,7 @@ public class AllowDednSalComp
{
ototDays = utilMethods.DaysAfter(ldEffDate, ldExpDate)+1;
try {
dResAmt = Double.parseDouble(calcPropAmtMap.get("AMOUNT").toString());
}
catch(Exception e) {
......@@ -1451,7 +1542,7 @@ public class AllowDednSalComp
}
}
//Modify by Varsha V on 10-09-2019 to call common method --[END]
// Modified by Piyush on 07/09/2019 [No further evaluation is required but just set amount in map as per PB code].Start
/*
try
......@@ -1487,8 +1578,8 @@ public class AllowDednSalComp
errorCode = "VPPAYPRC01\tException in gbfGetPropAmt of AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
*/
System.out.println("Evaluated values for RESULT 2"+strCompCode+" is "+dResAmt);
*/
System.out.println("Evaluated values for RESULT 2"+strCompCode+" is "+dResAmt);
exprsEngine.put(strCompCode , dResAmt);
allInputMap.put(strCompCode , dResAmt);
retVal = dResAmt;
......@@ -1496,100 +1587,100 @@ public class AllowDednSalComp
}
}
}
System.out.println("Evaluated values for RESULT "+strCompCode+" is "+dResAmt);
exprsEngine.put(strCompCode, dResAmt);
System.out.println("Evaluated values for RESULT "+strCompCode+" is "+dResAmt);
exprsEngine.put(strCompCode, dResAmt);
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].Start
allInputMap.put(strCompCode, dResAmt);
allInputMap.put(strCompCode, dResAmt);
// Modified by Piyush on 07/09/2019 [to create all ad code maps for select in formula].End
//dw_payrollwork1 : argEmpDataMap, dw_payrollwork : payAdMap
String key = strRunPrd+"-"+strEmpCode+"-"+strCompCode;
if(!payrollDetDataMapAll.containsKey(key)) {
System.out.println("Inside payrollDetDataMapAll if.....");
payrollDetDataMap = new LinkedHashMap();
payrollDetDataMap.put("PRD_CODE", strRunPrd);
payrollDetDataMap.put("EMP_CODE", strEmpCode);
payrollDetDataMap.put("AD_CODE", strCompCode);
if(argProcType.equalsIgnoreCase("AR"))
payrollDetDataMap.put("PRD_CODE__ACC", prdCodeArr);
if(argProcType.equalsIgnoreCase("PY") || argProcType.equalsIgnoreCase("AR"))
{
payrollDetDataMap.put("REF_TYPE", payAdMap.get("REF_TYPE"));
payrollDetDataMap.put("REF_NO", payAdMap.get("REF_NO"));
}
/*pstmt1.setString(1, strCompCode);
//dw_payrollwork1 : argEmpDataMap, dw_payrollwork : payAdMap
String key = strRunPrd+"-"+strEmpCode+"-"+strCompCode;
if(!payrollDetDataMapAll.containsKey(key)) {
System.out.println("Inside payrollDetDataMapAll if.....");
payrollDetDataMap = new LinkedHashMap();
payrollDetDataMap.put("PRD_CODE", strRunPrd);
payrollDetDataMap.put("EMP_CODE", strEmpCode);
payrollDetDataMap.put("AD_CODE", strCompCode);
if(argProcType.equalsIgnoreCase("AR"))
payrollDetDataMap.put("PRD_CODE__ACC", prdCodeArr);
if(argProcType.equalsIgnoreCase("PY") || argProcType.equalsIgnoreCase("AR"))
{
payrollDetDataMap.put("REF_TYPE", payAdMap.get("REF_TYPE"));
payrollDetDataMap.put("REF_NO", payAdMap.get("REF_NO"));
}
/*pstmt1.setString(1, strCompCode);
rs = pstmt1.executeQuery();
if(rs.next())
{
addescr = checkNull(rs.getString("descr"));
}*/
payrollDetDataMap.put("DESCR", addescr);
payrollDetDataMap.put("SEQ_NO", payAdMap.get("SEQ_NO"));
payrollDetDataMap.put("TYPE", payAdMap.get("TYPE"));
payrollDetDataMap.put("PAYABLE", payAdMap.get("PAYABLE"));
payrollDetDataMap.put("BASE_AMT", dBaseAmt);
payrollDetDataMap.put("SLAB_AMT", dSlabAmt);
// Modified by Piyush on 07/09/2019[It should be result amount]
// payrollDetDataMap.put("RESULT_AMT", adMap.get(strCompCode));
payrollDetDataMap.put("RESULT_AMT", dResAmt);
payrollDetDataMap.put("POST_YN", payAdMap.get("POST_YN"));
rndOff = (payAdMap.get("RND_OFF") == null ? "" : payAdMap.get("RND_OFF").toString());
//rndOff = argPayCompMap.get("RND_OFF").toString();
rndTo = Double.parseDouble(setNullToZero(payAdMap.get("RND_TO").toString()));
payrollDetDataMap.put("RND_OFF", rndOff);
payrollDetDataMap.put("RND_TO", rndTo);
payrollDetDataMap.put("CALC_AMT", dResAmt);
lAmount = 0;
}
else
{
System.out.println("Inside payrollDetDataMapAll else.....");
rndOff = payAdMap.get("RND_OFF").toString();
rndTo = Double.parseDouble(setNullToZero(payAdMap.get("RND_TO").toString()));
lAmount = Double.parseDouble(setNullToZero(payrollDetDataMap.get("amount").toString()));
}
if(!"N".equalsIgnoreCase(rndOff))
{
mamount = admCommon.gfGetRndAmt(Double.parseDouble(setNullToZero(adMap.get(strCompCode).toString())), rndOff, rndTo);
System.out.println("mamount:::"+mamount);
}
else
{
mamount = Double.parseDouble(setNullToZero(adMap.get(strCompCode).toString()));
mamount = Double.valueOf(format.format(mamount));
System.out.println("mamount:::"+mamount);
}
dResAmt = mamount + lAmount;
if("F".equalsIgnoreCase(strAdType) || ("P".equalsIgnoreCase(strAdType) && dPayAmt != 0))
{
nAdCode = checkNull(payAdMap.get("AD_CODE").toString());
if(!(nAdCode.equalsIgnoreCase(strCompCode)) && (dPayMinAmt != 0 || dPayMaxAmt != 0))
{
if(dPayMinAmt != 0 && dResAmt < dPayMinAmt)
{
dResAmt = dPayMinAmt;
}
if(dPayMaxAmt != 0 && dResAmt > dPayMaxAmt)
{
dResAmt = dPayMaxAmt;
}
}
}
payrollDetDataMap.put("AMOUNT", dResAmt);
try
payrollDetDataMap.put("DESCR", addescr);
payrollDetDataMap.put("SEQ_NO", payAdMap.get("SEQ_NO"));
payrollDetDataMap.put("TYPE", payAdMap.get("TYPE"));
payrollDetDataMap.put("PAYABLE", payAdMap.get("PAYABLE"));
payrollDetDataMap.put("BASE_AMT", dBaseAmt);
payrollDetDataMap.put("SLAB_AMT", dSlabAmt);
// Modified by Piyush on 07/09/2019[It should be result amount]
// payrollDetDataMap.put("RESULT_AMT", adMap.get(strCompCode));
payrollDetDataMap.put("RESULT_AMT", dResAmt);
payrollDetDataMap.put("POST_YN", payAdMap.get("POST_YN"));
rndOff = (payAdMap.get("RND_OFF") == null ? "" : payAdMap.get("RND_OFF").toString());
//rndOff = argPayCompMap.get("RND_OFF").toString();
rndTo = Double.parseDouble(setNullToZero(payAdMap.get("RND_TO").toString()));
payrollDetDataMap.put("RND_OFF", rndOff);
payrollDetDataMap.put("RND_TO", rndTo);
payrollDetDataMap.put("CALC_AMT", dResAmt);
lAmount = 0;
}
else
{
String strResult = String.valueOf(exprsEngine.eval(dResAmt+""));
System.out.println("strResult:::"+strResult);
if(strResult == null || strResult.trim().length() == 0)
{
dResAmt = 0d;
}
else
{
System.out.println("Inside payrollDetDataMapAll else.....");
rndOff = payAdMap.get("RND_OFF").toString();
rndTo = Double.parseDouble(setNullToZero(payAdMap.get("RND_TO").toString()));
lAmount = Double.parseDouble(setNullToZero(payrollDetDataMap.get("amount").toString()));
}
if(!"N".equalsIgnoreCase(rndOff))
{
mamount = admCommon.gfGetRndAmt(Double.parseDouble(setNullToZero(adMap.get(strCompCode).toString())), rndOff, rndTo);
System.out.println("mamount:::"+mamount);
}
else
{
mamount = Double.parseDouble(setNullToZero(adMap.get(strCompCode).toString()));
mamount = Double.valueOf(format.format(mamount));
System.out.println("mamount:::"+mamount);
}
dResAmt = mamount + lAmount;
if("F".equalsIgnoreCase(strAdType) || ("P".equalsIgnoreCase(strAdType) && dPayAmt != 0))
{
nAdCode = checkNull(payAdMap.get("AD_CODE").toString());
if(!(nAdCode.equalsIgnoreCase(strCompCode)) && (dPayMinAmt != 0 || dPayMaxAmt != 0))
{
if(dPayMinAmt != 0 && dResAmt < dPayMinAmt)
{
dResAmt = dPayMinAmt;
}
if(dPayMaxAmt != 0 && dResAmt > dPayMaxAmt)
{
dResAmt = dPayMaxAmt;
}
}
}
payrollDetDataMap.put("AMOUNT", dResAmt);
try
{
String strResult = String.valueOf(exprsEngine.eval(dResAmt+""));
System.out.println("strResult:::"+strResult);
if(strResult == null || strResult.trim().length() == 0)
{
dResAmt = 0d;
}
else
{
if ("NaN".equalsIgnoreCase(strResult))
{
errorCode = "VPPAYPRC01\tResult is non numeric - AD Code [" + strCompCode + "]";
break;
errorCode = "VPPAYPRC01\tResult is non numeric - AD Code [" + strCompCode + "]";
break;
}
else
{
......@@ -1599,47 +1690,47 @@ public class AllowDednSalComp
}
catch(Exception dsParseEx)
{
errorCode = "VPPAYPRC01\tException in converting result [" + strResult + "] of AD Code [" + strCompCode + "]\r\n" + dsParseEx.getMessage();
break;
errorCode = "VPPAYPRC01\tException in converting result [" + strResult + "] of AD Code [" + strCompCode + "]\r\n" + dsParseEx.getMessage();
break;
}
}
}
}
}
catch(Exception bEvalEx)
{
errorCode = "VPPAYPRC01\tException in AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
errorCode = "VPPAYPRC01\tException in AD Code [" + strCompCode + "]\r\n" + bEvalEx.getMessage();
break;
}
if("AR".equalsIgnoreCase(argProcType))
{
System.out.println("Inside argProcType if......");
retMap = payrollPrc.gbfSetArrDet(strRunPrd, strEmpCode, strCompCode, prdCodeArr, payrollDetDataMap, argConn);
if(retMap != null)
{
payrollDetDataMap = (LinkedHashMap)retMap.get("payrollDetMap");
retVal = Integer.parseInt(setNullToZero(retMap.get("retVal").toString()));
if(retVal != 0)
{
errorCode = "VTARR1";
break;
}
}
mamount = payrollPrc.gbfGetNewAmount(strCompCode, rndOff, rndTo, lAmount, adMap);
}
if("A".equalsIgnoreCase(payAdMap.get("PAYABLE").toString()))
{
allwamt = allwamt + mamount;
System.out.println("allwamt:::"+allwamt);
}
else if("D".equalsIgnoreCase(payAdMap.get("PAYABLE").toString()))
{
dednamt = dednamt + mamount;
System.out.println("dednamt:::"+dednamt);
}
String mapKey = strRunPrd+"-"+strEmpCode+"-"+strCompCode;
System.out.println("mapKey:::"+mapKey);
payrollDetDataMapAll.put(mapKey, payrollDetDataMap);
System.out.println("payrollDetDataMapAll:::"+payrollDetDataMapAll);
if("AR".equalsIgnoreCase(argProcType))
{
System.out.println("Inside argProcType if......");
retMap = payrollPrc.gbfSetArrDet(strRunPrd, strEmpCode, strCompCode, prdCodeArr, payrollDetDataMap, argConn);
if(retMap != null)
{
payrollDetDataMap = (LinkedHashMap)retMap.get("payrollDetMap");
retVal = Integer.parseInt(setNullToZero(retMap.get("retVal").toString()));
if(retVal != 0)
{
errorCode = "VTARR1";
break;
}
}
mamount = payrollPrc.gbfGetNewAmount(strCompCode, rndOff, rndTo, lAmount, adMap);
}
if("A".equalsIgnoreCase(payAdMap.get("PAYABLE").toString()))
{
allwamt = allwamt + mamount;
System.out.println("allwamt:::"+allwamt);
}
else if("D".equalsIgnoreCase(payAdMap.get("PAYABLE").toString()))
{
dednamt = dednamt + mamount;
System.out.println("dednamt:::"+dednamt);
}
String mapKey = strRunPrd+"-"+strEmpCode+"-"+strCompCode;
System.out.println("mapKey:::"+mapKey);
payrollDetDataMapAll.put(mapKey, payrollDetDataMap);
System.out.println("payrollDetDataMapAll:::"+payrollDetDataMapAll);
}
if(errorCode != null && errorCode.trim().length() > 0)
{
......@@ -1724,8 +1815,8 @@ public class AllowDednSalComp
}
return calDays;
}
private double gbfGetCalDays (LinkedHashMap argEmpDataMap, Timestamp adJoinDate, Timestamp adPrdFrDate, Timestamp adPrdToDate, double aiTotDays) throws ITMException
{
System.out.println("Calling gbfGetCalDays (Timestamp adJoinDate, Timestamp adPrdFrDate, Timestamp adPrdToDate, double aiTotDays) of AllowDednSalComp");
......@@ -1784,8 +1875,8 @@ public class AllowDednSalComp
String strRunPrd = "";
String strEmpCode = "";
String errorCode = "";
UtilMethods utilMethods = new UtilMethods();
E12GenericUtility genericUtility = new E12GenericUtility();
LinkedHashMap retMap = new LinkedHashMap();
......@@ -1891,7 +1982,7 @@ public class AllowDednSalComp
retMap.put("AMOUNT" , new Double(propAmt));
return retMap;
}
private double gbfGetPropAmt(String propOn, double paidDays, double workDays, Timestamp joinDate, Timestamp relieveDate, Timestamp prdFrDate, Timestamp prdToDate, double totDays, double acAmount, String runMode, String considerAttd) throws ITMException
{
System.out.println("Calling gbfGetPropAmt(String propOn, double paidDays, double workDays, Timestamp joinDate, Timestamp relieveDate, Timestamp prdFrDate, Timestamp prdToDate, double totDays, double acAmount, String runMode, String considerAttd) of AllowDednSalComp");
......@@ -1930,7 +2021,7 @@ public class AllowDednSalComp
{
amount = acAmount * paidDays/totDays;
}
}
catch (Exception e)
{
......@@ -1940,7 +2031,7 @@ public class AllowDednSalComp
System.out.println("amount from gbfGetPropAmt :: ["+amount+"]");
return amount;
}
private LinkedHashMap gbfGetSplitAttd(String prdCode, String empCode, Timestamp frDate, Timestamp toDate, double workDays, double lveTaken, double woffDays, double paidDays, LinkedHashMap argEmpDataMap, Connection conn) throws ITMException, SQLException
{
System.out.println("Calling gbfGetSplitAttd(String prdCode, String empCode, Timestamp frDate, Timestamp toDate, double workDays, double lveTaken, double woffDays, double paidDays, LinkedHashMap argEmpDataMap, Connection conn) of AllowDednSalComp");
......@@ -1981,7 +2072,7 @@ public class AllowDednSalComp
" sum(case when leave_days is null then 0 else leave_days end) as leave_days" +
" from attd_reg where emp_code = ? and attd_date between ? and ?";
pstmt1 = conn.prepareStatement(sql);
sql = "select work_days, paid_days, woff_days, lves_taken from attendance_mon_split " +
"where prd_code = ? and emp_code = ? " +
"and fr_date = :ad_frdate and to_date = :ad_todate";
......@@ -2083,7 +2174,6 @@ public class AllowDednSalComp
System.out.println("retMap from GbfGetSplitAttd :: ["+retMap+"]");
return retMap;
}
}
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