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