Commit 707e83be authored by ngadkari's avatar ngadkari

Provision needed to transfer positive payable to negative receivables and...

Provision needed to transfer positive payable to negative receivables and similarly provision needed to transfer positive receivables to negative paya 

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@183982 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b5226d56
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import ibase.utility.E12GenericUtility;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Session Bean implementation class PayRecXfrIC
*/
@Stateless
public class PayRecXfrIC extends ValidatorEJB implements PayRecXfrICRemote, PayRecXfrICLocal {
/**
* Default constructor.
*/
public PayRecXfrIC() {
}
E12GenericUtility genericUtility = new E12GenericUtility();
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
E12GenericUtility genericUtility = new E12GenericUtility();
System.out.println("----------------Inside RecPayXfrIC itemChanged-------------------");
try {
System.out.println("xmlString::["+xmlString+"]\nxmlString1::["+xmlString1+"]\nxmlString2::["+xmlString2+"]");
if (xmlString != null && xmlString.trim().length() > 0) {
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0) {
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0) {
dom2 = genericUtility.parseString(xmlString2);
}
retString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} catch (Exception e) {
System.out.println("Exception: RecPayXfrIC: itemChanged:" + this.getClass().getSimpleName() + "::" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String loginSite="";
String dateNow="";
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0, ctr = 0;
Timestamp currentDate= null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
try {
System.out.println("******************* NANDKUMAR GADKARI *******************");
System.out.println("----------------Inside itemChanged-------------------");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currentDate = new Timestamp(System.currentTimeMillis());
dateNow = (sdf.format(currentDate).toString()).trim();
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1 : parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if(childNode.getFirstChild() != null)
{
}
}
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("loginSite::["+loginSite+"]");
System.out.println("----------- inside itm_default ---------------");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + dateNow + "]]>").append("</tran_date>");
}
valueXmlString.append("</Detail1>");
break;
}//switch
valueXmlString.append("</Root>");
System.out.println("------ItemChanged::valueXmlString["+valueXmlString+"]");
}catch(Exception e)
{
System.out.println("Exception: RecPayXfrIC: itemChanged:" + this.getClass().getSimpleName() + "::" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next()) {
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (Exception ex) {
ex.printStackTrace();
throw new ITMException(ex);
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
private String checkNull(String str) {
if (str == null) {
return "";
} else {
return str;
}
}
private String checkNullAndTrim(String inputVal)
{
if ( inputVal == null )
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface PayRecXfrICLocal extends ValidatorLocal {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, 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;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface PayRecXfrICRemote extends ValidatorRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, 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;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.sql.*;
import ibase.system.config.AppConnectParm;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.utility.UserInfoBean;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.fin.PayRecXfrPrcRemote;
import ibase.webitm.ejb.fin.PayRecXfrPrcLocal;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@Stateless
public class PayRecXfrPrc extends ProcessEJB implements PayRecXfrPrcLocal , PayRecXfrPrcRemote{
String siteCode = "";
String payableV="";
String sdueDate = "",sdueDateTo="";
java.sql.Timestamp dueDateTo = null ,dueDateFrom = null;
String suppCodefrom ="";
String suppCodeTo ="";
E12GenericUtility genericUtility = new E12GenericUtility();
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0 )
{
System.out.println("XML String :::-:"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :::-:"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :PayRecXfrPrc :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
return rtrStr;
}
//getData()
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String errCode = "";
String errString = "";
String resultString = "";;
String getDataSql1= "",getDataSql2="",getDataSql3="";
String tempString = null;
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
Statement st = null;
StringBuffer retTabSepStrBuff = new StringBuffer("<?xml version = \"1.0\"?>");
retTabSepStrBuff.append("<DocumentRoot>");
retTabSepStrBuff.append("<description>").append("Datawindow Root").append("</description>");
retTabSepStrBuff.append("<group0>");
retTabSepStrBuff.append("<description>").append("Group0 description").append("</description>");
retTabSepStrBuff.append("<Header0>");
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
System.out.println("xtraParams $$$$$$$$$$$$$$$$$$$$$$$$ "+xtraParams);
String userId = "";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
String sql = "";
SimpleDateFormat sdf=null;
double netAmt =0 ,totAmt=0 , adjAmt=0;
try
{
conn = getConnection();
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
siteCode = genericUtility.getColumnValue("site_code",headerDom);
System.out.println("siteCode------>"+ siteCode);
if(siteCode == null || siteCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMSITECD1","","",conn);
return errString;
}
if(siteCode != null && siteCode.trim().length() != 0)
{
try
{
int count = 0;
sql = "SELECT COUNT(1) AS COUNT FROM SITE WHERE SITE_CODE = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode.trim());
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("COUNT");
System.out.println("SITE_CODE count is ::- "+count );
}
if(count == 0)
{
errCode = "VMSITE1";
errString = itmDBAccessEJB.getErrorString("site_code",errCode,userId,"",conn);
return errString;
}
rs.close();
pstmt.close();
}
catch(Exception ex)
{
System.out.println("Exception []::"+sql+ex.getMessage());
ex.printStackTrace();
}
}
sdueDate = genericUtility.getColumnValue("due_date__fr",headerDom);
System.out.println("due_date from is :::"+sdueDate);
if ( sdueDate == null || sdueDate.trim().length() == 0 )
{
sdueDate = "";
System.out.println("due_date is null.............");
errString = itmDBAccessEJB.getErrorString("","INVDT1","","",conn);
return errString;
}
sdueDate = genericUtility.getValidDateString(sdueDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dueDateFrom = java.sql.Timestamp.valueOf(sdueDate + " 00:00:00");
System.out.println("Due Date **..........................**:"+dueDateFrom);
sdueDateTo = genericUtility.getColumnValue("due_date__to",headerDom);
System.out.println("due_date to is :::"+sdueDateTo);
if ( sdueDateTo == null || sdueDateTo.trim().length() == 0 )
{
sdueDateTo = "";
System.out.println("due_date is null.............");
errString = itmDBAccessEJB.getErrorString("","INVDT1","","",conn);
return errString;
}
sdueDateTo = genericUtility.getValidDateString(sdueDateTo, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat());
dueDateTo = java.sql.Timestamp.valueOf(sdueDateTo + " 00:00:00");
System.out.println("Due Date to **..........................**:"+dueDateTo);
suppCodefrom = genericUtility.getColumnValue("sundry_code__fr",headerDom);
if ( suppCodefrom == null || suppCodefrom.equals("null") || suppCodefrom.trim().length() == 0 )
{
suppCodefrom = "";
errString = itmDBAccessEJB.getErrorString("","VTBLNKPRD","","",conn);
return errString;
}
suppCodeTo = genericUtility.getColumnValue("sundry_code__to",headerDom);
if ( suppCodeTo == null || suppCodeTo.equals("null") || suppCodeTo.trim().length() == 0 )
{
suppCodeTo = "";
errString = itmDBAccessEJB.getErrorString("","VTBLNKPRD","","",conn);
return errString;
}
payableV =genericUtility.getColumnValue("xfr_pay",headerDom);
if ( payableV == null || payableV.equals("null") || payableV.trim().length() == 0 )
{
payableV = "";
errString = itmDBAccessEJB.getErrorString("","VTBLNKPRD","","",conn);
return errString;
}
st = conn.createStatement();
try
{
getDataSql1= "SELECT M.SUNDRY_CODE,S.SUPP_NAME,M.TRAN_SER,M.TRAN_DATE, M.REF_NO, M.REF_DATE,M.TOT_AMT,M.ADJ_AMT,"
+"M.ACCT_CODE,M.CCTR_CODE, M.TRAN_ID,M.CURR_CODE, M.EXCH_RATE,M.DUE_DATE, M.SITE_CODE,M.FIN_ENTITY,M.BANK_CODE "
+"from MISC_PAYABLES M, SUPPLIER S "
+"where ( M.SUNDRY_CODE = S.SUPP_CODE) "
+ "and ( ( M.due_date between ? and ? )"
+ " and ( M.sundry_code between ? and ? ) "
+ "and ( M.site_code = ? ) ";
if("N".equalsIgnoreCase(payableV.trim()))
{
getDataSql1 = getDataSql1 + " AND ( M.tot_amt < 0 ) ";
}
if("P".equalsIgnoreCase(payableV.trim()))
{
getDataSql1 = getDataSql1 + " AND ( M.tot_amt > 0 ) ";
}
getDataSql1= getDataSql1 + "and ( M.tot_amt - M.adj_amt <> 0 ) ) ";
pstmt = conn.prepareStatement(getDataSql1);
System.out.println("The getDataSql becomes .................:"+getDataSql1);
pstmt.setTimestamp(1,dueDateFrom);
pstmt.setTimestamp(2,dueDateTo);
pstmt.setString(3,suppCodefrom);
pstmt.setString(4,suppCodeTo);
pstmt.setString(5,siteCode);
rs = pstmt.executeQuery();
while (rs.next())
{
retTabSepStrBuff.append("<Detail2>");
retTabSepStrBuff.append("<sundry_code>").append("<![CDATA[" + rs.getString(1) +"]]>").append("</sundry_code>");
retTabSepStrBuff.append("<supp_name>").append("<![CDATA[" + rs.getString(2) +"]]>").append("</supp_name>");
retTabSepStrBuff.append("<tran_ser>").append("<![CDATA[" + rs.getString(3) +"]]>").append("</tran_ser>");
retTabSepStrBuff.append("<tran_date>").append("<![CDATA[" +sdf.format( rs.getTimestamp(4)) +"]]>").append("</tran_date>");
retTabSepStrBuff.append("<ref_no>").append("<![CDATA[" + rs.getString(5) +"]]>").append("</ref_no>");
retTabSepStrBuff.append("<ref_date>").append("<![CDATA[" +sdf.format( rs.getTimestamp(6)) +"]]>").append("</ref_date>");
retTabSepStrBuff.append("<tot_amt>").append("<![CDATA[" + rs.getDouble(7) +"]]>").append("</tot_amt>");
retTabSepStrBuff.append("<adj_amt>").append("<![CDATA[" + rs.getDouble(8) +"]]>").append("</adj_amt>");
totAmt = rs.getDouble(7) ;
adjAmt= rs.getDouble(8);
netAmt = totAmt - adjAmt;
retTabSepStrBuff.append("<net_amt>").append("<![CDATA[" + netAmt +"]]>").append("</net_amt>");
retTabSepStrBuff.append("<acct_code>").append("<![CDATA[" + rs.getString(9) +"]]>").append("</acct_code>");
retTabSepStrBuff.append("<cctr_code>").append("<![CDATA[" + rs.getString(10) +"]]>").append("</cctr_code>");
retTabSepStrBuff.append("<tran_id>").append("<![CDATA[" + rs.getString(11) +"]]>").append("</tran_id>");
retTabSepStrBuff.append("<curr_code>").append("<![CDATA[" + rs.getString(12) +"]]>").append("</curr_code>");
retTabSepStrBuff.append("<exch_rate>").append("<![CDATA[" + rs.getDouble(13) +"]]>").append("</exch_rate>");
if(rs.getTimestamp("DUE_DATE") == null)
{
//retTabSepStrBuff.append("").append("\t");
retTabSepStrBuff.append("<due_date>").append("<![CDATA[]]>").append("</due_date>");
}
else
{
retTabSepStrBuff.append("<due_date>").append("<![CDATA[" +sdf.format( rs.getTimestamp(14)) +"]]>").append("</due_date>");
}
retTabSepStrBuff.append("<site_code>").append("<![CDATA[" + rs.getString(15) +"]]>").append("</site_code>");
retTabSepStrBuff.append("<fin_entity>").append("<![CDATA[" + rs.getString(16) +"]]>").append("</fin_entity>");
retTabSepStrBuff.append("<bank_code>").append("<![CDATA[" + rs.getString(17) +"]]>").append("</bank_code>");
retTabSepStrBuff.append("</Detail2>");
retTabSepStrBuff.append("\n");
}
//while
retTabSepStrBuff.append("</Header0>\r\n");
retTabSepStrBuff.append("</group0>\r\n");
retTabSepStrBuff.append("</DocumentRoot>\r\n");
System.out.println("xml:::::::::::gateData>"+ retTabSepStrBuff);
resultString = retTabSepStrBuff.toString();
}//try
catch (SQLException e)
{
System.out.println("SQLException ::PayRecXfrPrc :" +sql+ e.getMessage() + ":");
throw new ITMException(e);
}
if (!errCode.equals(""))
{
resultString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
System.out.println("resultString.........: " + resultString);
}
}//try
catch (Exception e)
{
System.out.println("Exception :PayRecXfrPrc :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}
catch(Exception e)
{}
}
return resultString;
}
//process()
/*******************************************************************************************
1. Function for transferring the payables to receivables .
2. The payable is adjusted and a new record is inserted in to recivables.
********************************************************************************************/
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
System.out.println("xmlString :::"+ xmlString);
System.out.println("xmlString2 :::"+ xmlString2);
System.out.println("below genericUtility :::-");
try
{
System.out.println("inside try1 block :::");
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom " + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom " + detailDom);
}
System.out.println("windowName" + windowName);
System.out.println("xtraParams" + xtraParams);
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :PayRecXfrPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("DetailDom ::"+ detailDom);
String childNodeName = "";
String siteCode = "",loginSite="";
String stringxmlInvString = "";
String custCode = "",suppName="",tranSer="",sTranDate="",refNo="",sRefDate="",sTotAmt="",sAdjAmt="",acctCode="";
String cctrCode = "",currCode="",sExchRate="",sDueDate="",finEntity="",bankCode="",refSerPay="",keyString="",recvTranID="";
double totAmt=0,adjAmt=0,fTotAmt=0,fAdjAmt=0,exchRate=0;
String errCode = "";
String errString = "";
String insertSql = "",sql="";
String drawnAt = null;
Connection conn = null;
Statement st = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
java.sql.Timestamp instr_Date = null;
Timestamp dueDate = null;
Timestamp refDate = null;
Timestamp statDate = null;
int lineNumber = 0;
int updCnt = 0,cnt=0;
int parentNodeListLength = 0;
int childNodeListLength = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
boolean flag = false;
Timestamp tranDate = null;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//HashMap<String, String> hdrMap = null;
try
{
conn = getConnection();
sTranDate = checkNull(genericUtility.getColumnValue("tran_date", headerDom));
if(sTranDate != null && sTranDate.trim().length() > 0){
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(sTranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("ParentNodeListLength ..........."+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
custCode = checkNull(genericUtility.getColumnValueFromNode("sundry_code", parentNode));
suppName=checkNull(genericUtility.getColumnValueFromNode("supp_name", parentNode));
tranSer=checkNull(genericUtility.getColumnValueFromNode("tran_ser", parentNode));
//tranDate=checkNull(genericUtility.getColumnValueFromNode("tran_date", parentNode));
refNo=checkNull(genericUtility.getColumnValueFromNode("ref_no", parentNode));
sRefDate=checkNull(genericUtility.getColumnValueFromNode("ref_date", parentNode));
if(sRefDate != null){
refDate = Timestamp.valueOf(genericUtility.getValidDateString(sRefDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
sTotAmt=checkNull(genericUtility.getColumnValueFromNode("tot_amt", parentNode));
if(sTotAmt != null && sTotAmt.trim().length() > 0)
{
totAmt = Double.parseDouble(sTotAmt);
}else
{
totAmt = 0;
}
sAdjAmt=checkNull(genericUtility.getColumnValueFromNode("adj_amt", parentNode));
if(sAdjAmt != null && sAdjAmt.trim().length() > 0)
{
adjAmt = Double.parseDouble(sAdjAmt);
}else{
adjAmt = 0;
}
acctCode=checkNull(genericUtility.getColumnValueFromNode("acct_code", parentNode));
cctrCode =checkNull(genericUtility.getColumnValueFromNode("cctr_code", parentNode));
//tranId=checkNull(genericUtility.getColumnValueFromNode("tran_id", parentNode));
currCode=checkNull(genericUtility.getColumnValueFromNode("curr_code", parentNode));
sExchRate=checkNull(genericUtility.getColumnValueFromNode("exch_rate", parentNode));
if(sExchRate != null && sExchRate.trim().length() > 0)
{
exchRate = Double.parseDouble(sExchRate);
}else{
exchRate = 0;
}
sDueDate=checkNull(genericUtility.getColumnValueFromNode("due_date", parentNode));
if(sDueDate != null){
dueDate = Timestamp.valueOf(genericUtility.getValidDateString(sDueDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
siteCode=checkNull(genericUtility.getColumnValueFromNode("site_code", parentNode));
finEntity=checkNull(genericUtility.getColumnValueFromNode("fin_entity", parentNode));
bankCode=checkNull(genericUtility.getColumnValueFromNode("bank_code", parentNode));
sql = "update receivables set adj_amt = tot_amt, stat_date = ?, status = 'A' " +
" where tran_ser = ? " +
" and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setString(2, tranSer);
pstmt.setString(3, refNo);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
//Generate receivables tran Id
sql =" SELECT KEY_STRING FROM TRANSETUP WHERE upper(TRAN_WINDOW) = 'T_RCVABLES'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
keyString = rs.getString("KEY_STRING");
}
rs.close();
rs=null;
pstmt.close();
pstmt = null;
String XMLString = "<?xml version=\"1.0\"?>\r\n<Root>\r\n<header>"+
"\r\n</header><Detail1>"+
"\r\n<site_code>"+siteCode+"</site_code>\r\n<tran_date>"+tranDate+"</tran_date></Detail1></Root>";
CommonConstants.setIBASEHOME();
TransIDGenerator tg = new TransIDGenerator(XMLString,"SYSTEM",CommonConstants.DB_NAME); //FOR DB2
recvTranID = tg.generateTranSeqID("RCVL","tran_id",keyString,conn);
System.out.println("Transaction Id Generated for Receivables :"+recvTranID);
totAmt = totAmt - adjAmt;
refSerPay="TEST";
insertSql= "insert into receivables(tran_id ,tran_ser ,tran_date ,ref_no ,ref_date,curr_code,exch_rate,cust_code,acct_code,"
+ "cctr_code,due_date,fin_entity, site_code, tot_amt,adj_amt,status ,stat_date, bank_code)"
+ "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(insertSql);
pstmt.setString(1,recvTranID);
pstmt.setString(2,refSerPay);
pstmt.setTimestamp(3,tranDate);
pstmt.setString(4,refNo);
pstmt.setTimestamp(5,refDate);
pstmt.setString(6,currCode);
pstmt.setDouble(7,exchRate);
pstmt.setString(8,custCode);
pstmt.setString(9,acctCode);
pstmt.setString(10,cctrCode);
pstmt.setTimestamp(11,dueDate);
pstmt.setString(12,finEntity);
pstmt.setString(13,siteCode);
pstmt.setDouble(14,totAmt * (-1));
pstmt.setDouble(15,0);
pstmt.setString(16,"U");
pstmt.setTimestamp(17,tranDate);
pstmt.setString(18,bankCode);
int count = pstmt.executeUpdate();
if(count < 1)
{
errString = "DS000 : Insert Into Receivables Failed";
return(errString);
}
pstmt.close();
pstmt =null;
if (errString == null || errString.trim().length() == 0) {
errString = itmDBAccessEJB.getErrorString("","VTCOMPL","","",conn);
if(conn != null){
conn.commit();
System.out.println("commited....!!!");
}
return errString;
}
}
}//try end
catch(Exception e)
{
System.out.println("Exception :PeriodStatUdpPrcEJB ::" + e.getMessage() + ":");
try
{
conn.rollback();
} catch (Exception d)
{
System.out.println("Exception : pay_rec_xfer =>"+ d.toString());
d.printStackTrace();
d.printStackTrace();
errString = d.getMessage();
throw new ITMException(d);
}
}
finally
{
System.out.println("Closing Connection....");
try
{
conn.close();
conn = null;
}
catch(Exception se){}
}
System.out.println("errString: "+errString);
return errString;
}
private String checkNullAndTrim(String inputVal)
{
if ( inputVal == null || "null".equals(inputVal))
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
private String checkNull(String input)
{
if (input == null || "null".equals(input))
{
input = "";
}
return input;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.utility.ITMException;
@Local
public interface PayRecXfrPrcLocal extends ibase.webitm.ejb.ProcessLocal{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.utility.ITMException;
@Remote
public interface PayRecXfrPrcRemote extends ibase.webitm.ejb.ProcessRemote{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
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