Commit 7c6148a4 authored by tmahadi's avatar tmahadi

Changes in Ecollection Module.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104176 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 972939a9
[Dolphin]
HeaderColumnWidths=335,74,146
SortOrder=1
SortRole=date
Timestamp=2016,6,10,11,5,29
Timestamp=2016,12,12,18,55,2
Version=3
ViewMode=1
......@@ -17,610 +17,506 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import java.text.DecimalFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
import javax.ejb.Stateless;
public class EcollectionIC extends ValidatorEJB implements EcollectionICLocal, EcollectionICRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
@Stateless
public class EcollectionIC extends ValidatorEJB implements EcollectionICLocal, EcollectionICRemote {
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
if (xmlString != null && xmlString.trim().length() > 0 )
{
Document dom = null, dom1 = null, dom2 = null;
try {
System.out.println("Called wfValData [S] from [EJB:" + this.getClass().getSimpleName() + "]");
if (xmlString != null && xmlString.trim().length() > 0) {
dom = parseString(xmlString);
System.out.println("xmlString["+xmlString+"]");
System.out.println("xmlString[" + xmlString + "]");
}
if (xmlString1 != null && xmlString1.trim().length() > 0 )
{
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
System.out.println("xmlString1["+xmlString1+"]");
System.out.println("xmlString1[" + xmlString1 + "]");
}
if (xmlString2 != null && xmlString2.trim().length() > 0 )
{
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
System.out.println("xmlString2["+xmlString2+"]");
System.out.println("xmlString2[" + xmlString2 + "]");
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EcollectionIC][wfValData( String, String )] :==>\n" + e.getMessage());
} catch (Exception e) {
System.out.println("Exception wfValData [S] in EJB [" + this.getClass().getSimpleName() + "] " + e.getLocalizedMessage());
throw new ITMException(e);
}
return(errString);
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String childNodeName = null;
String errString = "";
String errCode = "";
String userId = "";
String sql = "";
String errorType = "";
String custCode="",bankCode="",lineNo="",chqAmtStr="";
int cnt = 0;
int ctr=0;
int childNodeListLength;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
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>");
int currentFormNo =0;
String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode="";
java.util.Date tranDate = null;
double rcpAmt=0,rcpAmtNew=0,rcpAmtStatus=0.0;
double isInvAmt=0.0,chqAmt=0.0;
SimpleDateFormat dateFormat2 = null;
try
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("@@@@@@@@ wfvaldata called");
//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;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
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("site_code"))
{
siteCode = this.genericUtility.getColumnValue("site_code", dom);
if(siteCode != null && siteCode.trim().length() > 0 )
{
sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(genericUtility.getColumnValue("eff_date", dom) == null)
{
tranDate = null;
}
else
{
tranDate = dateFormat2.parse(genericUtility.getColumnValue("eff_date",dom));
sql = "select code from period where ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1,new java.sql.Date(tranDate.getTime()));
rs = pstmt.executeQuery();
if(rs.next())
{
prdCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select count(*) from period_stat where site_code = ? and prd_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String childNodeName = "", errString = "", errCode = "", userId = "", sql = "", errorType = "", custCode = "", bankCode = "", lineNo = "", chqAmtStr = "", siteCode = "", rcpAmtStr = "", refSer = "", refNo = "", prdCode = "";
int cnt = 0, ctr = 0, childNodeListLength = 0, currentFormNo = 0;
NodeList parentNodeList = null, childNodeList = null;
Node parentNode = null, childNode = null;
ArrayList<String> errList = new ArrayList<String>(), errFields = new ArrayList<String>();
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>");
java.util.Date tranDate = null;
double rcpAmt = 0, rcpAmtNew = 0, rcpAmtStatus = 0.0, isInvAmt = 0.0, chqAmt = 0.0;
SimpleDateFormat sdf = null;
try {
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("Called wfValData [D] from [EJB:" + this.getClass().getSimpleName() + "]");
// 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;
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
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();
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errCode = "VTSITEPD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
errCode = nfCheckPeriod("FIN",tranDate,siteCode);
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("site_code")) {
siteCode = this.genericUtility.getColumnValue("site_code", dom);
if (siteCode != null && siteCode.trim().length() > 0) {
sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode.trim());
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
else
{
errCode = "VMSITENUL";
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = this.genericUtility.getColumnValue("cust_code", dom);
if(custCode != null && custCode.trim().length() > 0 )
{
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE = ? " ;
if (genericUtility.getColumnValue("eff_date", dom) == null) {
tranDate = null;
} else {
tranDate = sdf.parse(genericUtility.getColumnValue("eff_date", dom));
sql = "select code from period where ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
pstmt.setDate(1, new java.sql.Date(tranDate.getTime()));
rs = pstmt.executeQuery();
if( rs.next())
{
cnt = rs.getInt("COUNT");
if (rs.next()) {
prdCode = rs.getString(1);
}
rs.close();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VMCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("bank_code"))
{
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
if(bankCode != null && bankCode.trim().length() > 0)
{
sql = "SELECT COUNT(*) AS COUNT FROM BANK WHERE BANK_CODE = ? " ;
sql = "select count(*) from period_stat where site_code = ? and prd_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
pstmt.setString(1, siteCode);
pstmt.setString(2, prdCode);
rs = pstmt.executeQuery();
if( rs.next())
{
cnt = rs.getInt("COUNT");
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VMBANKMIS1";
if (cnt == 0) {
errCode = "VTSITEPD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VMBANKCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else if (childNodeName.equalsIgnoreCase("chq_amt"))
{
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom);
if(chqAmtStr != null && chqAmtStr.trim().length() > 0)
{
chqAmt= Double.parseDouble(chqAmtStr);
if(chqAmt <= 0)
{
errCode = "VTRCPAMT";
errCode = nfCheckPeriod("FIN", tranDate, siteCode);
if (errCode != null && errCode.trim().length() > 0) {
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else
{
errCode = "VTRCPAMTNL";
}
} else {
errCode = "VMSITENUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.equalsIgnoreCase("cust_code")) {
custCode = this.genericUtility.getColumnValue("cust_code", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
if (custCode != null && custCode.trim().length() > 0) {
sql = "select count(*) as COUNT from customer c join site_customer s on c.cust_code = s.cust_code and s.site_code = ? and c.cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VTCUSTCD8";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else {
errCode = "VMCUSTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}// end for
break; // case 1 end
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("@@@@@@@@@@@@childNodeListLength["+childNodeListLength+"]");
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("ref_ser"))
{
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
if(refSer != null && refSer.trim().length() > 0)
{
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE TRAN_SER = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refSer);
rs = pstmt.executeQuery();
if( rs.next())
{
cnt = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTINVRESER";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.equalsIgnoreCase("bank_code")) {
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
if (bankCode != null && bankCode.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM BANK WHERE BANK_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("COUNT");
}
else
{
errCode = "VTNULRESER";
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VMBANKMIS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else if (childNodeName.equalsIgnoreCase("ref_no"))
{
refNo = this.genericUtility.getColumnValue("ref_no", dom);
lineNo = genericUtility.getColumnValue("line_no",dom);
refSer = genericUtility.getColumnValue("ref_ser",dom);
if(refNo != null && refNo.trim().length() > 0)
{
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE REF_NO = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNo);
rs = pstmt.executeQuery();
if( rs.next())
{
cnt = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTINVREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
if (isDulplicateFrmDom(dom2,refNo,lineNo,refSer))
{
errCode = "VTDUPREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} else {
errCode = "VMBANKCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.equalsIgnoreCase("chq_amt")) {
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom);
if (chqAmtStr != null && chqAmtStr.trim().length() > 0) {
chqAmt = Double.parseDouble(chqAmtStr);
if (chqAmt <= 0) {
errCode = "VTRCPAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
errCode = "VTNULREFNO";
} else {
errCode = "VTRCPAMTNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
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("ref_ser")) {
refSer = this.genericUtility.getColumnValue("ref_ser", dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom2, "1");
System.out.println("refSer : " + refSer + " :::custCode::: " + custCode);
if (refSer != null && refSer.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE TRAN_SER = ? and cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VTINVRESER";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else if (childNodeName.equalsIgnoreCase("rcp_amt"))
{
rcpAmtStr = genericUtility.getColumnValue("rcp_amt",dom);
refSer = genericUtility.getColumnValue("ref_ser",dom);
refNo = genericUtility.getColumnValue("ref_no",dom);
lineNo = genericUtility.getColumnValue("line_no",dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom1);
siteCode = this.genericUtility.getColumnValue("site_code", dom1);
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom1);
if (chqAmtStr != null && chqAmtStr.trim().length() > 0)
{
try
{
chqAmt= Double.parseDouble(chqAmtStr);
} catch (NumberFormatException n)
{
chqAmt = 0;
}
}
System.out.println("chqAmt>>>>>>["+chqAmt+"]");
/*if(rcpAmtNew <= 0)
{
errCode = "VTRCPAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}*/
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,checkNull(genericUtility.getColumnValue("ref_ser",dom)));
pstmt.setString(2,checkNull(genericUtility.getColumnValue("ref_no",dom)));
pstmt.setString(3,custCode);
pstmt.setString(4,siteCode);
rs = pstmt.executeQuery();
if( rs.next())
{
rcpAmt=rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtNew>>>["+rcpAmtNew+"]rcpAmt["+rcpAmt+"]");
//Start added by chandr shekar on 21-mar-2016
sql = "select sum(rcpdet.rcp_amt) as amt from rcpdet_form rcpdet,receipt_form rcpform " +
"where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? " +
"and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? " +
"AND rcpform.cust_code = ? and rcpform.site_code= ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,checkNull(genericUtility.getColumnValue("ref_ser",dom)));
pstmt.setString(2,checkNull(genericUtility.getColumnValue("ref_no",dom)));
pstmt.setString(3,custCode);
pstmt.setString(4,siteCode);
rs = pstmt.executeQuery();
if( rs.next())
{
rcpAmtStatus=rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtStatus>>>"+rcpAmtStatus);
//End added by chandrashekar on 21-mar-2016
if(rcpAmt-rcpAmtStatus < rcpAmtNew)
{
errCode = "VTINVTLAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if (ischqAmtGreater(dom2,chqAmt,lineNo))
{
errCode = "VTINVCQAMT";
} else {
errCode = "VTNULRESER";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} else if (childNodeName.equalsIgnoreCase("ref_no")) {
refNo = this.genericUtility.getColumnValue("ref_no", dom);
lineNo = genericUtility.getColumnValue("line_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom2, "1");
System.out.println("IN ref_no validation : refNo:::"+ refNo +":::refSer:::" + refSer + ":::custCode:::" + custCode);
if (refNo != null && refNo.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE REF_NO = ? and tran_ser = ? and cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
pstmt.setString(2, refSer);
pstmt.setString(3, custCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
errCode = "VTINVREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
} else {
if (isDulplicateFrmDom(dom2, refNo, lineNo, refSer)) {
errCode = "VTDUPREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} else {
errCode = "VTNULREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end for
break; // case 2 end
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
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 = "";
} else if (childNodeName.equalsIgnoreCase("rcp_amt")) {
rcpAmtStr = genericUtility.getColumnValue("rcp_amt", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
refNo = genericUtility.getColumnValue("ref_no", dom);
lineNo = genericUtility.getColumnValue("line_no", dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom1);
siteCode = this.genericUtility.getColumnValue("site_code", dom1);
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom1);
if (chqAmtStr != null && chqAmtStr.trim().length() > 0) {
try {
chqAmt = Double.parseDouble(chqAmtStr);
} catch (NumberFormatException n) {
chqAmt = 0;
}
}
if(errorType.equalsIgnoreCase("E"))
{
break;
System.out.println("chqAmt>>>>>>[" + chqAmt + "]");
/*
* if(rcpAmtNew <= 0) { errCode = "VTRCPAMT";
* errList.add(errCode);
* errFields.add(childNodeName.toLowerCase()); }
*/
//TODO Took care of validation in PostSave Activity.
/*sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmt = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtNew>>>[" + rcpAmtNew + "]rcpAmt[" + rcpAmt + "]");
// Start added by chandr shekar on 21-mar-2016
sql = "select nvl(sum(rcpdet.rcp_amt), 0) as amt from rcpdet_form rcpdet, receipt_form rcpform "
+ "where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? "
+ "and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? "
+ "AND rcpform.cust_code = ? and rcpform.site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmtStatus = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtStatus>>>" + rcpAmtStatus);
// End added by chandrashekar on 21-mar-2016
if (rcpAmt - rcpAmtStatus < rcpAmtNew) {
errCode = "VTINVTLAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}*/
/*
* if (ischqAmtGreater(dom2,chqAmt,lineNo)) { errCode =
* "VTINVCQAMT"; errList.add(errCode);
* errFields.add(childNodeName.toLowerCase()); }
*/
}
} // end for
break; // case 2 end
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if (errList != null && errListSize > 0) {
for (cnt = 0; cnt < errListSize; cnt++) {
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
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;
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
} else {
errStringXml = new StringBuffer("");
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (rs != null) {
rs.close();
rs = null;
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
} catch (Exception d) {
d.printStackTrace();
throw new ITMException(d);
}
errString = errStringXml.toString();
return errString;
}
errString = errStringXml.toString();
return errString;
}
// method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
// method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
Document dom = null, dom1 = null, dom2 = null;
String valueXmlString = "";
System.out.println("xmlString............."+xmlString);
System.out.println("xmlString1............"+xmlString1);
System.out.println("xmlString2............"+xmlString2);
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
System.out.println("xmlString............." + xmlString
+ "\nxmlString1............" + xmlString1
+ "\nxmlString2............" + xmlString2);
try {
if (xmlString != null && xmlString.trim().length() > 0) {
dom = parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EcollectionIC][itemChanged( String, String )] :==>\n" + e.getMessage());
valueXmlString = itemChanged(dom, dom1, dom2, objContext,
currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out
.println("Exception : [EcollectionIC][itemChanged( String, String )] :==>\n"
+ e.getMessage());
throw new ITMException(e);
}
return valueXmlString;
}
// method for item change
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String sql = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
E12GenericUtility genericUtility= new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0, childNodeListLength=0;
String columnValue="";
String loginSite="",loginSiteDesc="",siteCodeDesc="",hdrCustCode="",hdrSiteCode="";
String bankCode="",siteCode="",custCode="",bankName="",custName="",refNo="",refSer="",currencyCode="";
double rcpAmt1=0, exchangeRate= 0.0;
try
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
//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.setAutoCommit(false);
connDriver = null;
FinCommon finCommon= new FinCommon();
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null, childNodeList = null;
Node parentNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver();
int currentFormNo = 0, childNodeListLength = 0, ctr = 0;
String columnValue = "", loginSite = "", loginSiteDesc = "", siteCodeDesc = "", hdrCustCode = "", hdrSiteCode = "", bankCode = "", siteCode = "", custCode = "", bankName = "", custName = "", refNo = "", refSer = "", currencyCode = "", sql = "";
double rcpAmt1 = 0, exchangeRate = 0.0;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
System.out.println("Now the date is :=> " + sysDate);
try {
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
// 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.setAutoCommit(false);
connDriver = null;
FinCommon finCommon = new FinCommon();
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext.trim());
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
System.out.println("Now the date is :=> " + sysDate);
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'");
valueXmlString.append("<Detail1>");
if ( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
UserInfoBean userInfo = getUserInfo();
String userLevel = userInfo.getUserLevel();
System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo + "**************" + userLevel);
switch (currentFormNo) {
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'");
valueXmlString.append("<Detail1>");
if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite");
sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
loginSiteDesc = rs.getString("DESCR");
bankCode = rs.getString("BANK_CODE");
}
......@@ -628,451 +524,428 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
bankName = checkNull(rs.getString("BANK_NAME"));
//currencyCode = checkNull(rs.getString("CURR_CODE"));
// currencyCode = checkNull(rs.getString("CURR_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<tran_date><![CDATA[").append(checkNull(sysDate)).append("]]></tran_date>\r\n");
valueXmlString.append("<eff_date><![CDATA[").append(checkNull(sysDate)).append("]]></eff_date>\r\n");
valueXmlString.append("<site_code><![CDATA[").append(loginSite).append("]]></site_code>\r\n");
if("2".equalsIgnoreCase(userLevel)) {
valueXmlString.append("<site_code protect = '1'><![CDATA[").append(loginSite).append("]]></site_code>\r\n");
} else {
valueXmlString.append("<site_code><![CDATA[").append(loginSite).append("]]></site_code>\r\n");
}
valueXmlString.append("<descr><![CDATA[").append(loginSiteDesc).append("]]></descr>\r\n");
valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<status><![CDATA[").append("E").append("]]></status>\r\n");
valueXmlString.append("<tran_type><![CDATA[").append("E").append("]]></tran_type>\r\n");
valueXmlString.append("<bank_name>").append("<![CDATA["+bankName+"]]>").append("</bank_name>\r\n");
valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n");
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite, checkNull(sysDate), "S", conn);
//System.out.println("exchangeRate>>>>["+exchangeRate+"]");
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");
valueXmlString.append("<bank_name>").append("<![CDATA[" + bankName + "]]>").append("</bank_name>\r\n");
valueXmlString.append("<curr_code>").append("<![CDATA[" + currencyCode + "]]>").append("</curr_code>\r\n");
// exchangeRate =
// finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite,
// checkNull(sysDate), "S", conn);
// System.out.println("exchangeRate>>>>["+exchangeRate+"]");
valueXmlString.append("<exch_rate>").append("<![CDATA[" + exchangeRate + "]]>").append("</exch_rate>\r\n");
}
else if( currentColumn.trim().equalsIgnoreCase( "bank_code" ) )
{
bankCode = checkNull(genericUtility.getColumnValue("bank_code",dom));
currencyCode = checkNull(genericUtility.getColumnValue("curr_code",dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom));
} else if (currentColumn.trim().equalsIgnoreCase("bank_code")) {
bankCode = checkNull(genericUtility.getColumnValue(
"bank_code", dom));
currencyCode = checkNull(genericUtility.getColumnValue(
"curr_code", dom));
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
bankName = checkNull(rs.getString( "BANK_NAME" ));
//currencyCode = checkNull(rs.getString("CURR_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("date>>>>>>"+genericUtility.getColumnValue("tran_date", dom));
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode, genericUtility.getColumnValue("tran_date", dom), "S", conn);
//System.out.println("exchangeRate>>>>@@@@@@@@@["+exchangeRate+"]");
valueXmlString.append("<bank_name>").append("<![CDATA["+bankName+"]]>").append("</bank_name>\r\n");
//valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n");
//valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");
}else if( currentColumn.trim().equalsIgnoreCase( "cust_code" ) )
{
custCode = checkNull(genericUtility.getColumnValue("cust_code",dom));
sql = "SELECT CUST_NAME,CURR_CODE FROM CUSTOMER WHERE CUST_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
custName = checkNull(rs.getString( "CUST_NAME" ));
currencyCode = rs.getString("CURR_CODE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite, checkNull(sysDate), "S", conn);
System.out.println("exchangeRate in (cust_code) :"+exchangeRate);
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");
valueXmlString.append("<curr_code><![CDATA[").append(currencyCode).append("]]></curr_code>\r\n");
valueXmlString.append("<cust_name><![CDATA[").append(custName).append("]]></cust_name>\r\n");
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankName = checkNull(rs.getString("BANK_NAME"));
// currencyCode = checkNull(rs.getString("CURR_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("date>>>>>>"
+ genericUtility.getColumnValue("tran_date", dom));
// exchangeRate =
// finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode,
// genericUtility.getColumnValue("tran_date", dom), "S",
// conn);
// System.out.println("exchangeRate>>>>@@@@@@@@@["+exchangeRate+"]");
valueXmlString.append("<bank_name>")
.append("<![CDATA[" + bankName + "]]>")
.append("</bank_name>\r\n");
// valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n");
// valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("cust_code")) {
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
//sql = "SELECT CUST_NAME, CURR_CODE FROM CUSTOMER WHERE CUST_CODE = ?";
//TODO
sql = "select c.cust_name as CUST_NAME, c.curr_code as CURR_CODE from customer c join site_customer s on c.cust_code = s.cust_code and s.site_code = ? and c.cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery();
if (rs.next()) {
custName = checkNull(rs.getString("CUST_NAME"));
currencyCode = rs.getString("CURR_CODE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
exchangeRate = finCommon.getDailyExchRateSellBuy(
currencyCode, "", loginSite, checkNull(sysDate),
"S", conn);
System.out.println("exchangeRate in (cust_code) :"
+ exchangeRate);
valueXmlString.append("<exch_rate>")
.append("<![CDATA[" + exchangeRate + "]]>")
.append("</exch_rate>\r\n");
valueXmlString.append("<curr_code><![CDATA[")
.append(currencyCode).append("]]></curr_code>\r\n");
valueXmlString.append("<cust_name><![CDATA[")
.append(custName).append("]]></cust_name>\r\n");
}else if( currentColumn.trim().equalsIgnoreCase( "site_code" ) )
{
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom));
} else if (currentColumn.trim().equalsIgnoreCase("site_code")) {
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
siteCodeDesc = checkNull(rs.getString( "DESCR" ));
bankCode = rs.getString("BANK_CODE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
bankName = checkNull(rs.getString("BANK_NAME"));
//currencyCode = checkNull(rs.getString("CURR_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("date>>>>>>"+genericUtility.getColumnValue("tran_date", dom));
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode, genericUtility.getColumnValue("tran_date", dom), "S", conn);
//System.out.println("exchangeRate>>>>@@@@@@@@@>>>>>>>>>["+exchangeRate+"]");
valueXmlString.append("<descr><![CDATA[").append(siteCodeDesc).append("]]></descr>\r\n");
valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<bank_name><![CDATA[").append(bankName).append("]]></bank_name>\r\n");
/*valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n");
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");*/
}
valueXmlString.append("</Detail1>");
break;
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "] ==> '" + columnValue + "'");
if ( currentColumn.trim().equalsIgnoreCase("itm_default") )
{
hdrCustCode = this.genericUtility.getColumnValue("cust_code", dom1);
hdrSiteCode = this.genericUtility.getColumnValue("site_code", dom1);
valueXmlString.append("<line_no__ref><![CDATA[" ).append("1").append( "]]></line_no__ref>\r\n");
valueXmlString.append("<udf_str1><![CDATA[").append(hdrSiteCode).append("]]></udf_str1>\r\n");
valueXmlString.append("<udf_str2><![CDATA[").append(hdrCustCode).append("]]></udf_str2>\r\n");
}else if( currentColumn.trim().equalsIgnoreCase( "ref_no" ) ||currentColumn.trim().equalsIgnoreCase( "ref_ser" ) )
{
refNo = checkNull(genericUtility.getColumnValue("ref_no",dom));
refSer = checkNull(genericUtility.getColumnValue("ref_ser",dom));
custCode = this.genericUtility.getColumnValue("cust_code", dom1);
siteCode = this.genericUtility.getColumnValue("site_code", dom1);
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? and cust_code= ? and site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
rcpAmt1=rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("receipt amount["+getRequiredDecimal(rcpAmt1,2)+"]");
valueXmlString.append("<rcp_amt><![CDATA[").append( getRequiredDecimal(rcpAmt1,2) ).append("]]></rcp_amt>\r\n");
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
siteCodeDesc = checkNull(rs.getString("DESCR"));
bankCode = rs.getString("BANK_CODE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankName = checkNull(rs.getString("BANK_NAME"));
// currencyCode = checkNull(rs.getString("CURR_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("date>>>>>>"
+ genericUtility.getColumnValue("tran_date", dom));
// exchangeRate =
// finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode,
// genericUtility.getColumnValue("tran_date", dom), "S",
// conn);
// System.out.println("exchangeRate>>>>@@@@@@@@@>>>>>>>>>["+exchangeRate+"]");
valueXmlString.append("<descr><![CDATA[")
.append(siteCodeDesc).append("]]></descr>\r\n");
valueXmlString.append("<bank_code><![CDATA[")
.append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<bank_name><![CDATA[")
.append(bankName).append("]]></bank_name>\r\n");
/*
* valueXmlString.append("<curr_code>").append("<![CDATA["+
* currencyCode+"]]>").append("</curr_code>\r\n");
* valueXmlString
* .append("<exch_rate>").append("<![CDATA["+exchangeRate
* +"]]>").append("</exch_rate>\r\n");
*/
}
if(pstmt != null)
{
valueXmlString.append("</Detail1>");
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
hdrCustCode = this.genericUtility.getColumnValue("cust_code", dom1);
hdrSiteCode = this.genericUtility.getColumnValue("site_code", dom1);
valueXmlString.append("<line_no__ref><![CDATA[").append("1").append("]]></line_no__ref>\r\n");
valueXmlString.append("<udf_str1><![CDATA[").append(hdrSiteCode).append("]]></udf_str1>\r\n");
valueXmlString.append("<udf_str2><![CDATA[").append(hdrCustCode).append("]]></udf_str2>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("ref_no")
|| currentColumn.trim().equalsIgnoreCase("ref_ser")) {
refNo = checkNull(genericUtility.getColumnValue("ref_no",
dom));
refSer = checkNull(genericUtility.getColumnValue("ref_ser",
dom));
custCode = this.genericUtility.getColumnValue("cust_code",
dom1);
siteCode = this.genericUtility.getColumnValue("site_code",
dom1);
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? and cust_code= ? and site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmt1 = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("receipt amount["
+ getRequiredDecimal(rcpAmt1, 2) + "]");
valueXmlString.append("<rcp_amt><![CDATA[")
.append(getRequiredDecimal(rcpAmt1, 2))
.append("]]></rcp_amt>\r\n");
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
conn.close();
}
conn.close();
conn = null;
} catch (Exception d) {
d.printStackTrace();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
return valueXmlString.toString();
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input;
}
public String getRequiredDecimal(double actVal, int prec)//Added by chandrashekar on 11-08-14
public String getRequiredDecimal(double actVal, int prec)// Added by
// chandrashekar
// on 11-08-14
{
String fmtStr = "############0";
if (prec > 0)
{
if (prec > 0) {
fmtStr = fmtStr + "." + "000000000".substring(0, prec);
}
DecimalFormat decFormat = new DecimalFormat(fmtStr);
return decFormat.format(actVal);
}
public static java.util.Date relativeDate(java.util.Date date, int days)
{
public static java.util.Date relativeDate(java.util.Date date, int days) {
java.util.Date calculatedDate = null;
if (date != null)
{
if (date != null) {
final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DATE,days);
calendar.add(Calendar.DATE, days);
calculatedDate = new java.util.Date(calendar.getTime().getTime());
}
}
return calculatedDate;
}
private String errorType(Connection conn , String errorCode) throws ITMException
{
private String errorType(Connection conn, String errorCode)
throws ITMException {
String msgType = "";
PreparedStatement pstmt = null ;
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);
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())
{
if (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if(rs != null)
{
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
}
return msgType;
}
private boolean isDulplicateFrmDom(Document dom,String refNo, String lineNo,String refSer) throws ITMException
{
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String lineNoDom = "";
private boolean isDulplicateFrmDom(Document dom, String refNo,
String lineNo, String refSer) throws ITMException {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String lineNoDom = "", refNoDom = "", refSerDom = "";
boolean isDulplicate = false;
String refNoDom= "",refSerDom="";
System.out.println("---inside isDulplicateFrmDom--");
try
{
System.out.println("---inside method[isDulplicateFrmDom] -- EJB ["
+ this.getClass().getSimpleName() + "]");
try {
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- )
{
parentNode = parentList.item(prntCtr-1);
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
parentNode = parentList.item(prntCtr - 1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++)
{
for (int ctr = 0; ctr < childList.getLength(); ctr++) {
childNode = childList.item(ctr);
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute"))
{
if (childNode != null
&& childNode.getNodeName().equalsIgnoreCase(
"attribute")) {
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
if (updateFlag.equalsIgnoreCase("D"))
{
System.out.println("Break from here as the record is deleted");
updateFlag = childNode.getAttributes()
.getNamedItem("updateFlag").getNodeValue();
if (updateFlag.equalsIgnoreCase("D")) {
System.out
.println("Break from here as the record is deleted");
break;
}
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("line_no") )
{
lineNoDom = childNode.getFirstChild().getNodeValue().trim();
System.out.println("lineNo["+lineNo+"]lineNoDom["+lineNoDom+"]");
if (lineNo.equalsIgnoreCase(lineNoDom))
{
System.out.println("Break from here as line No match");
}
if (childNode != null
&& childNode.getFirstChild() != null
&& childNode.getNodeName().equalsIgnoreCase(
"line_no")) {
lineNoDom = childNode.getFirstChild().getNodeValue()
.trim();
System.out.println("lineNo[" + lineNo + "]lineNoDom["
+ lineNoDom + "]");
if (lineNo.equalsIgnoreCase(lineNoDom)) {
System.out
.println("Break from here as line No match");
break;
}
}
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("REF_NO") )
{
refNoDom = childNode.getFirstChild().getNodeValue().trim();
if (childNode != null
&& childNode.getFirstChild() != null
&& childNode.getNodeName().equalsIgnoreCase(
"ref_no")) {
refNoDom = childNode.getFirstChild().getNodeValue()
.trim();
}
if (childNode != null
&& childNode.getFirstChild() != null
&& childNode.getNodeName().equalsIgnoreCase(
"ref_ser")) {
refSerDom = childNode.getFirstChild().getNodeValue()
.trim();
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("ref_ser") )
{
refSerDom = childNode.getFirstChild().getNodeValue().trim();
}
}
if (refSer.trim().equalsIgnoreCase(refSerDom.trim()) && refNo.trim().equalsIgnoreCase(refNoDom.trim()) )
{
if (refSer.trim().equalsIgnoreCase(refSerDom.trim())
&& refNo.trim().equalsIgnoreCase(refNoDom.trim())) {
isDulplicate = true;
break;
}
}//for loop
}catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
}
catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("isDulplicate>>>>>> ["+isDulplicate+"]");
}
System.out.println("returning from method[isDulplicateFrmDom] -- EJB ["
+ this.getClass().getSimpleName() + "] return Value : ["
+ isDulplicate + "]");
return isDulplicate;
}
private boolean ischqAmtGreater(Document dom, double chqAmt, String lineNo)
{
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
}
String lineNoDom = "",rcpAmtSt="";
@SuppressWarnings("unused")
private boolean ischqAmtGreater(Document dom, double chqAmt, String lineNo) {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String rcpAmtSt = "";
boolean ischqAmtGreater = false;
double chqAmtMeth=0.0,chqAmtSum=0.0;
String refNoDom= "",refSerDom="";
double chqAmtMeth = 0.0, chqAmtSum = 0.0;
System.out.println("---inside ischqAmtGreater--");
try
{
try {
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- )
{
parentNode = parentList.item(prntCtr-1);
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
parentNode = parentList.item(prntCtr - 1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++)
{
for (int ctr = 0; ctr < childList.getLength(); ctr++) {
childNode = childList.item(ctr);
System.out.println("childNode>>>"+childNode);
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute"))
{
System.out.println("childNode>>>" + childNode);
if (childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) {
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>"+updateFlag);
if (updateFlag.equalsIgnoreCase("D"))
{
System.out.println("updateFlag>>>" + updateFlag);
if (updateFlag.equalsIgnoreCase("D")) {
System.out.println("Break from here as the record is deleted");
break;
}
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("rcp_amt") )
{
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0)
{
try
{
chqAmtMeth= Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n)
{
chqAmtMeth = 0;
}
}
if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("rcp_amt")) {
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) {
try {
chqAmtMeth = Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n) {
chqAmtMeth = 0;
}
}
}
}
chqAmtSum=chqAmtSum+chqAmtMeth;
}//for loop
System.out.println("chqAmtSum>>>["+chqAmtSum+"]chqAmt>>>>["+chqAmt+"]");
if (chqAmt < chqAmtSum)
{
chqAmtSum = chqAmtSum + chqAmtMeth;
}
System.out.println("chqAmtSum>>>[" + chqAmtSum + "]chqAmt>>>>[" + chqAmt + "]");
if (chqAmt < chqAmtSum) {
ischqAmtGreater = true;
}
}catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
finally
{
try
{
}
catch(Exception e)
{
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("ischqAmtGreater>>>>>> ["+ischqAmtGreater+"]");
}
System.out.println("ischqAmtGreater>>>>>> [" + ischqAmtGreater + "]");
return ischqAmtGreater;
}
//end of validation
}
}
package ibase.webitm.ejb.fin;
import org.w3c.dom.Document;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal,EcollectionPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal, EcollectionPostSaveRemote {
public String postSave(String xmlString, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException {
System.out.println("------------ postSave method called-----------------EcollectionPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
System.out.println("tranId111--->>[" + tranId + "]");
System.out.println("xml String--->>[" + xmlString + "]");
Document dom = null;
String errString="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
String errString = "";
try {
if (xmlString != null && xmlString.trim().length() > 0) {
dom = parseString(xmlString);
errString = postSave(dom, tranId, xtraParams, conn);
}
}
catch(Exception e)
{
System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n"+e.getMessage());
} catch (Exception e) {
System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n" + e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn)
{
System.out.println("in EcollectionPostSave tran_id---->>["+tranId+"]");
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="",errorString="";
double rcpamt=0;
double rcpamtSum=0;
int count=0;
try
{
// GenericUtility genericUtility = GenericUtility.getInstance();
}
public String postSave(Document dom, String tranId, String xtraParams, Connection conn) {
System.out.println("in EcollectionPostSave tran_id---->>[" + tranId + "]");
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql = "", errorString = "", custCode = "", siteCode = "", errCode = "";
double rcpAmt = 0, chqAmt = 0, rcpamtSum = 0, rcpAmtT = 0, rcpAmtNew = 0, rcpAmtStatus = 0;
int count = 0;
try {
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
tranId = genericUtility.getColumnValue("tran_id",dom);
System.out.println("tranId--->>["+tranId+"]");
String userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
tranId = genericUtility.getColumnValue("tran_id", dom);
chqAmt = Double.parseDouble(genericUtility.getColumnValue("chq_amt", dom, "1"));
custCode = genericUtility.getColumnValue("cust_code", dom, "1");
siteCode = genericUtility.getColumnValue("site_code", dom, "1");
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmt = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtNew>>>[" + rcpAmtNew + "]rcpAmt[" + rcpAmt + "]");
// Start added by chandr shekar on 21-mar-2016
sql = "select nvl(sum(rcpdet.rcp_amt), 0) as amt from rcpdet_form rcpdet, receipt_form rcpform "
+ "where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? "
+ "and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? "
+ "AND rcpform.cust_code = ? and rcpform.site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmtStatus = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtStatus>>>" + rcpAmtStatus);
// End added by chandrashekar on 21-mar-2016
if (rcpAmt - rcpAmtStatus < rcpAmtNew) {
errCode = "VTINVTLAMT";
errorString = getErrorString("", errCode, userId);
return errorString;
}
sql = "SELECT rcp_amt FROM RCPDET_FORM WHERE tran_id = ? ";
if(isChqAmtGreater(dom, chqAmt)){
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
System.out.println("tranId--->>[" + tranId + "]");
sql = "SELECT NVL(SUM(RCP_AMT), 0) FROM RCPDET_FORM WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while( rs.next() )
{
while (rs.next()) {
count++;
rcpamt=rs.getDouble(1);
rcpamtSum=rcpamtSum+rcpamt;
rcpAmtT = rs.getDouble(1);
rcpamtSum = rcpamtSum + rcpAmtT;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpamtSum>>>>>>>>" + rcpamtSum);
System.out.println("rcpamtSum>>>>>>>>"+rcpamtSum);
System.out.println("count>>>>>>>>"+count);
if(count >0)
{
sql="update receipt_form set chq_amt = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, rcpamtSum);
pstmt.setString(2, tranId);
count=pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]");
if(count >0 )
{
conn.commit();
if(chqAmt > rcpamtSum) {
System.out.println("Receipt Amount is Less... :)");
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
}else
{
System.out.println("count>>>>>>>>" + count);
/*if (count > 0) {
sql = "update receipt_form set chq_amt = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, rcpamtSum);
pstmt.setString(2, tranId);
count = pstmt.executeUpdate();
System.out.println("post count---->>[" + count + "]");
if (count > 0) {
conn.commit();
}
} else {
conn.rollback();
}
}
catch(Exception e)
{
System.out.println("Exception : EcollectionPostSave -->["+e.getMessage()+"]");
}*/
} catch (Exception e) {
System.out.println("Exception : EcollectionPostSave -->["
+ e.getMessage() + "]");
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception while rollbacking transaction....");
try {
conn.rollback();
} catch (Exception e1) {
System.out
.println("Exception while rollbacking transaction....");
e1.printStackTrace();
}
}
return errorString;
}
private String checkNull(String columnValue) {
return columnValue == null ? "" : columnValue;
}
private boolean isChqAmtGreater(Document dom, double chqAmt) {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String lineNoDom = "", rcpAmtSt = "";
boolean ischqAmtGreater = false;
double chqAmtMeth = 0.0, chqAmtSum = 0.0;
String refNoDom = "", refSerDom = "";
System.out.println("---inside ischqAmtGreater--");
try {
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
parentNode = parentList.item(prntCtr - 1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++) {
childNode = childList.item(ctr);
System.out.println("childNode>>>" + childNode);
if (childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) {
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>" + updateFlag);
if (updateFlag.equalsIgnoreCase("D")) {
System.out.println("Break from here as the record is deleted");
break;
}
}
if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("rcp_amt")) {
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) {
try {
chqAmtMeth = Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n) {
chqAmtMeth = 0;
}
}
}
}
chqAmtSum = chqAmtSum + chqAmtMeth;
}// for loop
System.out.println("chqAmtSum>>>[" + chqAmtSum + "] : chqAmt>>>>[" + chqAmt + "]");
if (chqAmt < chqAmtSum) {
ischqAmtGreater = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("ischqAmtGreater>>>>>> [" + ischqAmtGreater + "]");
return ischqAmtGreater;
}
}
......@@ -5,150 +5,153 @@
********************************************************/
package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule;
import java.util.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.fin.adv.ReceiptAdvConf;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.fin.adv.ReceiptAdvConf;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.utility.CommonConstants;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility;
public class EcollectionSchedule implements Schedule
{
@SuppressWarnings({ "rawtypes", "unused" })
public class EcollectionSchedule implements Schedule {
String chgUser = null;
String chgTerm = null;
static long count_records=0;
static long count_records = 0;
boolean isError = false;
String loginSiteCode = "";
String retString="";
String retString = "";
E12GenericUtility e12GenericUtility = new E12GenericUtility();
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
String startDateStr = null;
public static void main(String args[])
{
EcollectionSchedule ecs=new EcollectionSchedule();
System.out.println("Main Method Calling******************************************************88");
public static void main(String args[]) {
EcollectionSchedule ecs = new EcollectionSchedule();
System.out
.println("Main Method Calling******************************************************88");
}
public String schedulePriority( String wrkflwPriority )throws Exception
{
public String schedulePriority(String wrkflwPriority) throws Exception {
return "";
}
public String schedule(HashMap map)throws Exception
{
public String schedule(HashMap map) throws Exception {
return "";
}
public String schedule(String scheduleParamXML)throws Exception
{
String siteCode = "",actualLoginSiteCode="",errString="";
public String schedule(String scheduleParamXML) throws Exception {
String siteCode = "", actualLoginSiteCode = "", errString = "";
String xtraParams = "";
ibase.utility.UserInfoBean userInfo = null;
try
{
System.out.println("************ ["+scheduleParamXML+"]");
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
UserInfoBean userInfo = null;
try {
System.out.println("************ [" + scheduleParamXML + "]");
userInfo = new UserInfoBean(scheduleParamXML);
siteCode = userInfo.getSiteCode();
xtraParams = "loginEmpCode="+userInfo.getEmpCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode;
//GenericUtility genericUtility=GenericUtility.getInstance();
E12GenericUtility genericUtility= new E12GenericUtility();
Document dom=genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
xtraParams = "loginEmpCode=" + userInfo.getEmpCode() + "~~termId="
+ userInfo.getRemoteHost() + "~~loginSiteCode="
+ loginSiteCode;
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
Document dom = genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName("SCHEDULE"), parentNodeList = null, childNodeList = null;
Node parentNode = null, childNode = null;
int childNodeListLength = 0;
String childNodeName = null;
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
for (int ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
actualLoginSiteCode=childNode.getFirstChild().getNodeValue();
if (childNodeName != null && !"#text".equalsIgnoreCase(childNodeName)) {
if (ctr == 0) {
actualLoginSiteCode = childNode.getFirstChild().getNodeValue();
}
}
}
System.out.println("ActualLoginSiteCode----["+actualLoginSiteCode+"]");
System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("ecollection_log"));
if(("null".equals(actualLoginSiteCode) || actualLoginSiteCode.trim().length() == 0 ))
{
System.out.println("ActualLoginSiteCode----[" + actualLoginSiteCode + "]");
System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........." + intializingLog("ecollection_log"));
if (("null".equals(actualLoginSiteCode) || actualLoginSiteCode
.trim().length() == 0)) {
siteCode = userInfo.getSiteCode();
System.out.println("Site code >>>>>>>>>> "+siteCode);
errString= insertReceipt(siteCode,scheduleParamXML,xtraParams);
}
else
{
String[] arrStr =actualLoginSiteCode.split(",");
int len =arrStr.length;
for(int i =0;i<len;i++)
{
loginSiteCode =arrStr[i];
System.out.println("loginSiteCode>>>>>>>>"+loginSiteCode);
errString= insertReceipt(loginSiteCode,scheduleParamXML,xtraParams);
}
System.out.println("Site code >>>>>>>>>> " + siteCode);
errString = insertReceipt(siteCode, scheduleParamXML,
xtraParams);
} else {
String[] arrStr = actualLoginSiteCode.split(",");
int len = arrStr.length;
for (int i = 0; i < len; i++) {
loginSiteCode = arrStr[i];
System.out.println("loginSiteCode>>>>>>>>" + loginSiteCode);
errString = insertReceipt(loginSiteCode, scheduleParamXML,
xtraParams);
}
}
}
catch(Exception e)
{
} catch (Exception e) {
throw new Exception(e);
}
System.out.println("errString>>>["+errString+"]");
System.out.println("errString>>>[" + errString + "]");
return errString;
}
public String insertReceipt(String siteCode , String scheduleParamXML,String xtraParams) throws Exception
{
public String insertReceipt(String siteCode, String scheduleParamXML, String xtraParams) throws Exception {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
String sql="";
String tranId="";
String tranDate =null;
String bankCode = "",refNo="",custCode="",tranType="",rcpMode="",finEntity="",remarks="";
String sql1="",refSer="",lineNoRef="";
String errString ="",xmlString="";
String sql = "";
String tranId = "";
String tranDate = null;
String bankCode = "", refNoHdr = "", custCode = "", tranType = "", rcpMode = "", finEntity = "", remarks = "";
String sql1 = "", refSer = "", lineNoRef = "";
String errString = "", xmlString = "";
String strToWrite = "";
String endDateStr = null;
String currencyCode="",stmtId="";
String currencyCode = "", stmtId = "";
double exchRate = 0.0;
double rcpAmt=0,bankAmount=0,rcpAmtDet=0;
int cnt=0,lineNo=0,bankCnt=0;
Date refDate=null,effDate=null;
//E12GenericUtility e12GenericUtility = new E12GenericUtility();
double rcpAmt = 0, bankAmount = 0, rcpAmtDet = 0;
int cnt = 0, lineNo = 0, bankCnt = 0;
Date refDate = null, effDate = null;
// E12GenericUtility e12GenericUtility = new E12GenericUtility();
SimpleDateFormat sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
ReceiptAdvConf ReceiptAdv = new ReceiptAdvConf();
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
java.util.Date startDate = new java.util.Date(
System.currentTimeMillis());
java.util.Date endDate = new java.util.Date(System.currentTimeMillis());
try
{
try {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
......@@ -158,16 +161,17 @@ public class EcollectionSchedule implements Schedule
java.util.Calendar cal = java.util.Calendar.getInstance();
tranDate = simpleDateFormat.format(cal.getTime());
sql = "select bank_code,ref_no,chq_amt,cust_code,tran_type,rcp_mode,ref_date,eff_date," +
"remarks,tran_id,curr_code,exch_rate,stmt_id from " + " receipt_form where confirmed='Y' and status='C' and site_code= ? ";
/*sql = "select bank_code,ref_no,chq_amt,cust_code,tran_type,rcp_mode,ref_date,eff_date,"
+ "remarks,tran_id,curr_code,exch_rate,stmt_id from "
+ " receipt_form where confirmed='Y' and status='C' and site_code= ? ";*/
sql = "select d.ref_ser, h.bank_code,h.ref_no,h.chq_amt,h.cust_code,h.tran_type,h.rcp_mode,h.ref_date,h.eff_date,h.remarks,h.tran_id,h.curr_code,h.exch_rate,h.stmt_id from receipt_form h join rcpdet_form d on h.tran_id = d.tran_id and confirmed='Y' and status='C' and site_code= ? and d.line_no = 1";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
while (rs.next())
{
while (rs.next()) {
lineNo = 0;
bankCode = rs.getString("bank_code");
refNo = rs.getString("ref_no");
refNoHdr = rs.getString("ref_no");
custCode = rs.getString("cust_code");
rcpAmt = rs.getDouble("chq_amt");
tranType = rs.getString("tran_type");
......@@ -178,246 +182,297 @@ public class EcollectionSchedule implements Schedule
tranId = rs.getString("tran_id");
currencyCode = rs.getString("curr_code");
exchRate = rs.getDouble("exch_rate");
refSer = rs.getString("ref_ser");
refSer = refSer == null ? "" : refSer.trim();
stmtId = rs.getString("stmt_id");
stmtId = stmtId == null ? "" : stmtId.trim();
System.out.println("receipt form tranId:::::::::" + tranId);
strToWrite = tranId+",";
strToWrite = tranId + ",";
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strToWrite=strToWrite+startDateStr+",";
startDateStr = sdf1.format(startDate) + " " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
strToWrite = strToWrite + startDateStr + ",";
System.out.println("STARTING DATE"+startDateStr +"STRING TO WRITE"+strToWrite);
sql1 = " select fin_entity from site where site_code=? ";
System.out.println("STARTING DATE: [" + startDateStr + "]: STRING TO WRITE:[" + strToWrite + "].");
/*sql1 = "select * from receivables where cust_code = ? and tran_ser = ? and ref_no = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(1, custCode);
pstmt1.setString(2, refSer);
pstmt1.setString(3, refNo);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
finEntity = rs1.getString("fin_entity");
if (rs1.next()) {
} else {
System.out.println("Invalid Ref_No: [" + refNo + "]: for Transaction of E-Collection:[" + tranId + "].");
continue;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
pstmt1 = null;*/
finEntity = finEntity == null ? "" : finEntity.trim();
/*bankAmount=0;
sql1 = " select amount from bank_statement where site_code=? and bank_code= ? and ref_no= ?";
sql1 = " select fin_entity from site where site_code=? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
pstmt1.setString(2, bankCode);
pstmt1.setString(3, refNo);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
bankAmount = rs1.getDouble("amount");
if (rs1.next()) {
finEntity = rs1.getString("fin_entity");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;*/
//System.out.println("bankAmount>>>>>>[" + bankAmount + "]rcpAmt>>>>>[" + rcpAmt + ']');
//if (rcpAmt == bankAmount)
//{
StringBuffer xmlBuff = new StringBuffer();
StringBuffer advBuff = new StringBuffer();
errString = "";
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("receipt_adv").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\"").append(" objName=\"receipt_adv\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
pstmt1 = null;
xmlBuff.append("<tran_date><![CDATA[" + tranDate + "]]></tran_date>");
xmlBuff.append("<cust_code><![CDATA[" + custCode + "]]></cust_code>");
xmlBuff.append("<tran_type><![CDATA[" + tranType + "]]></tran_type>");
xmlBuff.append("<rcp_mode><![CDATA[" + rcpMode + "]]></rcp_mode>");
xmlBuff.append("<bank_code><![CDATA[" + bankCode + "]]></bank_code>");
xmlBuff.append("<ref_no><![CDATA[" + refNo + "]]></ref_no>");
if (refDate != null)
{
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>");
} else
{
xmlBuff.append("<ref_date><![CDATA[]]></ref_date>");
}
xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>");
xmlBuff.append("<confirmed><![CDATA[]]></confirmed>");
xmlBuff.append("<auto_recd><![CDATA[]]></auto_recd>");
xmlBuff.append("<adv_amt><![CDATA[").append("0").append("]]></adv_amt>");
xmlBuff.append("<bill_amt><![CDATA[").append("0").append("]]></bill_amt>");
if (effDate != null)
{
xmlBuff.append("<eff_date><![CDATA[" + sdf.format(effDate) + "]]></eff_date>");
} else
{
xmlBuff.append("<eff_date><![CDATA[]]></eff_date>");
}
xmlBuff.append("<diff_amt__exch><![CDATA[]]></diff_amt__exch>");
xmlBuff.append("<sale_order><![CDATA[]]></sale_order>");
xmlBuff.append("<cust_bank_ref><![CDATA[]]></cust_bank_ref>");
xmlBuff.append("<entry_batch_no><![CDATA[]]></entry_batch_no>");
xmlBuff.append("<emp_code__aprv><![CDATA[]]></emp_code__aprv>");
xmlBuff.append("<chq_amt><![CDATA[" + rcpAmt + "]]></chq_amt>");
xmlBuff.append("<advadj_amt><![CDATA[").append("0").append("]]></advadj_amt>");
xmlBuff.append("<fin_scheme><![CDATA[]]></fin_scheme>");
xmlBuff.append("<item_ser><![CDATA[]]></item_ser>");
xmlBuff.append("<rcp_type><![CDATA[]]></rcp_type>");
//xmlBuff.append("<remarks><![CDATA[" + remarks + "]]></remarks>");
xmlBuff.append("<remarks><![CDATA[Transaction created from Ecollection scheduler]]></remarks>");
xmlBuff.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlBuff.append("<curr_code><![CDATA["+currencyCode+"]]></curr_code>");
xmlBuff.append("<exch_rate><![CDATA["+exchRate+"]]></exch_rate>");
xmlBuff.append("</Detail1>");
sql1 = " select ref_ser,ref_no,line_no__ref,rcp_amt from rcpdet_form where tran_id=? ";
finEntity = finEntity == null ? "" : finEntity.trim();
/*
* bankAmount=0; sql1 =
* " select amount from bank_statement where site_code=? and bank_code= ? and ref_no= ?"
* ; pstmt1 = conn.prepareStatement(sql1); pstmt1.setString(1,
* siteCode); pstmt1.setString(2, bankCode); pstmt1.setString(3,
* refNo); rs1 = pstmt1.executeQuery(); if (rs1.next()) {
* bankAmount = rs1.getDouble("amount"); } rs1.close(); rs1 =
* null; pstmt1.close(); pstmt1 = null;
*/
// System.out.println("bankAmount>>>>>>[" + bankAmount +
// "]rcpAmt>>>>>[" + rcpAmt + ']');
// if (rcpAmt == bankAmount)
// {
if(stmtId.trim().length() == 0 ) {
String bankGroup = "";
sql1 = "select group_code from bank where bank_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setString(1, bankCode);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
lineNo++;
System.out.println("lineNo is " + lineNo);
refSer = rs1.getString("ref_ser");
refNo = rs1.getString("ref_no");
lineNoRef = rs1.getString("line_no__ref");
rcpAmtDet = rs1.getDouble("rcp_amt");
refSer = refSer == null ? "" : refSer.trim();
refNo = refNo == null ? "" : refNo.trim();
lineNoRef = lineNoRef == null ? "" : lineNoRef.trim();
//xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID=\"1\" dbID=''>");
xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID='"+lineNo+"' dbID=''>");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<line_no><![CDATA[" + lineNo + "]]></line_no>");
xmlBuff.append("<line_no__ref><![CDATA[" + lineNoRef + "]]></line_no__ref>");
xmlBuff.append("<ref_ser><![CDATA[" + refSer + "]]></ref_ser>");
xmlBuff.append("<ref_no><![CDATA[" + refNo + "]]></ref_no>");
xmlBuff.append("<rcp_amt><![CDATA[" + rcpAmtDet + "]]></rcp_amt>");
xmlBuff.append("</Detail2>");
if (rs1.next()) {
bankGroup = rs1.getString("group_code").trim();
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
xmlBuff.append(advBuff.toString());
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("xmlString " + xmlString);
errString = saveData(siteCode, xmlString, conn);
System.out.println("Passed xml in master State full errString " + errString);
if (errString.indexOf("Success") > -1)
{
String[] arrayForTranId = errString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.out.println("***********going for confirmation************");
String tranIdForIssue = arrayForTranId[1].substring(0, endIndex);
System.out.println("tranIdForIssue" + tranIdForIssue);
errString = ReceiptAdv.confirm(tranIdForIssue, xtraParams, "", conn);
System.out.println("=====Its Confirmed=====");
System.out.println("retString from conf ::" + errString);
if (errString.indexOf("VTCICONF3") > -1)
{
cnt=0;
bankCnt=0;
sql1 = " update receipt_form set status= 'P',TRAN_ID__RCP=? where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdForIssue);
pstmt1.setString(2, tranId);
cnt = pstmt1.executeUpdate();
/*if (cnt > 0)
{
System.out.println("UPDATE QUERY FOR STATUS");
conn.commit();
}*/
pstmt1.close();
pstmt1 = null;
sql1 = " update bank_statement set collection_form_ref= ? where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setString(2, stmtId);
bankCnt = pstmt1.executeUpdate();
/*if (bankCnt > 0)
{
System.out.println("UPDATE QUERY FOR STATUS");
conn.commit();
}*/
pstmt1.close();
pstmt1 = null;
if(cnt >0 && bankCnt>0)
{
conn.commit();
System.out.println("UPDATE QUERY FOR STATUS");
}
} else
{
System.out.println("connection roll back for confirmation");
conn.rollback();
}
} else
{
System.out.println("connection roll back for save data");
conn.rollback();
}
System.out.println("Passed xml in master State full final errString " + errString);
endDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
System.out.println("**** ecollection completed for.....[" + tranId + "] at [" + endDateStr + "]" );
strToWrite=strToWrite+endDateStr+",";
strToWrite = strToWrite + errString+"\r\n\r\n";
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
/*} else
{
sql1 = " update receipt_form set remarks = 'Mismatch amount in bank statement and total receipt amount',status= 'R' where tran_id = ? ";
java.sql.Date dtTemp = new java.sql.Date(refDate.getTime());
sql1 = "select b.tran_id as stmt_id from bank_statement b,site s, bank bank where s.fin_entity= ? " +
" and s.site_code = b.site_code and bank.bank_code=b.bank_code and bank.group_code= ? " +
" and b.amount=? and b.collection_form_ref is null and b.ref_no = ? and b.ref_date = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
cnt = pstmt1.executeUpdate();
if (cnt > 0)
{
conn.commit();
pstmt1.setString(1, finEntity);
pstmt1.setString(2, bankGroup);
pstmt1.setDouble(3, rcpAmt);
pstmt1.setString(4, refNoHdr);
pstmt1.setDate(5, dtTemp);
rs1 = pstmt1.executeQuery();
if(rs1.next()) {
stmtId = rs1.getString("stmt_id");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}*/
}
if(stmtId.trim().length() == 0) {
continue;
}
StringBuffer xmlBuff = new StringBuffer();
StringBuffer advBuff = new StringBuffer();
errString = "";
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("receipt_adv").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append(" ").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\" objName=\"receipt_adv\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[" + tranDate + "]]></tran_date>");
xmlBuff.append("<cust_code><![CDATA[" + custCode + "]]></cust_code>");
xmlBuff.append("<tran_type><![CDATA[" + tranType + "]]></tran_type>");
xmlBuff.append("<rcp_mode><![CDATA[" + rcpMode + "]]></rcp_mode>");
xmlBuff.append("<bank_code><![CDATA[" + bankCode + "]]></bank_code>");
xmlBuff.append("<ref_no><![CDATA[" + refNoHdr + "]]></ref_no>");
if (refDate != null) {
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>");
} else {
xmlBuff.append("<ref_date><![CDATA[]]></ref_date>");
}
xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>");
xmlBuff.append("<confirmed><![CDATA[]]></confirmed>");
xmlBuff.append("<auto_recd><![CDATA[]]></auto_recd>");
xmlBuff.append("<adv_amt><![CDATA[").append("0").append("]]></adv_amt>");
xmlBuff.append("<bill_amt><![CDATA[").append("0").append("]]></bill_amt>");
if (effDate != null) {
xmlBuff.append("<eff_date><![CDATA[" + sdf.format(effDate) + "]]></eff_date>");
} else {
xmlBuff.append("<eff_date><![CDATA[]]></eff_date>");
}
xmlBuff.append("<diff_amt__exch><![CDATA[]]></diff_amt__exch>");
xmlBuff.append("<sale_order><![CDATA[]]></sale_order>");
xmlBuff.append("<cust_bank_ref><![CDATA[]]></cust_bank_ref>");
xmlBuff.append("<entry_batch_no><![CDATA[]]></entry_batch_no>");
xmlBuff.append("<emp_code__aprv><![CDATA[]]></emp_code__aprv>");
xmlBuff.append("<chq_amt><![CDATA[" + rcpAmt + "]]></chq_amt>");
xmlBuff.append("<advadj_amt><![CDATA[").append("0").append("]]></advadj_amt>");
xmlBuff.append("<fin_scheme><![CDATA[]]></fin_scheme>");
xmlBuff.append("<item_ser><![CDATA[]]></item_ser>");
xmlBuff.append("<rcp_type><![CDATA[]]></rcp_type>");
xmlBuff.append("<remarks><![CDATA[Transaction created from Ecollection scheduler]]></remarks>");
xmlBuff.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlBuff.append("<curr_code><![CDATA[" + currencyCode + "]]></curr_code>");
xmlBuff.append("<exch_rate><![CDATA[" + exchRate + "]]></exch_rate>");
xmlBuff.append("</Detail1>");
sql1 = "select ref_ser,ref_no,line_no__ref,rcp_amt from rcpdet_form where tran_id=? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery();
while (rs1.next()) {
lineNo++;
System.out.println("lineNo is " + lineNo);
refSer = rs1.getString("ref_ser");
String refNo = rs1.getString("ref_no");
lineNoRef = rs1.getString("line_no__ref");
rcpAmtDet = rs1.getDouble("rcp_amt");
refSer = refSer == null ? "" : refSer.trim();
refNo = refNo == null ? "" : refNo.trim();
lineNoRef = lineNoRef == null ? "" : lineNoRef.trim();
// xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID=\"1\" dbID=''>");
xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID='" + lineNo + "' dbID=''>");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<line_no><![CDATA[" + lineNo + "]]></line_no>");
xmlBuff.append("<line_no__ref><![CDATA[" + lineNoRef + "]]></line_no__ref>");
xmlBuff.append("<ref_ser><![CDATA[" + refSer + "]]></ref_ser>");
xmlBuff.append("<ref_no><![CDATA[" + refNo + "]]></ref_no>");
xmlBuff.append("<rcp_amt><![CDATA[" + rcpAmtDet + "]]></rcp_amt>");
xmlBuff.append("</Detail2>");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
xmlBuff.append(advBuff.toString());
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("xmlString " + xmlString);
errString = saveData(siteCode, xmlString, scheduleParamXML, conn);
System.out
.println("Passed xml in master State full errString "
+ errString);
if (errString.indexOf("Success") > -1) {
String[] arrayForTranId = errString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.out
.println("***********going for confirmation************");
String tranIdForIssue = arrayForTranId[1].substring(0,
endIndex);
System.out.println("tranIdForIssue" + tranIdForIssue);
errString = ReceiptAdv.confirm(tranIdForIssue, xtraParams,
"", conn);
System.out.println("=====Its Confirmed=====");
System.out.println("retString from conf ::" + errString);
if (errString.indexOf("VTCICONF3") > -1) {
cnt = 0;
bankCnt = 0;
sql1 = " update receipt_form set status= 'P',TRAN_ID__RCP=? where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdForIssue);
pstmt1.setString(2, tranId);
cnt = pstmt1.executeUpdate();
/*
* if (cnt > 0) {
* System.out.println("UPDATE QUERY FOR STATUS");
* conn.commit(); }
*/
pstmt1.close();
pstmt1 = null;
sql1 = " update bank_statement set collection_form_ref= ? where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId);
pstmt1.setString(2, stmtId);
bankCnt = pstmt1.executeUpdate();
/*
* if (bankCnt > 0) {
* System.out.println("UPDATE QUERY FOR STATUS");
* conn.commit(); }
*/
pstmt1.close();
pstmt1 = null;
if (cnt > 0 && bankCnt > 0) {
conn.commit();
System.out.println("UPDATE QUERY FOR STATUS");
}
} else {
System.out
.println("connection roll back for confirmation");
conn.rollback();
}
} else {
System.out.println("connection roll back for save data");
conn.rollback();
}
System.out
.println("Passed xml in master State full final errString "
+ errString);
endDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System
.currentTimeMillis()));
endDateStr = sdf1.format(endDate) + " "
+ calendar.get(Calendar.HOUR) + ":"
+ calendar.get(Calendar.MINUTE) + ":"
+ calendar.get(Calendar.SECOND);
System.out.println("**** ecollection completed for.....["
+ tranId + "] at [" + endDateStr + "]");
strToWrite = strToWrite + endDateStr + ",";
strToWrite = strToWrite + errString + "\r\n\r\n";
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction" + endDateStr
+ "string to write" + strToWrite);
/*
* } else { sql1 =
* " update receipt_form set remarks = 'Mismatch amount in bank statement and total receipt amount',status= 'R' where tran_id = ? "
* ; pstmt1 = conn.prepareStatement(sql1); pstmt1.setString(1,
* tranId); cnt = pstmt1.executeUpdate(); if (cnt > 0) {
* conn.commit(); } pstmt1.close(); pstmt1 = null; }
*/
}
rs.close();
......@@ -425,111 +480,100 @@ public class EcollectionSchedule implements Schedule
pstmt.close();
pstmt = null;
}
catch(SQLException se)
{
} catch (SQLException se) {
isError = true;
System.out.println("Exception : insReceipt : EcollectionSchedule" +se.getMessage());
try
{
System.out.println("Exception : insReceipt : EcollectionSchedule"
+ se.getMessage());
try {
conn.rollback();
} catch (Exception se1) {
}
catch(Exception se1){}
throw new ITMException(se);
}finally
{
if(conn != null)
{
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
conn.close();
conn= null;
} finally {
if (conn != null) {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
conn.close();
conn = null;
}
}
System.out.println("errString........:: " + errString);
return errString;
return errString;
}
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
private String saveData(String siteCode, String xmlString, String scheduleParamXML, Connection conn) throws ITMException {
UserInfoBean userInfo = null;
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
try
{
try {
AppConnectParm appConnect = new AppConnectParm();
userInfo = new UserInfoBean(scheduleParamXML);
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2];
masterStateful.setUserInfo(userInfo);
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);
}
catch(ITMException itme)
{
//retString = masterStateful.processRequest(userInfo, xmlString, true, conn);
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
} catch (ITMException itme) {
System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme;
}
catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e);
}
return retString;
}
private String intializingLog(String fileName)
{
String log="intializingLog_Failed";
private String intializingLog(String fileName) {
String log = "intializingLog_Failed";
String strToWrite = "";
String currTime = null;
try{
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".txt";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
try {
SimpleDateFormat sdf1 = new SimpleDateFormat(
e12GenericUtility.getDBDateFormat());
try {
currTime = sdf1.format(
new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-", "");
calendar.setTime(new java.sql.Timestamp(System
.currentTimeMillis()));
fileName = fileName + currTime + calendar.get(Calendar.HOUR)
+ "" + calendar.get(Calendar.MINUTE) + ".txt";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME
+ File.separator + "EDI" + File.separator + fileName);
} catch (Exception e) {
System.out.println("Exception []::" + e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
startDateStr = sdf1.format(startDate) + " "
+ calendar.get(Calendar.HOUR) + ":"
+ calendar.get(Calendar.MINUTE) + ":"
+ calendar.get(Calendar.SECOND);
fos1.write(("Fetching Records Started At " + startDateStr + "\r\n")
.getBytes());
} catch (Exception e) {
System.out.println("Exception []::" + e.getMessage());
e.printStackTrace();
}
log ="intializingLog_Successesfull";
log = "intializingLog_Successesfull";
return log;
}
}
\ No newline at end of file
......@@ -7,407 +7,410 @@
package ibase.webitm.ejb.fin;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import ibase.utility.E12GenericUtility;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
@SuppressWarnings("unused")
@Stateless
public class EcollectionSubIC extends ValidatorEJB implements
EcollectionSubICLocal, EcollectionSubICRemote {
public class EcollectionSubIC extends ValidatorEJB implements EcollectionSubICLocal, EcollectionSubICRemote
{
E12GenericUtility genericUtility= new E12GenericUtility();
static E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
if (xmlString != null && xmlString.trim().length() > 0 )
{
try {
if (xmlString != null && xmlString.trim().length() > 0) {
dom = parseString(xmlString);
System.out.println("xmlString["+xmlString+"]");
printMessage("xmlString", xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0 )
{
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = parseString(xmlString1);
System.out.println("xmlString1["+xmlString1+"]");
printMessage("xmlString1", xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0 )
{
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = parseString(xmlString2);
System.out.println("xmlString2["+xmlString2+"]");
printMessage("xmlString2", xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EcollectionSubIC][wfValData( String, String )] :==>\n" + e.getMessage());
errString = wfValData(dom, dom1, dom2, objContext, editFlag,
xtraParams);
} catch (Exception e) {
printMessage("Exception wfValData[S]", e.getMessage());
throw new ITMException(e);
}
return(errString);
return errString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String childNodeName = null;
String errString = "";
String errCode = "";
String userId = "";
String sql = "";
String errorType = "";
String custCode="",bankCode="",lineNo="",rfDate="",tranIdRcp="",tranId="";
int cnt = 0;
int ctr=0,rcpformCnt=0,banktranCnt=0;
int childNodeListLength;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
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>");
int currentFormNo =0;
String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode="";
java.util.Date tranDate = null;
double rcpAmt=0,rcpAmtNew=0;
double isInvAmt=0;
SimpleDateFormat dateFormat2 = null;
Timestamp rfDatetmstmp=null;
Date currentDate = new Date();
try
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("@@@@@@@@ wfvaldata called");
//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;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
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("ref_no"))
{
refNo = this.genericUtility.getColumnValue("ref_no", dom);
rfDate = this.genericUtility.getColumnValue("ref_date", dom);
bankCode = this.genericUtility.getColumnValue("bank_code", dom);
siteCode = this.genericUtility.getColumnValue("site_code", dom);
tranId = this.genericUtility.getColumnValue("tran_id", dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom);
System.out.println("refNo>>>>>>" + refNo);
if (refNo != null && refNo.trim().length() > 0)
{
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rcpformCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
if (rcpformCnt > 1)
{
errCode = "VTINVREF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql = " select count(*) as cnt from bank_statement where site_code = ? and bank_code=? and ref_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
banktranCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
if (banktranCnt == 0)
{
errCode = "VTINREFNO1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String childNodeName = "", errString = "", errCode = "", userId = "", sql = "", errorType = "", custCode = "", bankCode = "", lineNo = "", rfDate = "", tranIdRcp = "", tranId = "", stmt_id = "", siteCode = "", rcpAmtStr = "", refSer = "", refNo = "", prdCode = "";
int cnt = 0, ctr = 0, rcpFormCnt = 0, bankTranCnt = 0, childNodeListLength = 0, currentFormNo = 0;
NodeList parentNodeList = null, childNodeList = null;
Node parentNode = null, childNode = null;
ArrayList<String> errList = new ArrayList<String>(), errFields = new ArrayList<String>();
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>");
java.util.Date tranDate = null;
double rcpAmt = 0, rcpAmtNew = 0, isInvAmt = 0;
SimpleDateFormat dateFormat2 = null;
Timestamp rfDatetmstmp = null;
Date currentDate = new Date();
try {
dateFormat2 = new SimpleDateFormat(
genericUtility.getApplDateFormat());
printMessage("call to wfValdata[D]", "Started");
// 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;
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
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();
if (rfDate != null)
{
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?";
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("ref_no")) {
refNo = checkNull(genericUtility.getColumnValue(
"ref_no", dom));
rfDate = checkNull(genericUtility.getColumnValue(
"ref_date", dom));
bankCode = checkNull(genericUtility.getColumnValue(
"bank_code", dom));
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
tranId = checkNull(genericUtility.getColumnValue(
"tran_id", dom));
custCode = checkNull(genericUtility.getColumnValue(
"cust_code", dom));
System.out.println("refNo -- -- " + refNo);
if (refNo != null && refNo.trim().length() > 0) {
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, refNo);
pstmt.setTimestamp(3, rfDatetmstmp);
pstmt.setString(4, tranId);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
tranIdRcp = checkNull(rs.getString("tran_id"));
if (rs.next()) {
rcpFormCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
/**
* Existing receipt found for above
* combination check the record from table
* rcpdishnr where receipt_no=tranIdRcp
* */
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
if (rcpFormCnt > 1) {
errCode = "VTINVREF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
/*
* sql =
* " select count(*) as cnt from bank_statement where site_code = ? and bank_code=? and ref_no=? "
* ; pstmt = conn.prepareStatement(sql);
* pstmt.setString(1, siteCode);
* pstmt.setString(2, bankCode);
* pstmt.setString(3, refNo); rs =
* pstmt.executeQuery(); if (rs.next()) {
* bankTranCnt = rs.getInt("cnt"); } rs.close();
* rs = null; pstmt.close(); pstmt = null;
*
* if (bankTranCnt == 0) { errCode =
* "VTINREFNO1"; errList.add(errCode);
* errFields.add(childNodeName.toLowerCase()); }
*/
if (rfDate != null && rfDate.trim().length() > 0) {
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
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);
pstmt.setString(2, refNo);
pstmt.setTimestamp(3, rfDatetmstmp);
pstmt.setString(4, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
if (rs.next()) {
tranIdRcp = checkNull(rs.getString("tran_id"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ Dishponer cnt :- [" + cnt + "]");
if (cnt == 0)
{
if (tranIdRcp != null && tranIdRcp.trim().length() > 0) {
/**
* Unconfirmed record found ERROR
* (Duplicate utr_no found)
* Existing receipt found for above
* combination check the record from
* table rcpdishnr where
* receipt_no=tranIdRcp
* */
errCode = "VTUTRDUPL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ Dishponer cnt :- [" + cnt + "]");
if (cnt == 0) {
// Unconfirmed record found ERROR (Duplicate utr_no found)
errCode = "VTUTRDUPL";
errList.add(errCode);
errFields.add(childNodeName
.toLowerCase());
}
}
}
} else {
errCode = "VTNULREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else
{
errCode = "VTNULREFNO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}else if (childNodeName.equalsIgnoreCase("ref_date") )
{
rfDate = this.genericUtility.getColumnValue("ref_date", dom);
if(rfDate == null || rfDate.trim().length()==0)
{
} else if (childNodeName.equalsIgnoreCase("ref_date")) {
rfDate = checkNull(genericUtility.getColumnValue("ref_date", dom));
if (rfDate == null || rfDate.trim().length() == 0) {
errCode = "VTNULREFDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}else
{
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(currentDate.before(rfDatetmstmp))
{
System.out.println("rfDatetmstmp < currentDate : "+rfDatetmstmp+" < "+currentDate);
} else {
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate,genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if (currentDate.before(rfDatetmstmp)) {
System.out.println("rfDatetmstmp < currentDate : " + rfDatetmstmp + " < " + currentDate);
errCode = "VTREFDTLE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
errFields.add(childNodeName.toLowerCase());
}
}
}
}// end for
break; // case 1 end
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
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;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
} else if (childNodeName.equalsIgnoreCase("stmt_id")) {
stmt_id = checkNull(genericUtility.getColumnValue("stmt_id", dom));
if (stmt_id.trim().length() > 0) {
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
String finEntity = "", bankGroup = "";
sql = " select fin_entity from site where site_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
finEntity = checkNull(rs.getString("fin_entity"));
}
printMessage("finEntity", finEntity);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select group_code from bank where bank_code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankGroup = checkNull(rs.getString("group_code"));
}
printMessage("bankGroup", bankGroup);
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
String colFormRef = "";
//sql = "select collection_form_ref from bank_statement where tran_id = ?";
sql = "select b.collection_form_ref from bank_statement b,site s,bank bank where s.fin_entity=? "
+ " and s.site_code=b.site_code "
+ " and bank.bank_code=b.bank_code and bank.group_code= ? "
+ " and b.tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity);
pstmt.setString(2, bankGroup);
pstmt.setString(3, stmt_id);
rs = pstmt.executeQuery();
if(rs.next()) {
colFormRef = checkNull(rs.getString(1));
} else {
errCode = "VTINVSTMID";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(colFormRef.trim().length() > 0){
errCode = "VTECSREFID";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}// end for
}
break; // case 1 end
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if (errList != null && errListSize > 0) {
for (cnt = 0; cnt < errListSize; cnt++) {
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
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;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
} else {
errStringXml = new StringBuffer("");
}
} catch (Exception e) {
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
} catch (Exception d) {
d.printStackTrace();
throw new ITMException(d);
}
errString = errStringXml.toString();
return errString;
}
errString = errStringXml.toString();
return errString;
}
//end of validation
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
// end of validation
private void printMessage(String fieldname, String value) {
System.out.println(this.getClass().getSimpleName().toUpperCase() + " : [" + fieldname + "][" + value + "]");
}
public String getRequiredDecimal(double actVal, int prec)
{
private String checkNull(String input) {
return input == null ? "" : input;
}
public String getRequiredDecimal(double actVal, int prec) {
String fmtStr = "############0";
if (prec > 0)
{
if (prec > 0) {
fmtStr = fmtStr + "." + "000000000".substring(0, prec);
}
DecimalFormat decFormat = new DecimalFormat(fmtStr);
return decFormat.format(actVal);
}
public static java.util.Date relativeDate(java.util.Date date, int days)
{
public static java.util.Date relativeDate(java.util.Date date, int days) {
java.util.Date calculatedDate = null;
if (date != null)
{
if (date != null) {
final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DATE,days);
calendar.add(Calendar.DATE, days);
calculatedDate = new java.util.Date(calendar.getTime().getTime());
}
}
return calculatedDate;
}
private String errorType(Connection conn , String errorCode) throws ITMException
{
private String errorType(Connection conn, String errorCode)
throws ITMException {
String msgType = "";
PreparedStatement pstmt = null ;
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);
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())
{
if (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception ex)
{
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if(rs != null)
{
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
}
return msgType;
}
}
}
[Dolphin]
HeaderColumnWidths=328,70,146
SortOrder=1
SortRole=date
Sorting=2
Timestamp=2016,6,10,11,6,27
Timestamp=2016,12,12,18,55,58
Version=3
ViewMode=1
......@@ -2,67 +2,65 @@
Title : EcollectionConf[F14ISUN014]
Date : 17/02/15
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
@Stateless
public class EcollectionConf extends ActionHandlerEJB implements EcollectionConfLocal, EcollectionConfRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf confirm called>>>>>>>>>>>>>>>>>>>");
String confirmed = "",siteCode="",bankCode="";
public class EcollectionConf extends ActionHandlerEJB implements
EcollectionConfLocal, EcollectionConfRemote {
public String confirm(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException {
System.out.println("Calling from " + this.getClass().getSimpleName() + " : confirm");
String confirmed = "", siteCode = "", bankCode = "";
String sql = "";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
String errString = null;
ResultSet rs = null;
String loginEmpCode="",status="",refNo="",tranIdRcp="",custCode="";
String finEntity="",bankstmtTranId="",bankGroup="";
int cnt = 0;
int rcpformCnt=0,rcpCnt=0;
double chqAmt=0.0;
Timestamp rfDate=null;
String loginEmpCode = "", status = "", refNo = "", tranIdRcp = "", custCode = "", stmtId = "";
String finEntity = "", bankstmtTranId = "", bankGroup = "";
int cnt = 0;
int rcpformCnt = 0, rcpCnt = 0;
double chqAmt = 0.0;
Timestamp rfDate = null;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
Timestamp sysDate = null;
E12GenericUtility genericUtility= new E12GenericUtility();
E12GenericUtility genericUtility = new E12GenericUtility();
try {
try
{
ConnDriver connDriver = null;
connDriver = new 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
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("@@@@@tranId"+tranId+"]");
sql = " select confirmed,status,ref_no,site_code,bank_code,cust_code,ref_date,chq_amt from receipt_form where tran_id = ? ";
if (tranId != null && tranId.trim().length() > 0) {
System.out.println("@@@@@tranId" + tranId + "]");
//Commented by Tajuddin Mahadi to include Statement Id while confirming.
//sql = " select confirmed,status,ref_no,site_code,bank_code,cust_code,ref_date,chq_amt from receipt_form where tran_id = ? ";
sql = "SELECT confirmed, status, ref_no, site_code, bank_code, cust_code, ref_date, chq_amt, stmt_id from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
confirmed = rs.getString("confirmed");
status = rs.getString("status");
refNo = rs.getString("ref_no");
......@@ -71,215 +69,211 @@ conn = getConnection();
custCode = rs.getString("cust_code");
rfDate = rs.getTimestamp("ref_date");
chqAmt = rs.getDouble("chq_amt");
stmtId = rs.getString("stmt_id");
}
System.out.println("refNo>>>>>>>>"+refNo);
System.out.println("rfDate>>>>>>>>"+rfDate);
System.out.println("refNo>>>>>>>>" + refNo);
System.out.println("rfDate>>>>>>>>" + rfDate);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("S".equalsIgnoreCase(status))
{
if (refNo == null || refNo.trim().length() == 0)
{
errString = itmDBAccessLocal.getErrorString("", "VTNULREFNO", "");
return errString;
}else if (rfDate == null)
{
errString = itmDBAccessLocal.getErrorString("", "VTNULREFDT", "");
return errString;
} else
{
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
rcpformCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
if( rcpformCnt > 1 )
{
errString = itmDBAccessLocal.getErrorString("", "VTINVREF", "");
if ("S".equalsIgnoreCase(status)) {
if (refNo == null || refNo.trim().length() == 0) {
errString = itmDBAccessLocal.getErrorString("", "VTNULREFNO", "");
return errString;
}
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);
pstmt.setString(2, refNo);
pstmt.setTimestamp(3, rfDate);
pstmt.setString(4, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
tranIdRcp=checkNull(rs.getString("tran_id"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (tranIdRcp != null && tranIdRcp.trim().length()>0)
{
/**
* Existing receipt found
* for above combination
* check the record from table rcpdishnr
* where receipt_no=tranIdRcp
* */
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
} else if (rfDate == null) {
errString = itmDBAccessLocal.getErrorString("", "VTNULREFDT", "");
return errString;
} else {
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt("cnt");
}
if (rs.next()) {
rcpformCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@V@ Dishponer cnt :- ["+cnt+"]");
if(cnt==0)
{
/**
* Unconfirmed record found
* ERROR (Duplicate utr_no found)
* */
errString = itmDBAccessLocal.getErrorString("", "VTUTRDUPL", "");
if (rcpformCnt > 1) {
errString = itmDBAccessLocal.getErrorString("", "VTINVREF", "");
return errString;
}
}
System.out.println("@V@ Tran id receipt :- ["+tranIdRcp+"]");
if ("Y".equalsIgnoreCase(confirmed))
{
errString = itmDBAccessLocal.getErrorString("", "VTINVCONF2", "");
return errString;
} else
{
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
//Start added by chandr shekar on 18-mar-2016
sql = " select fin_entity from site where site_code=? ";
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, siteCode);
pstmt.setString(1, custCode);
pstmt.setString(2, refNo);
pstmt.setTimestamp(3, rfDate);
pstmt.setString(4, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
finEntity =checkNull(rs.getString("fin_entity"));
if (rs.next()) {
tranIdRcp = checkNull(rs.getString("tran_id"));
}
System.out.println("finEntity>>>>>>>>"+finEntity);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select group_code from bank where bank_code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
if (tranIdRcp != null && tranIdRcp.trim().length() > 0) {
/**
* Existing receipt found for above combination
* check the record from table rcpdishnr where
* receipt_no=tranIdRcp
* */
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
bankGroup =checkNull(rs.getString("group_code"));
}
System.out.println("bankGroup>>>>>>>>"+bankGroup);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select b.tran_id from bank_statement b,site s,bank bank where s.fin_entity=? " +
" and s.site_code=b.site_code " +
" and bank.bank_code=b.bank_code and bank.group_code= ? "+
" and b.ref_no=? and b.ref_date=? and b.amount=? and b.collection_form_ref is null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity);
pstmt.setString(2, bankGroup);
pstmt.setString(3, refNo);
pstmt.setTimestamp(4, rfDate);
pstmt.setDouble(5, chqAmt);
rs = pstmt.executeQuery();
if (rs.next())
{
System.out.println("@V@ Dishponer cnt :- [" + cnt
+ "]");
if (cnt == 0) {
/**
* Unconfirmed record found ERROR (Duplicate
* utr_no found)
* */
errString = itmDBAccessLocal.getErrorString("",
"VTUTRDUPL", "");
return errString;
}
bankstmtTranId =checkNull(rs.getString("tran_id"));
}
System.out.println("bankstmtTranId>>>>>>>>"+bankstmtTranId);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(bankstmtTranId.trim().length() == 0)
{
sql = " update receipt_form set remarks = 'Bank statement Tran Id is not found.',status= 'R' where tran_id = ? ";
System.out.println("@V@ Tran id receipt :- ["
+ tranIdRcp + "]");
if ("Y".equalsIgnoreCase(confirmed)) {
errString = itmDBAccessLocal.getErrorString("", "VTINVCONF2", "");
return errString;
} else {
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
/*Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
// Start added by chandr shekar on 18-mar-2016
sql = " select fin_entity from site where site_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
if (cnt > 0)
{
conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTCONFREJ", "");
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
finEntity = checkNull(rs.getString("fin_entity"));
}
System.out.println("finEntity>>>>>>>>" + finEntity);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}else
{
// End added by chandrshekar on 18-mar-2016
sql = " update receipt_form set confirmed = 'Y',conf_date = ?, emp_code__aprv = ? " +
" ,status= 'C',stmt_id= ? where tran_id = ? ";
sql = "select group_code from bank where bank_code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate);
pstmt.setString(2, loginEmpCode);
pstmt.setString(3, bankstmtTranId);
pstmt.setString(4, tranId);
cnt = pstmt.executeUpdate();
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankGroup = checkNull(rs.getString("group_code"));
}
System.out.println("bankGroup>>>>>>>>" + bankGroup);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
conn.commit();
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
sql = "select b.tran_id from bank_statement b,site s,bank bank where s.fin_entity=? "
+ " and s.site_code=b.site_code "
+ " and bank.bank_code=b.bank_code and bank.group_code= ? "
+ " and b.ref_no=? and b.ref_date=? and b.amount=? and b.collection_form_ref is null";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity);
pstmt.setString(2, bankGroup);
pstmt.setString(3, refNo);
pstmt.setTimestamp(4, rfDate);
pstmt.setDouble(5, chqAmt);
rs = pstmt.executeQuery();
if (rs.next()) {
bankstmtTranId = checkNull(rs.getString("tran_id"));
}
System.out.println("bankstmtTranId>>>>>>>>" + bankstmtTranId);
rs.close();
rs = null;
pstmt.close();
pstmt = null;*/
/*if (bankstmtTranId.trim().length() == 0) {
sql = "select stmt_id from receipt_form where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next()) {
sql = "update receipt_form set confirmed = 'Y',conf_date = ?, emp_code__aprv = ?," +
" status= 'C' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate);
pstmt.setString(2, loginEmpCode);
pstmt.setString(3, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0) {
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
conn.commit();
} else {
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
}
} else {
sql = " update receipt_form set remarks = remarks where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
if (cnt > 0) {
conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTCONFREJ", "");
}
pstmt.close();
pstmt = null;
}
}*/
// else {
// End added by chandrshekar on 18-mar-2016
sql = " update receipt_form set confirmed = 'Y', conf_date = sysdate, emp_code__aprv = ?, status= 'C' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginEmpCode);
pstmt.setString(2, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0) {
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
conn.commit();
} else {
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
}
//}
}
}
}
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNSUBCON", "");
} else {
errString = itmDBAccessLocal.getErrorString("",
"VTNSUBCON", "");
}
}
// end if errstrng
} catch (Exception e)
{
if(conn!=null)
{
} catch (Exception e) {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException ex) {
......@@ -290,71 +284,58 @@ conn = getConnection();
}
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null && !conn.isClosed())
{
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
conn = null;
}
if(rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf submit called>>>>>>>>>>>>>>>>>>>");
String sql = "",status="",confirmed="";
public String submit(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException {
System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf submit called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "", confirmed = "";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
ResultSet rs = null;
int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try
{
try {
ConnDriver connDriver = null;
connDriver = new 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
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("tranId>>>["+tranId+"]");
if (tranId != null && tranId.trim().length() > 0) {
System.out.println("tranId>>>[" + tranId + "]");
sql = " select status,confirmed from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
status = rs.getString("status");
confirmed = rs.getString("confirmed");
}
......@@ -362,161 +343,135 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
if ("S".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB2","");
return errString;
}else if ("X".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB4","");
if ("S".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTINVSUB2", "");
return errString;
} else if ("C".equalsIgnoreCase(status) || "Y".equalsIgnoreCase(confirmed))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB3","");
} else if ("X".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTINVSUB4", "");
return errString;
}else if ("R".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB5","");
} else if ("C".equalsIgnoreCase(status)
|| "Y".equalsIgnoreCase(confirmed)) {
errString = itmDBAccessLocal.getErrorString("",
"VTINVSUB3", "");
return errString;
} else if ("P".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTECLNPRC1","");
} else if ("R".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTINVSUB5", "");
return errString;
}else
{
} else if ("P".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTECLNPRC1", "");
return errString;
} else {
sql = " update receipt_form set status = 'S' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0)
{
errString = itmDBAccessLocal.getErrorString("", "VTSTATSUBM", "");
conn.commit();
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
if (cnt > 0) {
errString = itmDBAccessLocal.getErrorString("",
"VTSTATSUBM", "");
conn.commit();
} else {
errString = itmDBAccessLocal.getErrorString("",
"VTNCONFT", "");
}
}
}
// end if errstrng
} catch (Exception e)
{
if(conn!=null)
{
} catch (Exception e) {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException ex) {
e.printStackTrace();
throw new ITMException(e);
}
}
e.printStackTrace();
throw new ITMException(e);
} finally
{
try
{
if(conn != null && !conn.isClosed())
{
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
conn = null;
}
if(rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e)
{
} catch (Exception e) {
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
public String open(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf open called>>>>>>>>>>>>>>>>>>>");
String sql = "",status="";
public String open(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException {
System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf open called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
ResultSet rs = null;
int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try
{
try {
ConnDriver connDriver = null;
connDriver = new 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
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("tranId>>>["+tranId+"]");
if (tranId != null && tranId.trim().length() > 0) {
System.out.println("tranId>>>[" + tranId + "]");
sql = " select status from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
status = rs.getString("status");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("R".equalsIgnoreCase(status) || "X".equalsIgnoreCase(status))
{
if ("R".equalsIgnoreCase(status) || "X".equalsIgnoreCase(status)) {
sql = " update receipt_form set status = 'E',confirmed = 'N' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0)
{
if (cnt > 0) {
conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTECOLOPEN", "");
errString = itmDBAccessLocal.getErrorString("",
"VTECOLOPEN", "");
}
}else
{
errString = itmDBAccessLocal.getErrorString("","VTECNOTREJ","");
} else {
errString = itmDBAccessLocal.getErrorString("",
"VTECNOTREJ", "");
}
}
// end if errstrng
} catch (Exception e)
{
if(conn!=null)
{
} catch (Exception e) {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException ex) {
......@@ -527,28 +482,22 @@ conn = getConnection();
}
e.printStackTrace();
throw new ITMException(e);
} finally
{
try
{
if(conn != null && !conn.isClosed())
{
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
conn = null;
}
if(rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e)
{
} catch (Exception e) {
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
......@@ -558,37 +507,33 @@ conn = getConnection();
return errString;
}
public String cancel(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf cancel called>>>>>>>>>>>>>>>>>>>");
String sql = "",status="",confirmed="";
public String cancel(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException {
System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf cancel called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "", confirmed = "";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
ResultSet rs = null;
int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try
{
try {
ConnDriver connDriver = null;
connDriver = new 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
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("tranId>>>["+tranId+"]");
if (tranId != null && tranId.trim().length() > 0) {
System.out.println("tranId>>>[" + tranId + "]");
sql = " select status,confirmed from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.next()) {
status = rs.getString("status");
confirmed = rs.getString("confirmed");
}
......@@ -596,38 +541,37 @@ conn = getConnection();
rs = null;
pstmt.close();
pstmt = null;
if (!"X".equalsIgnoreCase(status) && !"C".equalsIgnoreCase(status) && !"P".equalsIgnoreCase(status))
{
if (!"X".equalsIgnoreCase(status)
&& !"C".equalsIgnoreCase(status)
&& !"P".equalsIgnoreCase(status)) {
sql = " update receipt_form set status = 'X' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0)
{
if (cnt > 0) {
conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTECLNCAN", "");
errString = itmDBAccessLocal.getErrorString("",
"VTECLNCAN", "");
}
}else if("X".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTECLNCANX","");
}else if("C".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTECLNCANC","");
}else if("P".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTECLNPRC","");
} else if ("X".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTECLNCANX", "");
} else if ("C".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTECLNCANC", "");
} else if ("P".equalsIgnoreCase(status)) {
errString = itmDBAccessLocal.getErrorString("",
"VTECLNPRC", "");
}
}
// end if errstrng
} catch (Exception e)
{
if(conn!=null)
{
} catch (Exception e) {
if (conn != null) {
try {
conn.rollback();
} catch (SQLException ex) {
......@@ -638,28 +582,22 @@ conn = getConnection();
}
e.printStackTrace();
throw new ITMException(e);
} finally
{
try
{
if(conn != null && !conn.isClosed())
{
} finally {
try {
if (conn != null && !conn.isClosed()) {
conn.close();
conn = null;
}
if(rs != null)
{
if (rs != null) {
rs.close();
rs = null;
}
if(pstmt != null)
{
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e)
{
} catch (Exception e) {
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
......@@ -669,15 +607,12 @@ conn = getConnection();
return errString;
}
private String checkNull(String str)
{
if(str == null)
{
private String checkNull(String str) {
if (str == null) {
return "";
}
else
{
return str ;
} else {
return str;
}
}
......
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