Commit d415061f authored by vkadam's avatar vkadam

Add some missing variables for validation.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98611 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cd7fe39e
/********************************************************
Title : MiscPaySubAct[F14FSUN003]
Date : 17/SEP/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.fin.adv; package ibase.webitm.ejb.fin.adv;
import ibase.system.config.ConnDriver; import ibase.webitm.utility.*;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.*;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.fin.FinCommon; import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.PrintStream;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import javax.ejb.Stateless;
@Stateless
public class MiscPaySubAct extends ActionHandlerEJB
implements MiscPaySubActLocal, MiscPaySubActRemote
{
String userId = ""; String termId = "";
GenericUtility genericUtility = GenericUtility.getInstance();
public String actionHandler(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException
{
System.out.println("---ActionHandler---@@@@@@@@xtraParams[" + xtraParams + "]@@@@@@forcedFlag[" + forcedFlag + "]");
Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt1 = null; PreparedStatement pstmt2 = null;
ResultSet rs = null; ResultSet rs1 = null; ResultSet rs2 = null;
String retString = "";
String sql = ""; String sql1 = ""; String sql2 = "";
String confStatus = ""; String wfStatus = ""; String sundryType = ""; String sundryCode = ""; String payMode = ""; String supPayMod = ""; String bankCode = ""; String chqNo = "";
int cnt = 0; int cnt1 = 0;
Timestamp datesubmit = null;
double totAmt = 0.0D; double totAmtMiscPay = 0.0D; double adjAmtMiscPay = 0.0D; double payAmt = 0.0D;
ArrayList stnCdList = new ArrayList();
boolean stanCdBlank = false; boolean stanCdDupl = false; boolean stanCodeInv = false;
Timestamp tranDate = null;
String refNo = ""; String tranSer = "";
FinCommon fin = new FinCommon();
try
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
this.userId = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
this.termId = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if ((this.userId == null) || (this.userId.trim().length() == 0))
{
this.userId = "SYSTEM";
}
if ((this.termId == null) || (this.termId.trim().length() == 0))
{
this.termId = "SYSTEM";
}
System.out.println(">>>>>>>>>>tranId:" + tranId);
sql = "SELECT CONFIRMED,CASE WHEN WF_STATUS IS NULL THEN 'O' ELSE WF_STATUS END AS WF_STATUS,SUNDRY_CODE,SUNDRY_TYPE,PAY_MODE,BANK_CODE,REF_NO FROM MISC_PAYMENT WHERE TRAN_ID= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
confStatus = rs.getString("CONFIRMED").trim();
wfStatus = rs.getString("WF_STATUS").trim();
sundryCode = checkNull(rs.getString("SUNDRY_CODE"));
sundryType = checkNull(rs.getString("SUNDRY_TYPE"));
payMode = checkNull(rs.getString("PAY_MODE"));
bankCode = checkNull(rs.getString("BANK_CODE"));
chqNo = checkNull(rs.getString("REF_NO"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
String str1;
if ("Y".equalsIgnoreCase(confStatus))
{
retString = itmDBAccessLocal.getErrorString("", "VTDIST26", "");
str1 = retString;
return str1;
}
if ("S".equalsIgnoreCase(wfStatus))
{
retString = itmDBAccessLocal.getErrorString("", "ALRDYSUBMT", "");
str1 = retString;
return str1;
}
if (("N".equalsIgnoreCase(confStatus)) && ("O".equalsIgnoreCase(wfStatus)))
{
sql = "select sum(pay_amt) as totAmt from misc_paydet where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
totAmt = rs.getDouble("totAmt");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (totAmt < 0.0D)
{
retString = itmDBAccessLocal.getErrorString("", "VTAMTMIS1", "");
str1 = retString;
return str1;
}
sql1 = "select TRAN_SER,vouch_no,pay_amt from misc_paydet where tran_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
tranSer = checkNull(rs1.getString("TRAN_SER"));
refNo = checkNull(rs1.getString("vouch_no"));
payAmt = rs1.getDouble("pay_amt");
sql = "SELECT tot_amt as tot_amt, adj_amt as adj_amt , sundry_type as sundrytype from misc_payables where tran_ser = ? and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
while (rs.next())
{
totAmtMiscPay = rs.getDouble("tot_amt");
adjAmtMiscPay = rs.getDouble("adj_amt");
System.out.println("totAmtMiscPay =========" + totAmtMiscPay);
System.out.println("adjAmtMiscPay =========" + adjAmtMiscPay);
System.out.println("Pay Amount ============ " + payAmt);
if (Math.abs(totAmtMiscPay - adjAmtMiscPay) >= Math.abs(payAmt))
{
continue;
}
System.out.println("Entering the if condition Pay Amount ============ " + payAmt);
retString = itmDBAccessLocal.getErrorString("", "VTBAL1", "");
str1 = retString;
return str1;
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
pstmt1.close();
pstmt1 = null;
rs1.close();
rs1 = null;
System.out.println("@V@ Sundry Type :- [" + sundryType + "]");
System.out.println("@V@ Sundry Code :- [" + sundryCode + "]");
if ("S".equalsIgnoreCase(sundryType))
{
System.out.println("@V@ Pay Mode :- [" + payMode + "]");
sql = "select pay_mode from SUPPLIER where supp_code=?"; import java.rmi.RemoteException;
pstmt = conn.prepareStatement(sql); import java.sql.*;
pstmt.setString(1, sundryCode); import java.text.SimpleDateFormat;
import java.util.*;
rs = pstmt.executeQuery();
if (rs.next())
{
supPayMod = checkNull(rs.getString("pay_mode"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("@V@ Supplier Pay Mode :- [" + supPayMod + "]");
if (("N".equalsIgnoreCase(supPayMod)) && (!supPayMod.equalsIgnoreCase(payMode)))
{
System.out.println("@V@ Pay Mode not matching");
retString = itmDBAccessLocal.getErrorString("", "VTPYMDDIFF", "");
str1 = retString;
return str1;
}
}
sql = "select stan_code from misc_paydet where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next())
{
if ((rs.getString("stan_code") == null) || (checkNull(rs.getString("stan_code")).length() == 0))
{
stanCdBlank = true;
break;
}
System.out.println("@V@ Stan code not blank");
sql2 = "select count(*) a cnt from station where stan_code=?";
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1, checkNull(rs.getString("stan_code")));
rs2 = pstmt2.executeQuery();
if (rs2.next())
{
cnt1 = rs2.getInt("cnt");
}
pstmt2.close();
pstmt2 = null;
rs2.close();
rs2 = null;
if (cnt1 == 0)
{
stanCodeInv = true;
break;
}
if ("E".equalsIgnoreCase(sundryType))
continue;
System.out.println("@V@ Sundry type NOT 'E'");
if (stnCdList.size() > 0)
{
System.out.println("@V@ List size is NOT 0 :-[" + stnCdList.size() + "]");
if (!stnCdList.contains(rs.getString("stan_code")))
{
System.out.println("@V@ Stan code match found");
stanCdDupl = true;
break;
}
System.out.println("@V@ Stan code added in list");
stnCdList.add(rs.getString("stan_code"));
}
else
{
System.out.println("@V@ First Stan code added in list");
stnCdList.add(rs.getString("stan_code"));
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (stanCdBlank)
{
System.out.println("@V@ Station code null found");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDBLK", "");
str1 = retString;
return str1;
}
if (stanCodeInv)
{
System.out.println("@V@ Station code invalid");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDINV", "");
str1 = retString;
return str1;
}
if (!"E".equalsIgnoreCase(sundryType))
{
if (stanCdDupl)
{
System.out.println("@V@ Station code Duplicate found");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDDPL", "");
str1 = retString;
return str1;
}
}
sql = "select count(*) AS CNT from misc_payment a,misc_paydet b where a.tran_id=b.tran_id and wf_status='S'"
+ " AND CONFIRMED='N' and b.tran_id <> ? and b.VOUCH_NO in(select VOUCH_NO from misc_paydet where tran_id=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("CNT");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (cnt > 0)
{
System.out.println("@V@ Voucher Duplicate found in 'misc_payment'");
retString = itmDBAccessLocal.getErrorString("", "VTVCHNODPL", "");
str1 = retString;
return str1;
}
sql = "SELECT COUNT(*) AS CNT FROM BANKTRAN_LOG WHERE BANK_CODE=? AND TRAN_TYPE='P' AND TRAN_SER <> 'R-DIS' AND REF_NO=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
pstmt.setString(2, chqNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("CNT");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (cnt > 0)
{
System.out.println("@V@ Duplicate cheque found");
retString = itmDBAccessLocal.getErrorString("", "VTCHQ3", "");
str1 = retString;
return str1;
}
sql = "UPDATE MISC_PAYMENT SET WF_STATUS='S',emp_code__submit=?,submit_date=? WHERE tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, this.userId);
datesubmit = new Timestamp(System.currentTimeMillis());
pstmt.setTimestamp(2, datesubmit);
pstmt.setString(3, tranId);
int rowcnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (rowcnt > 0)
{
retString = itmDBAccessLocal.getErrorString("", "SUBMITSUCC", "");
System.out.println(">>>>>>>>>>>>>>>Before conn.commit()");
conn.commit();
}
}
} import javax.ejb.Stateless;
catch (Exception e)
{
try
{
conn.rollback();
}
catch (Exception localException1) {
}
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try {
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ((conn != null) && (!conn.isClosed()))
{
conn.close();
conn = null;
}
}
catch (Exception ef) {
System.out.println(ef.getMessage());
ef.printStackTrace();
throw new ITMException(ef);
}
}
try
{
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ((conn != null) && (!conn.isClosed()))
{
conn.close();
conn = null;
}
}
catch (Exception ef) {
System.out.println(ef.getMessage());
ef.printStackTrace();
throw new ITMException(ef);
}
System.out.println("Returning Result ::" + retString); @Stateless
return retString;
}
private String checkNull(String input) public class MiscPaySubAct extends ActionHandlerEJB implements MiscPaySubActLocal, MiscPaySubActRemote
{ {
if (input == null) /**
{ * The public method is used for update the Workflow status
input = ""; * @param tranId
} * @param xtraParams contais additional information such as loginEmpCode,loginCode,chgTerm etc
return input; * @param forcedFlag (true or false)
} */
} String userId = "", termId = "";
\ No newline at end of file GenericUtility genericUtility = GenericUtility.getInstance();
@Override
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
System.out.println("---ActionHandler---@@@@@@@@xtraParams["+xtraParams+"]@@@@@@forcedFlag["+forcedFlag+"]");
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
ResultSet rs = null, rs1 = null, rs2 = null;
String retString = "";
String sql = ""; String sql1 = ""; String sql2 = "";
String confStatus="",wfStatus="",sundryCode = "", payMode = "", supPayMod = "", bankCode = "", chqNo = "",sundryType="";
/*String currAppdate ="";
String tranIdTest="",todayStr="";*/
java.sql.Timestamp datesubmit=null;
//added by vishakha on 03/Aug/2015 for validations on Submit button.
double totAmt = 0.0,totAmtMiscPay = 0.0,adjAmtMiscPay = 0.0,payAmt = 0.0;
int cnt = 0, cnt1 = 0;
ArrayList<String> stnCdList = new ArrayList<String>();
boolean stanCdBlank = false, stanCdDupl = false, stanCodeInv = false;
// String ignorechklimit ="",tranKeyFld = "",bankCode = "",siteCode = "",payType = "";
Timestamp tranDate = null;
String refNo = "",tranSer = "";
FinCommon fin = new FinCommon();
try
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if (userId == null || userId.trim().length() == 0)
{
userId = "SYSTEM";
}
if (termId == null || termId.trim().length() == 0)
{
termId = "SYSTEM";
}
System.out.println(">>>>>>>>>>tranId:"+tranId);
sql = "SELECT CONFIRMED,CASE WHEN WF_STATUS IS NULL THEN 'O' ELSE WF_STATUS END AS WF_STATUS,SUNDRY_CODE,SUNDRY_TYPE,PAY_MODE,"
+ "BANK_CODE,REF_NO FROM MISC_PAYMENT WHERE TRAN_ID= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
confStatus = rs.getString("CONFIRMED").trim();
wfStatus = rs.getString("WF_STATUS").trim();
sundryCode = checkNull(rs.getString("SUNDRY_CODE"));
sundryType = checkNull(rs.getString("SUNDRY_TYPE"));
payMode = checkNull(rs.getString("PAY_MODE"));
bankCode = checkNull(rs.getString("BANK_CODE"));
chqNo = checkNull(rs.getString("REF_NO"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( "Y".equalsIgnoreCase(confStatus) )
{
retString = itmDBAccessLocal.getErrorString("","VTDIST26","");
return retString;
}
if( "S".equalsIgnoreCase(wfStatus) )
{
retString = itmDBAccessLocal.getErrorString("","ALRDYSUBMT","");
return retString;
}
if( "N".equalsIgnoreCase(confStatus) && "O".equalsIgnoreCase(wfStatus))
{
//added by vishakha on 03/Aug/2015 as to incorporate the validations on submit button like those on commit button.
sql = "select sum(pay_amt) as totAmt from misc_paydet where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
totAmt = rs.getDouble("totAmt");//fetching totalAmount from details
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(totAmt < 0.0)//total amount should not be negative
{
retString = itmDBAccessLocal.getErrorString("","VTAMTMIS1","");
return retString;
}
sql1 = "select TRAN_SER,vouch_no,pay_amt from misc_paydet where tran_id = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
while ( rs1.next() )
{
tranSer = checkNull(rs1.getString("TRAN_SER"));
refNo = checkNull(rs1.getString("vouch_no"));
payAmt = rs1.getDouble("pay_amt");
sql = "SELECT tot_amt as tot_amt, adj_amt as adj_amt , sundry_type as sundrytype from misc_payables where tran_ser = ?"
+ " and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranSer);
pstmt.setString(2,refNo);
rs = pstmt.executeQuery();
while ( rs.next() )
{
totAmtMiscPay = rs.getDouble("tot_amt");
adjAmtMiscPay = rs.getDouble("adj_amt");
System.out.println("totAmtMiscPay ========="+ totAmtMiscPay);
System.out.println("adjAmtMiscPay ========="+ adjAmtMiscPay);
System.out.println("Pay Amount ============ "+ payAmt);
if(Math.abs(totAmtMiscPay - adjAmtMiscPay) < Math.abs(payAmt))//if there is no balance in misc_payables
{
System.out.println("Entering the if condition Pay Amount ============ "+ payAmt);
retString = itmDBAccessLocal.getErrorString("","VTBAL1","");
return retString;
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
pstmt1.close();
pstmt1 = null;
rs1.close();
rs1 = null;
/**
* VALLABH KADAM
* Validation for [F14FSUN003]
* on [16/SEP/15]
* */
System.out.println("@V@ Sundry Type :- [" + sundryType + "]");
System.out.println("@V@ Sundry Code :- [" + sundryCode + "]");
if ("S".equalsIgnoreCase(sundryType))
{
System.out.println("@V@ Pay Mode :- [" + payMode + "]");
sql = "select pay_mode from SUPPLIER where supp_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundryCode);
rs = pstmt.executeQuery();
if (rs.next())
{
supPayMod = checkNull(rs.getString("pay_mode"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("@V@ Supplier Pay Mode :- [" + supPayMod + "]");
if (("N".equalsIgnoreCase(supPayMod)) && (!supPayMod.equalsIgnoreCase(payMode)))
{
System.out.println("@V@ Pay Mode not matching");
retString = itmDBAccessLocal.getErrorString("", "VTPYMDDIFF", "");
return retString;
}
}
sql = "select stan_code from misc_paydet where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next())
{
if ((rs.getString("stan_code") == null) || (checkNull(rs.getString("stan_code")).length() == 0))
{
stanCdBlank = true;
break;
}
else
{
System.out.println("@V@ Stan code not blank");
// sql2 = "select count(*) a cnt from station where stan_code=?";
// pstmt2 = conn.prepareStatement(sql2);
// pstmt2.setString(1, checkNull(rs.getString("stan_code")));
//
// rs2 = pstmt2.executeQuery();
// if (rs2.next())
// {
// cnt1 = rs2.getInt("cnt");
// }
// pstmt2.close();
// pstmt2 = null;
// rs2.close();
// rs2 = null;
//
// if (cnt1 == 0)
// {
// stanCodeInv = true;
// break;
// }
if (!"E".equalsIgnoreCase(sundryType))
{
System.out.println("@V@ Sundry type NOT 'E'");
if (stnCdList.size() > 0)
{
System.out.println("@V@ List size is NOT 0 :-[" + stnCdList.size() + "]");
if (!stnCdList.contains(rs.getString("stan_code")))
{
System.out.println("@V@ Stan code match NOT found");
stanCdDupl = true;
break;
}
else
{
System.out.println("@V@ Stan code added in list");
stnCdList.add(rs.getString("stan_code"));
}
}
else
{
System.out.println("@V@ First Stan code added in list");
stnCdList.add(rs.getString("stan_code"));
}
}
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (stanCdBlank)
{
System.out.println("@V@ Station code null found");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDBLK", "");
return retString;
}
if (stanCodeInv)
{
System.out.println("@V@ Station code invalid");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDINV", "");
return retString;
}
if (!"E".equalsIgnoreCase(sundryType))
{
if (stanCdDupl)
{
System.out.println("@V@ Station code Duplicate found");
retString = itmDBAccessLocal.getErrorString("", "VTSTNCDDPL", "");
return retString;
}
}
sql = "select count(*) AS CNT from misc_payment a,misc_paydet b where a.tran_id=b.tran_id and wf_status='S'"
+ " AND CONFIRMED='N' and b.tran_id <> ? and b.VOUCH_NO in(select VOUCH_NO from misc_paydet where tran_id=?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setString(2, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("CNT");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (cnt > 0)
{
System.out.println("@V@ Voucher Duplicate found in 'misc_payment'");
retString = itmDBAccessLocal.getErrorString("", "VTVCHNODPL", "");
return retString;
}
sql = "SELECT COUNT(*) AS CNT FROM BANKTRAN_LOG WHERE BANK_CODE=? AND TRAN_TYPE='P' AND TRAN_SER <> 'R-DIS' AND REF_NO=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
pstmt.setString(2, chqNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("CNT");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (cnt > 0)
{
System.out.println("@V@ Duplicate cheque found");
retString = itmDBAccessLocal.getErrorString("", "VTCHQ3", "");
return retString;
}
/**
* VALLABH KADAM
* Validation for [F14FSUN003]
* on [16/SEP/15]
* END
* */
//SQL for update the work flow status/..........
sql = "UPDATE MISC_PAYMENT SET WF_STATUS='S',emp_code__submit=?,submit_date=? WHERE tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,userId);
datesubmit=new java.sql.Timestamp(System.currentTimeMillis());
pstmt.setTimestamp(2,datesubmit);
pstmt.setString(3,tranId);
int rowcnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if(rowcnt > 0)
{
retString = itmDBAccessLocal.getErrorString("","SUBMITSUCC","");
System.out.println(">>>>>>>>>>>>>>>Before conn.commit()");
conn.commit();
//return retString;
}
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (Exception e1)
{
}
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if( conn != null && ! conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch(Exception ef)
{
System.out.println(ef.getMessage());
ef.printStackTrace();
throw new ITMException(ef);
}
}
System.out.println("Returning Result ::"+retString);
return retString;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
}
/********CODE COMMENTED as it only checks the balance for bank_type = 'B'*********/
/*public String getBalChk(String bankCode,String siteCode,Timestamp tranDate,double netAmt,Connection conn)throws Exception
{
System.out.println("@@@@@@getBalChk method@@@@@@@");
String errCode = "";
double bal = 0.0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "",bankType = "",acctprd = "";
sql = "select bank_type as ls_type from bank where bank_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
bankType = checkNull(rs.getString("ls_type"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
sql = "select code as ls_acctprd from acctprd where ? between fr_date and to_date ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDate);
rs = pstmt.executeQuery();
if ( rs.next() )
{
acctprd = rs.getString("ls_acctprd");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(bankType == "C")
{
sql = "select sum(dr_amt - cr_amt) as lc_bal from sundrybal where acct_prd = ? and prd_code = 'zzzzzz' and site_code = ? and sundry_type = 'B' and sundry_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctprd);
pstmt.setString(2,siteCode);
pstmt.setString(3,bankCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
bal = rs.getDouble("lc_bal");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("Value of sum(dr_amt - cr_amt)"+bal);
System.out.println("Value of net amount ==========="+netAmt);
if(netAmt > 0.0 && netAmt > bal )
{
errCode = itmDBAccessLocal.getErrorString("","VTPAYAMT","");
return errCode;
}
}
return errCode;
}
sql = "select tran_id as ls_keyfld, bank_code as ls_bank, net_amt as lc_net, site_code as ls_site, tran_date as ld_tran_date,ref_no , pay_type as ls_pay_type from misc_payment where tran_id = ? for update nowait";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
tranKeyFld = checkNull(rs.getString("ls_keyfld"));
bankCode = checkNull(rs.getString("ls_bank"));
netAmt = rs.getDouble("lc_net");
tranDate = rs.getTimestamp("ld_tran_date");
siteCode = checkNull(rs.getString("ls_site"));
payType = checkNull(rs.getString("ls_pay_type"));
refNo = checkNull(rs.getString("ref_no"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
ignorechklimit = fin.getFinparams("999999","IGNORE_WARNINGS",conn);
System.out.println("Value of Ignore chk limit ===="+ignorechklimit);
if("NULLFOUND".equals(ignorechklimit ) || ignorechklimit == null)
{
ignorechklimit = "N";
System.out.println("Value of Ignore chk limit ===="+ignorechklimit);
}
if("N".equalsIgnoreCase(ignorechklimit))
{
System.out.println("Insiding****BalChk condition");
retString = getBalChk(bankCode,siteCode,tranDate,netAmt,conn);
if(retString.trim().length() > 0)
{
return retString;
}
}*/
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