Commit 266c865a authored by msalla's avatar msalla

In bank receipt/payment and pdc - duplicate ref_no of header toconsiders both...

In bank receipt/payment  and pdc - duplicate ref_no of header toconsiders both pdc and receip/payment also consider dishonour/payment cancellation

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@203259 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b35cb829
//Win Name = W_BANK_RECO_MULTISEL
//Modification:
//05062007 - 1)The display sequence changes (Changes on Datawindow)(Tarani)
// -2)Currence code to be consider from bank statement and banktran log(Tarani)
// -3)partial reconcilation no to be done(Tarani)
//14062007 - 1)if two record present in banktransaction and one record select from banktranlog then one record
// is reconcile and other is pending(Tarani)
// 2)It is not allowed to select multiple record from bankstatement and banktran log(Tarani)
// 3)amount calculation from payment & receipt (Tarani)
//Modification by msalam on18/06/07
//1. Allow multiple to multiple processing.
//2. Dont allow Tran-type P & R processing at a time in case of multiple to multiple operation.
package ibase.webitm.ejb.fin;
import ibase.utility.E12GenericUtility;
import java.util.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BankReconcileMultiSelPrc extends ibase.webitm.ejb.ProcessEJB implements BankReconcileMultiSelPrcLocal,BankReconcileMultiSelPrcRemote //javax.ejb.SessionBean
{
// ibase.webitm.utility.GenericUtility genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
ibase.webitm.ejb.ITMDBAccessEJB itmDBAccessEJB = new ibase.webitm.ejb.ITMDBAccessEJB();
ibase.utility.CommonConstants commonConstants = new ibase.utility.CommonConstants();
java.sql.Connection conn = null;
java.sql.PreparedStatement pstmt=null;
java.sql.ResultSet rs=null;
String bankCode =null;
java.util.Vector BankStTranIdVec = new java.util.Vector();
java.util.Vector BankTranLogVec = new java.util.Vector();
/*public void ejbCreate() throws java.rmi.RemoteException, javax.ejb.CreateException
{
try
{
//conn = connDriver.getConnectDB("DriverITM");
System.out.println("BankReconcileMultiSelPrcEJB ejbCreate called.........");
}
catch (Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :ejbCreate :==>"+e);
throw new javax.ejb.CreateException();
}
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String process() throws java.rmi.RemoteException,ibase.webitm.utility.ITMException
{
return "";
}
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws java.rmi.RemoteException,ibase.webitm.utility.ITMException
{
org.w3c.dom.Document headerDom = null;
org.w3c.dom.Document detailDom = null;
System.out.println("xmlString::::::::::::;"+ xmlString);
System.out.println("xmlString2:::::::::::;"+ xmlString2);
System.out.println("windowName:::::::::::;"+ windowName);
System.out.println("xtraParams:::::::::::;"+ xtraParams);
String rtrStr ="";
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = e.getMessage();
}
return rtrStr;
}//END OF GETDATA(1)
public String getData(org.w3c.dom.Document headerDom, org.w3c.dom.Document detailDom, String windowName, String xtraParams) throws java.rmi.RemoteException,ibase.webitm.utility.ITMException
{
String errCode = "";
String errString = null;
String resultString = "";
String getDataSql= "" ;
StringBuffer retTabSepStrBuff = new StringBuffer();
try
{
if(conn==null)
{
ibase.system.config.ConnDriver connDriver = new ibase.system.config.ConnDriver();
//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
connDriver = null;
}
}
catch (Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :ejbCreate :==>"+e);
}
try
{
bankCode = genericUtility.getColumnValue("bank_code",headerDom);
System.out.println("Processing Bankcode:::::::::::["+bankCode+"]");
if ( bankCode == null || bankCode.trim().length() == 0 )
{
bankCode = "";
System.out.println("bankCode From is Null...");
errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn);
return errString;
}
getDataSql ="SELECT TRAN_ID,REF_NO,REF_DATE,AMOUNT,CURR_CODE,EXCH_RATE,TRAN_TYPE,REF_MODE,EFF_DATE,SITE_CODE,STAT_NO,STAT_DATE,AMT_ADJ,STATUS "
+" FROM BANK_STATEMENT WHERE ( BANK_STATEMENT.BANK_CODE = '"+bankCode.trim()+"') AND "
+"( BANK_STATEMENT.STATUS = 'E' ) ORDER BY REF_NO ASC ";
System.out.println("get Data Sql "+getDataSql);
pstmt = conn.prepareStatement(getDataSql);
//pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
while(rs.next())
{
//TRAN_ID
retTabSepStrBuff.append((rs.getString(1)==null?" ":rs.getString(1))).append("\t");
//REF_NO
retTabSepStrBuff.append((rs.getString(2)==null?" ":rs.getString(2))).append("\t");
//REF_DATE
retTabSepStrBuff.append(rs.getTimestamp(3)).append("\t");
//AMOUNT(BC)
retTabSepStrBuff.append(rs.getString(4)).append("\t");
//CURR_CODE
retTabSepStrBuff.append((rs.getString(5)==null?" ":rs.getString(5))).append("\t");
//EXCH_RATE
retTabSepStrBuff.append(rs.getString(6)).append("\t");
//(AMOUNT/EXCHRATE)--AMOUNT
//retTabSepStrBuff.append(rs.getDouble(4)/rs.getDouble(6)).append("\t");
//retTabSepStrBuff.append("xxx").append("\t");
//TRAN_TYPE
retTabSepStrBuff.append((rs.getString(7)==null?" ":rs.getString(7))).append("\t");
//REF_MODE
retTabSepStrBuff.append((rs.getString(8)==null?" ":rs.getString(8))).append("\t");
//EFF_DATE
retTabSepStrBuff.append((rs.getString(9)==null?" ":rs.getString(9))).append("\t");
//SITE_CODE
retTabSepStrBuff.append((rs.getString(10)==null?" ":rs.getString(10))).append("\t");
//STAT_NO
retTabSepStrBuff.append((rs.getString(11)==null?" ":rs.getString(11))).append("\t");
//STAT_DATE
retTabSepStrBuff.append(rs.getTimestamp(12)).append("\t");
//AMT_ADJ
retTabSepStrBuff.append(rs.getString(13)).append("\t");
//STATUS
retTabSepStrBuff.append((rs.getString(14)==null?" ":rs.getString(14))).append("\t");
retTabSepStrBuff.append(" ").append("\n");
}
rs.close();
pstmt.close();
System.out.println("retTabSepStrBuff:::::::::::::"+retTabSepStrBuff);
resultString = retTabSepStrBuff.toString();
}
catch (java.sql.SQLException e)
{
System.out.println("SQLException :BankReconcileMultiSelPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ibase.webitm.utility.ITMException(e);
}
catch (Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ibase.webitm.utility.ITMException(e);
}
finally
{
try
{
retTabSepStrBuff = null;
if(conn != null)
{
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
throw new ibase.webitm.utility.ITMException(e);
}
}
return resultString;
}//END OF GETDATA(2)
//PROCESS
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws java.rmi.RemoteException,ibase.webitm.utility.ITMException
{
System.out.println("P R O C E S S I N G[UPDATE]......................");
System.out.println("xmlString::::::::;;;"+xmlString);
System.out.println("xmlString2:::::::;;;"+xmlString2);
System.out.println("windowName:::::::;;;"+windowName);
System.out.println("xtraParams:::::::;;;"+xtraParams);
String retStr = "";
org.w3c.dom.Document detailDom = null;
org.w3c.dom.Document headerDom = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
retStr = e.getMessage();
}
return retStr;
}//END OF PROCESS (1)
public String process(org.w3c.dom.Document headerDom, org.w3c.dom.Document detailDom, String windowName, String xtraParams) throws java.rmi.RemoteException,ibase.webitm.utility.ITMException
{
bankCode = genericUtility.getColumnValue("bank_code",headerDom);
System.out.println("Processing Bankcode:::::::::::["+bankCode+"]");
org.w3c.dom.NodeList parentNodeList = null;
org.w3c.dom.NodeList childNodeList = null;
org.w3c.dom.Node parentNode = null;
org.w3c.dom.Node childNode = null;
String errString = null;;
String tranIdBS =null;
String tranIdBT =null;
String sqlBS =null;
String sqlBT =null;
String sqlBS1 =null;
//05062007
String sqlBT1 =null;
String tranIdBs = null;
String statusBS = null;
String statusBT =null;
String BanktranLogTranIds=null;
String childNodeName = "";
int parentNodeListLength =0;
int childNodeListLength = 0;
double amtBS =0;
double adjAmtBS =0;
double balBS = 0;
double amtBT = 0;
double adjAmtBT =0;
double balBT =0;
double amtAdjust=0;
//ADDED MY MSALAM ON 14/0607
int noOfBankLogTran = 0;
int noOfBankStatement = 0;
boolean isTranTypePAvailable = false;
boolean isMulToMulOpr = false;
boolean isSameTypeOpr = true;
java.sql.PreparedStatement pstmtBS=null;
java.sql.ResultSet rsBS=null;
java.sql.PreparedStatement pstmtBT=null;
java.sql.ResultSet rsBT=null;
StringBuffer btBuf = new StringBuffer();
StringBuffer bsBuf = new StringBuffer();
double bankStTot = 0;
double bankTrTot = 0;
try
{
if(conn==null)
{
ibase.system.config.ConnDriver connDriver = new ibase.system.config.ConnDriver();
//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
connDriver = null;
}
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength:::::::::"+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("tran_id"))
{
if(childNode.getFirstChild()!=null)
{
tranIdBS = childNode.getFirstChild().getNodeValue();
if(!BankStTranIdVec.contains(tranIdBS.trim()))
{
BankStTranIdVec.add(tranIdBS.trim());
}
}
}
if (childNodeName.equals("banktran_log"))
{
if(childNode.getFirstChild()!=null)
{
BanktranLogTranIds = childNode.getFirstChild().getNodeValue();
System.out.println("BanktranLogTranIds::::::::::::["+BanktranLogTranIds+"]");
if(BanktranLogTranIds.trim().length()>0)
{
String[] token = BanktranLogTranIds.split(",");
for(int i=0;i<token.length;i++)
{
if(!BankTranLogVec.contains(token[i].trim()))
{
BankTranLogVec.add(token[i].trim());
}
}
}
}
}
}//INNER FOR LOOP
}
//14062007
noOfBankStatement = BankStTranIdVec.size();
noOfBankLogTran = BankTranLogVec.size();
//Commented by msalam on 18/06/07 as multiple processing on both side allowed.
/*
if((BankStTranIdVec.size()>1) && (BankTranLogVec.size()>1) )
{
errString="MULSELNA";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
*/
for(int i=0;i<BankStTranIdVec.size();i++)
{
tranIdBS = (String)BankStTranIdVec.get(i);
if(i==BankStTranIdVec.size()-1)
{
bsBuf.append("'").append(tranIdBS).append("'");
}
else
{
bsBuf.append("'").append(tranIdBS).append("'").append(",");
}
}
for(int i=0;i<BankTranLogVec.size();i++)
{
tranIdBT = (String)BankTranLogVec.get(i);
if(i==BankTranLogVec.size()-1)
{
btBuf.append("'").append(tranIdBT).append("'");
}
else
{
btBuf.append("'").append(tranIdBT).append("'").append(",");
}
}
System.out.println("BankStatement[BUFFER] ::::"+bsBuf.toString());
System.out.println("BankTranLog[BUFFER] ::::"+btBuf.toString());
// ADDED ON 05062007
int count = 0;
//if the currency code not match of select record of bank statement then give error
sqlBS1 = " SELECT COUNT(DISTINCT(CURR_CODE)) FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' ";
pstmtBS = conn.prepareStatement(sqlBS1);
rsBS = pstmtBS.executeQuery();
if(rsBS.next())
{
count = rsBS.getInt(1);
}
rsBS.close();
pstmtBS.close();
System.out.println("BankStatement[DISTINCT CURRENCY] ::"+sqlBS1+"["+count+"]");
if(count!=1)
{
errString="VTRECOCUR1";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
count =0;
//if the currency code not match of select record of bank tran log then give error
sqlBT1 = " SELECT COUNT(DISTINCT(CURR_CODE)) FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' ";
pstmtBS = conn.prepareStatement(sqlBT1);
rsBS = pstmtBS.executeQuery();
if(rsBS.next())
{
count = rsBS.getInt(1);
}
rsBS.close();
pstmtBS.close();
System.out.println("BanktranLog[DISTINCT CURRENCY] ::"+sqlBT1+"["+count+"]");
if(count!=1)
{
errString="VTRECOCUR2";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
double amt =0;
/////////////////////Dont allow Tran-type P & R together for multiple to multiple operation
if((BankStTranIdVec.size()>1) && (BankTranLogVec.size()>1) ){
isMulToMulOpr = true;
sqlBS1 = " SELECT COUNT(DISTINCT(TRAN_TYPE)) FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' ";
pstmtBS = conn.prepareStatement(sqlBS1);
rsBS = pstmtBS.executeQuery();
if(rsBS.next())
{
count = rsBS.getInt(1);
}
rsBS.close();
pstmtBS.close();
System.out.println("BankStatement[DISTINCT TRAN_TYPE] ::"+sqlBS1+"["+count+"]");
if(count!=1)
{
errString="MULTTNA1";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
count =0;
//if the TRAN_TYPE not match of select record of bank tran log then give error
sqlBT1 = " SELECT COUNT(DISTINCT(TRAN_TYPE)) FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' ";
pstmtBS = conn.prepareStatement(sqlBT1);
rsBS = pstmtBS.executeQuery();
if(rsBS.next())
{
count = rsBS.getInt(1);
}
rsBS.close();
pstmtBS.close();
System.out.println("BanktranLog[DISTINCT TRAN_TYPE] ::"+sqlBT1+"["+count+"]");
if(count!=1)
{
errString="MULTTNA2";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
sqlBS1 = " SELECT sum(AMOUNT-AMT_ADJ), TRAN_TYPE FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' GROUP BY TRAN_TYPE ";
sqlBT1 = " SELECT sum(AMOUNT-AMT_ADJ), TRAN_TYPE FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' GROUP BY TRAN_TYPE ";
//sqlBS1 = " SELECT AMOUNT-AMT_ADJ, TRAN_TYPE FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' ";
//sqlBT1 = " SELECT AMOUNT-AMT_ADJ, TRAN_TYPE FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' ";
System.out.println("BankStatement Amount[SQL] ::"+sqlBS1);
System.out.println("BankTranLog Amount[SQL] ::::"+sqlBT1);
pstmtBS = conn.prepareStatement(sqlBS1);
rsBS = pstmtBS.executeQuery();
String tranTypeBS = null;
String tranTypeBT = null;
String positiveType = null;
if(rsBS.next()){
amt = 0;
amt = rsBS.getDouble(1);
tranTypeBS = rsBS.getString(2);
bankStTot = amt;
}
pstmtBT = conn.prepareStatement(sqlBT1);
rsBT = pstmtBT.executeQuery();
if(rsBT.next()){
amt = 0;
amt = rsBT.getDouble(1);
tranTypeBT = rsBT.getString(2);
positiveType = tranTypeBT;
bankTrTot = amt;
}
if(!(tranTypeBS.equalsIgnoreCase(tranTypeBT)))
{
System.out.println("TRAN_TYPE Miss Match ***************");
errString="DTTNA";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
}
else{
//For one to multiple operation
sqlBS1 = " SELECT AMOUNT-AMT_ADJ, TRAN_TYPE FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' ";
sqlBT1 = " SELECT AMOUNT-AMT_ADJ, TRAN_TYPE FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' ";
pstmtBS = conn.prepareStatement(sqlBS1);
rsBS = pstmtBS.executeQuery();
pstmtBT = conn.prepareStatement(sqlBT1);
rsBT = pstmtBT.executeQuery();
String tranTypeBs = null;
String tranTypeBT = null;
String positiveType = null;
if(noOfBankStatement == 1){
if(rsBS.next()){
amt = 0;
amt = rsBS.getDouble(1);
tranTypeBs = rsBS.getString(2);
positiveType = tranTypeBs;
bankStTot = amt;
}
}
if(noOfBankLogTran == 1){
if(rsBT.next()){
amt = 0;
amt = rsBT.getDouble(1);
tranTypeBT = rsBT.getString(2);
positiveType = tranTypeBT;
bankTrTot = amt;
}
}
if(noOfBankLogTran == 1)
while(rsBS.next())
{
amt =0;
amt = rsBS.getDouble(1);
tranTypeBs = rsBS.getString(2);
if(positiveType.equalsIgnoreCase(tranTypeBs))
{
bankStTot = bankStTot + amt;
}
else
{
bankStTot = bankStTot - amt;
isTranTypePAvailable = true;
}
}
if(noOfBankStatement == 1)
while(rsBT.next())
{
amt =0;
amt = rsBT.getDouble(1);
tranTypeBT = rsBT.getString(2);
if(positiveType.equalsIgnoreCase(tranTypeBT))
{
bankTrTot = bankTrTot + amt;
}
else
{
bankTrTot = bankTrTot - amt;
isTranTypePAvailable = true;
}
}
}//End of else
if(isTranTypePAvailable == true)//Operation is not have same tran type on both sides
isSameTypeOpr = false;
rsBS.close();
pstmtBS.close();
rsBT.close();
pstmtBT.close();
System.out.println("BankStTot ::::["+bankStTot+"]");
System.out.println("bankTrTot ::::["+bankTrTot+"]");
if(bankTrTot != bankStTot)
{
System.out.println("Amount Miss Match ***************");
errString="AMTMISS";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
System.out.println("errString ::::["+errString+"]");
return errString;
}
// END 05062007
sqlBS = " SELECT TRAN_ID,AMOUNT,AMT_ADJ,STATUS, TRAN_TYPE FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' order by tran_id ";
sqlBT = " SELECT TRAN_ID,AMOUNT,AMT_ADJ,STATUS, TRAN_TYPE FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' order by tran_id ";
String tempErrStr = null;
if( isSameTypeOpr == false){//Operation has same tran type on both sides
Object recoArray[];
Reco rec = null;
String errStr = null;
String recoTable = null;
///////////////////////
try{
if(noOfBankStatement != 1){
recoTable = "STATEMENT";
recoArray = reconcile(sqlBS, recoTable);
System.out.println("recoArr.len in stat :: " + recoArray.length);
System.out.println("After recoArray = reconcile(sqlBS)");
for(int updCounter = 0; updCounter < recoArray.length ; updCounter++){
rec = (Reco)recoArray[updCounter];
errStr = updateBankStatement(rec.tranId, rec.adjAmt, rec.status);
}
}
if(noOfBankLogTran != 1){
//Log to Log reconciliation
recoTable = "TRANLOG";
System.out.println("Before recoArray = reconcile(sqlBS)");
recoArray = reconcile(sqlBT, recoTable);
System.out.println("recoArr.len in lot :: " + recoArray.length);
System.out.println("After recoArray = reconcile(sqlBS)");
for(int updCounter = 0; updCounter < recoArray.length ; updCounter++){
rec = (Reco)recoArray[updCounter];
errStr = updateBankTranLog(rec.tranId, rec.adjAmt, rec.status);
}
//End of Log to Log reconciliation
}
}catch(Exception ex){
ex.printStackTrace();
errString="SPRECOERR";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
//End of statement to statement reconciliation
//////////////////////
}
System.out.println("Processing for SAME TYPE BOTH THE SIDE");
//sqlBS = " SELECT TRAN_ID,AMOUNT,AMT_ADJ,STATUS FROM BANK_STATEMENT WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+bsBuf.toString()+") and status <> 'R' order by tran_id ";
//sqlBT = " SELECT TRAN_ID,AMOUNT,AMT_ADJ,STATUS FROM BANKTRAN_LOG WHERE BANK_CODE ='"+bankCode.trim()+"' and TRAN_ID IN ("+btBuf.toString()+") and status <> 'R' order by tran_id ";
System.out.println("BankStatement[SQL] ::" + sqlBS);
System.out.println("BankTranLog[SQL] ::::" + sqlBT);
pstmtBS = conn.prepareStatement(sqlBS);
rsBS = pstmtBS.executeQuery();
pstmtBT = conn.prepareStatement(sqlBT);
while(rsBS.next())
{
balBS = 0.0;
tranIdBs = rsBS.getString(1);
amtBS = rsBS.getDouble(2);
adjAmtBS =rsBS.getDouble(3);
statusBS = rsBS.getString(4);
balBS = amtBS - adjAmtBS;
System.out.println("Bank Stat amtBs[" + amtBS + "]");
System.out.println("Bbalance in adjAmtBs[" + adjAmtBS + "]");
System.out.println("Bbalance in statusBS[" + statusBS + "]");
System.out.println("Bank Stat Tran Id["+tranIdBs+"]");
System.out.println("Bbalance in bank_statement["+balBS+"]");
rsBT = pstmtBT.executeQuery();
statusBT = " ";
statusBS = " ";
tempErrStr = "";
while(rsBT.next() && !statusBS.equalsIgnoreCase("R"))
{
String tStatusBT = null;
balBT = 0.0;
tranIdBT = rsBT.getString(1);
amtBT = rsBT.getDouble(2);
adjAmtBT =rsBT.getDouble(3);
statusBT = rsBT.getString(4);
tStatusBT = statusBT;
balBT = amtBT - adjAmtBT;
System.out.println("--BS Tran = " + tranIdBs + " BS Log = " + tranIdBT + " --");
System.out.println("Comparing Against["+tranIdBs+"]");
System.out.println("Bank Log Id["+tranIdBT+"]");
System.out.println("Bbalance in bank_tranlog["+balBS+","+balBT+"]");
if(balBS == balBT)
{
amtAdjust = balBS;
statusBS = "R";
statusBT = "R";
System.out.println("AmtAdjust To be adjust (balBS ==balBT):::["+amtAdjust+"]");
}
else if(balBS > balBT)
{
amtAdjust = balBT;
statusBT = "R";
statusBS = "P";
System.out.println("AmtAdjust To be adjust (balBS >balBT):::["+amtAdjust+"]");
}
else if (balBS < balBT)
{
amtAdjust = balBS;
statusBS = "R";
statusBT = "P";
System.out.println("AmtAdjust To be adjust (balBS < balBT):::["+amtAdjust+"]");
}
adjAmtBT = adjAmtBT + amtAdjust;
adjAmtBS = adjAmtBS + amtAdjust;
tempErrStr = insertBankRecoTrace(tranIdBs, tranIdBT, amtAdjust);
if(tempErrStr.length() != 0){
System.out.println("insertBankRecoTrace error :: " + tempErrStr);
break;
}
tempErrStr = updateBankTranLog(tranIdBT, adjAmtBT, statusBT);
if(tempErrStr.length() != 0){
System.out.println("updateBankTranLog error :: " + tempErrStr);
break;
}
tempErrStr = updateBankStatement(tranIdBs,adjAmtBS,statusBS);
if(tempErrStr.length() != 0){
System.out.println("updateBankStatement error :: " + tempErrStr);
break;
}
balBS = balBS - amtAdjust;
System.out.println("DIFFERENT :::["+balBS+"]");
//14062007
// if(balBS<= 0)
// break;
}//End of rsBT.next()
System.out.println("TEMP ERR STR = " + tempErrStr);
System.out.println("End of --BS Tran = " + tranIdBs + " BS Log = " + tranIdBT + " --");
if(tempErrStr.length() != 0){
errString = tempErrStr;
break;
}
}//End of rsBS.next()
pstmtBS.close();
pstmtBT.close();
if (errString == null || errString.trim().length() == 0)
{
try{
conn.commit();
}catch(Exception ex){}
System.out.println("errString is null************** ");
errString="VTCOMPL";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
else
{
System.out.println("errString is not null ***************");
errString="VTPRCERR";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
}
catch(Exception e)
{
System.out.println("Exception :BankReconcileMultiSelPrcEJB :process(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
errString="MAINERR1";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
//throw new ibase.webitm.utility.ITMException(e);
}
finally
{
System.out.println("Closing Connection...."+errString);
try
{
BankTranLogVec.clear();
BankStTranIdVec.clear();
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
errString = "MAINERR2";
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
}
}//END OF PROCESS(2)
private String updateBankStatement(String tranId,double adjAmt,String status)
{
java.sql.PreparedStatement upstmt = null;
String update ="";
String errString = "";
System.out.println("Update BankStatement------------->>>");
System.out.println("TranId:::["+tranId+"]");
System.out.println("Status:::["+status+"]");
System.out.println("AdjAmt:::["+adjAmt+"]");
System.out.println(" In Stat StId, Status, Amt :: " + tranId + ", " + status + ", " + adjAmt);
try
{
update = " UPDATE BANK_STATEMENT SET STATUS = '"+status+"', AMT_ADJ = "+adjAmt+" WHERE TRAN_ID = '"+tranId+"' ";
upstmt = conn.prepareStatement(update);
//upstmt.setString(1,status);
//upstmt.setDouble(2,adjAmt);
//upstmt.setString(3,tranId.trim());
//upstmt.setString(4,refno.trim());
int u = upstmt.executeUpdate();
System.out.println("No of record update in BankStatement:::["+u+"]");
upstmt.close();
//conn.commit();
}
catch(java.sql.SQLException seUpdate)
{
errString = "UPDBSERR1";
System.out.println("SQLException(Update BankStatement) :[Excuting Query Failed ]" + update + seUpdate.getMessage());
}
catch(Exception exUpdate)
{
errString = "UPDBSERR2";
System.out.println("Exception3(Update BankStatement) ::"+update +exUpdate.getMessage());
exUpdate.printStackTrace();
}
return errString;
}
//updateBankTranLog
private String updateBankTranLog(String tranId,double adjAmt,String status)
{
java.sql.PreparedStatement upstmt = null;
String update ="";
String errString = "";
System.out.println("Update BankTranLog--------------->>>");
//System.out.println("TranId:::["+tranId+"]");
//System.out.println("Status:::["+status+"]");
//System.out.println("AdjAmt:::["+adjAmt+"]");
System.out.println(" In Bank Lot TrId, Status, Amt :: " + tranId + ", " + status + ", " + adjAmt);
try
{
update = " UPDATE BANKTRAN_LOG SET STATUS = '"+status+"', AMT_ADJ = "+adjAmt+" WHERE TRAN_ID = '"+tranId+"' ";
upstmt = conn.prepareStatement(update);
//upstmt.setString(1,status);
//upstmt.setDouble(2,adjAmt);
//upstmt.setString(3,tranId.trim());
//upstmt.setString(4,refno.trim());
int u = upstmt.executeUpdate();
System.out.println("No of record update in banktran_log:::["+u+"]");
upstmt.close();
//conn.commit();
}
catch(java.sql.SQLException seUpdate)
{
errString = "UPDBTLBSERR1";
System.out.println("SQLException(Update BankTranLog) :[Excuting Query Failed ]" + update + seUpdate.getMessage());
}
catch(Exception exUpdate)
{
errString = "UPDBTLBSERR1";
System.out.println("Exception3(Update BankTranLog) ::"+update +exUpdate.getMessage());
exUpdate.printStackTrace();
}
return errString;
}
private String insertBankRecoTrace(String tranIdBS,String tranIdBT,double adjAmount)
{
java.sql.PreparedStatement ipstmt = null;
String insert = "";
String errString = "";
//System.out.println("TranId(BankStatement):::["+tranIdBS+"]");
//System.out.println("TranId(BankTransaction):::["+tranIdBT+"]");
//System.out.println("AdjAmt:::"+adjAmount);
System.out.println("StId, TrId, Amt :: " + tranIdBS + ", " + tranIdBT + ", " + adjAmount);
try
{
insert = " INSERT INTO BANKRECO_TRACE (TRAN_ID__STAT, TRAN_ID__LOG, AMOUNT ) VALUES (?,?,?)";
ipstmt = conn.prepareStatement(insert);
ipstmt.setString(1,tranIdBS);
ipstmt.setString(2,tranIdBT);
ipstmt.setDouble(3,adjAmount);
System.out.println("Insert a record in Trace---------------->>>["+ipstmt.executeUpdate()+"]");
ipstmt.close();
//conn.commit();
}
catch(java.sql.SQLException seinsert)
{
errString = "INSBRTERR1";
System.out.println("SQLException(insert in to Trace) :[Excuting Query Failed ]" + insert + seinsert.getMessage());
}
catch(Exception exinsert)
{
errString = "INSBRTERR2";
System.out.println("Exception(insert in to Trace) ::"+insert +exinsert.getMessage());
exinsert.printStackTrace();
}
return errString;
}
//added by ms alam on 22/06/07
private String insertBankRecoTrace(String tranIdBS,String tranIdBT, double amount, double amountSt, double amountLog)
{ //insertBankRecoTrace(fromStatId, toStatId, 0, amtAdjust, 0);
java.sql.PreparedStatement ipstmt = null;
String insert = "";
String errString = "";
//System.out.println("TranId(BankStatement):::["+tranIdBS+"]");
//System.out.println("TranId(BankTransaction):::["+tranIdBT+"]");
//System.out.println("AdjAmt:::"+adjAmount);
System.out.println("StId, TrId, Amt, AmtSt, AmtLog :: " + tranIdBS + ", " + tranIdBT + ", " + amount + ", " + amountSt + ", " + amountLog);
try
{
insert = " INSERT INTO BANKRECO_TRACE (TRAN_ID__STAT, TRAN_ID__LOG, AMOUNT, amount_ST, amount_Log ) VALUES (?,?,?,?,?)";
ipstmt = conn.prepareStatement(insert);
ipstmt.setString(1, tranIdBS);
ipstmt.setString(2, tranIdBT);
ipstmt.setDouble(3, amount);
ipstmt.setDouble(4, amountSt);
ipstmt.setDouble(5, amountLog);
System.out.println("Insert a record in Trace---------------->>>["+ipstmt.executeUpdate()+"]");
ipstmt.close();
//conn.commit();
}
catch(java.sql.SQLException seinsert)
{
errString = "INSBRTERR4";
System.out.println("SQLException(insert in to Trace) :[Excuting Query Failed ]" + insert + seinsert.getMessage());
}
catch(Exception exinsert)
{
errString = "INSBRTERR5";
System.out.println("Exception(insert in to Trace) ::"+insert +exinsert.getMessage());
exinsert.printStackTrace();
}
return errString;
}
//end of bank reco trace by ms alam
private Object[] reconcile(String sql, String forTable) throws Exception{
String tranIdBS = "";
double amtBS = 0.0;
double adjAmtBS = 0.0;
String statusBS = "";
double balBS = 0.0;
String tranTypeBS = "";
double amtAdjust = 0.0;
String tranIdBT = "";
double amtBT = 0.0;
double adjAmtBT = 0.0;
String statusBT = "";
double balBT = 0.0;
String tranTypeBT = "";
String fromStatId = null, toStatId = null;
String errStr = null;
java.sql.PreparedStatement pstmt=null;
java.sql.ResultSet rs=null;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
List recoList = new ArrayList();
while(rs.next())
{
balBS = 0.0;
tranIdBS = rs.getString(1);
amtBS = rs.getDouble(2);
adjAmtBS =rs.getDouble(3);
statusBS = rs.getString(4);
tranTypeBS = rs.getString(5);
balBS = amtBS - adjAmtBS;
//Reco(String tranId, double amt, double adjAmt, String status, String tranType)
Reco rec = new Reco(tranIdBS, amtBS, adjAmtBS, statusBS, tranTypeBS);
recoList.add(rec);
}
Object statArray[] = (Object [])recoList.toArray();
Reco fromRec = null;
Reco toRec = null;
System.out.println("statArr.len in reco ::: " + statArray.length);
for(int fromCounter = 0; fromCounter < statArray.length; fromCounter++)
{
fromRec = (Reco)statArray[fromCounter];
balBS = 0.0;
tranIdBS = fromRec.tranId;//statArray[fromCounter].tranId;
amtBS = fromRec.amt; //statArray[fromCounter].amt;
adjAmtBS = fromRec.adjAmt; //statArray[fromCounter].adjAmt;
statusBS = fromRec.status; //fromRec.statArray[fromCounter].status;
tranTypeBS = fromRec.tranType; //statArray[fromCounter].tranType;
balBS = amtBS - adjAmtBS;
statusBS = " ";
for(int toCounter = fromCounter + 1;
toCounter < statArray.length && !(fromRec.status.equals("R"));
toCounter++)
{
toRec = (Reco)statArray[toCounter];
balBT = 0.0;
tranIdBT = toRec.tranId;
amtBT = toRec.amt;
adjAmtBT = toRec.adjAmt;
statusBT = toRec.status;
tranTypeBT = toRec.tranType;
balBT = amtBT - adjAmtBT;
amtAdjust = 0.0;
if(!((fromRec.tranType).equals(toRec.tranType)) && !statusBT.equals("R")){
System.out.println("In fromRec.tranType).equals(toRec.tranType ");
if(balBS == balBT)
{
amtAdjust = balBS;
statusBS = "R";
statusBT = "R";
//insert trace (fromTranId, toTranId, amount =0, amount_st = balBT)
fromStatId = fromRec.tranId;
toStatId = toRec.tranId;
//update stat (fromTranId, adjAmt = balBT, status = R)
fromRec.adjAmt = balBT;
fromRec.status = "R";
//End of update stat (fromTranId, adjAmt = balBT, status = R)
//update stat (toTranId, adjAmt = balBT, status = R);
toRec.adjAmt = balBT;
toRec.status = "R";
//End of update stat (toTranId, adjAmt = balBT, status = R);
System.out.println("AmtAdjust To be adjust (balBS ==balBT):::["+amtAdjust+"]");
}
else if(balBS > balBT)
{
amtAdjust = balBT;
statusBT = "R";
statusBS = "P";
fromStatId = fromRec.tranId;
toStatId = toRec.tranId;
//insert trace (fromTranId, toTranId, amount =0, amount_st = balBT)
//update stat (fromTranId, adjAmt = balBT, status = P)
fromRec.adjAmt += balBT;
fromRec.status = "P";
//End of update stat (fromTranId, adjAmt = balBT, status = R)
//update stat (toTranId, adjAmt = balBT, status = R);
toRec.adjAmt = balBT;
toRec.status = "R";
//End ofupdate stat (toTranId, adjAmt = balBT, statur = R);
System.out.println("AmtAdjust To be adjust (balBS >balBT):::["+amtAdjust+"]");
}
else if (balBS < balBT)
{
amtAdjust = balBS;
statusBS = "R";
statusBT = "P";
//insert trace (fromTranId, toTranId, amount =0, amount_st = balBS)
fromStatId = fromRec.tranId;
toStatId = toRec.tranId;
//uupdate stat (fromTranId, adjAmt = balBT, status = R)
fromRec.adjAmt += balBS;
fromRec.status = "R";
//End of update stat (fromTranId, adjAmt = balBT, status = R)
//update stat (toTranId, adjAmt = balBT, status = R);
toRec.adjAmt += balBS;
toRec.status = "P";
//End of update stat (toTranId, adjAmt = balBT, statur = P);
System.out.println("AmtAdjust To be adjust (balBS < balBT):::["+amtAdjust+"]");
}
if(forTable.equals("STATEMENT"))
errStr = insertBankRecoTrace(fromStatId, toStatId, 0, amtAdjust, 0);
else if(forTable.equals("TRANLOG"))
errStr = insertBankRecoTrace(fromStatId, toStatId, 0, 0, amtAdjust);
if(errStr != null && errStr.length() != 0){
throw new Exception();
}
}//End of tranType not equal it
}//End of inner for loop
if(errStr != null && errStr.length() != 0){
throw new Exception();
}
}//End of outer for loop
return statArray;
}//End of Statement To Statement Reco
//added by msalam on 22/06/07
private class Reco{
public String tranId = "";
public double amt = 0.0;
public double adjAmt = 0.0;
public String status = "";
public String tranType = "";
public double bal = 0.0;
public Reco(String tranId, double amt, double adjAmt, String status, String tranType){
this.tranId = tranId;
this.amt = amt;
this.adjAmt = adjAmt;
this.status = status;
this.tranType = tranType;
this.bal = amt - adjAmt;
}
}
}//END OF EJB
package ibase.webitm.ejb.fin;
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.Calendar;
import java.util.Date;
import java.util.List;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.itextpdf.text.log.SysoCounter;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
public class PdcGivenIC extends ValidatorEJB implements PdcGivenRemote, PdcGivenLocal {
E12GenericUtility genericUtility = new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
DistCommon disCommon = null;
ValidatorEJB validator = null;
UtilMethods utilMethods = UtilMethods.getInstance();
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException {
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
finCommon = new FinCommon();
disCommon = new DistCommon();
validator = new ValidatorEJB();
try {
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
errString = wfValData(dom, dom1, objContext, editFlag, xtraParams);
} catch (Exception e) {
throw new ITMException(e);
}
return errString;
}
private String checkNull(String input) {
return input == null ? "" : input.trim();
}
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams)
throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null, detail2List, childDetilList = null;
;
Node parentNode = null;
Node childNode = null;
finCommon = new FinCommon();
disCommon = new DistCommon();
validator = new ValidatorEJB();
Node itemNode = null, lineNoNode = null, detailNode = null, chidDetailNode = null;
String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String tranId = "", tranIdRcp = "";
String custCode = "";
String siteCode = "";
String finEntity = "";
String currCode = "";
String acctCodeBal = "";
String tranDateS = "";
String cctrCodeBal = "";
String userId = "";
String sql = "";
String errCode = "";
String errorType = "";
String errString = "";
String hsiteCode = "";
String hcurrCode = "";
String acctCodeAdv = "";
String cctrCodeAdv = "";
String tranType = "", loginSiteDescr = "", amountbrow, amounthdr;
String rcpMode = "";
String cctrCodeCf = "";
String groupCode = "";
String hgroupCode = "";
String acctCodeCf = "";
String finScheme = "";
String projCode = "";
String tranIdAdvbking = "";
String htranIdAdvbking = "";
String hcustCode = "";
String bankCode = "";
String analCode = "";
String refNo = "";
String refSer = "";
String lineNoRef = "";
String htranId = "";
String cctrCodeAr = "";
String acctCode = "";
String cctrCode = "";
String empCode = "";
String acctCodeAr = "";
String hbankCode = "";
String Sdays = "";
String remark = "";
String refDateS = "";
String dueDateS = "";
String siteSpecificBank = "";
String rDshCnf = "";
String taxClass = "", taxEnv = "", taxChap;
double diffAmtExch = 0.0D;
double exchRate = 0.0D;
String amount = "";
double chequeAmt = 0.0D;
double balAmt = 0.0D;
double amountBc = 0.0D;
double rcpAmt = 0.0D;
double rcpAmt1 = 0.0D;
double billDiscAmt = 0.0D, amtBc;
String advAmt = "", confGivenAmt = null;
double amt = 0.0D;
double totAmt = 0.0D;
double pendingAmt = 0.0D;
double adjAmt = 0.0D, amtdtl;
double amtbrow = 0, amtHdr = 0, currCHdr = 0;
Timestamp rfDate = null;
String sundryType = null, currCodeHdr = null, cctrCodeAp = null, acctCodeAp = null, sundryCode = null,
bankCodedep = null, sundryTypeAcct = null;
int ctr = 0;
int currentFormNo = 0;
int cnt = 0;
int crt = 0;
int Idays = 0;
java.util.Date tranDate = null;
java.util.Date effDate = null;
java.util.Date refDate = null;
java.util.Date dueDate = null;
java.util.Date heffDate = null;
java.util.Date htranDate = null;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
SimpleDateFormat sdf = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
String effBankStr = "", rcpacctAmt = "", tranDateStr = null;
String refType = "", paymentno = "", guid = "", custbankref = null, tranid = null, tranidhdr, exchrate, amtStr;
String amountbc, givenAmt;
double advAmtd, confAmt = 0, gAmount;
double rcpacctAmtdbl = 0, osamt = 0, amtbc, exrate;
SimpleDateFormat simpleDateFormat = null;
Calendar currentDate = Calendar.getInstance();
int childNodeListLength;
int errListSize = errList.size();
try {
conn = getConnection();
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("user ID form XtraParam : " + userId);
loginSiteDescr = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo) {
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("bank_code")) {
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
if (bankCodedep != null && bankCodedep.trim().length() > 0) {
errCode = finCommon.isBankCode(siteCode, bankCode, "FIN", conn);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF BANK_code
else if (childNodeName.equalsIgnoreCase("sundry_code")) {
sundryCode = checkNull(genericUtility.getColumnValue("sundry_code", dom));
if (sundryCode != null && sundryCode.trim().length() > 0) {
sundryType = checkNull(genericUtility.getColumnValue("sundry_type", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
errCode = finCommon.isSundryCode(siteCode, sundryType, sundryCode, "PDC-P", conn);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF SUNDRY_code
else if (childNodeName.equalsIgnoreCase("curr_code")) {
currCode = this.genericUtility.getColumnValue("curr_code", dom);
System.out.println("currCide is:::" + currCode);
if (currCode == null && currCode.trim().length() == 0) {
errCode = "VECUR2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
} else {
sql = "select count(*) from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("currcode..." + currCode);
}
}
// END OF curr_code
else if (childNodeName.equalsIgnoreCase("emp_code_sign1")) {
empCode = this.genericUtility.getColumnValue("emp_code_sign1", dom);
if (empCode != null && empCode.trim().length() > 0) {
sql = "select count(*) from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VMEMPCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF emp_code_sign1
else if (childNodeName.equalsIgnoreCase("emp_code_sign2")) {
empCode = this.genericUtility.getColumnValue("emp_code_sign2", dom);
if (empCode != null && empCode.trim().length() > 0) {
sql = "select count(*) from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VMEMPCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF EMP_CODE_SIGN2
else if (childNodeName.equalsIgnoreCase("site_code")) {
siteCode = this.genericUtility.getColumnValue("site_code", dom);
tranDateS = this.genericUtility.getColumnValue("tran_date", dom);
sql = "SELECT COUNT(*) FROM SITE WHERE SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
if (cnt == 0) {
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
errCode = finCommon.nfCheckPeriod("FIN", tranDate, siteCode, conn);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// END OF SITE_CODE
else if (childNodeName.equalsIgnoreCase("acct_code__ap")) {
sundryType = checkNull(genericUtility.getColumnValue("sundry_type", dom));
acctCodeAp = checkNull(genericUtility.getColumnValue("acct_code__ap", dom));
if (acctCodeAp != null && acctCodeAp.trim().length() > 0) {
sql = "select sundry_type from accounts where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCodeAp);
rs = pstmt.executeQuery();
if (rs.next()) {
sundryTypeAcct = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (!sundryType.equals(sundryTypeAcct)) {
errCode = "ACCTTYPE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF acct_code__ap
else if (childNodeName.equalsIgnoreCase("adv_amt")) {
advAmt = this.genericUtility.getColumnValue("adv_amt", dom);
if (advAmt != null && advAmt.trim().length() > 0) {
advAmtd = Double.parseDouble(advAmt);
} else {
advAmtd = 0;
}
if (advAmtd < 0) {
errCode = "VTRCPADV1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
// END OF ADV_AMT
else if (childNodeName.equalsIgnoreCase("ref_no")) {
System.out.println("this id ref no block");
refNo = this.genericUtility.getColumnValue("ref_no", dom);
if (refNo != null && refNo.trim().length() > 0) {
System.out.println("enter ref no is 1" + refNo);
tranid = this.genericUtility.getColumnValue("tran_id", dom);
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
sql = "select count(*) from pdc_given where ref_no=? and bank_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
sql = "select tran_id from misc_payment where ref_no = ? and bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
paymentno = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// misc_payment_canc with ref no
if (paymentno != null && paymentno.trim().length() > 0) {
sql = "select count(*) from misc_payment_canc where ref_no=? and payment_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, paymentno);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
System.out.println("@V@ received:- [" + cnt + "]");
errCode = "VTDUPREF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
// end
sql = "select count(*) from payment_exp where ref_no=? and bank_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0) {
System.out.println("@V@ received:- [" + cnt + "]");
errCode = "VTDUPREF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
//// END OF REF_NO
else if (childNodeName.equalsIgnoreCase("cctr_code__ap")) {
cctrCodeAp = genericUtility.getColumnValue("cctr_code__ap", dom);
if (cctrCodeAp != null && cctrCodeAp.trim().length() > 0) {
acctCodeAp = genericUtility.getColumnValue("acct_code__ap", dom);
errCode = finCommon.isCctrCode(acctCodeAp, cctrCodeAp, "FIN", conn);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
// END OF CCTR_CODE_A
} // close tag
System.out.println(" itemchanged case 1 valueXmlString : " + valueXmlString);
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("ref_no")) {
System.out.println("welcomne refno");
refNo = this.genericUtility.getColumnValue("ref_no", dom);
givenAmt = this.genericUtility.getColumnValue("amount", dom);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
tranDateS = this.genericUtility.getColumnValue("tran_date", dom1);
if (tranDateS != null) {
tranDate = Timestamp.valueOf(
genericUtility.getValidDateString(tranDateS, genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
siteCode = this.genericUtility.getColumnValue("site_code", dom1);
if (givenAmt != null && givenAmt.trim().length() > 0) {
gAmount = Double.parseDouble(givenAmt);
} else {
gAmount = 0;
}
System.out.println("given amount is===" + gAmount);
sql = "select count(*), sum(tot_Amt - adj_amt) from misc_payables where tran_ser = ? and ref_no = ? and site_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
pstmt.setString(3, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
osamt = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("totamt::" + osamt);
if (cnt == 0) {
errCode = "VMREF1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql = "select sum(pdc_givendet.amount) from pdc_given,pdc_givendet WHERE ( pdc_given.tran_id = pdc_givendet.tran_id ) and "
+ "( pdc_givendet.ref_ser = ? ) AND ( pdc_givendet.ref_no = ? ) AND ( pdc_given.status = 'C' )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next()) {
confGivenAmt = rs.getString(1);
}
if (confGivenAmt != null && confGivenAmt.trim().length() > 0) {
confAmt = Double.parseDouble(confGivenAmt);
} else {
confAmt = 0;
}
System.out.println("confamount:::" + confAmt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((osamt - confAmt) < gAmount) {
errCode = "VTRCPT6";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.trim().equalsIgnoreCase("curr_code")) {
currCode = this.genericUtility.getColumnValue("curr_code", dom);
currCodeHdr = this.genericUtility.getColumnValue("curr_code", dom1);
if (!currCode.equals(currCodeHdr)) {
errCode = "VTCUR3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
valueXmlString.append("</Detail2>");
}
errListSize = errList.size();
cnt = 0;
String errFldName = null;
System.out.println("errListSize [" + errListSize + "] errFields size [" + errFields.size() + "]");
if ((errList != null) && (errListSize > 0)) {
for (cnt = 0; cnt < errListSize; cnt++) {
errCode = (String) errList.get(cnt);
System.out.println("errCode :" + errCode);
int pos = errCode.indexOf("~");
System.out.println("pos :" + pos);
if (pos > -1) {
errCode = errCode.substring(0, pos);
}
System.out.println("error code is :" + errCode);
errFldName = (String) errFields.get(cnt);
System.out.println(" cnt [" + cnt + "] errCode [" + errCode + "] errFldName [" + errFldName + "]");
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if (errString.length() > 0) {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,
errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E")) {
break;
}
}
errStringXml.append("</Errors> </Root> \r\n");
} else {
errStringXml = new StringBuffer("");
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception d) {
d.printStackTrace();
}
} // end of finally statement
return errStringXml.toString();
}
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException, ITMException {
String errString = "";
Document dom = null;
Document domhr = null;
Document domAll = null;
String retString = "";
try {
System.out.println("************** Inside itemChanged method ****************");
if (xmlString != null && xmlString.trim().length() > 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
domhr = genericUtility.parseString(xmlString1);
}
retString = itemChanged(dom, domhr, objContext, currentColumn, editFlag, xtraParams);
System.out.println("retString::::::::::" + retString);
} catch (Exception e) {
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return retString;
}
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag,
String xtraParams) throws RemoteException, ITMException {
Connection conn = null;
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
SimpleDateFormat sdf;
int currentFormNo = 0, ctr = 0;
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int childNodeListLength = 0;
Timestamp tranDate = null;
int pos;
String acctCodeBal = null, cctrCodeBal = null, acctCodeSal = null, cctrCodeSal = null;
java.util.Date refDate = null;
java.util.Date effDate = null;
java.util.Date dueDate = null;
java.util.Date htranDate = null;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
SimpleDateFormat dateFormat1 = null;
String hcurrCode = "", reStr = "", userId;
int childNodeLength = 0;
String sundrytype = null, sundrycode = null, sitecode, acctCodeApAdv = null, cctrCodeApAdv = null;
String colname, code, descr = null, stype, mcurr = null, msite = null, bankcode = null, bankdescr = null,
tranrefrcv;
String loginSite, amount = null, finent = null, fname = null, mname = null, lname = null, descr1 = null,
descr2 = null, acctCodeAdv = null, cctrCodeAdv = null, bankcodedep;
String tranId, refNo, currCode = null, acctCode = null, cctrCode = null, acctDescr = null, cctrDescr = null,
currDescr = null, refSer = null, exchrate;
String code1, code2, custCode = null, sfname, smname, slname, tranSer;
double exrate = 0, hexchrate, advAmt;
String exchRate = null, acctCodefp, cctrCodefp;
String billAmt, empCode = null;
String chqAmt, acctCodeAp = null;
double discount = 0, taxAmt = 0, amt = 0, amtBc, totAmt = 0, adjAmt = 0, diffAmtExch, rcpAmt, intAmt,
adjAmtBc = 0;
double intPerc, chqamt, billamt = 0, amtdet = 0;
String loginSiteDescr = null, tranid = null, status = null, cctrCodeAp = null, tranDateS = null;
double noOfDays;
String sql;
try {
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
dateFormat1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
conn.setAutoCommit(false);
connDriver = null;
this.finCommon = new FinCommon();
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0)) {
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo) {
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
System.out.println("first receipt mode ------>" + genericUtility.getColumnValue("rcp_mode", dom));
do {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn)) {
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) {
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sitecode = genericUtility.getColumnValue("site_code", dom);
// get login site description
sql = " select descr from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next()) {
loginSiteDescr = rs.getString("descr");
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_code protect =\"1\">").append("<![CDATA[" + loginSite + "]]>")
.append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + loginSiteDescr + "]]>")
.append("</site_descr>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + sdf.format(new Date()) + "]]>")
.append("</tran_date>");
// valueXmlString.append("<sundry_desc>").append("<![CDATA[" + sdf.format(new
// Date()) + "]]>").append("</sundry_desc>");
valueXmlString.append("<ref_date>").append("<![CDATA[" + sdf.format(new Date()) + "]]>")
.append("</ref_date>");
}
else if ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim())) {
System.out.println("Inside itm_defaultedit");
tranid = genericUtility.getColumnValue("tran_id", dom);
sql = "select status, sundry_code, sundry_type, site_code from pdc_given where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranid);
rs = pstmt.executeQuery();
if (rs.next()) {
status = rs.getString(1);
sundrycode = rs.getString(2);
sundrytype = rs.getString(3);
sitecode = rs.getString(4);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
else if ("bank_code".equalsIgnoreCase(currentColumn.trim())) {
bankcode = checkNull(genericUtility.getColumnValue("bank_code", dom));
tranDateS = this.genericUtility.getColumnValue("tran_date", dom);
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = "select bank_name from bank where bank_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankcode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("bank_name"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bank_name>").append("<![CDATA[" + descr + "]]>").append("</bank_name>");
sql = "select emp_code from bank_sign where bank_code =? and ? between eff_from and valid_upto";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankcode);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if (rs.next()) {
empCode = checkNull(rs.getString("emp_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<emp_code__sign1>").append("<![CDATA[" + empCode + "]]>")
.append("</emp_code__sign1>");
}
else if ("site_code".equalsIgnoreCase(currentColumn.trim())) {
sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select descr, bank_code , fin_entity from site where site_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr1 = checkNull(rs.getString("descr"));
bankcode = checkNull(rs.getString("bank_code"));
finent = checkNull(rs.getString("fin_entity"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("site_code::::" + descr1 + " finentity:::" + finent + "bancode:::" + bankcode);
valueXmlString.append("<site_descr>").append("<![CDATA[" + descr1 + "]]>").append("</site_descr>");
sql = "select bank_name from bank where bank_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankcode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankdescr = checkNull(rs.getString("bank_name"));
}
System.out.println("bank_code::::" + bankdescr);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from finent where fin_entity =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finent);
rs = pstmt.executeQuery();
if (rs.next()) {
mcurr = rs.getString("curr_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("curr_code11::::" + mcurr);
valueXmlString.append("<bank_code>").append("<![CDATA[" + bankcode + "]]>").append("</bank_code>");
valueXmlString.append("<bank_name>").append("<![CDATA[" + bankdescr + "]]>").append("</bank_name>");
valueXmlString.append("<curr_code>").append("<![CDATA[" + mcurr + "]]>").append("</curr_code>");
System.out.println("currency..." + mcurr);
setNodeValue(dom, "bank_code", bankcode);
reStr = itemChanged(dom, dom1, objContext, "bank_code", editFlag, xtraParams);
pos = reStr.indexOf("<Detail1>");
reStr = reStr.substring(pos + 9);
pos = reStr.indexOf("</Detail1>");
reStr = reStr.substring(0, pos);
valueXmlString.append(reStr);
}
else if ("emp_code__sign1".equalsIgnoreCase(currentColumn.trim())) {
empCode = checkNull(genericUtility.getColumnValue("emp_code__sign1", dom));
sql = "select emp_fname, emp_lname from employee where emp_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("emp_fname"));
lname = checkNull(rs.getString("emp_lname"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<emp_fname>").append("<![CDATA[" + fname + "]]>").append("</emp_fname>");
valueXmlString.append("<emp_lname>").append("<![CDATA[" + lname + "]]>").append("</emp_lname>");
}
else if ("emp_code__sign2".equalsIgnoreCase(currentColumn.trim())) {
empCode = checkNull(genericUtility.getColumnValue("emp_code__sign2", dom));
sql = "select emp_fname, emp_lname from employee where emp_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("emp_fname"));
lname = checkNull(rs.getString("emp_lname"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<emp_fname1>").append("<![CDATA[" + fname + "]]>").append("</emp_fname1>");
valueXmlString.append("<emp_lname1>").append("<![CDATA[" + lname + "]]>").append("</emp_lname1>");
}
else if ("sundry_code".equalsIgnoreCase(currentColumn.trim())) {
sundrycode = checkNull(genericUtility.getColumnValue("sundry_code", dom));
sundrytype = checkNull(genericUtility.getColumnValue("sundry_type", dom));
tranrefrcv = checkNull(genericUtility.getColumnValue("tran_ref_rcv", dom));
sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
loginSite = checkNull(getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
switch (sundrytype) {
case "C":
sql = "select cust_name, curr_code, site_code, acct_code__ar, cctr_code__ar from customer where cust_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("cust_name"));
currCode = checkNull(rs.getString("curr_code"));
sitecode = checkNull(rs.getString("site_code"));
acctCodeAdv = checkNull(rs.getString("acct_code__ar"));
cctrCodeAdv = checkNull(rs.getString("cctr_code__ar"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "R":// for strategic Customer
sql = "select case when first_name is null then '' else first_name end as first_name,"
+ " case when middle_name is null then '' else middle_name end as middle_name ,"
+ " case when last_name is null then '' else last_name end as last_name, "
+ " a.curr_code, a.site_code, a.acct_code__ar, a.cctr_code__ar from strg_customer b,customer a "
+ " where b.cust_code =a.cust_code and b.sc_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("first_name"));
mname = checkNull(rs.getString("middle_name"));
lname = checkNull(rs.getString("last_name"));
currCode = checkNull(rs.getString("curr_code"));
sitecode = checkNull(rs.getString("site_code"));
acctCodeAdv = checkNull(rs.getString("acct_code__ar"));
cctrCodeAdv = checkNull(rs.getString("cctr_code__ar"));
}
descr = fname.trim() + ' ' + mname.trim() + ' ' + lname.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "B": // Bank
sql = "select bank_name, curr_code, site_code, acct_code__bal, cctr_code__bal from bank where bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("bank_name"));
currCode = checkNull(rs.getString("curr_code"));
sitecode = checkNull(rs.getString("site_code"));
acctCodeBal = checkNull(rs.getString("acct_code__bal"));
cctrCodeBal = checkNull(rs.getString("cctr_code__bal"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "E": // Employee
sql = "select emp_fname, emp_lname, site_code__acct, acct_code__sal, cctr_code__sal from employee, site \n"
+ " where employee.pay_site = site.site_code and emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("emp_fname"));
lname = checkNull(rs.getString("emp_lname"));
sitecode = checkNull(rs.getString("site_code__acct"));
acctCodeSal = checkNull(rs.getString("acct_code__sal"));
cctrCodeSal = checkNull(rs.getString("cctr_code__sal"));
}
descr = fname.trim() + ' ' + lname.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from site, finent where site.fin_entity = finent.fin_entity and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
currCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "P":// Sales Person
sql = "select sp_name,curr_code,acct_code__ap, cctr_code__ap, acct_code__ap_adv, cctr_code__ap_adv from sales_pers where sales_pers =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("sp_name"));
currCode = checkNull(rs.getString("curr_code"));
acctCodeAp = checkNull(rs.getString("acct_code__ap"));
cctrCodeAp = checkNull(rs.getString("cctr_code__ap"));
acctCodeApAdv = checkNull(rs.getString("acct_code__ap_adv"));
cctrCodeApAdv = checkNull(rs.getString("cctr_code__ap_adv"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "T": // Transporter
sql = "select tran_name, curr_code,acct_code__fp, cctr_code__fp from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("tran_name"));
currCode = checkNull(rs.getString("curr_code"));
acctCodefp = checkNull(rs.getString("acct_code__fp"));
cctrCodefp = checkNull(rs.getString("cctr_code__fp"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "O":// Other accounts
sql = "select descr, curr_code from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("descr"));
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "S":
sql = " select supp_name, curr_code, acct_code__ap, cctr_code__ap, acct_code__ap_adv, cctr_code__ap_adv from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("supp_name"));
currCode = checkNull(rs.getString("curr_code"));
acctCodeAp = checkNull(rs.getString("acct_code__ap"));
cctrCodeAp = checkNull(rs.getString("cctr_code__ap"));
acctCodeApAdv = checkNull(rs.getString("acct_code__ap_adv"));
cctrCodeApAdv = checkNull(rs.getString("cctr_code__ap_adv"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "X":
sql = "select tauth_name, acct_code__ap, cctr_code__ap from tax_authority where tauth_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("tauth_name"));
acctCodeAp = checkNull(rs.getString("acct_code__ap"));
cctrCodeAp = checkNull(rs.getString("cctr_code__ap"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from site, finent where site.fin_entity = finent.fin_entity and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "L":
sql = "select party_name,acct_code__ap, cctr_code__ap, acct_code__ap_adv, cctr_code__ap_adv from loanparty where party_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("party_name"));
acctCodeAp = checkNull(rs.getString("acct_code__ap"));
cctrCodeAp = checkNull(rs.getString("cctr_code__ap"));
acctCodeApAdv = checkNull(rs.getString("acct_code__ap_adv"));
cctrCodeApAdv = checkNull(rs.getString("cctr_code__ap_adv"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
}
sql = "select descr from accounts where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCodeAp);
rs = pstmt.executeQuery();
if (rs.next()) {
descr1 = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<sundry_desc>").append("<![CDATA[" + descr + "]]>").append("</sundry_desc>");
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
valueXmlString.append("<accounts_descr>").append("<![CDATA[" + descr1 + "]]>")
.append("</accounts_descr>");
valueXmlString.append("<acct_code__ap>").append("<![CDATA[" + acctCodeAp + "]]>")
.append("</acct_code__ap>");
if ((loginSite == null || loginSite.trim().length() == 0) && sitecode.trim().length() > 0) {
valueXmlString.append("<site_code>").append("<![CDATA[" + sitecode + "]]>")
.append("</site_code>");
sql = "select descr, fin_entity from site where site_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr2 = checkNull(rs.getString("descr"));
finent = checkNull(rs.getString("fin_entity"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<site_descr>").append("<![CDATA[" + descr2 + "]]>")
.append("</site_descr>");
if (currCode == null || currCode.trim().length() == 0) {
sql = "select curr_code from finent where fin_entity =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finent);
rs = pstmt.executeQuery();
if (rs.next()) {
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>")
.append("</curr_code>");
}
}
}
else if ("acct_code__ap".equalsIgnoreCase(currentColumn.trim())) {
acctCodeAp = checkNull(genericUtility.getColumnValue("acct_code__ap", dom));
sql = "select descr from accounts where acct_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCodeAp);
rs = pstmt.executeQuery();
if (rs.next()) {
descr1 = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<accounts_descr>").append("<![CDATA[" + descr1 + "]]>")
.append("</accounts_descr>");
} else if ("amount".equalsIgnoreCase(currentColumn.trim())) {
chqAmt = genericUtility.getColumnValue("amount", dom);
if (chqAmt != null && chqAmt.trim().length() > 0) {
chqamt = Double.parseDouble(chqAmt);
} else {
chqamt = 0;
}
billAmt = genericUtility.getColumnValue("adj_amt", dom);
if (billAmt != null && billAmt.trim().length() > 0) {
billamt = Double.parseDouble(billAmt);
} else {
chqamt = 0;
}
/*
* advAmt = chqamt - billamt; System.out.println("advaamt is:"+advAmt);
* valueXmlString.append("<adv_amt>").append("<![CDATA[" + advAmt +
* "]]>").append("</adv_amt>");
*/
}
valueXmlString.append("</Detail1>");
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn-------->>[" + currentColumn + "]");
valueXmlString.append("<Detail2>");
if ("ref_no".equalsIgnoreCase(currentColumn.trim())) {
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
exchRate = genericUtility.getColumnValue("exch_rate", dom);
amount = genericUtility.getColumnValue("amount", dom);
if (amount != null && amount.trim().length() > 0) {
amtdet = Double.parseDouble(amount);
} else {
amtdet = 0;
}
if (exchRate != null && exchRate.trim().length() > 0) {
exrate = Double.parseDouble(exchRate);
} else {
exrate = 0;
}
if ((refNo == null) || (refNo.trim().length() == 0))
refNo = "";
sql = " select tran_ser, tran_date, ref_no, ref_date, curr_code, exch_rate, acct_code, "
+ " cctr_code,due_date, tot_amt,sundry_code,adj_amt "
+ " from misc_payables where tran_ser=? and ref_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next()) {
tranSer = rs.getString(1);
tranDate = rs.getTimestamp(2);
refNo = rs.getString(3);
refDate = rs.getDate(4);
currCode = rs.getString(5);
exrate = rs.getDouble(6);
acctCode = rs.getString(7);
cctrCode = rs.getString(8);
dueDate = rs.getDate(9);
totAmt = rs.getDouble(10);
sundrycode = rs.getString(11);
adjAmt = rs.getDouble(12);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
System.out.println("test2 currncy" + currCode);
rs = pstmt.executeQuery();
if (rs.next()) {
currDescr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (adjAmt == 0) {
amt = totAmt - adjAmt;
}
amtBc = (amtdet * exrate);
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
valueXmlString.append("<currency_descr>").append("<![CDATA[" + currDescr + "]]>")
.append("</currency_descr>");
valueXmlString.append("<exch_rate>").append("<![CDATA[" + exrate + "]]>").append("</exch_rate>");
valueXmlString.append("<due_date>").append("<![CDATA[" + simpleDateFormat.format(dueDate) + "]]>")
.append("</due_date>");
valueXmlString.append("<amount>").append("<![CDATA[" + amt + "]]>").append("</amount>");
valueXmlString.append("<amount__bc>").append("<![CDATA[" + amtBc + "]]>").append("</amount__bc>");
valueXmlString.append("<acct_code>").append("<![CDATA[" + acctCode + "]]>").append("</acct_code>");
valueXmlString.append("<cctr_code>").append("<![CDATA[" + cctrCode + "]]>").append("</cctr_code>");
}
else if ("amount".equalsIgnoreCase(currentColumn.trim())) {
amount = genericUtility.getColumnValue("amount", dom);
if (amount != null && amount.trim().length() > 0) {
amt = Double.parseDouble(amount);
}
else {
amt = 0;
}
System.out.println("amount is " + amt);
exchRate = genericUtility.getColumnValue("exch_rate", dom);
if (exchRate != null && exchRate.trim().length() > 0) {
exrate = Double.parseDouble(exchRate);
} else {
exrate = 0;
}
amtBc = amt * exrate;
System.out.println("adjamt::" + amtBc);
valueXmlString.append("<amount__bc>").append("<![CDATA[" + amtBc + "]]>").append("</amount__bc>");
}
valueXmlString.append("</Detail2>");
}
valueXmlString.append("</Root>");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (pstmt != null)
pstmt.close();
if (rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
conn = null;
}
} catch (Exception d) {
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private double checkDouble(String input) {
if (input == null || input.trim().length() == 0) {
return 0;
} else {
return Double.parseDouble(input);
}
}
private static void setNodeValue(Document dom, String nodeName, String nodeVal) throws Exception {
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null) {
if (tempNode.getFirstChild() == null) {
CDATASection cDataSection = dom.createCDATASection(nodeVal);
tempNode.appendChild(cDataSection);
} else {
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface PdcGivenLocal extends ValidatorLocal {
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface PdcGivenRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
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.Calendar;
import java.util.Date;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.itextpdf.text.log.SysoCounter;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
public class PdcReceivedIC extends ValidatorEJB implements PdcReceivedRemote, PdcReceivedLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
DistCommon disCommon = null;
ValidatorEJB validator = null;
UtilMethods utilMethods = UtilMethods.getInstance();
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
finCommon = new FinCommon();
disCommon = new DistCommon();
validator = new ValidatorEJB();
try
{
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch (Exception e)
{
throw new ITMException(e);
}
return errString;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null,detail2List,childDetilList = null;;
Node parentNode = null;
Node childNode = null;
finCommon = new FinCommon();
disCommon = new DistCommon();
validator = new ValidatorEJB();
Node itemNode = null,lineNoNode = null,detailNode = null,chidDetailNode = null;
String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String tranId = "", tranIdRcp = "";
String custCode = "";
String siteCode = "";
String finEntity = "";
String currCode = "";
String acctCodeBal = "";
String tranDateS = "";
String cctrCodeBal = "";
String userId = "";
String sql = "";
String errCode = "";
String errorType = "";
String errString = "";
String hsiteCode = "";
String hcurrCode = "";
String acctCodeAdv = "";
String cctrCodeAdv = "";
String tranType = "", loginSiteDescr = "",amountbrow,amounthdr;
String rcpMode = "";
String cctrCodeCf = "";
String groupCode = "";
String hgroupCode = "";
String acctCodeCf = "";
String finScheme = "";
String projCode = "";
String tranIdAdvbking = "";
String htranIdAdvbking = "";
String hcustCode = "";
String bankCode = "";
String analCode = "";
String refNo = "";
String refSer = "";
String lineNoRef = "";
String htranId = "";
String cctrCodeAr = "";
String acctCode = "";
String cctrCode = "";
String empCode = "";
String acctCodeAr = "";
String hbankCode = "";
String Sdays = "";
String remark = "";
String refDateS = "";
String dueDateS = "";
String siteSpecificBank = "";
String rDshCnf = "";
String taxClass = "", taxEnv = "", taxChap;
double diffAmtExch = 0.0D;
double exchRate = 0.0D;
String amount ="";
double chequeAmt = 0.0D;
double balAmt = 0.0D;
double amountBc = 0.0D;
double rcpAmt = 0.0D;
double rcpAmt1 = 0.0D;
double billDiscAmt = 0.0D,amtBc;
String advAmt = "",confPDCAmt = null ;
double amt = 0.0D;
double totAmt = 0.0D;
double pendingAmt = 0.0D;
double adjAmt = 0.0D, amtdtl;
double amtbrow = 0, amtHdr = 0;
Timestamp rfDate = null;
String sundryType = null, sundryCode = null, bankCodedep = null;
int ctr = 0;
int currentFormNo = 0;
int cnt = 0;
int crt = 0;
int Idays = 0;
java.util.Date tranDate = null;
java.util.Date effDate = null;
java.util.Date refDate = null;
java.util.Date dueDate = null;
java.util.Date heffDate = null;
java.util.Date htranDate = null;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
SimpleDateFormat sdf = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
String effBankStr = "", rcpacctAmt = "", tranDateStr = null;
String refType = "", guid = "", custbankref = null, tranid, tranidhdr, exchrate, amtStr;
String amountbc;
double advAmtd,confAmt = 0;
double rcpacctAmtdbl = 0, osamt = 0,amtbc,exrate;
SimpleDateFormat simpleDateFormat = null;
Calendar currentDate = Calendar.getInstance();
int childNodeListLength;
int errListSize = errList.size();
try {
conn = getConnection();
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("user ID form XtraParam : "+userId);
loginSiteDescr = (genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("tran_date"))
{
tranDateS = this.genericUtility.getColumnValue("tran_date", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("trandate is :"+tranDate);
if (tranDate == null)
{
errCode = "VMTRANDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("bank_code__dep"))
{
bankCodedep = this.genericUtility.getColumnValue("bank_code__dep", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
System.out.println("bank cpde:"+bankCodedep+" site code is: "+siteCode);
if (bankCodedep != null && bankCodedep.trim().length() > 0)
{
//errCode = isBankCode(bankCodedep, siteCode, "FIN"); // done
errCode=finCommon.isBankCode(siteCode, bankCodedep, "FIN", conn);
if (errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("sundry_type"))
{
sundryType = this.genericUtility.getColumnValue("sundry_type", dom);
System.out.println("sundry type:"+sundryType);
if (sundryType == null && sundryType.trim().length() == 0)
{
errCode = "VTSUNTYPE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("sundry_code"))
{
sundryCode = checkNull(genericUtility.getColumnValue("sundry_code", dom));
if (sundryCode != null && sundryCode.trim().length() > 0)
{
sundryType = checkNull(genericUtility.getColumnValue("sundry_type", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
errCode = finCommon.isSundryCode(siteCode, sundryType, sundryCode, "PDC-P", conn);
if (errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("ref_no"))
{
System.out.println("this id ref no block");
refNo = this.genericUtility.getColumnValue("ref_no", dom);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
tranDateS = this.genericUtility.getColumnValue("tran_date", dom);
tranid = this.genericUtility.getColumnValue("tran_id", dom);
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
amount = this.genericUtility.getColumnValue("amount", dom);
System.out.println("ref no:"+refNo);
if(amount!= null && amount.trim().length()>0)
{
amt=Double.parseDouble(amount);
}
else
{
amt=0;
}
// for ref no duplicate value check--
if(refNo!= null && refNo.trim().length() > 0)
{
//System.out.println("enter ref no is 1"+refNo);
sql = "select count(*) from pdc_received where ref_no=? and status not in ('X','P')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ pdc_received no count:- [" + cnt + "]");
if(cnt > 0 && tranid != null && tranid.trim().length() > 0)
{
System.out.println("enter ref no is 1"+refNo);
sql = "select count(*) from rcpdishnr where receipt_no=? and tran_ser='R'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranid);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
System.out.println("@V@ pdc_received no count11:- [" + cnt + "]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
System.out.println("rcpdishnr :" + cnt);
errCode = "VTNREC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql = "select count(*) from receipt where ref_no=? and tran_id <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, tranid);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
System.out.println("@V@ pdc_received no count22:- [" + cnt + "]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt > 0)
{
System.out.println("@V@ received:- [" + cnt + "]");
errCode = "VTPDCREC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
else if(childNodeName.equalsIgnoreCase("curr_code"))
{
currCode = this.genericUtility.getColumnValue("curr_code",dom);
System.out.println("currCide is:::"+currCode);
if (currCode != null && currCode.trim().length() > 0)
{
sql = "select count(*) from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
if (cnt == 0)
{
errCode = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("currcode..."+currCode);
}
else
{
errCode = "VMCURRCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("emp_code_sign1"))
{
empCode = this.genericUtility.getColumnValue("emp_code_sign1", dom);
if (empCode == null && empCode.trim().length() == 0)
{
errCode = "VEEMP2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VMEMPCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("emp_code_sign2"))
{
empCode = this.genericUtility.getColumnValue("emp_code_sign2", dom);
if (empCode == null && empCode.trim().length() == 0)
{
errCode = "VEEMP2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VMEMPCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = this.genericUtility.getColumnValue("site_code", dom);
tranDateS= this.genericUtility.getColumnValue("tran_date", dom);
sql = "SELECT COUNT(*) FROM SITE WHERE SITE_CODE = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs= pstmt.executeQuery();
if (rs.next())
{
cnt= rs.getInt(1);
if (cnt == 0)
{
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs= null;
pstmt.close();
pstmt= null;
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
errCode = finCommon.nfCheckPeriod("FIN", tranDate, siteCode, conn);
if (errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("adv_amt"))
{
advAmt = this.genericUtility.getColumnValue("adv_amt", dom);
if(advAmt != null && advAmt.trim().length()>0)
{
advAmtd=Double.parseDouble(advAmt);
}
else
{
advAmtd=0;
}
if (advAmtd < 0)
{
errCode = "VTRCPADV1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("amount"))
{
amount =this.genericUtility.getColumnValue("amount",dom);
if(amount != null && amount.trim().length()>0)
{
amt=Double.parseDouble(amount);
}
else
{
amt=0;
}
if(amt < 0)
{
errCode = "VMAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(amt==0)
{
errCode = "VTAMTNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("acct_code__adv"))
{
acctCodeAdv = this.genericUtility.getColumnValue("acct_code__adv", dom);
advAmt = this.genericUtility.getColumnValue("adv_amt", dom);
if(advAmt != null && advAmt.trim().length()>0)
{
advAmtd=Double.parseDouble(advAmt);
}
else
{
advAmtd=0;
}
if(advAmtd != 0 && acctCodeAdv != null && acctCodeAdv.trim().length() != 0)
{
siteCode = this.genericUtility.getColumnValue("site_code", dom);
errCode = finCommon.isAcctCode(siteCode, acctCodeAdv, "FIN", conn);
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("cctr_code__adv"))
{
cctrCodeAdv = this.genericUtility.getColumnValue("cctr_code__adv", dom);
acctCodeAdv = this.genericUtility.getColumnValue("acct_code__adv", dom);
advAmt = this.genericUtility.getColumnValue("adv_amt", dom);
if(advAmt != null && advAmt.trim().length()>0)
{
advAmtd=Double.parseDouble(advAmt);
}
else
{
advAmtd=0.0;
}
if(advAmtd != 0.0)
{
if( acctCodeAdv != null && acctCodeAdv.trim().length() > 0 )
{
errCode = finCommon.isCctrCode(acctCodeAdv, cctrCodeAdv, "FIN", conn);
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
else if(childNodeName.equalsIgnoreCase("cust_bank__ref"))
{
custbankref = this.genericUtility.getColumnValue("cust_bank__ref", dom);
if (custbankref == null || custbankref.trim().length() == 0)
{
errCode = "VTCBREF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
valueXmlString.append("</Detail1>");
}
// close tag
System.out.println(" itemchanged case 1 valueXmlString : "+valueXmlString);
break;
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.trim().equalsIgnoreCase("ref_ser"))
{
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
if (refSer != null && refSer.trim().length() > 0)
{
sql = " select count(*) from refser where ref_ser = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
if (cnt == 0)
{
errCode = "VTREFSER7";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if(childNodeName.equalsIgnoreCase("ref_no"))
{
System.out.println("welcomne refno");
refNo = this.genericUtility.getColumnValue("ref_no", dom);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
tranDateS = this.genericUtility.getColumnValue("tran_date", dom1);
System.out.println("trandate id 11:;:"+tranDateS);
tranid = this.genericUtility.getColumnValue("tran_id", dom1);
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("trandate id :;:"+tranDate);
amount = this.genericUtility.getColumnValue("amount", dom);
System.out.println("hello amount"+amount);
if(amount!= null && amount.trim().length()>0)
{
amt=Double.parseDouble(amount);
}
else
{
amt=0;
}
System.out.println("amount is==="+amt);
sql = "select count(*), sum(tot_Amt - adj_amt) from receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
osamt = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("totamt::"+osamt);
if(cnt == 0)
{
errCode = "VMREF1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql=" SELECT sum(pdc_recdet.amount) from pdc_received,pdc_recdet WHERE ( pdc_received.tran_id = pdc_recdet.tran_id ) and "
+ "( pdc_recdet.ref_ser = ? ) AND ( pdc_recdet.ref_no = ? ) AND ( pdc_received.status = 'C' )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
confPDCAmt = rs.getString(1);
}
if(confPDCAmt!= null && confPDCAmt.trim().length()>0)
{
confAmt=Double.parseDouble(confPDCAmt);
}
else
{
confAmt=0;
}
System.out.println("confamount:::"+confAmt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((osamt - confAmt) < amt)
{
errCode = "VTRCPT6";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.trim().equalsIgnoreCase("curr_code"))
{
currCode = this.genericUtility.getColumnValue("curr_code", dom);
if (currCode == null)
{
errCode = "VTCUR3";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.trim().equalsIgnoreCase("exch_rate"))
{
exchrate = this.genericUtility.getColumnValue("exch_rate", dom);
System.out.println("ex rate::"+exchrate);
if (exchrate == null)
{
errCode = "VTINVEXR";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("amount"))
{
amount = this.genericUtility.getColumnValue("amount", dom);
System.out.println("amount 111:"+amount);
if(amount != null && amount.trim().length()>0)
{
amt=Double.parseDouble(amount);
}
else
{
amt=0;
}
System.out.println("amount 112:"+amt);
refNo = this.genericUtility.getColumnValue("ref_no", dom);
htranId = this.genericUtility.getColumnValue("tran_id", dom1);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
sql = "select count(*), sum(tot_Amt - adj_amt ) from receivables where tran_ser =? and ref_no =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
osamt = rs.getDouble(2);
}
System.out.println("amount in detail 2:"+osamt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(amt < 0 && osamt > 0)
{
errCode = "VMAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(amt == 0)
{
errCode = "VTAMTNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(errCode.trim().length() == 0)
{
tranId = this.genericUtility.getColumnValue("tran_id", dom1);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
refNo = this.genericUtility.getColumnValue("ref_no", dom);
// amtbrow = Double.parseDouble(this.genericUtility.getColumnValue("amount", dom));
// parentNodeList = dom.getElementsByTagName("Detail2");
amount = genericUtility.getColumnValue("amount",dom);
//System.out.println("Detail 2 List "+detail2List);
if(amount != null && amount.trim().length() > 0)
{
amt = Double.parseDouble(amount.trim());
}
for(int t =0; t < parentNodeList.getLength(); t++ )
{
detailNode = parentNodeList.item(t);
childDetilList = detailNode.getChildNodes();
for(int p =0; p < childDetilList.getLength(); p++ )
{
chidDetailNode = childDetilList.item(p);
//System.out.println("current child node>>>>>>>>>> " + chidDetailNode.getNodeName() );
if(chidDetailNode.getNodeName().equalsIgnoreCase("amount") )
{
//System.out.println("line node found >>>>>" + chidDetailNode.getNodeName());
if(chidDetailNode.getFirstChild() != null )
{
amountbrow = chidDetailNode.getFirstChild().getNodeValue();
if(amountbrow != null && amountbrow.trim().length() > 0)
{
amtbrow = Double.parseDouble(amountbrow.trim());
totAmt = totAmt + amtbrow;
}
}
}
}
}
amounthdr = genericUtility.getColumnValue("amount", dom1);
if(amounthdr != null && amounthdr.trim().length() > 0)
{
amtHdr = Double.parseDouble(amounthdr.trim());
}
if (totAmt > amtHdr)
{
errCode = "VTADJAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("amount__bc"))
{
amountbc =this.genericUtility.getColumnValue("amount__bc", dom);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
refNo = this.genericUtility.getColumnValue("ref_no", dom);
System.out.println("amount is:::"+amountbc);
sql = "select count(*),sum(tot_Amt - adj_amt) from receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
osamt = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(amountbc!= null && amountbc.trim().length()>0)
{
amtbc=Double.parseDouble(amountbc);
}
else
{
amtbc=0;
}
System.out.println("amount is 222:::"+amountbc);
if (amtbc < 0 && osamt > 0)
{
errCode = "VMAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if (amtbc == 0)
{
errCode = "VTAMTNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
valueXmlString.append("</Detail2>");
}
errListSize = errList.size();
cnt = 0;
String errFldName = null;
System.out.println("errListSize [" + errListSize + "] errFields size [" + errFields.size() + "]");
if ((errList != null) && (errListSize > 0))
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String)errList.get(cnt);
System.out.println("errCode :"+errCode);
int pos = errCode.indexOf("~");
System.out.println("pos :"+pos);
if(pos>-1)
{
errCode=errCode.substring(0,pos);
}
System.out.println("error code is :"+errCode);
errFldName = (String)errFields.get(cnt);
System.out.println(" cnt [" + cnt + "] errCode [" + errCode + "] errFldName [" + errFldName + "]");
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") +
8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString +
errString.substring(errString.indexOf("</trace>") +
8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}// end of finally statement
return errStringXml.toString();
}
public String itemChanged(String xmlString, String xmlString1, String objContext,
String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
String errString = "";
Document dom = null;
Document domhr = null;
Document domAll = null;
String retString = "";
try {
System.out.println("************** Inside itemChanged method ****************");
if (xmlString != null && xmlString.trim().length() > 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
domhr = genericUtility.parseString(xmlString1);
}
retString = itemChanged(dom, domhr, objContext, currentColumn, editFlag, xtraParams);
System.out.println("retString::::::::::" + retString);
} catch (Exception e) {
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return retString;
}
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException, ITMException
{
Connection conn = null;
// Added by sarita on 01/06/2017
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
SimpleDateFormat sdf;
int currentFormNo = 0, ctr = 0;
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int childNodeListLength = 0;
java.util.Date tranDate = null;
// String tranDate = null;
java.util.Date refDate = null;
java.util.Date effDate = null;
java.util.Date dueDate = null;
java.util.Date htranDate = null;
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
SimpleDateFormat dateFormat1 = null;
;
String hcurrCode = "", reStr = "", userId;
int childNodeLength = 0;
String sundrytype, sundrycode, sitecode;
String colname, code, descr = null, stype, mcurr = null, msite = null, bankcode = null, bankdescr = null,
tranrefrcv;
String loginSite,amount = null, finent = null, fname = null, mname = null, lname = null, descr1 = null, descr2 = null,
acctCodeAdv = null, cctrCodeAdv = null, bankcodedep;
String tranId, refNo, currCode = null, acctCode = null, cctrCode = null, acctDescr = null, cctrDescr = null,
currDescr = null, refSer = null,exchrate;
String code1, code2, custCode = null, sfname, smname, slname, tranSer;
double exrate = 0, hexchrate, advAmt;
String exchRate = null;
String billAmt;
String chqAmt;
double discount = 0, taxAmt = 0, amt = 0,amtBc, totAmt = 0, adjAmt = 0, diffAmtExch, rcpAmt, intAmt,
adjAmtBc = 0;
double intPerc,chqamt,billamt = 0;
String loginSiteDescr = null;
double noOfDays;
String sql;
try {
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
dateFormat1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
conn.setAutoCommit(false);
connDriver = null;
this.finCommon = new FinCommon();
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
System.out.println("first receipt mode ------>"+genericUtility.getColumnValue("rcp_mode", dom));
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals(currentColumn))
{
childNode.getFirstChild();
}
ctr++;
}
while ((ctr < childNodeListLength) && (!childNodeName.equals(currentColumn)));
if("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sitecode = genericUtility.getColumnValue("site_code", dom);
// get login site description
sql = " select descr from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next()) {
loginSiteDescr = rs.getString("descr");
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_code protect =\"1\">").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + loginSiteDescr + "]]>").append("</site_descr>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + sdf.format(new Date()) + "]]>").append("</tran_date>");
valueXmlString.append("<ref_date>").append("<![CDATA[" + sdf.format(new Date()) + "]]>").append("</ref_date>");
}
else if ("bank_code__dep".equalsIgnoreCase(currentColumn.trim()))
{
bankcodedep = checkNull(genericUtility.getColumnValue("bank_code__dep", dom));
sql = "select bank_name from bank where bank_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankcodedep);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString("bank_name"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<bank_name>").append("<![CDATA[" + descr + "]]>").append("</bank_name>");
}
else if ("site_code".equalsIgnoreCase(currentColumn.trim()))
{
sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select descr, bank_code , fin_entity from site where site_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr1 = checkNull(rs.getString("descr"));
bankcode = checkNull(rs.getString("bank_code"));
finent = checkNull(rs.getString("fin_entity"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("site_code::::"+descr1+" finentity:::"+finent+"bancode:::"+bankcode);
valueXmlString.append("<site_descr>").append("<![CDATA[" + descr1 + "]]>").append("</site_descr>");
sql = "select bank_name from bank where bank_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankcode);
rs = pstmt.executeQuery();
if (rs.next())
{
bankdescr = checkNull(rs.getString("bank_name"));
}
System.out.println("bank_code::::"+bankdescr);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from finent where fin_entity =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finent);
rs = pstmt.executeQuery();
if (rs.next())
{
mcurr = rs.getString("curr_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("curr_code11::::"+mcurr);
valueXmlString.append("<bank_code__dep>").append("<![CDATA[" + bankcode + "]]>").append("</bank_code__dep>");
valueXmlString.append("<bank_name>").append("<![CDATA[" + bankdescr + "]]>").append("</bank_name>");
valueXmlString.append("<curr_code>").append("<![CDATA[" + mcurr + "]]>").append("</curr_code>");
System.out.println("currency..."+mcurr);
}
else if ("sundry_code".equalsIgnoreCase(currentColumn.trim()))
{
sundrycode = checkNull(genericUtility.getColumnValue("sundry_code", dom));
sundrytype = checkNull(genericUtility.getColumnValue("sundry_type", dom));
tranrefrcv = checkNull(genericUtility.getColumnValue("tran_ref_rcv", dom));
sitecode = checkNull(genericUtility.getColumnValue("site_code", dom));
loginSite = checkNull(getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
if ("C".equalsIgnoreCase(sundrytype))
{
valueXmlString.append("<tran_ref_rcv protect='1'>").append("<![CDATA[" + tranrefrcv + "]]>").append("</tran_ref_rcv>");
}
else
{
valueXmlString.append("<tran_ref_rcv protect='0'>").append("<![CDATA[" + tranrefrcv + "]]>").append("</tran_ref_rcv>");
}
switch (sundrytype)
{
case "C":
sql = "select cust_name, curr_code, site_code, acct_code__adv, cctr_code__adv from customer where cust_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("cust_name"));
currCode = checkNull(rs.getString(2));
sitecode = checkNull(rs.getString("site_code"));
acctCodeAdv = checkNull(rs.getString("acct_code__adv"));
cctrCodeAdv = checkNull(rs.getString("cctr_code__adv"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "R":// for strategic Customer
sql = "select case when first_name is null then '' else first_name end as first_name,"
+ " case when middle_name is null then '' else middle_name end as middle_name ,"
+ " case when last_name is null then '' else last_name end as last_name, "
+ " a.curr_code, a.site_code, a.acct_code__adv, a.cctr_code__adv from strg_customer b,customer a "
+ " where b.cust_code =a.cust_code and b.sc_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("first_name"));
mname = checkNull(rs.getString("middle_name"));
lname = checkNull(rs.getString("last_name"));
currCode = checkNull(rs.getString("curr_code"));
sitecode = checkNull(rs.getString("site_code"));
acctCodeAdv = checkNull(rs.getString("acct_code__adv"));
cctrCodeAdv = checkNull(rs.getString("cctr_code__adv"));
}
descr = fname.trim() + ' ' + mname.trim() + ' ' + lname.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "B": // Bank
sql = "select bank_name, curr_code, site_code from bank where bank_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("bank_name"));
currCode = checkNull(rs.getString("curr_code"));
sitecode = checkNull(rs.getString("site_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "E": // Employee
sql = "select emp_fname, emp_lname, site_code__acct from employee, site \n"
+ " where employee.pay_site = site.site_code and emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
fname = checkNull(rs.getString("emp_fname"));
lname = checkNull(rs.getString("emp_lname"));
sitecode = checkNull(rs.getString("site_code__acct"));
}
descr = fname.trim() + ' ' + lname.trim();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from site, finent where site.fin_entity = finent.fin_entity and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
currCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "P":// Sales Person
sql = "select sp_name,curr_code from sales_pers where sales_pers =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("sp_name"));
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "T": // Transporter
sql = "select tran_name, curr_code from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("tran_name"));
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "O":// Other accounts
sql = "select descr, curr_code from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("descr"));
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "S":
sql = " select supp_name, curr_code from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("supp_name"));
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "X":
sql = "select tauth_name from tax_authority where tauth_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("tauth_name"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select curr_code from site, finent where site.fin_entity = finent.fin_entity and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next()) {
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
case "L":
sql = "select party_name from loanparty where party_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sundrycode);
rs = pstmt.executeQuery();
if (rs.next()) {
descr = checkNull(rs.getString("party_name"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
break;
}
valueXmlString.append("<sundry_desc>").append("<![CDATA[" + descr + "]]>").append("</sundry_desc>");
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
valueXmlString.append("<acct_code__adv>").append("<![CDATA[" + acctCodeAdv + "]]>").append("</acct_code__adv>");
valueXmlString.append("<cctr_code__adv>").append("<![CDATA[" + cctrCodeAdv + "]]>").append("</cctr_code__adv>");
System.out.println("currency code2---"+currCode);
if ((loginSite == null || loginSite.trim().length() == 0) && sitecode.trim().length() > 0)
{
valueXmlString.append("<site_code>").append("<![CDATA[" + sitecode + "]]>").append("</site_code>");
sql = "select descr, fin_entity from site where site_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sitecode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr2 = checkNull(rs.getString("descr"));
finent = checkNull(rs.getString("fin_entity"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<site_descr>").append("<![CDATA[" + descr2 + "]]>").append("</site_descr>");
if (currCode==null ||currCode.trim().length() == 0) {
sql = "select curr_code from finent where fin_entity =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finent);
rs = pstmt.executeQuery();
if (rs.next())
{
currCode = checkNull(rs.getString("curr_code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
}
}
}
else if ("amount".equalsIgnoreCase(currentColumn.trim()))
{
chqAmt =genericUtility.getColumnValue("amount", dom);
if(chqAmt != null && chqAmt.trim().length()==0)
{
chqamt=Double.parseDouble(chqAmt);
}
else
{
chqamt=0;
}
billAmt =genericUtility.getColumnValue("adj_amt", dom);
if(billAmt != null && billAmt.trim().length()==0)
{
billamt=Double.parseDouble(billAmt);
}
else
{
chqamt=0;
}
advAmt = chqamt - billamt;
valueXmlString.append("<adv_amt>").append("<![CDATA[" + advAmt + "]]>").append("</adv_amt>");
}
valueXmlString.append("</Detail1>");
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn-------->>[" + currentColumn + "]");
valueXmlString.append("<Detail2>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sitecode = genericUtility.getColumnValue("site_code", dom);
// get login site description
sql = " select descr from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next())
{
loginSiteDescr = rs.getString("descr");
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_code protect =\"1\">").append("<![CDATA[" + loginSite+ "]]>").append("</site_code>");
}
else if ("ref_no".equalsIgnoreCase(currentColumn.trim()))
{
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
if ((refNo == null) || (refNo.trim().length() == 0))
refNo = "";
sql = " select tran_ser, tran_date, ref_no, ref_date, curr_code, exch_rate, acct_code, "
+ " cctr_code,due_date, discount, tax_amt, tot_amt, cust_code,adj_amt "
+ " from receivables where tran_ser=? and ref_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
tranSer = rs.getString(1);
tranDate = rs.getDate(2);
refNo = rs.getString(3);
refDate = rs.getDate(4);
currCode = rs.getString(5);
exrate = rs.getDouble(6);
acctCode = rs.getString(7);
cctrCode = rs.getString(8);
dueDate = rs.getDate(9);
discount = rs.getDouble(10);
taxAmt = rs.getDouble(11);
totAmt = rs.getDouble(12);
custCode = rs.getString(13);
adjAmt = rs.getDouble(14);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
System.out.println("test2 currncy"+currCode);
rs = pstmt.executeQuery();
if (rs.next()) {
currDescr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (adjAmt == 0)
{
amt= totAmt - adjAmt;
adjAmtBc = amt* exrate;
}
valueXmlString.append("<curr_code>").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
valueXmlString.append("<currency_descr>").append("<![CDATA[" + currDescr + "]]>").append("</currency_descr>");
valueXmlString.append("<exch_rate>").append("<![CDATA[" + exrate + "]]>").append("</exch_rate>");
valueXmlString.append("<due_date>").append("<![CDATA[" + simpleDateFormat.format(dueDate) + "]]>").append("</due_date>");
valueXmlString.append("<ref_date>").append("<![CDATA[" + simpleDateFormat.format(refDate) + "]]>").append("</ref_date>");
valueXmlString.append("<amount>").append("<![CDATA[" + amt + "]]>").append("</amount>");
valueXmlString.append("<amount__bc>").append("<![CDATA[" + adjAmtBc + "]]>").append("</amount__bc>");
valueXmlString.append("<acct_code>").append("<![CDATA[" + acctCode + "]]>").append("</acct_code>");
valueXmlString.append("<cctr_code>").append("<![CDATA[" + cctrCode + "]]>").append("</cctr_code>");
}
else if ("amount".equalsIgnoreCase(currentColumn.trim()))
{
amount= genericUtility.getColumnValue("amount", dom1);
if(amount != null && amount.trim().length()==0)
{
amt=Double.parseDouble(amount);
}
else
{
amt=0;
}
exchRate=genericUtility.getColumnValue("exch_rate", dom);
if(exchRate != null && exchRate.trim().length()==0)
{
exrate=Double.parseDouble(exchRate);
}
else
{
exrate=0;
}
amtBc= amt * exrate;
System.out.println("adjamt::"+amtBc);
valueXmlString.append("<amount__bc>").append("<![CDATA[" +amtBc + "]]>").append("</amount__bc>");
}
valueXmlString.append("</Detail2>");
}
valueXmlString.append("</Root>");
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (pstmt != null)
pstmt.close();
if (rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
conn = null;
}
}
catch (Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
}
finally {
try {
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private double checkDouble(String input) {
if (input == null || input.trim().length() == 0) {
return 0;
} else {
return Double.parseDouble(input);
}
}
}
\ No newline at end of file
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface PdcReceivedLocal extends ValidatorLocal {
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface PdcReceivedRemote extends ValidatorRemote{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
......@@ -30,7 +30,7 @@ import ibase.webitm.utility.ITMException;
@Stateless
public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, ReceiptAdvRemote
{
// GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
......@@ -170,7 +170,7 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
ArrayList errFields = new ArrayList();
//SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy");
//SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-mm-dd");
SimpleDateFormat dateFormat2 = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -179,17 +179,28 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
String effBankStr="",rcpacctAmt="";
String refType = "",guid = "";
double rcpacctAmtdbl=0;
//Calendar currentDate = Calendar.getInstance();--by monika
try
{
finCommon = new FinCommon();
disCommon = new DistCommon();
validator = new ValidatorEJB();
//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
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
dateFormat2=new SimpleDateFormat(genericUtility.getApplDateFormat());//Changed By Manoj dtd 08/08/2014
//sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());//Changed By Manoj dtd 08/08/2014
//String tranDateStr = sdf.format(currentDate.getTime());--by monika
//System.out.println("current date:::::"+tranDateStr);
//SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());--commemt by monika
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
System.out.println("current date:::::"+sysDate);
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
......@@ -213,20 +224,34 @@ conn = getConnection();
tranDateS=this.genericUtility.getColumnValue("tran_date", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
if (tranDateS != null && !tranDateS.matches("\\d{4}-[01]\\d-[0-3]\\d"))
/*// if (tranDateS != null && !tranDateS.matches("\\d{4}-[01]\\d-[0-3]\\d")
if (tranDateS != null ))
{
tranDate = dateFormat2.parse(tranDateS);
/* errCode = this.checkPeriod("FIN", siteCode, tranDate, conn);
tranDate = sdf.parse(tranDateS);
errCode = this.checkPeriod("FIN", siteCode, tranDate, conn);
if(errCode != null && errCode.trim().length() >0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}*/
}
}
else
{
errCode = "VMTRANDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}*/
tranDateS = this.genericUtility.getColumnValue("tran_date", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateS,
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(tranDate == null)
{
errCode = "VMTRANDT";
errList.add(errCode);
......@@ -234,14 +259,14 @@ conn = getConnection();
}
}
//Added By PriyankaC on 18JAN2019.
//Added By PriyankaC on 18JAN2019.
if (childNodeName.equalsIgnoreCase("guid"))
{
guid =this.genericUtility.getColumnValue("guid", dom);
System.out.println("GUID number : " +guid);
if (guid != null && guid.trim().length() > 0)
{
if(tranId == null ||tranId.trim().length() == 0 )
{
tranId = "@@";
......@@ -277,7 +302,7 @@ conn = getConnection();
}
else
{
}
}
//Added By PriyankaC on 18JAN2019.
......@@ -380,7 +405,7 @@ conn = getConnection();
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
*/
*/
siteCode = this.genericUtility.getColumnValue("site_code", dom);
errCode = finCommon.isSundryCode(siteCode, "C", custCode, "RCP", conn);
if (errCode != null && errCode.trim().length() > 0 )
......@@ -424,7 +449,7 @@ conn = getConnection();
{
System.out.println("prioddddddddd");
tranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom));
tranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom));
//Changes and Commented By Ajay on 21-12-2017:START
//errCode = this.nfCheckPeriod("FIN", tranDate, siteCode);
errCode = finCommon.nfCheckPeriod("FIN", tranDate, siteCode, conn);
......@@ -489,14 +514,14 @@ conn = getConnection();
else
{
errCode = "VMCURRCD1";
errCode = "VECUR2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("acct_code__bal"))
{
acctCodeBal = this.genericUtility.getColumnValue("acct_code__bal", dom);
if(acctCodeBal != null && acctCodeBal.trim().length() > 0)
{
......@@ -513,7 +538,7 @@ conn = getConnection();
else if (childNodeName.equalsIgnoreCase("cctr_code__bal"))
{
cctrCodeBal = this.genericUtility.getColumnValue("cctr_code__bal", dom);
analCode = this.genericUtility.getColumnValue("anal_code", dom);
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
......@@ -533,9 +558,9 @@ conn = getConnection();
else if (childNodeName.equalsIgnoreCase("acct_code__adv"))
{
acctCodeAdv = this.genericUtility.getColumnValue("acct_code__adv", dom);
advAmt = doublevalue(this.genericUtility.getColumnValue("adv_amt", dom));
//if ((advAmt != 0.0) && ((acctCodeAdv.trim().length() != 0) && (acctCodeAdv != null))) Commented by Ajay on 17/05/18
......@@ -554,8 +579,8 @@ conn = getConnection();
}
else if (childNodeName.equalsIgnoreCase("cctr_code__adv"))
{
cctrCodeAdv = this.genericUtility.getColumnValue("cctr_code__adv", dom);
acctCodeAdv = this.genericUtility.getColumnValue("acct_code__adv", dom);
advAmt = Double.parseDouble(this.genericUtility.getColumnValue("adv_amt", dom));
......@@ -612,7 +637,7 @@ conn = getConnection();
}
else if (childNodeName.equalsIgnoreCase("ref_date"))
{
refDate = dateFormat2.parse(this.genericUtility.getColumnValue("ref_date", dom));
refDate = sdf.parse(this.genericUtility.getColumnValue("ref_date", dom));
if (refDate == null)
{
errCode = "VTDAT3";
......@@ -621,7 +646,7 @@ conn = getConnection();
}
tranType = this.genericUtility.getColumnValue("tran_type", dom);
rcpMode = this.genericUtility.getColumnValue("rcp_mode", dom);
effDate = dateFormat2.parse(this.genericUtility.getColumnValue("eff_date", dom));
effDate = sdf.parse(this.genericUtility.getColumnValue("eff_date", dom));
if(tranType != null && tranType.trim().length() != 0)
{
......@@ -718,7 +743,7 @@ conn = getConnection();
}
else if (childNodeName.equalsIgnoreCase("anal_code"))
{
analCode = this.genericUtility.getColumnValue("anal_code", dom);
if(analCode != null && analCode.trim().length() >0)
{
......@@ -738,7 +763,7 @@ conn = getConnection();
finScheme = this.genericUtility.getColumnValue("fin_scheme", dom);
if(finScheme != null && finScheme.trim().length() > 0)
{
tranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom));
tranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom));
java.sql.Date tranDatesql = new java.sql.Date(tranDate.getTime());
sql = "select count(*) from fin_scheme where fin_scheme = ? and start_date <= ? and end_date >= ? and amt_type = ? ";
pstmt = conn.prepareStatement(sql);
......@@ -896,12 +921,12 @@ conn = getConnection();
tranIdAdvbking = this.genericUtility.getColumnValue("tran_id__advbking", dom);
if(tranIdAdvbking != null && tranIdAdvbking.trim().length() > 0)
{
tranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom));
tranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom));
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
sql = "select count(*) from advbking where confirmed = 'Y' and bal_amt > 0 and (? between to_char(eff_date,'yyyy-mm-dd') and to_char(valid_upto,'yyyy-mm-dd'))and bank_code = ? and tran_id = ? and status = 'A' ";
sql = "select count(*) from advbking where confirmed = 'Y' and bal_amt > 0 and (? between to_char(eff_date,'yyyy-mm-dd') and to_char(valid_upto,'yyyy-mm-dd'))and bank_code = ? tran_id = ? and status = 'A' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranDate.toString());
pstmt.setString(2, bankCode);
pstmt.setString(1, bankCode);
pstmt.setString(2, tranDate.toString());
pstmt.setString(3, tranIdAdvbking);
rs = pstmt.executeQuery();
if(rs.next())
......@@ -932,11 +957,11 @@ conn = getConnection();
* ref_no= ref no, ref_date= ref date
* tran_id <> current tran id
* */
String rDt = checkNull(this.genericUtility.getColumnValue("ref_date", dom));
rfDate = Timestamp.valueOf(genericUtility.getValidDateString(rDt.trim(),genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())+ " 00:00:00.0");
genericUtility.getDBDateFormat())+ " 00:00:00.0");
refNo = checkNull(this.genericUtility.getColumnValue("ref_no", dom));
custCode = checkNull(this.genericUtility.getColumnValue("cust_code", dom));
tranId = checkNull(this.genericUtility.getColumnValue("tran_id", dom));
......@@ -944,7 +969,7 @@ conn = getConnection();
{
tranId="@@@@@@";
}
sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
......@@ -956,13 +981,78 @@ conn = getConnection();
{
tranIdRcp=checkNull(rs.getString("tran_id"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ Tran id receipt :- ["+tranIdRcp+"]");
//CHANGES BY MONIKA-20 JUNE-2019--to check refno in bank-receipt header--
if(refNo!= null && refNo.trim().length()>0)
{
//check from receipt
sql = "select count(*) from receipt where ref_no=? and tran_id <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, tranId);
rs= pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ reference no count:- ["+cnt+"]");
if(cnt>0 && tranIdRcp!=null && tranIdRcp.trim().length()>0)
{
sql = "select count(*) from rcpdishnr where receipt_no=? and tran_ser='R'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt==0)
{
System.out.println("rcpdishnr :"+cnt);
errCode = "VTNREC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql = "select count(*) from pdc_received p where ref_no=? and status not in ('X','P')";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, refNo);
rs= pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs= null;
pstmt.close();
pstmt= null;
if(cnt>0)
{
System.out.println("@V@ pdc_received:- ["+cnt+"]");
errCode = "VTPDCREC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//END
if (tranIdRcp != null && tranIdRcp.trim().length()>0)
{
/**
......@@ -974,7 +1064,7 @@ conn = getConnection();
sql = "select count(*) as cnt from rcpdishnr where receipt_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -984,7 +1074,7 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ Dishponer cnt :- ["+cnt+"]");
if(cnt==0)
{
......@@ -1005,7 +1095,7 @@ conn = getConnection();
sql = "select confirmed from rcpdishnr where receipt_no=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -1015,7 +1105,7 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ confirmed found :-["+rDshCnf+"]");
if("N".equalsIgnoreCase(rDshCnf))
{
......@@ -1166,8 +1256,8 @@ conn = getConnection();
refDateS = this.genericUtility.getColumnValue("ref_date", dom);
if(refDateS != null && !refDateS.equals("DD/MM/YY"))
{
refDate = dateFormat2.parse(refDateS);
htranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom1));
refDate = sdf.parse(refDateS);
htranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom1));
if (!htranDate.before(refDate))
continue;
errCode = "VXVOUDATE";
......@@ -1180,7 +1270,7 @@ conn = getConnection();
dueDateS = this.genericUtility.getColumnValue("due_date", dom);
if(dueDateS != null && !dueDateS.equals("DD/MM/YY"))
{
dueDate = dateFormat2.parse(dueDateS);
dueDate = sdf.parse(dueDateS);
}
}
else if (childNodeName.equalsIgnoreCase("curr_code"))
......@@ -1207,8 +1297,8 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
/*hcurrCode = this.genericUtility.getColumnValue("curr_code", dom1);
if(hcurrCode != null && hcurrCode.trim().length() > 0)
{
......@@ -1218,7 +1308,7 @@ conn = getConnection();
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
*/
*/
}
else
{
......@@ -1244,7 +1334,7 @@ conn = getConnection();
}
else if (childNodeName.equalsIgnoreCase("cctr_code__ar"))
{
cctrCodeAr = this.genericUtility.getColumnValue("cctr_code__ar", dom);
if (cctrCodeAr != null && cctrCodeAr.trim().length() > 0)
{
......@@ -1555,7 +1645,7 @@ conn = getConnection();
hcustCode = this.genericUtility.getColumnValue("cust_code", dom1);
hsiteCode = this.genericUtility.getColumnValue("site_code", dom1);
hcurrCode = this.genericUtility.getColumnValue("curr_code", dom1);
htranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom1));
htranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom1));
sql = "select cust_code, site_code, curr_code, due_date from receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
......@@ -1660,7 +1750,7 @@ conn = getConnection();
{
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
amount = doublevalue(this.genericUtility.getColumnValue("amount", dom));
htranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom1));
htranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom1));
hbankCode = this.genericUtility.getColumnValue("bank_code", dom1);
sql = "select count(*) from misc_payables where tran_ser = ? and ref_no = ?";
......@@ -1755,8 +1845,8 @@ conn = getConnection();
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
*/
*/
}
else
{
......@@ -1768,9 +1858,9 @@ conn = getConnection();
}
else if (childNodeName.equalsIgnoreCase("tran_date"))
{
heffDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom1));
heffDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom1));
htranDate = dateFormat2.parse(this.genericUtility.getColumnValue("tran_date", dom1));
htranDate = sdf.parse(this.genericUtility.getColumnValue("tran_date", dom1));
if (heffDate.before(htranDate))
{
errCode = "VTINVDT";
......@@ -1927,7 +2017,7 @@ conn = getConnection();
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
*/
*/
}
else
{
......@@ -2002,7 +2092,7 @@ conn = getConnection();
}
else
{
effBankStr = checkNull(this.genericUtility.getColumnValue("eff_bank", dom));
rcpacctAmt=checkNull(this.genericUtility.getColumnValue("amount", dom));
if(effBankStr==null || effBankStr.trim().length()==0)
......@@ -2024,8 +2114,8 @@ conn = getConnection();
errList.add("VTPSNTALW");
errFields.add("amount".toLowerCase());
}
}
}
......@@ -2046,9 +2136,9 @@ conn = getConnection();
System.out.println("pos :"+pos);
if(pos>-1)
{
errCode=errCode.substring(0,pos);
errCode=errCode.substring(0,pos);
}
System.out.println("error code is :"+errCode);
errFldName = (String)errFields.get(cnt);
System.out.println(" cnt [" + cnt + "] errCode [" + errCode + "] errFldName [" + errFldName + "]");
......@@ -2548,7 +2638,7 @@ conn = getConnection();
e.getMessage());
}
return valueXmlString;
}
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
......@@ -2679,18 +2769,18 @@ conn = getConnection();
PreparedStatement pstmt = null;
String hCurrCode = "",reStr="";
ResultSet rs = null;
// GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
dateFormat1=new SimpleDateFormat(genericUtility.getApplDateFormat());
//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;
this.finCommon = new FinCommon();
......@@ -2706,15 +2796,15 @@ conn = getConnection();
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
// added by -Monika-13 MAY 2019-To make chq amount protected in Receivable JV
winName = getObjName(parentNode);
System.out.println( "winName :: " + winName );
//end
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
......@@ -2736,7 +2826,7 @@ conn = getConnection();
if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
tranType = genericUtility.getColumnValue("tran_type", dom);
//Added by Pavan R on 19/Feb/2K18[Start] entry_batch_no value is set to “NULL” in receipt table on edit mode
entryBtchNo = genericUtility.getColumnValue("entry_batch_no", dom);
//Added by Pavan R on 19/Feb/2K18[End]
......@@ -2791,7 +2881,7 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
if (fcurrCode.trim().equals(currCode.trim()) )
{
valueXmlString.append("<exch_rate protect = \"1\">").append("<![CDATA["+genericUtility.getColumnValue("exch_rate", dom)+"]]>").append("</exch_rate>");
......@@ -2815,8 +2905,8 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
if (instrPerSlip > 0)
{
//valueXmlString.append("<exch_rate protect = \"1\">").append("<![CDATA["+genericUtility.getColumnValue("exch_rate", dom)+"]]>").append("</exch_rate>");
......@@ -2833,17 +2923,17 @@ conn = getConnection();
}
System.out.println(" detail count [" + instrPerSlip + "] valueXmlString [" + valueXmlString.toString() + "]" );
//changes by-MOnika-14-may-2019
if("w_receivables_jv".equalsIgnoreCase(winName))
{
chequeAmt = doublevalue(genericUtility.getColumnValue("chq_amt", dom));
valueXmlString.append("<chq_amt protect=\"1\">").append("<![CDATA[" + chequeAmt + "]]>").append("</chq_amt>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
......@@ -2857,17 +2947,17 @@ conn = getConnection();
valueXmlString.append("<exch_rate protect = \"0\">").append("<![CDATA["+""+"]]>").append("</exch_rate>");
valueXmlString.append("<site_code >").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
setNodeValue(dom, "site_code", getAbsString(siteCode));
//changes by-MOnika-14-may-2019
if("w_receivables_jv".equalsIgnoreCase(winName))
{
chequeAmt = doublevalue(genericUtility.getColumnValue("chq_amt", dom));
valueXmlString.append("<chq_amt protect=\"1\">").append("<![CDATA[" + chequeAmt + "]]>").append("</chq_amt>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("tran_date"))
{
......@@ -2906,7 +2996,7 @@ conn = getConnection();
rcpMode = genericUtility.getColumnValue("rcp_mode", dom);
bankCodeprv = genericUtility.getColumnValue("bank_code", dom);
System.out.println("BankCode dom"+bankCode);
if (rcpMode.equals("C"))
{
sql = "select descr, fin_entity, cash_code from site where site_code = ?";
......@@ -2989,9 +3079,9 @@ conn = getConnection();
//bankCode = bankCode.trim();
sql = " select bank_name, acct_code__bal, cctr_code__bal, acct_code__cf, cctr_code__cf,acct_code__cf_ar, cctr_code__cf_ar from bank where bank_code = ?";
pstmt = conn.prepareStatement(sql);
......@@ -3029,21 +3119,21 @@ conn = getConnection();
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>");
valueXmlString.append("<fin_entity>").append("<![CDATA[" + finEntity + "]]>").append("</fin_entity>");
valueXmlString.append("<finent_descr>").append("<![CDATA[" + finentDescr + "]]>").append("</finent_descr>");
if(bankCodeprv==null || bankCodeprv.trim().length()==0)
{
valueXmlString.append("<bank_code>").append("<![CDATA[" + bankCode + "]]>").append("</bank_code>");
valueXmlString.append("<bank_bank_name>").append("<![CDATA[" + bankName + "]]>").append("</bank_bank_name>");
valueXmlString.append("<acct_code__bal>").append("<![CDATA[" + acctCodeBal + "]]>").append("</acct_code__bal>");
valueXmlString.append("<cctr_code__bal>").append("<![CDATA[" + cctrCodeBal + "]]>").append("</cctr_code__bal>");
valueXmlString.append("<acct_code__cf>").append("<![CDATA[" + acctCodeCf + "]]>").append("</acct_code__cf>");
valueXmlString.append("<cctr_code__cf >").append("<![CDATA[" + cctrCodeCf + "]]>").append("</cctr_code__cf>");
valueXmlString.append("<bank_code>").append("<![CDATA[" + bankCode + "]]>").append("</bank_code>");
valueXmlString.append("<bank_bank_name>").append("<![CDATA[" + bankName + "]]>").append("</bank_bank_name>");
valueXmlString.append("<acct_code__bal>").append("<![CDATA[" + acctCodeBal + "]]>").append("</acct_code__bal>");
valueXmlString.append("<cctr_code__bal>").append("<![CDATA[" + cctrCodeBal + "]]>").append("</cctr_code__bal>");
valueXmlString.append("<acct_code__cf>").append("<![CDATA[" + acctCodeCf + "]]>").append("</acct_code__cf>");
valueXmlString.append("<cctr_code__cf >").append("<![CDATA[" + cctrCodeCf + "]]>").append("</cctr_code__cf>");
}
custCode = genericUtility.getColumnValue("cust_code", dom);
//if (custCode.equals(" ")) Commented by Ajay on 17/05/18
if (" ".equals(custCode))//Add by Ajay on 17/05/18
if (" ".equals(custCode))//Add by Ajay on 17/05/18
{
valueXmlString.append("<cust_name>").append("<![CDATA["+""+"]]>").append("</cust_name>");
valueXmlString.append("<acct_code__ar>").append("<![CDATA[]]>").append("</acct_code__ar>");
......@@ -3235,8 +3325,8 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
*/
*/
advAmt = Double.parseDouble(genericUtility.getColumnValue("adv_amt", dom));
if (advAmt == 0.0D)
{
......@@ -3394,22 +3484,22 @@ conn = getConnection();
valueXmlString.append("</Detail1>");
break;
case 2:
reStr = itemChanged(dom1, dom1, dom2, "1", "itm_defaultedit", editFlag, xtraParams);
reStr = reStr.substring(reStr.indexOf("<Detail1>"), reStr.indexOf("</Detail1>"));
System.out.println("Detail 1String" + reStr);
valueXmlString = new StringBuffer(
"<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append(reStr);
valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("site_code", dom1) + "]]>").append("</site_code>");
valueXmlString.append("<cust_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("cust_code", dom1) + "]]>").append("</cust_code>");
valueXmlString.append("<curr_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("curr_code", dom1) + "]]>").append("</curr_code>");
valueXmlString.append("<sale_order protect = \"1\">").append("<![CDATA[" + checkNull(genericUtility.getColumnValue("sale_order", dom1)) + "]]>").append("</sale_order>");
valueXmlString.append("</Detail1>");
reStr = itemChanged(dom1, dom1, dom2, "1", "itm_defaultedit", editFlag, xtraParams);
reStr = reStr.substring(reStr.indexOf("<Detail1>"), reStr.indexOf("</Detail1>"));
System.out.println("Detail 1String" + reStr);
valueXmlString = new StringBuffer(
"<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append(reStr);
valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("site_code", dom1) + "]]>").append("</site_code>");
valueXmlString.append("<cust_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("cust_code", dom1) + "]]>").append("</cust_code>");
valueXmlString.append("<curr_code protect = \"1\">").append("<![CDATA[" + genericUtility.getColumnValue("curr_code", dom1) + "]]>").append("</curr_code>");
valueXmlString.append("<sale_order protect = \"1\">").append("<![CDATA[" + checkNull(genericUtility.getColumnValue("sale_order", dom1)) + "]]>").append("</sale_order>");
valueXmlString.append("</Detail1>");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
......@@ -3534,7 +3624,7 @@ conn = getConnection();
// 21/09/13 manoharan to get the exchange rate for detail currency
// 03/07/14 manoharan in case receivables.curr_code = header curr_code use the same exch_rate in header
// else get the exch_rate from master
siteCode = genericUtility.getColumnValue("site_code", dom1);
hCurrCode = genericUtility.getColumnValue("curr_code", dom1);
if ( hCurrCode.trim().equals(currCode.trim()) )
......@@ -3641,7 +3731,7 @@ conn = getConnection();
{
valueXmlString.append("<due_date/>");
}
valueXmlString.append("<disc_amt>").append("<![CDATA[" + getReqDecimal(discount, 3) + "]]>").append("</disc_amt>");
valueXmlString.append("<tax_amt>").append("<![CDATA[" + getReqDecimal(taxAmt, 3) + "]]>").append("</tax_amt>");
valueXmlString.append("<net_amt>").append("<![CDATA[" + getReqDecimal(totAmt, 3) + "]]>").append("</net_amt>");
......@@ -3659,7 +3749,7 @@ conn = getConnection();
System.out.println("Rcp Amt from else" + rcpAmt);
valueXmlString.append("<rcp_amt>").append("<![CDATA[" + getReqDecimal((totAmt - adjAmt), 3) + "]]>").append("</rcp_amt>");
rcpAmt = totAmt - adjAmt;
}
valueXmlString.append("<acct_code__ar>").append("<![CDATA[" + acctCode + "]]>").append("</acct_code__ar>");
valueXmlString.append("<accounts_descr>").append("<![CDATA[" + accDescr + "]]>").append("</accounts_descr>");
......@@ -3817,7 +3907,7 @@ conn = getConnection();
siteCode = genericUtility.getColumnValue("site_code", dom1);
currCode = genericUtility.getColumnValue("curr_code", dom);
hexchRate = finCommon.getDailyExchRateSellBuy(currCode,"",siteCode, genericUtility.getColumnValue("tran_date", dom1), "S", conn);
exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom));
}
bdFluctuationCf = finCommon.getFinparams("999999", "BD_FLUCTUATION_CF" ,conn);
......@@ -3832,7 +3922,7 @@ conn = getConnection();
}
else
{
siteCode = genericUtility.getColumnValue("site_code", dom1);
currCode = genericUtility.getColumnValue("curr_code", dom);
exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom));
......@@ -4080,7 +4170,7 @@ conn = getConnection();
valueXmlString.append("<currency_descr>").append("<![CDATA[" + currDescr + "]]>").append("</currency_descr>");
valueXmlString.append("<exch_rate>").append("<![CDATA[" + exchRate + "]]>").append("</exch_rate>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + simpleDateFormat.format(dueDate) + "]]>").append("</tran_date>");
valueXmlString.append("<amount>").append("<![CDATA[" + (getReqDecimal((adjAmt - totAmt),3)) + "]]>").append("</amount>");
valueXmlString.append("<amount>").append("<![CDATA[" + (adjAmt - totAmt) + "]]>").append("</amount>");
valueXmlString.append("<sundry_type>").append("<![CDATA[" + sundryType + "]]>").append("</sundry_type>");
valueXmlString.append("<sundry_code>").append("<![CDATA[" + sundryCode + "]]>").append("</sundry_code>");
valueXmlString.append("<acct_code>").append("<![CDATA[" + acctCode + "]]>").append("</acct_code>");
......@@ -4283,7 +4373,7 @@ conn = getConnection();
}
}
return valueXmlString.toString();
}
}
private String errorType(Connection conn, String errorCode)
{
......@@ -4347,7 +4437,7 @@ conn = getConnection();
private static void setNodeValue(Document dom, String nodeName, String nodeVal)
throws Exception
{
{
Node tempNode = dom.getElementsByTagName(nodeName).item(0);
if (tempNode != null)
......@@ -4363,7 +4453,7 @@ conn = getConnection();
}
}
tempNode = null;
}
}
private static String getAbsString(String str) {
return (str == null) || (str.trim().length() == 0) || ("null".equalsIgnoreCase(str.trim())) ? "" : str.trim();
......@@ -4768,9 +4858,9 @@ conn = getConnection();
}
return retVal;
}
// method getobj added-Monika-13-MAY-2019-To make chq amount protected in Receivable JV
private String getObjName(Node node) throws Exception
{
String objName = null;
......@@ -4789,12 +4879,12 @@ conn = getConnection();
objName = detailNode.getAttributes().getNamedItem("objName").getNodeValue();
}
}
*/
*/
return "w_" + objName;
}
}
\ No newline at end of file
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