Commit c1675276 authored by arane's avatar arane

Issues In Bank Related Transactions

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@214832 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 63d55e89
......@@ -56,16 +56,13 @@ public class SupplierBankConf extends ActionHandlerEJB implements SupplierBankCo
private String confirmSuppBank(String tranId, String xtraParams,String forcedFlag) throws RemoteException,ITMException
{
System.out.println("SuppBankConf>>>> confirm method called>>>>>>>");
String suppCode = "";
String bankCode = "";
String runMode = "", ediOption = "", dataStr = "", confirmed = "";
String suppCode = "", bankCode = "", runMode = "", ediOption = "", dataStr = "", confirmed = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean isPreExist=false;
ConnDriver connDriver = new ConnDriver();
String errString = "", retString = "", sql = "", empCodeAprv = "", activeYn = "";
String effFromStr="",validUptoStr="";
String errString = "", retString = "", sql = "", empCodeAprv = "", activeYn = "", effFromStr="",validUptoStr="";
SimpleDateFormat sdf = null,sdf1=null;
Timestamp preTmstp=null,effFromTmstp=null,validUptoTmstp=null,effFromTmstp1=null,validUptoTmstp1=null;
Timestamp validUptoDt=null,validUpto=null,effFromDt=null;
......@@ -79,43 +76,65 @@ public class SupplierBankConf extends ActionHandlerEJB implements SupplierBankCo
try
{
//Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false);
connDriver = null;
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String[] pkValuesArr = string2StringArray(tranId, ":");
suppCode = checkNull(pkValuesArr[0]).trim();
// Modified by Anagha Rane 09JAN2019 start [to get primary fields columns]
/*suppCode = checkNull(pkValuesArr[0]).trim();
effFromStr = checkNull(pkValuesArr[1]).trim();
validUptoStr = pkValuesArr[2].trim();
validUptoStr = pkValuesArr[2].trim();*/
if(pkValuesArr.length > 0) {
suppCode = checkNull(pkValuesArr[0]).trim();
}
if(pkValuesArr.length > 1)
{
bankCode = checkNull(pkValuesArr[1]).trim();
}
if(pkValuesArr.length > 2)
{
effFromStr = checkNull(pkValuesArr[2]).trim();
}
if(effFromStr != null && effFromStr.trim().length() > 0)
{
effFromDt = Timestamp.valueOf(genericUtility.getValidDateString(effFromStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+ " 00:00:00.0");
}
/*if(validUptoStr != null && validUptoStr.trim().length() > 0)
{
validUptoDt = Timestamp.valueOf(genericUtility.getValidDateString(validUptoStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+ " 00:00:00.0");
}*/
// Modified by Anagha Rane 09JAN2019 end [to get primary fields columns]
System.out.println("Effective from TimeStamp pkvalues>>>>>>>>"+effFromDt);
System.out.println("Valid from TimeStamp pkvalues>>>>>>>>"+validUptoDt);
//System.out.println("Valid from TimeStamp pkvalues>>>>>>>>"+validUptoDt);
empCodeAprv = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
runMode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"runMode");
System.out.println("Employee Code ------->> " + empCodeAprv+"Run Mode>>>" + runMode);
Date currdt = new java.sql.Date(new java.util.Date().getTime());
System.out.println("Date>>>>>>>>>>" + currdt);
//System.out.println("Date>>>>>>>>>>" + currdt);
sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
Timestamp currDate = java.sql.Timestamp.valueOf(sdf1.format(currdt).toString() + " 00:00:00.0");
System.out.println("TimeStamp currDate>>>"+currDate);
System.out.println("Tran ID>>>>>>>>"+tranId);
System.out.println("TimeStamp currDate>>>"+currDate +"Tran ID>>>>>>>>"+tranId+"Supplier Code>>>>>>>>"+suppCode);
/*System.out.println("Tran ID>>>>>>>>"+tranId);
System.out.println("Supplier Code>>>>>>>>"+suppCode);
sql = "select confirmed, active_yn from supplier_bank where supp_code= ? and eff_from = ? and valid_upto = ?";
*/
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
//sql = "select confirmed, active_yn from supplier_bank where supp_code= ? and eff_from = ? and valid_upto = ?";
sql = "select confirmed, active_yn from supplier_bank where supp_code= ? and bank_code__ben= ? and eff_from = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppCode);
pstmt.setTimestamp(2, effFromDt);
pstmt.setTimestamp(3, validUptoDt);
/*pstmt.setTimestamp(2, effFromDt);
pstmt.setTimestamp(3, validUptoDt);*/
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
pstmt.setString(2, bankCode);
pstmt.setTimestamp(3, effFromDt);
rs = pstmt.executeQuery();
if (rs.next())
{
......@@ -132,30 +151,36 @@ conn = getConnection();
if (confirmed != null && confirmed.equalsIgnoreCase("Y"))
{
System.out.println("This tansaction is already confirmed");
//System.out.println("This tansaction is already confirmed");
errString = itmDBAccessEJB.getErrorString("", "VTINVCONF2", "","", conn);
System.out.println("ErrorString inside Confirmed YES"+errString);
//System.out.println("ErrorString inside Confirmed YES"+errString);
return errString;
}
else
{
sql="select eff_from,valid_upto from supplier_bank where supp_code = ?" +
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
//sql="select eff_from,valid_upto from supplier_bank where supp_code = ?" +
sql="select eff_from,valid_upto from supplier_bank where supp_code = ? and bank_code__ben = ? and eff_from = ? " +
" and active_yn = 'N' and confirmed= 'N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppCode);
pstmt.setString(2, bankCode);
pstmt.setTimestamp(3, effFromDt);
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
rs = pstmt.executeQuery();
if (rs.next())
{
effFromTmstp1 = rs.getTimestamp("eff_from");
validUptoTmstp1 = rs.getTimestamp("valid_upto");
System.out.println("Effective effFromTmstp1>>>>>"+effFromTmstp1);
System.out.println("Valid upto validUptoTmstp1>>>>>"+validUptoTmstp1);
System.out.println("Effective effFromTmstp1>>>>>"+effFromTmstp1+"Valid upto validUptoTmstp1>>>>>"+validUptoTmstp1);
//System.out.println("Valid upto validUptoTmstp1>>>>>"+validUptoTmstp1);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
validUptoDt = validUptoTmstp1;
if(effFromTmstp1.after(validUptoTmstp1))
{
System.out.println("Active_N $ Confirm_N>>>");
......@@ -166,11 +191,15 @@ conn = getConnection();
/**
* To get eff_from & valid_upto from previous saved record if any
* */
sql="select eff_from,valid_upto from supplier_bank where supp_code = ?" +
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
//sql="select eff_from,valid_upto from supplier_bank where supp_code = ?" +
sql="select eff_from,valid_upto from supplier_bank where supp_code = ? and bank_code__ben = ? and eff_from <> ? " +
" and active_yn = 'Y' and confirmed= 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppCode);
pstmt.setString(2, bankCode);
pstmt.setTimestamp(3, effFromDt);
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
rs = pstmt.executeQuery();
if (rs.next())
{
......@@ -178,9 +207,9 @@ conn = getConnection();
validUptoTmstp = rs.getTimestamp("valid_upto");
isPreExist=true;
System.out.println("Effective Date>>>>>"+effFromTmstp);
System.out.println("Valid upto Date>>>>>"+validUptoTmstp);
System.out.println("isPreExist>>>>>"+isPreExist);
System.out.println("Effective Date>>>>>"+effFromTmstp+"Valid upto Date>>>>>"+validUptoTmstp+"isPreExist>>>>>"+isPreExist);
/*System.out.println("Valid upto Date>>>>>"+validUptoTmstp);
System.out.println("isPreExist>>>>>"+isPreExist);*/
}
pstmt.close();
pstmt = null;
......@@ -189,25 +218,30 @@ conn = getConnection();
if(effFromTmstp == null && validUptoTmstp == null)
{
System.out.println("Inside if(effFromTmstp==null && validUptoTmstp==null)");
// /**
// * update the current record with confirmed='Y' and active_yn='Y'
//
// sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and eff_from = ? and valid_upto= ?";
sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and eff_from = ? and valid_upto= ?";
// /**
// * update the current record with confirmed='Y' and active_yn='Y'
//
// sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and eff_from = ? and valid_upto= ?";
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
//sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and eff_from = ? and valid_upto= ?";
sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and bank_code__ben = ? and eff_from = ? and valid_upto= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCodeAprv);
pstmt.setTimestamp(3, currDate);
pstmt.setTimestamp(4, currDate);
pstmt.setString(5, suppCode);
pstmt.setTimestamp(6, effFromDt);
pstmt.setTimestamp(7, validUptoDt);
pstmt.setString(6, bankCode);
pstmt.setTimestamp(7, effFromDt);
pstmt.setTimestamp(8, validUptoDt);
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
updateCount = pstmt.executeUpdate();
System.out.println("no of row update updateCount: " + updateCount);
System.out.println("Confirm Date>>>>>" + currDate);
/*System.out.println("Confirm Date>>>>>" + currDate);
System.out.println("Employee Approved Code>>> " + empCodeAprv);
System.out.println("Supplier Code>>>>" + suppCode);
System.out.println("new java.sql.Date(new java.util.Date().getTime())"+new java.sql.Date(new java.util.Date().getTime()));
System.out.println("new java.sql.Date(new java.util.Date().getTime())"+new java.sql.Date(new java.util.Date().getTime()));*/
pstmt.close();
pstmt = null;
if (updateCount > 0)
......@@ -224,30 +258,35 @@ conn = getConnection();
{
System.out.println("Inside ELSE OF (effFromTmstp==null && validUptoTmstp==null)");
//Updating the field confirmed = 'Y', active_yn='Y', conf_date,emp_code__aprv, eff_from
sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and eff_from = ? and valid_upto= ?";
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
sql = "update supplier_bank set confirmed = 'Y', wf_status='C', active_yn='Y', conf_date = ?,emp_code__aprv = ?, eff_from =?, status_date= ? where supp_code = ? and bank_code__ben = ? and eff_from = ? and valid_upto= ?";
pstmt = conn.prepareStatement(sql);
// pstmt.setTimestamp(1, currDate);
// pstmt.setTimestamp(1, currDate);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCodeAprv);
pstmt.setTimestamp(3, currDate);
pstmt.setTimestamp(3, currDate);//???eff_from
pstmt.setTimestamp(4, currDate);
pstmt.setString(5, suppCode);
pstmt.setTimestamp(6, effFromDt);
pstmt.setTimestamp(7, validUptoDt);
pstmt.setString(6, bankCode);
pstmt.setTimestamp(7, effFromDt);
pstmt.setTimestamp(8, validUptoDt);
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
updateCount = pstmt.executeUpdate();
System.out.println("no of row update: " + updateCount);
System.out.println("Confirm Date>>>>>" + currDate);
/*System.out.println("Confirm Date>>>>>" + currDate);
System.out.println("Employee Approved Code>>> " + empCodeAprv);
System.out.println("Supplier Code>>>>" + suppCode);
System.out.println("Supplier Code>>>>" + suppCode);*/
pstmt.close();
pstmt = null;
if (updateCount > 0)
{
System.out.println("The selected transaction is confirmed successfully");
System.out.println("validUptoTmstp>>>>>"+validUptoTmstp);
System.out.println("effFromDt>>>>>"+effFromDt);
System.out.println("validUptoTmstp>>>>>"+validUptoTmstp+"effFromDt>>>>>"+effFromDt);
//System.out.println("effFromDt>>>>>"+effFromDt);
if(isPreExist)
{
if(effFromTmstp != null && validUptoTmstp != null) // Added by Anagha Rane 09JAN2019 start [to handle NPE]
{
/** if validUptoTmstp(Saved Record) is greater than Effective date(Current Record)
* then previous date of Confirmation date will be saved*/
......@@ -270,34 +309,42 @@ conn = getConnection();
//If validUptoTmstp(preTmstp) is less than Effective Date(Previous Record)
if(preTmstp.before(effFromTmstp))
{
System.out.println("if(preTmstp.before(effFromTmstp))");
/*System.out.println("if(preTmstp.before(effFromTmstp))");
System.out.println("preTmstp < effFromTmstp : "+preTmstp+" < "+effFromTmstp);
System.out.println("Previous date inside else>>>>>"+preTmstp);
System.out.println("Effective from date(Database)>>>>>"+effFromTmstp);
// conn.rollback();
System.out.println("Commited after previous");
*/
// conn.rollback();
//System.out.println("Commited after previous");
errString = itmDBAccessEJB.getErrorString("", "VTINVPREDT","", "", conn);
System.out.println("if(preTmstp.before(currDate)) Error String"+errString);
System.out.println("ErrorString inside if(preTmstp.before(effFromTmstp))"+errString);
/*System.out.println("if(preTmstp.before(currDate)) Error String"+errString);
System.out.println("ErrorString inside if(preTmstp.before(effFromTmstp))"+errString);*/
return errString;
}
//Updating previous saved to active_yn = 'N', valid_upto=preTmstp
sql="update supplier_bank set active_yn = 'N', valid_upto= ? where trim(supp_code)=? and trim(eff_from) = ? and trim(valid_upto)= ?";
// Modified by Anagha Rane 09JAN2019 start [to update primary fields columns]
//sql="update supplier_bank set active_yn = 'N', valid_upto= ? where trim(supp_code)=? and and trim(eff_from) = ? and trim(valid_upto)= ?";
sql="update supplier_bank set active_yn = 'N', valid_upto= ? where trim(supp_code)=? and bank_code__ben = ? and trim(eff_from) = ? and trim(valid_upto)= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setTimestamp(1, preTmstp);
pstmt.setString(2, suppCode);
pstmt.setTimestamp(3, effFromTmstp);
pstmt.setTimestamp(4, validUptoTmstp);
pstmt.setString(3, bankCode);
// Modified by Anagha Rane 09JAN2019 end [to update primary fields columns]
pstmt.setTimestamp(4, effFromTmstp);
pstmt.setTimestamp(5, validUptoTmstp);
updateCount1 = pstmt.executeUpdate();
System.out.println("no of row update: " + updateCount1);
System.out.println("Valid Upto New (Previous Date)>>>>>" + preTmstp);
/*System.out.println("Valid Upto New (Previous Date)>>>>>" + preTmstp);
System.out.println("Supplier Code>>>>" + suppCode);
System.out.println("Effective Date in TimeStamp>>>>" + effFromTmstp);
System.out.println("Valid Upto Date in TimeStamp>>>>" + validUptoTmstp);
*/
pstmt.close();
pstmt = null;
}
}
//if (updateCount1 > 0) // Modified by Anagha Rane 09JAN2019 end [to return confirm msg on update count]
if (updateCount1 > 0)
{
System.out.println(">>The selected transaction is confirmed");
......@@ -347,7 +394,7 @@ conn = getConnection();
}
catch (SQLException se)
{
System.out.println("SQLException : class SupplierBankConf : ");
System.out.println("SQLException : class SupplierBankConf : "+ se.getMessage());
se.printStackTrace();
try
{
......@@ -355,10 +402,11 @@ conn = getConnection();
}
catch (Exception e)
{
System.out.println("Exception : Occured during rollback........");
System.out.println("Exception : Occured during rollback........"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);//exception thrown by AnaghaRane 06/01/2020
}
throw new ITMException(se);//
}
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