Commit eacb611d authored by arawankar's avatar arawankar

EmpLeaveCancel.java

-Changes commented which are made for leave encashment cancellation
-Below new component created for leave encashment cancellation for sun
EmpEncLeaveCanc.java
EmpEncLeaveCancLocal.java
EmpEncLeaveCancRemote.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195356 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 26d42c72
package ibase.webitm.ejb.adm.adv;
//Date: 15/09/2018
/*
1. Changes need in post logic
2. Provision of site wise Parameter for "ALLOW_CANCEL_LVEENC"
3.
*/
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.webitm.bean.sys.ProteusDataSource;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
//import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.adm.AdmCommon;
import ibase.webitm.ejb.adm.AttdProcess;
//Added by Anjali R. on[06/08/2018][To create reversal voucher on cancel of leave encashment]
import ibase.webitm.ejb.adm.HRVoucherReversal;
import ibase.webitm.ejb.adm.LeaveEncase;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
@Stateless
public class EmpEncLeaveCanc extends ActionHandlerEJB implements EmpEncLeaveCancLocal,EmpEncLeaveCancRemote
{
private UtilMethods utilMethod = null ;
private AdmCommon admCommon = null;
private E12GenericUtility genericUtility = null;
private String errXml ="";
private String termId = "",loginEmpCode = "",userId = "";
private HashMap lveRuleList = null;
private ArrayList errList = null;
private ArrayList fldList = null;
private String leaveXmlData = "";
private ProteusDataSource proteusDataSource = null;
//Modified by Anjali R. on [07/08/2018][Start]
private String ExtraParams = "";
private String forceFlag = "";
//Modified by Anjali R. on [07/08/2018][End]
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
genericUtility = new E12GenericUtility();
String retString = "";
Connection conn = null;
// Modified by Piyush on 15/09/2018.Start
Boolean isError = false;
String sqlStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int cnt = 0;
// Modified by Piyush on 15/09/2018.End
//Modified by Anjali R. on [18/09/2018][Start]
ITMDBAccessEJB itmDBAccess = null;
//Modified by Anjali R. on [18/09/2018][End]
try
{
conn = getConnection();
//Modified by Anjali R. on [18/09/2018][Start]
itmDBAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [18/09/2018][End]
//Modified by Anjali R. on [07/08/2018][Start]
ExtraParams = xtraParams;
forceFlag = forcedFlag;
//Modified by Anjali R. on [07/08/2018][End]
//Modified by Anjali R. on [04/01/2019][Other than encashment use flag,not allow to cancel the leave][Start]
String useFlag = "";
sqlStr = "select use_flag from empleave where tran_id = ?";
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
useFlag = checkNull(rs.getString("use_flag"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(!useFlag.equalsIgnoreCase("E"))
{
isError = true;
conn.rollback();
retString = itmDBAccess.getErrorString("", "VTLVECAN02", "", "", conn);
return retString;
}
//Modified by Anjali R. on [04/01/2019][Other than encashment use flag,not allow to cancel the leave][End]
retString = confirm( tranId, xtraParams, forcedFlag, conn);
System.out.println("retString-from confirm method--["+retString+"]");
//Modified by Anjali R. on [18/09/2018][If confirm method return string,then show success message][Start]
if(retString == null || retString.trim().length() == 0)
{
retString = "VTLVECAR01";//Transaction Cancelled!
isError = false;
conn.commit();
}
else
{
conn.rollback();
isError = true;
return retString;
}
//Modified by Anjali R. on [18/09/2018][If confirm method return string,then show success message][End]
// Modified by Piyush on 15/09/2018.Start
sqlStr = "SELECT COUNT(1) AS CNT FROM EMPLEAVE WHERE TRAN_ID = ? AND STATUS = 'C'";
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("CNT");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
isError = true;
//Modified by Anjali R. on [18/09/2018][In case of leave not cancelled][Start]
retString = itmDBAccess.getErrorString("", "VTLVECAN01", "", "", conn);
return retString;
//Modified by Anjali R. on [18/09/2018][In case of leave not cancelled][End]
}
else
{
retString = itmDBAccess.getErrorString("", retString, "", "", conn);
}
// Modified by Piyush on 15/09/2018.End
}
catch(Exception e)
{
System.out.println("Exception :EmpLeaveCancel :confirm():" + e.getMessage() + ":");
retString = genericUtility.createErrorString(e);
e.printStackTrace();
// Modified by Piyush on 15/09/2018.Start
isError = true;
throw new ITMException(e);
// Modified by Piyush on 15/09/2018.End
}
finally
{
try
{
if(conn != null)
{
// Modified by Piyush on 15/09/2018.Start
if (isError)
{
conn.rollback();
}
else
{
conn.commit();
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// Modified by Piyush on 15/09/2018.End
conn.close();
conn = null;
}
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
return retString;
}
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException
{
System.out.println("--------------Confirm method for cancel Empleave -------------");
ResultSet rs=null;
PreparedStatement pstmt = null;
String retString = "";
String errString = "",errCode = "";
HashMap hMap = new HashMap();
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
//Added & Commented by sarita to use object of ITMDBAccessEJB instead ITMDBAccessLocal on 20 JULY 18. [START]
//ITMDBAccessLocal itmDBAccess = null;
ITMDBAccessEJB itmDBAccess = null;
//Added & Commented by sarita to use object of ITMDBAccessEJB instead ITMDBAccessLocal on 20 JULY 18. [END]
if (genericUtility == null)
{
genericUtility = new E12GenericUtility();
}
if (admCommon == null)
{
admCommon = new AdmCommon();
}
if (utilMethod == null)
{
utilMethod = new UtilMethods();
}
try
{
this.errXml ="";
this.errList = new ArrayList();
this.fldList = new ArrayList();
this.lveRuleList = admCommon.createLveRuleList();
this.userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
this.termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
this.loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
//Added & Commented by sarita to create object instead creating lookup for ITMDBAccessEJB on 20 JULY 18 [START]
//appConnect = new AppConnectParm();
//initialCtx = new InitialContext(appConnect.getProperty());
//itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
itmDBAccess = new ITMDBAccessEJB();
//Added & Commented by sarita to create object instead creating lookup for ITMDBAccessEJB on 20 JULY 18 [END]
if (this.leaveXmlData != null && this.leaveXmlData.trim().length() > 0)
{
this.proteusDataSource = new ProteusDataSource("empLeave", this.leaveXmlData, 1);
}
System.out.println("Calling Post Logic......");
retString = postLogic(tranId, tranId, 2, xtraParams, conn);
System.out.println("return Error List of Post Logic :: "+this.errList);
int cnt =0;
String errorCode = "";
String errFldName = null, errorType = "";
StringBuffer errStringXml = new StringBuffer();
if ( this.errList != null && this.errList.size() > 0 )
{
for (cnt = 0; cnt < this.errList.size(); cnt++ )
{
errCode = (String)this.errList.get(cnt);
errFldName = (String)this.fldList.get(cnt);
System.out.println("errCode .........."+errCode);
//Added and commented by sarita on to call getErrorString connection method on 20 JULY 2018 [START]
//errString = itmDBAccess.getErrorString( errFldName, errCode, this.userId );
errString = itmDBAccess.getErrorString(errFldName,errCode,this.userId,"",conn);
//Added and commented by sarita on to call getErrorString connection method on 20 JULY 2018 [END]
/*errorType = getErrorType( errCode , conn );
if ( errorType.equalsIgnoreCase("E"))
{
*/
break;
//}
//errString = "";
}
this.errList.clear();
this.errList = null;
this.fldList.clear();
this.fldList = null;
}
System.out.println("errString--["+errString+"]");
if (errString == null || errString.trim().length() == 0)
{
//Modified by Anjali R. on [18/09/2018][Connection commit will not be happen here][Start]
//conn.commit();
//Modified by Anjali R. on [18/09/2018][Connection commit will not be happen here][End]
//Modified by Anjali R. on [18/09/2018][In case of success ,this method will return empty string][Start]
//Added and commented by sarita on to call getErrorString connection method on 20 JULY 2018 [START]
//errString = itmDBAccess.getErrorString( "", "VTLVECAR01" , this.userId );
//errString = itmDBAccess.getErrorString("","VTLVECAR01",this.userId,"",conn);
errString = "";
//Added and commented by sarita on to call getErrorString connection method on 20 JULY 2018 [END]
//Modified by Anjali R. on [18/09/2018][In case of success ,this method will return empty string][End]
}
else
{
conn.rollback();
}
}
catch(Exception e)
{
System.out.println("Exception :EmpLeaveCancel :confirm():" + e.getMessage() + ":");
retString = genericUtility.createErrorString(e);
e.printStackTrace();
//Modified by Anjali R. on[18/09/2018][Start]
try
{
conn.rollback();
}catch(Exception e1)
{
System.out.println("Exception :EmpLeaveCancel :confirm():" + e1.getMessage() + ":");
}
//Modified by Anjali R. on[18/09/2018][End]
// Modified by Piyush on 15/09/2018
throw new ITMException(e);
}
finally
{
this.errXml ="";
this.leaveXmlData = "";
this.errList = null;
this.fldList = null;
this.lveRuleList = null;
this.proteusDataSource = null;
this.admCommon = null;
this.utilMethod = null;
//Added by sarita on 25 JULY 18 [START]
itmDBAccess = null;
//Added by sarita on 25 JULY 18 [END]
}
System.out.println("Error String Returned from Cancellation of leave :: [" + errString + "]");
return errString;
}
private String postLogic (String tranidFr,String tranidTo,int commit,String xtraParms,Connection conn) throws ITMException
{
HashMap errCode = new HashMap();
String tranId = "" ,useFlag = "",tranidTrimmed = "",status = "",errCode1 = "";
int cnt = 0 , count = 0;
java.sql.Timestamp currDate = null;
LeaveEncase leaveEnc ;
String isError = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("tranidFr :: ["+tranidFr+"]");
System.out.println("tranidTo :: ["+tranidTo+"]");
if(tranidFr == tranidTo)
{
tranId = tranidFr;
tranidTrimmed = tranId.trim();
errCode = cancelLeave(tranId,commit,conn);
sql = "select status,use_flag from empleave where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
status = checkNull(rs.getString("status"));
useFlag = checkNull(rs.getString("use_flag"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(status.equals("C") && utilMethod.pos("CVE" ,useFlag.trim()) > 0)
{
currDate = utilMethod.dateTime(utilMethod.today() , utilMethod.stringToTime("00:00"));
sql = "select count(1) as cnt from wf_prc_status where ref_ser in ('E-LVE','E-LVF','E-LVN') and ref_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranidTrimmed);
rs = pstmt.executeQuery();
while(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (cnt > 0)
{
sql = "";
sql = "update obj_sign_trans set SIGN_DATE = ? , SIGN_STATUS = 'S' , SIGN_REMARKS = 'Application Canceled'"+
"where ref_ser in ('E-LVE','E-LVF','E-LVN') and ref_id = ? and sign_status = 'U'";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2,tranidTrimmed);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][Start]
//if(count == 0)
//{
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][End]
count = 0;
sql = "";
sql = "update wf_prc_status set process_status = 9 , status_remarks = 'Leave application is canceled from ERP'" +
"where ref_ser in ('E-LVE','E-LVF','E-LVN') and ref_id = ? and process_status < 3";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranidTrimmed);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
if(count == 0)
{
sql = "";
sql = "update empleave set WRKFLW_STATUS = 'Z' where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
}
else
{
errCode1 = "DS000";
}
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][Start]
/*}
else
{
errCode1 = "DS000";
}*/
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][End]
System.out.println("errCode1---["+errCode1+"]");
if(errCode1.trim().length() > 0)
{
conn.rollback();
}
//Modified by Anjali R. on [18/09/2018][Connection will not be commit in this method][Start]
/*else
{
conn.commit();
}*/
//Modified by Anjali R. on [18/09/2018][Connection will not be commit in this method][End]
}
}
//}
}
if(errCode.size() > 0)
{
//conn.rollback();
}
else
{
/*errCode1 = "VTLVCANC01";
errList.add(errCode1);
fldList.add("");*/
//Modified by Anjali R. on [18/09/2018][Connection will not be commit in this method][Start]
//conn.commit();
//Modified by Anjali R. on [18/09/2018][Connection will not be commit in this method][End]
}
}
catch(Exception e)
{
//Modified by Anjali R. on [19/09/2018][Start]
e.printStackTrace();
try
{
conn.rollback();
}
catch (Exception e1)
{
e1.printStackTrace();
}
//Modified by Anjali R. on [19/09/2018][End]
// Modified by Piyush on 15/09/2018
throw new ITMException(e);
}
return errCode1;
}
private HashMap cancelLve(String tranId,int commit, Connection connectionObject) throws RemoteException,ITMException
{
HashMap hmap = new HashMap();
/*ArrayList this.errList = new ArrayList();
ArrayList this.fldList = new ArrayList();*/
String useFlag = "" , val1 = "", val2 = "", status = "" , errCode = "";
double val5 = 0 , lveDays = 0;
java.sql.Timestamp val3 = null , val4 = null , date3 = null;
String empCode = "" , lveCode = "", extraArg = "",empCodeAprv = "";
java.sql.Timestamp lveDateFr = null, lveDateTo = null;
java.sql.Timestamp cfDate = null, cfDateList[] = null, effDate = null;
long row = 0;
int noRows = 0;
String sql = "",sql1 = "",sql2 = "";
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null;
ResultSet resultSet = null ,resultSet1 = null,resultSet2 = null;
AttdProcess attdProc;
try
{
do
{
sql = "SELECT EMP_CODE, LVE_CODE, LVE_DATE_FR , LVE_DATE_TO ,STATUS , NO_DAYS , USE_FLAG FROM EMPLEAVE_CANCEL WHERE TRAN_ID = ? ";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, tranId);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
noRows++;
empCode = checkNull(resultSet.getString("EMP_CODE"));
lveCode = checkNull(resultSet.getString("LVE_CODE"));
lveDateFr = resultSet.getTimestamp("LVE_DATE_FR");
lveDateTo = resultSet.getTimestamp("LVE_DATE_TO");
status = checkNull(resultSet.getString("STATUS"));
lveDays = resultSet.getDouble("NO_DAYS");
useFlag = checkNull(resultSet.getString("USE_FLAG"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(status.equals("C"))
{
errCode = "VTEMPLVE13";
break;
}
noRows = 0;
sql1 = "SELECT EFF_DATE , UPTO_DATE , LVES_ALLOC FROM EMPLVE_TRACE WHERE TRAN_ID = ? ORDER BY EFF_DATE ";
pstmt1 = connectionObject.prepareStatement(sql1);
pstmt1.setString(1, tranId);
resultSet1 = pstmt1.executeQuery();
while(resultSet1.next())
{
noRows++;
val3 = resultSet1.getTimestamp("EFF_DATE");
val4 = resultSet1.getTimestamp("UPTO_DATE");
val5 = resultSet1.getDouble("LVES_ALLOC");
}
if(cfDate == null)
{
cfDate = lveDateFr;
}
if(noRows > 0)
{
if(val3.before(cfDate))
{
cfDate = val3;
}
sql2 = "";
//Modified by Anjali R. on [19/09/2018][Query to update ench days in case of encashment][Start]
if("E".equalsIgnoreCase(useFlag))
{
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS = BAL_DAYS + ?,ENCH_DAYS = ENCH_DAYS -? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE <= ?";
}
else
{
//Modified by Anjali R. on [19/09/2018][Query to update ench days in case of encashment][End]
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS = BAL_DAYS + ?,CONS_DAYS = CONS_DAYS -? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE <= ?";
}
pstmt2 = connectionObject.prepareStatement(sql2);
pstmt2.setDouble(1, val5);
pstmt2.setDouble(2, val5);
pstmt2.setString(3, empCode);
pstmt2.setString(4, lveCode);
pstmt2.setTimestamp(5, val3);
pstmt2.setTimestamp(6, val4);
noRows = pstmt2.executeUpdate();
System.out.println("noRows updated in leavebal::["+noRows+"]");
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
sql1 = "";
sql1 = "DELETE FROM EMPLVE_TRACE WHERE TRAN_ID = ? AND EFF_DATE = ? AND UPTO_DATE = ?";
pstmt2 = connectionObject.prepareStatement(sql1);
pstmt2.setString(1, tranId);
pstmt2.setTimestamp(2, val3);
pstmt2.setTimestamp(3, val4);
noRows = pstmt2.executeUpdate();
System.out.println("noRows deleted from emplve_trace::["+noRows+"]");
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
}
if(errCode != null && errCode.trim().length() > 0)
{
break;
}
date3 = utilMethod.dateTime(utilMethod.todaySqlDate(),utilMethod.now());
sql = "";
noRows = 0;
sql = "update empleave_cancel set chg_term = ?, chg_user = ?,chg_date = ? where tran_id = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, this.termId);
pstmt.setString(2, this.userId);
pstmt.setTimestamp(3, date3);
pstmt.setString(4, tranId);
noRows = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
noRows = 0;
sql = "";
sql = "DELETE FROM EMPLEAVE_SUMMARY WHERE TRAN_ID = ? AND USE_FLAG = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, useFlag);
noRows = pstmt.executeUpdate();
System.out.println("noRows--["+noRows+" deleted from EMPLEAVE_SUMMARY");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
noRows = 0;
sql = "";
sql = "update empleave set status = 'C' , status_date = ? where tran_id = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setTimestamp(1, date3);
pstmt.setString(2, tranId);
noRows = pstmt.executeUpdate();
System.out.println("noRows--1111-["+noRows+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
break;
}
while(true);
if(errCode != null && errCode.trim().length() != 0)
{
this.errList.add(errCode);
this.fldList.add("");
//Commented by Anjali R. on[19/09/2018][Start]
/*if(commit == 2)
{
connectionObject.rollback();
}*/
//Commented by Anjali R. on[19/09/2018][End]
}
else
{
this.errXml = "";
if(status.equals("A") && useFlag.equals("C"))
{
attdProc = new AttdProcess();
//errCode = attdProc.attdProcess(empCode, lveDateFr,lveDateTo ,1 , connectionObject);
}
/*addGlobArgs(extraArg);
attdProc.setGlobals(extraArg);*/
//errCode = attdProc.autoAttdProc(empCode , lveDateFr , lveDateTo , 1);
//$$$$$$$$$$$$$$$$$$$$$$$$$$$//errCode = attdProc.attdProcess( lveDateFr , lveDateTo ,empCode , "1",connectionObject);
}
if(commit == 2)
{
if(utilMethod.pos(errCode , "<error") > 0 )
{
this.errXml = errCode;
this.errList.add(errCode);
this.fldList.add("");
//connectionObject.rollback();//Commented by Anjali R. on[19/09/2018]
}
else
{
this.errXml = "";
//Modified by Anjali R. on [18/09/2018][Commit will not happen here]
//connectionObject.commit();
/*if(status.equals("A"))
{
int count1 = 0;
noRows = 0;
sql = "";
sql = "SELECT EFF_DATE FROM LEAVEBAL WHERE EMP_CODE = ? AND EFF_DATE > ? AND LVE_CODE = ? ORDER BY EFF_DATE";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setTimestamp(2, cfDate);
pstmt.setString(3, lveCode);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
noRows++;
effDate = resultSet.getTimestamp("EFF_DATE");
}
if(noRows > 0)
{
count1 = utilMethod.upperBound(cfDateList);
count1 = count1 + 1;
cfDateList[count1] = effDate;
System.out.println("effDate ::::"+effDate);
if(cfDateList.length > 0)
{
// BoLeaveOpenBalance leaveBal = new BoLeaveOpenBalance();
StringBuffer leaveOpenBal = new StringBuffer();
leaveOpenBal.dataobject = "d_lve_open_bal";
leaveOpenBal.SetTransObject(sqlca);
leaveOpenBal.reset();
leaveOpenBal.insertrow(0);
for(row = 1;row <= cfDateList.length;row++)
{
leaveOpenBal.append("<emp_code__fr>").append(empCode).append("</emp_code__fr>");
leaveOpenBal.append("<emp_code__to>").append(empCode).append("</emp_code__to>");
leaveOpenBal.append("<leave_type__fr>").append(lveCode).append("</leave_type__fr>");
leaveOpenBal.append("<leave_type__to>").append(lveCode).append("</leave_type__to>");
leaveOpenBal.append("<resign_emp>").append("N").append("</resign_emp>");
leaveOpenBal.append("<proc_date>").append(cfDateList[(int) row]).append("</proc_date>");
//errCode = leaveBal.process(leaveOpenBal.describe("datawindow.data"), "",extraArg);
errCode = "";
}
}
}
}*/
}
}
}
catch(Exception e)
{
e.printStackTrace();
//Modified by Anjali R. on[19/09/2018][Start]
try
{
connectionObject.rollback();
}
catch(Exception e1)
{
System.out.println("Exception in empleave cancel component--["+e1.getMessage()+"]");
throw new ITMException(e1);
}
//Modified by Anjali R. on[19/09/2018][End]
throw new ITMException(e);
}
//buildErrxml();
//Modified by Anjali R. on [31/12/2018][Start]
hmap.put("ERRORCODE",this.errList);
hmap.put("FLDLIST", this.fldList);
//Modified by Anjali R. on [31/12/2018][End]
return hmap;
}
private HashMap cancelLeave (String tranId, int commit, Connection connectionObject) throws RemoteException,ITMException
{
String useFlag = "" , val1 = "", val2 = "", status = "" , errCode = "";
double val5 = 0 , lveDays = 0 ;
int ediOption = 0;
java.sql.Timestamp val3 = null , val4 = null , date3 = null;
java.sql.Timestamp lveFromDate = null,lveToDate = null;
String empCode = "" , lveCode = "" , sql1 = "";
String empStatus = "",empCodeApprv = "";
java.sql.Timestamp lveDateFr = null , lveDateTo = null, statusDate = null;
StringBuffer empLveCancel ;//DataStore empLveCancel;
//AEDFunctionsAdv functionsAdv = new AEDFunctionsAdv();
String sql = "";
PreparedStatement pstmt = null;
ResultSet resultSet = null;
int noRows = 0;
int count = 0;
HashMap hmap = new HashMap();
E12GenericUtility genericUtility;
/*ArrayList this.errList = new ArrayList();
ArrayList this.fldList = new ArrayList();*/
try
{
genericUtility = new E12GenericUtility();
do
{
sql = "SELECT EMP_CODE, LVE_CODE, LVE_DATE_FR , LVE_DATE_TO ,STATUS , NO_DAYS , USE_FLAG FROM EMPLEAVE WHERE TRAN_ID = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,tranId);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
empCode = checkNull(resultSet.getString("EMP_CODE"));
lveCode = checkNull(resultSet.getString("LVE_CODE"));
lveDateFr = resultSet.getTimestamp("LVE_DATE_FR");
lveDateTo = resultSet.getTimestamp("LVE_DATE_TO");
status = checkNull(resultSet.getString("STATUS"));
lveDays = resultSet.getDouble("NO_DAYS");
useFlag = checkNull(resultSet.getString("USE_FLAG"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(status.equals("C"))
{
errCode = "VTEMPLVE13";
this.errList.add(errCode);
this.fldList.add("");
break;
}
else if(useFlag.equals("E"))
{
if(status.equals("A"))
{
// Modified by Piyush on 15/09/2018.Start
String siteCode = "" , cadreCode = "" , gradeCode = "";
sql = "SELECT PAY_SITE, CADRE, GRADE FROM EMPLOYEE WHERE EMP_CODE = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,empCode);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
siteCode = checkNull(resultSet.getString("PAY_SITE"));
cadreCode = checkNull(resultSet.getString("CADRE"));
gradeCode = checkNull(resultSet.getString("GRADE"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String currDateStr = sdf.format(new Date());
Timestamp currDateTime = java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(currDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()));
String allowEnvLveCancel = checkNull(admCommon.getAdmEnv(siteCode, cadreCode,gradeCode , "ALLOW_CANCEL_LVEENC", currDateTime, connectionObject));
if("NULLFOUND".equalsIgnoreCase(allowEnvLveCancel))
{
allowEnvLveCancel = checkNull(admCommon.getEnv("999999", "ALLOW_CANCEL_LVEENC", connectionObject));
}
if(!("Y".equalsIgnoreCase(allowEnvLveCancel )))
{
errCode = "VTEMPLVE21";
this.errList.add(errCode);
this.fldList.add("");
break;
}
// Modified by Piyush on 15/09/2018.End
//Modified by Anjali R. on [03/08/2018][To cancel approved leave encashment entries][Start]
/*errCode = "VTEMPLVE21";
this.errList.add(errCode);
this.fldList.add("");
break;*/
//cancellation of approved leaves in case of encashment
errCode = cancelEnchLeaves(tranId,connectionObject);
System.out.println("errCode--["+errCode+"]");
//Modified by Anjali R. on[19/09/2018][Start]
/*if(errCode != null && errCode.trim().length() > 0)
{
errCode = errCode;
System.out.println("errCode---["+errCode+"]");
this.errList.add(errCode);
this.fldList.add("");
break;
}*/
if ((errCode != null) && (errCode.trim().length() > 0) && (errCode.indexOf("<Errors>") != -1))
{
try
{
connectionObject.rollback();//Modified by Anjali R. on [31/12/2018][In case of error system should rollbacked entire transaction]
System.out.println("Inside try");
Document errDom = genericUtility.parseString(errCode);
System.out.println("errDom--[" + errDom + "]");
NodeList parentNodeList = errDom.getElementsByTagName("error");
System.out.println("parentNodeList----[" + parentNodeList.getLength() + "]");
Node parentNode = null;
int parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength--[" + parentNodeListLength + "]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++)
{
parentNode = parentNodeList.item(prntCtr);
System.out.println("parentNode---[" + parentNode + "]");
errCode = parentNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("errCode--[" + errCode + "]");
if ((errCode != null) && (errCode.trim().length() > 0))
{
errList.add(errCode);
fldList.add("");
break;
}
}
System.out.println("errList--[" + errList + "]");
break;//Modified by Anjali R. on [31/12/2018][In case of error system should rollbacked entire transaction]
}
catch (Exception e)
{
connectionObject.rollback();//Modified by Anjali R. on [31/12/2018][In case of error system should rollbacked entire transaction]
System.out.println("exception while adding error in errList--[" + e.getMessage() + "]");
e.printStackTrace();
throw new ITMException(e);
}
}
//Modified by Anjali R. on[19/09/2018][End]
//Modified by Anjali R. on [03/08/2018][To cancel approved leave encashment entries][End]
}
}
else if(useFlag.equals("L"))
{
errCode = "VTLVE16";
this.errList.add(errCode);
this.fldList.add("");
break;
}
else if(useFlag.equals("V") && status.equals("A"))
{
errCode ="VTLVE16";
this.errList.add(errCode);
this.fldList.add("");
break;
}
sql = "select case when status is null then '' else status end as status from employee where emp_code = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,empCode);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
empStatus = checkNull(resultSet.getString("status"));
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(empStatus.equals("S"))
{
errCode = "VTEMPSEP1";
this.errList.add(errCode);
this.fldList.add("");
break;
}
String empCodeAprv = "",lveType = "",prdCode = "",remarks = "",tranIdPayr="",
authEmp = "",authEmpAlternate = "",chgdate = "",chguser = "",chgterm = "",
leaveStarts = "",leaveEnds = "";
java.sql.Timestamp statusDate1 = null,lvefrdate1 = null,lvetodate1 = null,aprvDate1= null,applDate = null;
//String startTime = "",endTime = "",aprvDate = "";
java.sql.Timestamp startTime = null,endTime = null,aprvDate = null,chgDate = null;
double enchAmt = 0,noDays = 0,noDaysAdv = 0;
PreparedStatement ps = null;String txt = "";
ResultSet rs1 = null;int cnt1 = 0;
txt = " Select TRAN_ID ,EMP_CODE, LVE_DATE_FR, LVE_DATE_TO,LVE_CODE,EMP_CODE__APRV,APRV_DATE,LVE_TYPE,"+
" USE_FLAG,ENCH_AMT,NO_DAYS,STATUS,STATUS_DATE,PRD_CODE,REMARKS,TRAN_ID__PAYR,NO_DAYS_ADV,APPL_DATE,"+
" AUTH_EMP,AUTH_EMP_ALTERNATE,DBSYSDATE() as current_date,?,?,LEAVE_STARTS, LEAVE_ENDS, START_TIME, END_TIME "+
" FROM EMPLEAVE WHERE TRAN_ID = ?";
ps = connectionObject.prepareStatement(txt);
ps.setString(1, userId);
ps.setString(2, termId);
ps.setString(3, tranId);
rs1 = ps.executeQuery();
while(rs1.next())
{
cnt1++;
tranId = checkNull(rs1.getString("TRAN_ID"));
empCode = checkNull(rs1.getString("EMP_CODE"));
//Modified by Anjali R. on [04/06/2018][To take LVE_DATE_FR,LVE_DATE_TO in timestamp data type][Start]
//lvefrdate1 = checkNull(rs1.getString("LVE_DATE_FR"));
//lvetodate1 = checkNull(rs1.getString("LVE_DATE_TO"));
lveFromDate = rs1.getTimestamp("LVE_DATE_FR");
lveToDate = rs1.getTimestamp("LVE_DATE_TO");
//Modified by Anjali R. on [04/06/2018][To take LVE_DATE_FR,LVE_DATE_TO in timestamp data type][End]
lveCode = checkNull(rs1.getString("LVE_CODE"));
empCodeAprv = checkNull(rs1.getString("EMP_CODE__APRV"));
//Modified by Anjali R. on [06/06/2018][To get apprv date in timestamp data type][Start]
//aprvDate1 = checkNull(rs1.getString("APRV_DATE"));
aprvDate1 = rs1.getTimestamp("APRV_DATE");
//Modified by Anjali R. on [06/06/2018][To get apprv date in timestamp data type][End]
lveType = checkNull(rs1.getString("LVE_TYPE"));
useFlag = checkNull(rs1.getString("USE_FLAG"));
enchAmt = rs1.getDouble("ENCH_AMT");
noDays = rs1.getDouble("NO_DAYS");
status = checkNull(rs1.getString("STATUS"));
//Modified by Anjali R. on[04/06/2018][To take status date in timestamp data type][Start]
//statusDate1 = checkNull(rs1.getString("STATUS_DATE"));
statusDate1 = rs1.getTimestamp("STATUS_DATE");
//Modified by Anjali R. on[04/06/2018][To take status date in timestamp data type][End]
prdCode = checkNull(rs1.getString("PRD_CODE"));
remarks = checkNull(rs1.getString("REMARKS"));
tranIdPayr = checkNull(rs1.getString("TRAN_ID__PAYR"));
noDaysAdv = rs1.getDouble("NO_DAYS_ADV");
//Modified by Anjali R. on[06/06/2018][To get appl date in timestamp data type][Start]
applDate = rs1.getTimestamp("APPL_DATE");
//applDate = checkNull(rs1.getString("APPL_DATE"));
//Modified by Anjali R. on[06/06/2018][To get appl date in timestamp data type][End]
authEmp = checkNull(rs1.getString("AUTH_EMP"));
authEmpAlternate = checkNull(rs1.getString("AUTH_EMP_ALTERNATE"));
leaveStarts = checkNull(rs1.getString("LEAVE_STARTS"));
leaveEnds = checkNull(rs1.getString("LEAVE_ENDS"));
//Modified by Anjali R. on[04/06/2018][To take START_TIME,END_TIME in timestamp data type][Start]
//startTime = checkNull(rs1.getString("START_TIME"));
//endTime = checkNull(rs1.getString("END_TIME"));
startTime = rs1.getTimestamp("START_TIME");
endTime = rs1.getTimestamp("END_TIME");
chgDate = rs1.getTimestamp("current_date");
//Modified by Anjali R. on[04/06/2018][To take START_TIME,END_TIME in timestamp data type][End]
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(ps != null)
{
ps.close();
ps = null;
}
count = 0;
int rowsUpdate = 0;String newSql = "";
PreparedStatement ps2 = null;
newSql = "INSERT INTO EMPLEAVE_CANCEL(TRAN_ID ,EMP_CODE, LVE_DATE_FR, LVE_DATE_TO,LVE_CODE,EMP_CODE__APRV,APRV_DATE,LVE_TYPE,"+
" USE_FLAG,ENCH_AMT,NO_DAYS,STATUS,STATUS_DATE,PRD_CODE,REMARKS,TRAN_ID__PAYR,NO_DAYS_ADV,APPL_DATE,"+
" AUTH_EMP,AUTH_EMP_ALTERNATE,CHG_DATE,CHG_USER,CHG_TERM,LEAVE_STARTS,LEAVE_ENDS,START_TIME,END_TIME) "+
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
ps2 = connectionObject.prepareStatement(newSql);
ps2.setString(1, tranId);
ps2.setString(2, empCode);
//Modified by Anjali R. on[04/06/2018][To set timestamp values in lve from and to][Start]
//ps2.setString(3, lvefrdate1.length() > 0?genericUtility.getValidDateString(lvefrdate1, genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()):null);
//ps2.setString(4, lvetodate1.length() > 0?genericUtility.getValidDateString(lvetodate1, genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()):null);
ps2.setTimestamp(3, lveFromDate);
ps2.setTimestamp(4, lveToDate);
//Modified by Anjali R. on[04/06/2018][To set timestamp values in lve from and to][End]
ps2.setString(5, lveCode);
ps2.setString(6, empCodeAprv);
//Modified by Anjali R. on[06/06/2018][To set aprv date in timestamp data type][Start]
//ps2.setString(7,aprvDate1.length() > 0?genericUtility.getValidDateString(aprvDate1, genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()):null);
ps2.setTimestamp(7,aprvDate1);
//Modified by Anjali R. on[06/06/2018][To set aprv date in timestamp data type][End]
ps2.setString(8, lveType);
ps2.setString(9, useFlag);
ps2.setDouble(10, enchAmt);
ps2.setDouble(11, noDays);
ps2.setString(12, status);
//Modified by Anjali R. on[04/06/2018][To set status date in timestamp data type][Start]
//ps2.setString(13, statusDate1.length() > 0?genericUtility.getValidDateString(statusDate1,genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()):null);
ps2.setTimestamp(13, statusDate1);
//Modified by Anjali R. on[04/06/2018][To set status date in timestamp data type][End]
ps2.setString(14, prdCode);
ps2.setString(15, remarks);
ps2.setString(16, tranIdPayr);
ps2.setDouble(17, noDaysAdv);
//Modified by Anjali R. on[06/06/2018][To set appl date in timestamp data type][Start]
//ps2.setString(18, applDate.length() > 0?genericUtility.getValidDateString(applDate, genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()):null);
ps2.setTimestamp(18, applDate);
//Modified by Anjali R. on[06/06/2018][To set appl date in timestamp data type][End]
ps2.setString(19, authEmp);
ps2.setString(20, authEmpAlternate);
ps2.setTimestamp(21, chgDate);
ps2.setString(22, userId);
ps2.setString(23, termId);
ps2.setString(24, leaveStarts);
ps2.setString(25, leaveEnds);
//Modified by Anjali R. on[04/06/2018][To set START_TIME,END_TIME in timestamp data type][Start]
//ps2.setString(25,startTime.length() > 0?genericUtility.getValidDateString(startTime, genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()):null);
//ps2.setString(26,endTime.length() > 0?genericUtility.getValidDateString(endTime,genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()):null);
ps2.setTimestamp(26,startTime);
ps2.setTimestamp(27,endTime);
//Modified by Anjali R. on[04/06/2018][To set START_TIME,END_TIME in timestamp data type][End]
rowsUpdate = ps2.executeUpdate();
System.out.println("rowsUpdate----["+rowsUpdate+"]");
if(ps2 != null)
{
ps2.close();
ps2 = null;
}
if(rowsUpdate > 0)
{
if(status.equals("A"))
{
hmap = cancelLve(tranId , 2 , connectionObject);
if(errCode != null && errCode.trim().length() > 0 &&utilMethod.pos(errCode , "<Errors>") > 0)
{
break;
}
else
{
noRows = 0;
sql = "select edi_option from transetup where tran_window = 'w_empleave_cancel'";
pstmt = connectionObject.prepareStatement(sql);
resultSet = pstmt.executeQuery();
while(resultSet.next())
{
noRows++;
ediOption = resultSet.getInt("edi_option");
}
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
/*if(noRows == 0)
{
errCode = "DS000";
this.errList.add(errCode);
this.fldList.add("");
break;
}*/
if(ediOption > 0 )
{
empLveCancel = new StringBuffer();
/*empLveCancel.dataobject = "d_empleave_cancel_edit";
empLveCancel.settransobject(sqlca);
empLveCancel.retrieve(tranId);
*/
if(ediOption == 2)
{
//To be done later on
//functionsAdv.post nf_create_edi_multi("w_empleave_cancel",empLveCancel.describe("datawindow.syntax") +"\r"+empLveCancel.describe("datawindow.syntax.data"),'E',ediOption, 1, "","","","","","");
}
else
{
//To be done later on
//functionsAdv.nf_create_edi_multi("w_empleave_cancel",empLveCancel.describe("datawindow.syntax") +"\r"+empLveCancel.describe("datawindow.syntax.data"),'E',ediOption, 1, "","","","","","");
}
}
}
}
else if(status.equals("R"))
{
statusDate = utilMethod.dateTime(utilMethod.todaySqlDate(),utilMethod.now());
sql = "";
noRows = 0;
sql = "update empleave set status = 'C' , status_date = ? where tran_id = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setTimestamp(1,statusDate);
pstmt.setString(2, tranId);
noRows = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("noRows---@@@@["+noRows+"]");
}
}
break;
}while(true);
if(errCode != null && errCode.trim().length() > 0 )
{
if(utilMethod.pos(errCode , "<Errors>") == 0)
{
this.errList.add(errCode);
this.fldList.add("");
}
else
{
this.errXml = errCode;
}
//Modified by Anjali R. on [18/09/2018][Connection commit will not happen here][Start]
/*if(commit == 2)
{
connectionObject.rollback();
}*/
}
/*else if(commit == 2)
{
connectionObject.commit();
}*/
//Modified by Anjali R. on [18/09/2018][Connection commit will not happen here][End]
}
catch(Exception e)
{
e.printStackTrace();
//Modified by Anjali R. on [18/09/2018][Start]
try
{
connectionObject.rollback();
}
catch(Exception e1)
{
System.out.println("Exception in empleave cancel component--["+e1.getMessage()+"]");
throw new ITMException(e1);
}
//Modified by Anjali R. on [18/09/2018][End]
throw new ITMException(e);
}
hmap.put("ERRORCODE",this.errList);
hmap.put("FLDLIST", this.fldList);
return hmap;
}
private String getErrorType(String errorCode , Connection conn) throws RemoteException, ITMException
{
String errorType = "";
String sqlStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sqlStr = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while (rs.next())
{
errorType = checkNull(rs.getString("MSG_TYPE"));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(errorType == null || errorType.trim().length() == 0)
{
errorType = "E";
}
}
catch (Exception e)
{
//Modified by Anjali R. on [18/09/2018][Start]
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception in empleave cancel component--["+e1.getMessage()+"]");
throw new ITMException(e1);
}
//Modified by Anjali R. on [18/09/2018][End]
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e1)
{
e1.printStackTrace();
}
}
return errorType;
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
//Modified by Anjali R. on[06/08/2018][Added method to cancel leave approved encashment entries.][Start]
private String cancelEnchLeaves(String tranId ,Connection conn) throws ITMException
{
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String empCode = "";
String encashMode = "";
String prdCodePayroll = "";
String tranIdPayr = "";
double enchAmt = 0.0;
String adCode = "";
String lveCode = "";
int month = 0;
int cnt = 0;
int updCount = 0;
String refNo = "";
int count = 0;
Timestamp frDate = null;
Timestamp toDate = null;
Timestamp lveDateFr = null;
String retString = "";
String frDateStr = "";
String toDateStr = "";
String lveDateFrStr = "";
String arrearVoucherStatus = "";
String siteCode = "";
String finYearErr = "";
String chgUser = "";//Modified by Anjali R. on [31/12/2018]
SimpleDateFormat simpleDateFormat = null;
ITMDBAccessEJB itmdbAccessEJB = null;
E12GenericUtility genericUtility = null;
HRVoucherReversal hrVoucherReversal = null;
AdmCommon admCommon = null;
try
{
itmdbAccessEJB = new ITMDBAccessEJB();
genericUtility = new E12GenericUtility();
hrVoucherReversal = new HRVoucherReversal();
admCommon = new AdmCommon();
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
siteCode = genericUtility.getValueFromXTRA_PARAMS(ExtraParams, "loginSiteCode");
//Modified by Anjali R. on [31/12/2018][Start]
chgUser = genericUtility.getValueFromXTRA_PARAMS(ExtraParams,"loginCode");
//Modified by Anjali R. on [31/12/2018][End]
System.out.println("siteCode--["+siteCode+"]");
sql = "select emp_code,ench_amt,encash_mode,prd_code__payroll,tran_id__payr,lve_code,lve_date_fr from empleave where tran_id =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
empCode = checkNull(rs.getString("emp_code"));
encashMode = checkNull(rs.getString("encash_mode"));
prdCodePayroll = checkNull(rs.getString("prd_code__payroll"));
tranIdPayr = checkNull(rs.getString("tran_id__payr"));
enchAmt = rs.getDouble("ench_amt");
lveCode = checkNull(rs.getString("lve_code"));
lveDateFr = rs.getTimestamp("lve_date_fr");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(lveDateFr != null)
{
lveDateFrStr = genericUtility.getValidDateString(lveDateFr, genericUtility.getDBDateTimeFormat());
System.out.println("tranDateStr---["+lveDateFrStr+"]");
}
//Modified by Anjali R. on [18/09/2018][Start]
//String allowEnvLveCancel = admCommon.getEnv("999999", "ALLOW_CANCEL_LVEENC", conn);
//if("Y".equalsIgnoreCase(allowEnvLveCancel ))
//{
//Modified by Anjali R. on [18/09/2018][End]
//Modified by Anjali R. [03/01/2019][Start]
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, chgUser);
pstmt.setString(4, lveDateFrStr);
pstmt.setString(5, "CANC_LVE_ENC");
rs = pstmt.executeQuery();
if(rs.next())
{
finYearErr = checkNull(rs.getString("err_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(finYearErr != null && finYearErr.trim().length() > 0)
{
retString = itmdbAccessEJB.getErrorString("", finYearErr, userId,"",conn);
//retString = finYearErr;
return retString;
}
//Modified by Anjali R. [03/01/2019][End]
//If encashment amount paid through voucher then ench mode is "V" ,through payroll then ench mode "P"
if("V".equalsIgnoreCase(encashMode))
{
if(tranIdPayr!=null && tranIdPayr.trim().length()>0)
{
//Modified by Anjali R. [03/01/2019][Start]
/*sql = "select FN_CHECK_ACCOUNTING_YEAR(?,?,?,?) as err_code from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, tranIdPayr);
pstmt.setString(3, userId);
pstmt.setString(4, lveDateFrStr);
rs = pstmt.executeQuery();
if(rs.next())
{
finYearErr = checkNull(rs.getString("err_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(finYearErr != null && finYearErr.trim().length() > 0)
{
retString = itmdbAccessEJB.getErrorString("", finYearErr, userId,"",conn);
//retString = finYearErr;
return retString;
}*/
//Modified by Anjali R. [03/01/2019][End]
sql = "select status from empleave_ench_arr where tran_id__lve = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
arrearVoucherStatus = checkNull(rs.getString("status"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//If arrears voucher is exist in confirm status
if("A".equalsIgnoreCase(arrearVoucherStatus))
{
retString = itmdbAccessEJB.getErrorString("", "VTADMLVE04", "","",conn);
//retString = "VTADMLVE04";
return retString;
}
else if("X".equalsIgnoreCase(arrearVoucherStatus) || arrearVoucherStatus == null || arrearVoucherStatus.trim().length() == 0)
{
retString = hrVoucherReversal.actionHandler(tranIdPayr, ExtraParams, forceFlag,conn);
System.out.println("retString---["+retString+"]");
}
}
}
else if("P".equalsIgnoreCase(encashMode))
{
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
frDate = rs.getTimestamp("fr_date");
toDate = rs.getTimestamp("to_date");
}
else
{
retString = itmdbAccessEJB.getErrorString("prd_code", "VTADMLVE03", "", "",conn);
//retString = "VTADMLVE03";
return retString;
}
System.out.println("frDate--["+frDate+"]toDate--["+toDate+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
month = frDate.getMonth() + 1;
System.out.println("month--["+month+"]");
frDateStr = simpleDateFormat.format(frDate);
System.out.println("frDateStr--["+frDateStr+"]");
toDateStr = simpleDateFormat.format(toDate);
System.out.println("toDateStr--["+toDateStr+"]");
//Modified by Anjali R. on [31/12/2018][To update full year in ref_no][Start]
//refNo = frDateStr+lveCode;
SimpleDateFormat simpleDtFormat = new SimpleDateFormat("dd/MM/yyyy");
String frDtStr = simpleDtFormat.format(frDate);
refNo = frDtStr+lveCode;
//Modified by Anjali R. on [31/12/2018][To update full year in ref_no][End]
sql = "select ad_code__ench from leaves where lve_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lveCode);
rs = pstmt.executeQuery();
if(rs.next())
{
adCode = checkNull(rs.getString("ad_code__ench"));
}
System.out.println("adCode--["+adCode+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = " select count(*) as cnt from employee_mthad where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, adCode);
pstmt.setTimestamp(4, frDate);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Count --["+cnt+"]");
if(cnt == 0)
{
sql = "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(?,?,?,?,?,'F',?,?,?,?,'E',?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, adCode);
pstmt.setTimestamp(4, frDate);
pstmt.setTimestamp(5, toDate);
pstmt.setDouble(6, enchAmt * -1);
pstmt.setTimestamp(7,new java.sql.Timestamp(System.currentTimeMillis()) );
pstmt.setString(8,userId);
pstmt.setString(9, termId);
pstmt.setString(10, refNo);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Updated ["+updCount+"] rows in employee_mthad table");
}
else
{
updCount = 0;
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][Start]
/*sql = "update employee_mthad set ref_type = 'E' ,ref_no = ?,type = 'F',amount = amount + ? "
+ "where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";*/
sql = "update employee_mthad set ref_type = 'E' ,ref_no = ?,type = 'F',amount = amount + ?,chg_date = ?,chg_term= ?,chg_user = ? "
+ "where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][End]
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setDouble(2, enchAmt*-1);
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][Start]
pstmt.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()) );
pstmt.setString(4,chgUser);
pstmt.setString(5, chgUser);
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][End]
pstmt.setString(6, empCode);
pstmt.setInt(7, month);
pstmt.setString(8, adCode);
pstmt.setTimestamp(9, frDate);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Updated ["+updCount+"] rows in employee mthad table.");
}
sql = "select count(1) as cnt from payroll where emp_code = ? and prd_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("count--["+count+"]");
if(count > 0)
{
//Modified by Anjali R. on [03/01/2019][Start]
//retString = admCommon.payarrToProcUpdation(prdCodePayroll, prdCodePayroll, empCode, empCode, "PY", "w_empleave", "", adCode,enchAmt*-1 , frDateStr, toDateStr, ExtraParams, conn);
retString = admCommon.payarrToProcUpdation(prdCodePayroll, prdCodePayroll, empCode, empCode, "AR", "w_empleave", "", adCode,enchAmt*-1 , frDateStr, toDateStr, ExtraParams, conn);
//Modified by Anjali R. on [03/01/2019][End]
System.out.println("retString--["+retString+"]");
//Modified by Anjali R. on[19/09/2018][Start]
if(retString != null && retString.trim().length() > 0)
{
conn.rollback();
retString = itmdbAccessEJB.getErrorString("", retString, "", "",conn);
return retString;
}
//Modified by Anjali R. on[19/09/2018][End]
}
}
//}
}
catch(Exception e)
{
System.out.println("Exception in cancelEnchLeaves--["+e.getMessage()+"]");
e.printStackTrace();
try
{
conn.rollback();
}
catch (Exception e1)
{
System.out.println("SQLException---["+e1.getMessage()+"]");
e1.printStackTrace();
throw new ITMException(e1);
}
System.out.println("Exception---["+e.getMessage()+"]");
e.printStackTrace();
retString = "DS000";
return retString;
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception in finally block--["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
//Modified by Anjali R. on[06/08/2018][Added method to cancel leave approved encashment entries.][End]
}
\ No newline at end of file
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
public interface EmpEncLeaveCancLocal extends ActionHandlerLocal
{
@Override
public String confirm(String arg0, String arg1, String arg2, Connection arg3)
throws RemoteException, ITMException;
@Override
public String confirm(String arg0, String arg1, String arg2)
throws RemoteException, ITMException;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
public interface EmpEncLeaveCancRemote extends ActionHandlerRemote
{
@Override
public String confirm(String arg0, String arg1, String arg2)
throws RemoteException, ITMException;
@Override
public String confirm(String arg0, String arg1, String arg2,
Connection arg3, UserInfoBean arg4) throws RemoteException,
ITMException;
}
......@@ -3,7 +3,7 @@
1. Changes need in post logic
2. Provision of site wise Parameter for "ALLOW_CANCEL_LVEENC"
3.
*/
*/
package ibase.webitm.ejb.adm.adv;
......@@ -70,18 +70,18 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
ResultSet rs = null;
int cnt = 0;
// Modified by Piyush on 15/09/2018.End
//Modified by Anjali R. on [18/09/2018][Start]
ITMDBAccessEJB itmDBAccess = null;
//Modified by Anjali R. on [18/09/2018][End]
try
{
conn = getConnection();
//Modified by Anjali R. on [18/09/2018][Start]
itmDBAccess = new ITMDBAccessEJB();
//Modified by Anjali R. on [18/09/2018][End]
//Modified by Anjali R. on [07/08/2018][Start]
ExtraParams = xtraParams;
forceFlag = forcedFlag;
......@@ -102,8 +102,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
return retString;
}
//Modified by Anjali R. on [18/09/2018][If confirm method return string,then show success message][End]
// Modified by Piyush on 15/09/2018.Start
sqlStr = "SELECT COUNT(1) AS CNT FROM EMPLEAVE WHERE TRAN_ID = ? AND STATUS = 'C'";
pstmt = conn.prepareStatement(sqlStr);
......@@ -134,7 +134,7 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
else
{
retString = itmDBAccess.getErrorString("", retString, "", "", conn);
}
// Modified by Piyush on 15/09/2018.End
}
......@@ -275,7 +275,7 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//Modified by Anjali R. on [18/09/2018][Connection commit will not be happen here][Start]
//conn.commit();
//Modified by Anjali R. on [18/09/2018][Connection commit will not be happen here][End]
//Modified by Anjali R. on [18/09/2018][In case of success ,this method will return empty string][Start]
//Added and commented by sarita on to call getErrorString connection method on 20 JULY 2018 [START]
//errString = itmDBAccess.getErrorString( "", "VTLVECAR01" , this.userId );
......@@ -305,7 +305,7 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//Modified by Anjali R. on[18/09/2018][End]
// Modified by Piyush on 15/09/2018
throw new ITMException(e);
}
finally
{
......@@ -402,27 +402,28 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//if(count == 0)
//{
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][End]
count = 0;
count = 0;
sql = "";
sql = "update wf_prc_status set process_status = 9 , status_remarks = 'Leave application is canceled from ERP'" +
"where ref_ser in ('E-LVE','E-LVF','E-LVN') and ref_id = ? and process_status < 3";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranidTrimmed);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
if(count == 0)
{
sql = "";
sql = "update wf_prc_status set process_status = 9 , status_remarks = 'Leave application is canceled from ERP'" +
"where ref_ser in ('E-LVE','E-LVF','E-LVN') and ref_id = ? and process_status < 3";
sql = "update empleave set WRKFLW_STATUS = 'Z' where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranidTrimmed);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
if(count == 0)
{
sql = "";
sql = "update empleave set WRKFLW_STATUS = 'Z' where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
count = pstmt.executeUpdate();
}
else
{
errCode1 = "DS000";
}
}
else
{
errCode1 = "DS000";
}
//Modified by Anjali R. on[18/09/2018][To update wf_prc_status ][Start]
/*}
else
......@@ -441,8 +442,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
conn.commit();
}*/
//Modified by Anjali R. on [18/09/2018][Connection will not be commit in this method][End]
}
}
}
//}
}
if(errCode.size() > 0)
......@@ -563,8 +564,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
}
else
{
//Modified by Anjali R. on [19/09/2018][Query to update ench days in case of encashment][End]
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS = BAL_DAYS + ?,CONS_DAYS = CONS_DAYS -? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE <= ?";
//Modified by Anjali R. on [19/09/2018][Query to update ench days in case of encashment][End]
sql2 = "UPDATE LEAVEBAL SET BAL_DAYS = BAL_DAYS + ?,CONS_DAYS = CONS_DAYS -? WHERE EMP_CODE = ? AND LVE_CODE = ? AND EFF_DATE = ? AND UPTO_DATE <= ?";
}
pstmt2 = connectionObject.prepareStatement(sql2);
pstmt2.setDouble(1, val5);
......@@ -596,7 +597,10 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
}
}
if(errCode.trim().length() != 0)
//Modified by Anjali R. on [07/01/2019][Start]
//if(errCode.trim().length() != 0)
if(errCode != null && errCode.trim().length() > 0)
//Modified by Anjali R. on [07/01/2019][End]
{
break;
}
......@@ -647,7 +651,6 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
if(errCode != null && errCode.trim().length() != 0)
{
this.errList.add(errCode);
this.fldList.add("");
//Commented by Anjali R. on[19/09/2018][Start]
......@@ -821,8 +824,13 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
{
if(status.equals("A"))
{
//Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][Start]
errCode = "VTEMPLVE21";
this.errList.add(errCode);
this.fldList.add("");
break;
// Modified by Piyush on 15/09/2018.Start
String siteCode = "" , cadreCode = "" , gradeCode = "";
/*String siteCode = "" , cadreCode = "" , gradeCode = "";
sql = "SELECT PAY_SITE, CADRE, GRADE FROM EMPLOYEE WHERE EMP_CODE = ?";
pstmt = connectionObject.prepareStatement(sql);
pstmt.setString(1,empCode);
......@@ -862,57 +870,60 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
// Modified by Piyush on 15/09/2018.End
//Modified by Anjali R. on [03/08/2018][To cancel approved leave encashment entries][Start]
/*errCode = "VTEMPLVE21";
errCode = "VTEMPLVE21";
this.errList.add(errCode);
this.fldList.add("");
break;*/
break;
//cancellation of approved leaves in case of encashment
errCode = cancelEnchLeaves(tranId,connectionObject);
System.out.println("errCode--["+errCode+"]");
//Modified by Anjali R. on[19/09/2018][Start]
/*if(errCode != null && errCode.trim().length() > 0)
if(errCode != null && errCode.trim().length() > 0)
{
errCode = errCode;
System.out.println("errCode---["+errCode+"]");
this.errList.add(errCode);
this.fldList.add("");
break;
}*/
}
if ((errCode != null) && (errCode.trim().length() > 0) && (errCode.indexOf("<Errors>") != -1))
{
try
{
System.out.println("Inside try");
Document errDom = genericUtility.parseString(errCode);
System.out.println("errDom--[" + errDom + "]");
NodeList parentNodeList = errDom.getElementsByTagName("error");
System.out.println("parentNodeList----[" + parentNodeList.getLength() + "]");
Node parentNode = null;
int parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength--[" + parentNodeListLength + "]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++)
{
parentNode = parentNodeList.item(prntCtr);
System.out.println("parentNode---[" + parentNode + "]");
errCode = parentNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("errCode--[" + errCode + "]");
if ((errCode != null) && (errCode.trim().length() > 0))
{
errList.add(errCode);
fldList.add("");
}
}
System.out.println("errList--[" + errList + "]");
}
catch (Exception e)
{
System.out.println("exception while adding error in errList--[" + e.getMessage() + "]");
e.printStackTrace();
throw new ITMException(e);
}
}
{
try
{
connectionObject.rollback();//Modified by Anjali R. on [31/12/2018][In case of error system should rollbacked entire transaction]
System.out.println("Inside try");
Document errDom = genericUtility.parseString(errCode);
System.out.println("errDom--[" + errDom + "]");
NodeList parentNodeList = errDom.getElementsByTagName("error");
System.out.println("parentNodeList----[" + parentNodeList.getLength() + "]");
Node parentNode = null;
int parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength--[" + parentNodeListLength + "]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++)
{
parentNode = parentNodeList.item(prntCtr);
System.out.println("parentNode---[" + parentNode + "]");
errCode = parentNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("errCode--[" + errCode + "]");
if ((errCode != null) && (errCode.trim().length() > 0))
{
errList.add(errCode);
fldList.add("");
}
}
System.out.println("errList--[" + errList + "]");
}
catch (Exception e)
{
connectionObject.rollback();//Modified by Anjali R. on [31/12/2018][In case of error system should rollbacked entire transaction]
System.out.println("exception while adding error in errList--[" + e.getMessage() + "]");
e.printStackTrace();
throw new ITMException(e);
}
}*/
//Modified by Anjali R. on[19/09/2018][End]
//Modified by Anjali R. on [03/08/2018][To cancel approved leave encashment entries][End]
//Modified by Anjali R. on [04/01/2019][Not allow to cancel the leave encashment][End]
}
}
else if(useFlag.equals("L"))
......@@ -946,7 +957,7 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
{
pstmt.close();
pstmt = null;
}
}
if(empStatus.equals("S"))
{
errCode = "VTEMPSEP1";
......@@ -1192,15 +1203,13 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
{
connectionObject.rollback();
}*/
}
/*else if(commit == 2)
{
connectionObject.commit();
}*/
//Modified by Anjali R. on [18/09/2018][Connection commit will not happen here][End]
}
catch(Exception e)
{
......@@ -1328,6 +1337,8 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
String siteCode = "";
String finYearErr = "";
String chgUser = "";//Modified by Anjali R. on [31/12/2018]
SimpleDateFormat simpleDateFormat = null;
ITMDBAccessEJB itmdbAccessEJB = null;
......@@ -1342,6 +1353,11 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
admCommon = new AdmCommon();
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
siteCode = genericUtility.getValueFromXTRA_PARAMS(ExtraParams, "loginSiteCode");
//Modified by Anjali R. on [31/12/2018][Start]
chgUser = genericUtility.getValueFromXTRA_PARAMS(ExtraParams,"loginCode");
//Modified by Anjali R. on [31/12/2018][End]
System.out.println("siteCode--["+siteCode+"]");
sql = "select emp_code,ench_amt,encash_mode,prd_code__payroll,tran_id__payr,lve_code,lve_date_fr from empleave where tran_id =?";
pstmt = conn.prepareStatement(sql);
......@@ -1378,12 +1394,44 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
//if("Y".equalsIgnoreCase(allowEnvLveCancel ))
//{
//Modified by Anjali R. on [18/09/2018][End]
//If encashment amount paid through voucher then ench mode is "V" ,through payroll then ench mode "P"
if("V".equalsIgnoreCase(encashMode))
//Modified by Anjali R. [03/01/2019][Start]
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, chgUser);
pstmt.setString(4, lveDateFrStr);
pstmt.setString(5, "CANC_LVE_ENC");
rs = pstmt.executeQuery();
if(rs.next())
{
finYearErr = checkNull(rs.getString("err_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(finYearErr != null && finYearErr.trim().length() > 0)
{
retString = itmdbAccessEJB.getErrorString("", finYearErr, userId,"",conn);
//retString = finYearErr;
return retString;
}
//Modified by Anjali R. [03/01/2019][End]
//If encashment amount paid through voucher then ench mode is "V" ,through payroll then ench mode "P"
if("V".equalsIgnoreCase(encashMode))
{
if(tranIdPayr!=null && tranIdPayr.trim().length()>0)
{
if(tranIdPayr!=null && tranIdPayr.trim().length()>0)
{
sql = "select FN_CHECK_ACCOUNTING_YEAR(?,?,?,?) as err_code from dual";
//Modified by Anjali R. [03/01/2019][Start]
/*sql = "select FN_CHECK_ACCOUNTING_YEAR(?,?,?,?) as err_code from dual";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, tranIdPayr);
......@@ -1404,65 +1452,23 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt.close();
pstmt = null;
}
if(finYearErr != null && finYearErr.trim().length() > 0)
{
retString = itmdbAccessEJB.getErrorString("", finYearErr, userId,"",conn);
//retString = finYearErr;
return retString;
}
}*/
//Modified by Anjali R. [03/01/2019][End]
sql = "select status from empleave_ench_arr where tran_id__lve = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
arrearVoucherStatus = checkNull(rs.getString("status"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//If arrears voucher is exist as confirm status
if("A".equalsIgnoreCase(arrearVoucherStatus))
{
retString = itmdbAccessEJB.getErrorString("", "VTADMLVE04", "","",conn);
//retString = "VTADMLVE04";
return retString;
}
else if("X".equalsIgnoreCase(arrearVoucherStatus) || arrearVoucherStatus == null || arrearVoucherStatus.trim().length() == 0)
{
retString = hrVoucherReversal.actionHandler(tranIdPayr, ExtraParams, forceFlag,conn);
System.out.println("retString---["+retString+"]");
}
}
}
else if("P".equalsIgnoreCase(encashMode))
{
sql = "select fr_date, to_date from period where code = ?";
sql = "select status from empleave_ench_arr where tran_id__lve = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
frDate = rs.getTimestamp("fr_date");
toDate = rs.getTimestamp("to_date");
}
else
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
retString = itmdbAccessEJB.getErrorString("prd_code", "VTADMLVE03", "", "",conn);
//retString = "VTADMLVE03";
return retString;
arrearVoucherStatus = checkNull(rs.getString("status"));
}
System.out.println("frDate--["+frDate+"]toDate--["+toDate+"]");
if(rs != null)
{
rs.close();
......@@ -1473,136 +1479,196 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
pstmt.close();
pstmt = null;
}
month = frDate.getMonth() + 1;
System.out.println("month--["+month+"]");
frDateStr = simpleDateFormat.format(frDate);
System.out.println("frDateStr--["+frDateStr+"]");
toDateStr = simpleDateFormat.format(toDate);
System.out.println("toDateStr--["+toDateStr+"]");
refNo = frDateStr+lveCode;
System.out.println("refNo--["+refNo+"]");
sql = "select ad_code__ench from leaves where lve_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lveCode);
rs = pstmt.executeQuery();
if(rs.next())
//If arrears voucher is exist in confirm status
if("A".equalsIgnoreCase(arrearVoucherStatus))
{
adCode = checkNull(rs.getString("ad_code__ench"));
}
System.out.println("adCode--["+adCode+"]");
if(rs != null)
{
rs.close();
rs = null;
retString = itmdbAccessEJB.getErrorString("", "VTADMLVE04", "","",conn);
//retString = "VTADMLVE04";
return retString;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
else if("X".equalsIgnoreCase(arrearVoucherStatus) || arrearVoucherStatus == null || arrearVoucherStatus.trim().length() == 0)
{
retString = hrVoucherReversal.actionHandler(tranIdPayr, ExtraParams, forceFlag,conn);
System.out.println("retString---["+retString+"]");
}
sql = " select count(*) as cnt from employee_mthad where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
}
}
else if("P".equalsIgnoreCase(encashMode))
{
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
frDate = rs.getTimestamp("fr_date");
toDate = rs.getTimestamp("to_date");
}
else
{
retString = itmdbAccessEJB.getErrorString("prd_code", "VTADMLVE03", "", "",conn);
//retString = "VTADMLVE03";
return retString;
}
System.out.println("frDate--["+frDate+"]toDate--["+toDate+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
month = frDate.getMonth() + 1;
System.out.println("month--["+month+"]");
frDateStr = simpleDateFormat.format(frDate);
System.out.println("frDateStr--["+frDateStr+"]");
toDateStr = simpleDateFormat.format(toDate);
System.out.println("toDateStr--["+toDateStr+"]");
//Modified by Anjali R. on [31/12/2018][To update full year in ref_no][Start]
//refNo = frDateStr+lveCode;
SimpleDateFormat simpleDtFormat = new SimpleDateFormat("dd/MM/yyyy");
String frDtStr = simpleDtFormat.format(frDate);
refNo = frDtStr+lveCode;
//Modified by Anjali R. on [31/12/2018][To update full year in ref_no][End]
sql = "select ad_code__ench from leaves where lve_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lveCode);
rs = pstmt.executeQuery();
if(rs.next())
{
adCode = checkNull(rs.getString("ad_code__ench"));
}
System.out.println("adCode--["+adCode+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = " select count(*) as cnt from employee_mthad where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, adCode);
pstmt.setTimestamp(4, frDate);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Count --["+cnt+"]");
if(cnt == 0)
{
sql = "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(?,?,?,?,?,'F',?,?,?,?,'E',?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, adCode);
pstmt.setTimestamp(4, frDate);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
pstmt.setTimestamp(5, toDate);
pstmt.setDouble(6, enchAmt * -1);
pstmt.setTimestamp(7,new java.sql.Timestamp(System.currentTimeMillis()) );
pstmt.setString(8,userId);
pstmt.setString(9, termId);
pstmt.setString(10, refNo);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Count --["+cnt+"]");
if(cnt == 0)
{
sql = "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(?,?,?,?,?,'F',?,?,?,?,'E',?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setInt(2, month);
pstmt.setString(3, adCode);
pstmt.setTimestamp(4, frDate);
pstmt.setTimestamp(5, toDate);
pstmt.setDouble(6, enchAmt * -1);
pstmt.setTimestamp(7,new java.sql.Timestamp(System.currentTimeMillis()) );
pstmt.setString(8,userId);
pstmt.setString(9, termId);
pstmt.setString(10, refNo);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Updated ["+updCount+"] rows in employee_mthad table");
}
else
{
updCount = 0;
sql = "update employee_mthad set ref_type = 'E' ,ref_no = ?,type = 'F',amount = amount + ? "
+ "where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setDouble(2, enchAmt*-1);
pstmt.setString(3, empCode);
pstmt.setInt(4, month);
pstmt.setString(5, adCode);
pstmt.setTimestamp(6, frDate);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Updated ["+updCount+"] rows in employee mthad table.");
}
System.out.println("Updated ["+updCount+"] rows in employee_mthad table");
}
else
{
updCount = 0;
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][Start]
/*sql = "update employee_mthad set ref_type = 'E' ,ref_no = ?,type = 'F',amount = amount + ? "
+ "where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";*/
sql = "update employee_mthad set ref_type = 'E' ,ref_no = ?,type = 'F',amount = amount + ?,chg_date = ?,chg_term= ?,chg_user = ? "
+ "where emp_code = ? and month_code = ? and ad_code = ? and eff_date = ?";
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][End]
sql = "select count(1) as cnt from payroll where emp_code = ? and prd_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
pstmt.setString(1, refNo);
pstmt.setDouble(2, enchAmt*-1);
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][Start]
pstmt.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()) );
pstmt.setString(4,chgUser);
pstmt.setString(5, chgUser);
//Modified by Anjali R. [31/12/2018][To update chg_date,chg_term and chg_usr][End]
pstmt.setString(6, empCode);
pstmt.setInt(7, month);
pstmt.setString(8, adCode);
pstmt.setTimestamp(9, frDate);
updCount = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("count--["+count+"]");
if(count > 0)
System.out.println("Updated ["+updCount+"] rows in employee mthad table.");
}
sql = "select count(1) as cnt from payroll where emp_code = ? and prd_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCodePayroll);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("count--["+count+"]");
if(count > 0)
{
//Modified by Anjali R. on [03/01/2019][Start]
//retString = admCommon.payarrToProcUpdation(prdCodePayroll, prdCodePayroll, empCode, empCode, "PY", "w_empleave", "", adCode,enchAmt*-1 , frDateStr, toDateStr, ExtraParams, conn);
retString = admCommon.payarrToProcUpdation(prdCodePayroll, prdCodePayroll, empCode, empCode, "AR", "w_empleave", "", adCode,enchAmt*-1 , frDateStr, toDateStr, ExtraParams, conn);
//Modified by Anjali R. on [03/01/2019][End]
System.out.println("retString--["+retString+"]");
//Modified by Anjali R. on[19/09/2018][Start]
if(retString != null && retString.trim().length() > 0)
{
retString = admCommon.payarrToProcUpdation(prdCodePayroll, prdCodePayroll, empCode, empCode, "PY", "w_empleave", "", adCode,enchAmt*-1 , frDateStr, toDateStr, ExtraParams, conn);
System.out.println("retString--["+retString+"]");
//Modified by Anjali R. on[19/09/2018][Start]
if(retString != null && retString.trim().length() > 0)
{
conn.rollback();
retString = itmdbAccessEJB.getErrorString("", retString, "", "",conn);
return retString;
}
//Modified by Anjali R. on[19/09/2018][End]
conn.rollback();
retString = itmdbAccessEJB.getErrorString("", retString, "", "",conn);
return retString;
}
//Modified by Anjali R. on[19/09/2018][End]
}
}
//}
}
catch(Exception e)
......@@ -1620,7 +1686,6 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
e1.printStackTrace();
throw new ITMException(e1);
}
System.out.println("Exception---["+e.getMessage()+"]");
e.printStackTrace();
retString = "DS000";
......@@ -1630,16 +1695,16 @@ public class EmpLeaveCancel extends ActionHandlerEJB implements EmpLeaveCancelL
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception 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