Commit 9442a88c authored by arawankar's avatar arawankar

HRVoucherReversal.java

-bug fixing for create payroll voucher
-Changes made to errstring 


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@190950 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0fc537f5
...@@ -30,7 +30,7 @@ public class HRVoucherReversal ...@@ -30,7 +30,7 @@ public class HRVoucherReversal
public String actionHandler(String tranID, String xtraParams, String forcedFlag,Connection conn) throws RemoteException,ITMException public String actionHandler(String tranID, String xtraParams, String forcedFlag,Connection conn) throws RemoteException,ITMException
{ {
ITMDBAccessEJB itmDBAccessEjb = null; ITMDBAccessEJB itmDBAccessEjb = new ITMDBAccessEJB();
AdmCommon admCommon = null; AdmCommon admCommon = null;
FinCommon finCommon = null; FinCommon finCommon = null;
String sql = ""; String sql = "";
...@@ -77,7 +77,8 @@ public class HRVoucherReversal ...@@ -77,7 +77,8 @@ public class HRVoucherReversal
String payMode = ""; String payMode = "";
String chgTerm = ""; String chgTerm = "";
String chgUser = ""; String chgUser = "";
Timestamp chgDate = null; //Timestamp chgDate = null;
Timestamp revTranDate = null; // Modified by Piyush on 15/09/2018
int lineNo = 0; int lineNo = 0;
String acctCode = ""; String acctCode = "";
...@@ -85,13 +86,20 @@ public class HRVoucherReversal ...@@ -85,13 +86,20 @@ public class HRVoucherReversal
double amountDet = 0.0; double amountDet = 0.0;
String adCode = ""; String adCode = "";
String retString = ""; String retString = "";
//Modified by Anjali R. on [19/08/2018][Start]
PayrollVoucherConf payrollVoucherConf = null;
E12GenericUtility genericUtility = null;
//Modified by Anjali R. on [19/08/2018][End]
try try
{ {
itmDBAccessEjb = new ITMDBAccessEJB(); itmDBAccessEjb = new ITMDBAccessEJB();
admCommon = new AdmCommon(); admCommon = new AdmCommon();
finCommon = new FinCommon(); finCommon = new FinCommon();
E12GenericUtility genericUtility = new E12GenericUtility(); genericUtility = new E12GenericUtility();
PayrollVoucherConf payrollVoucherConf = new PayrollVoucherConf(); payrollVoucherConf = new PayrollVoucherConf();
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime()); String sysDateStr = sdf.format(currentDate.getTime());
...@@ -121,16 +129,20 @@ public class HRVoucherReversal ...@@ -121,16 +129,20 @@ public class HRVoucherReversal
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
// Modified by Piyush on 15/09/2018[Trandate should be current date and should be in application date format. Should be after confirmation checking].Start
/*
if(tranDate != null) if(tranDate != null)
{ {
tranDateStr = genericUtility.getValidDateString(tranDate, genericUtility.getDBDateTimeFormat()); tranDateStr = genericUtility.getValidDateString(tranDate, genericUtility.getDBDateTimeFormat());
System.out.println("tranDateStr---["+tranDateStr+"]"); System.out.println("tranDateStr---["+tranDateStr+"]");
} }
*/
// Modified by Piyush on 15/09/2018[Trandate should be current date and should be in application date format. Should be after confirmation checking].End
if("X".equalsIgnoreCase(confirm)) if("X".equalsIgnoreCase(confirm))
{ {
//errorString = itmDBAccessEjb.getErrorString("confirmed", "VTADMLVE01", "","",conn); errorString = itmDBAccessEjb.getErrorString("", "VTADMLVE01", "","",conn);
errorString = "VTADMLVE01"; //errorString = "VTADMLVE01";
return errorString; return errorString;
} }
else else
...@@ -181,16 +193,22 @@ public class HRVoucherReversal ...@@ -181,16 +193,22 @@ public class HRVoucherReversal
autoPost = getAutoPostValue (empCode, "AUTO_POST", conn); autoPost = getAutoPostValue (empCode, "AUTO_POST", conn);
if("NULLFOUND".equalsIgnoreCase(autoPost)) if("NULLFOUND".equalsIgnoreCase(autoPost))
{ {
//errorString = itmDBAccessEjb.getErrorString("", "VSENVAR1", "", "", conn); errorString = itmDBAccessEjb.getErrorString("", "VSENVAR1", "", "", conn);
errorString = "VSENVAR1"; //errorString = "VSENVAR1";
return errorString; return errorString;
} }
System.out.println("autoPost value:::::[" + autoPost + "]"); System.out.println("autoPost value:::::[" + autoPost + "]");
// Modified by Piyush on 15/09/2018[Trandate should be current date and should be in application date format. Should be after confirmation checking].Start
tranDateStr = sysDateStr;
System.out.println("tranDateStr---["+tranDateStr+"]");
// Modified by Piyush on 15/09/2018[Trandate should be current date and should be in application date format. Should be after confirmation checking].End
reversalVoucherTranId = generateTranId("w_payr_voucher", siteCodeAcct, tranDateStr,conn) ; reversalVoucherTranId = generateTranId("w_payr_voucher", siteCodeAcct, tranDateStr,conn) ;
System.out.println("reversalVoucherTranId--["+reversalVoucherTranId+"]"); System.out.println("reversalVoucherTranId--["+reversalVoucherTranId+"]");
// Modified by Piyush on 15/09/2018[Added ref_no]
sql = "select TRAN_TYPE, EFF_DATE, REF_DATE, " + String refId = "";
sql = "select TRAN_TYPE, EFF_DATE, REF_DATE, REF_NO, " +
"BANK_CODE, AUTO_PAY, PAY_MODE, SITE_CODE, FIN_ENTITY, REMARKS, " + "BANK_CODE, AUTO_PAY, PAY_MODE, SITE_CODE, FIN_ENTITY, REMARKS, " +
"ANAL_CODE, CONFIRMED, PAID, ACCT_CODE__PAY, CCTR_CODE__PAY, TOT_AMT, ENTRY_BATCH_NO, VOUCH_TYPE, " + "ANAL_CODE, CONFIRMED, PAID, ACCT_CODE__PAY, CCTR_CODE__PAY, TOT_AMT, ENTRY_BATCH_NO, VOUCH_TYPE, " +
"CURR_CODE, EXCH_RATE, TOT_AMT__BC, HOLD from PAYR_VOUCHER where TRAN_ID=?"; "CURR_CODE, EXCH_RATE, TOT_AMT__BC, HOLD from PAYR_VOUCHER where TRAN_ID=?";
...@@ -220,6 +238,16 @@ public class HRVoucherReversal ...@@ -220,6 +238,16 @@ public class HRVoucherReversal
exchRate = rs.getDouble("EXCH_RATE"); exchRate = rs.getDouble("EXCH_RATE");
totAmtBC = rs.getDouble("TOT_AMT__BC"); totAmtBC = rs.getDouble("TOT_AMT__BC");
hold = checkNull(rs.getString("HOLD")); hold = checkNull(rs.getString("HOLD"));
// Modified by Piyush on 15/09/2018[Added ref_no]
refId = checkNull(rs.getString("REF_NO"));
if (refId.trim().length() == 0)
{
refId = "RV-" + tranID;
}
else
{
refId = "RV-" + refId;
}
} }
if(rs != null) if(rs != null)
{ {
...@@ -233,21 +261,31 @@ public class HRVoucherReversal ...@@ -233,21 +261,31 @@ public class HRVoucherReversal
} }
System.out.println("@V@ Inserting Payer_voucher"); System.out.println("@V@ Inserting Payer_voucher");
chgDate=Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) revTranDate=Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())
+ " 00:00:00.0"); + " 00:00:00.0");
//chgDate=Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())
// + " 00:00:00.0");
//Check period is open or not //Check period is open or not
errorString = finCommon.nfCheckPeriod("ADM", chgDate, siteCode, conn); // Modified by Piyush on 15/09/2018 [As per Sun Component].Start
//ValidatorEJB validatorEJB = new ValidatorEJB();
errorString = finCommon.nfCheckPeriod("ADM", revTranDate, siteCode, conn);
// Modified by Piyush on 15/09/2018 [As per Sun Component].End
System.out.println("errorString for period checking--["+errorString+"]"); System.out.println("errorString for period checking--["+errorString+"]");
if(errorString != null && errorString.trim().length() >0) if(errorString != null && errorString.trim().length() >0)
{ {
//Modified by Anjali R. on[19/09/2018]
errorString = itmDBAccessEjb.getErrorString("", errorString, "", "", conn);//seems nfCheckPeriod returns only error code
return errorString; return errorString;
} }
// Modified by Piyush on 15/09/2018
/*
String refId=""; String refId="";
refId="RV-"+reversalVoucherTranId; refId="RV-"+reversalVoucherTranId;
*/
sql = " INSERT INTO PAYR_VOUCHER (TRAN_ID, TRAN_DATE, TRAN_TYPE, EFF_DATE, EMP_CODE, REF_NO, REF_DATE, " + 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, REMARKS, " + "BANK_CODE, AUTO_PAY, PAY_MODE, CHG_DATE, CHG_USER, CHG_TERM, SITE_CODE, FIN_ENTITY, REMARKS, " +
...@@ -257,13 +295,21 @@ public class HRVoucherReversal ...@@ -257,13 +295,21 @@ public class HRVoucherReversal
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, reversalVoucherTranId); pstmt.setString(1, reversalVoucherTranId);
pstmt.setTimestamp(2, chgDate); // Modified by Piyush on 15/09/2018
// pstmt.setTimestamp(2, chgDate);
pstmt.setTimestamp(2, revTranDate);
//pstmt.setString(3, tranType); //pstmt.setString(3, tranType);
pstmt.setString(3, "A"); // Modified by Piyush on 15/09/2018
pstmt.setTimestamp(4, effDate); // pstmt.setString(3, "A");
pstmt.setString(3, tranType);
// Modified by Piyush on 15/09/2018
// pstmt.setTimestamp(4, effDate);
pstmt.setTimestamp(4, revTranDate);
pstmt.setString(5, empCode); pstmt.setString(5, empCode);
pstmt.setString(6, refId); pstmt.setString(6, refId);
pstmt.setTimestamp(7, chgDate); // Modified by Piyush on 15/09/2018
// pstmt.setTimestamp(7, chgDate);
pstmt.setTimestamp(7, new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(8, bankCode); pstmt.setString(8, bankCode);
pstmt.setString(9, autoPay); pstmt.setString(9, autoPay);
pstmt.setString(10, payMode); pstmt.setString(10, payMode);
...@@ -341,7 +387,7 @@ public class HRVoucherReversal ...@@ -341,7 +387,7 @@ public class HRVoucherReversal
retString = checkNull(payrollVoucherConf.confirm(reversalVoucherTranId, forcedFlag, xtraParams, conn)); retString = checkNull(payrollVoucherConf.confirm(reversalVoucherTranId, forcedFlag, xtraParams, conn));
System.out.println("retString---["+retString+"]"); System.out.println("retString---["+retString+"]");
} }
if(retString.length() > 0 && retString.indexOf("VTMCONF2") != -1 ) if(retString == null || retString.trim().length() == 0 )
{ {
errorString = ""; errorString = "";
System.out.println("@V@ Payrol voucher confirmed.."); System.out.println("@V@ Payrol voucher confirmed..");
...@@ -349,6 +395,9 @@ public class HRVoucherReversal ...@@ -349,6 +395,9 @@ public class HRVoucherReversal
else else
{ {
errorString = retString; errorString = retString;
//Modified by Anjali R. on [19/08/2018][In case of error ,connection will rollback][Start]
conn.rollback();
//Modified by Anjali R. on [19/08/2018][In case of error ,connection will rollback][End]
} }
} }
...@@ -357,6 +406,22 @@ public class HRVoucherReversal ...@@ -357,6 +406,22 @@ public class HRVoucherReversal
{ {
System.out.println("Exception in actionHandler method--["+ e.getMessage()+"]"); System.out.println("Exception in actionHandler method--["+ e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
//Modified by Anjali R. on [18/09/2018][Start]
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception in actionHandler method--["+ e1.getMessage()+"]");
e1.printStackTrace();
throw new ITMException(e1);
}
retString = itmDBAccessEjb.getErrorString("", "VTLVECAN01", "", "", conn);
return retString;
//Modified by Anjali R. on [18/09/2018][End]
// Modified by Piyush on 15/09/2018
//throw new ITMException(e);
} }
finally finally
{ {
...@@ -372,6 +437,10 @@ public class HRVoucherReversal ...@@ -372,6 +437,10 @@ public class HRVoucherReversal
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(payrollVoucherConf != null)
{
payrollVoucherConf = null;
}
} }
catch(Exception e ) catch(Exception e )
{ {
...@@ -399,7 +468,8 @@ public class HRVoucherReversal ...@@ -399,7 +468,8 @@ public class HRVoucherReversal
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
try { try
{
sql="select ddf_hr_site_env_value(?,SYSDATE,?)as var_value from dual"; sql="select ddf_hr_site_env_value(?,SYSDATE,?)as var_value from dual";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, empCode); pstmt.setString(1, empCode);
...@@ -421,9 +491,19 @@ public class HRVoucherReversal ...@@ -421,9 +491,19 @@ public class HRVoucherReversal
pstmt = null; pstmt = null;
} }
} }
catch (SQLException e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
//Modified by Anjali R. on[19/09/2018][Start]
try
{
conn.rollback();
}
catch(Exception e1)
{
throw new ITMException(e1);
}
//Modified by Anjali R. on[19/09/2018][End]
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
...@@ -475,11 +555,16 @@ public class HRVoucherReversal ...@@ -475,11 +555,16 @@ public class HRVoucherReversal
keyCol = rs.getString("TRAN_ID_COL"); keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER"); tranSer = rs.getString("REF_SER");
} }
if(rs != null)
{
rs.close(); rs.close();
rs=null; rs=null;
}
if(pstmt != null)
{
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
}
System.out.println("keyString :"+keyString); System.out.println("keyString :"+keyString);
...@@ -507,6 +592,18 @@ public class HRVoucherReversal ...@@ -507,6 +592,18 @@ public class HRVoucherReversal
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception :HRVoucherReversal :generateTranId :Exception ::" + e.getMessage() + ":"); System.out.println("Exception :HRVoucherReversal :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);
}
//Modified by Anjali R. on[19/09/2018][End]
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
......
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