Commit ab8befc4 authored by kshinde's avatar kshinde

Reverse advance adjusted in receipt from undo Receivable process

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@198470 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b2c3e27d
......@@ -84,7 +84,7 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
String sql = "";
SimpleDateFormat sdf=null;
double netAmt =0 ,totAmt=0 , adjAmt=0;
String refNoHeader="",tranType="",tranId="",remarks="",refNo="",refSer="",custCode="",itemSer="";
String refNoHeader="",tranSer="",tranId="",remarks="",refNo="",refSer="",custCode="",itemSer="";
int rows = 0;
try
{
......@@ -110,14 +110,15 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
refNoHeader = "";
}
/*tranType = genericUtility.getColumnValue("tran_type",headerDom);
if ( tranType == null || tranType.equals("null") || tranType.trim().length() == 0 )
tranSer = genericUtility.getColumnValue("tran_type",headerDom);
if ( tranSer == null || tranSer.equals("null") || tranSer.trim().length() == 0 )
{
tranType = "S-INV";
tranSer = "";
}*/
}
custCode = genericUtility.getColumnValue("cust_code",headerDom);
......@@ -131,7 +132,14 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
try
{
if("R-ADV".equalsIgnoreCase(tranSer.trim()))
{
getDataSql1 = "select ref_no_adj,ref_ser_adj,adj_amt,tot_amt,net_amt from receivables_adj where ref_no= ? and ref_ser='R-ADV' ";
}
else
{
getDataSql1 = "select ref_no,ref_ser,adj_amt,tot_amt,net_amt from receivables_adj where ref_no_adj= ? ";
}
// + "and ref_ser_adj= ?";
pstmt = conn.prepareStatement(getDataSql1);
......@@ -151,6 +159,7 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
totAmt =rs.getDouble(4);
netAmt =rs.getDouble(5);
//retTabSepStrBuff.append("<Detail2>");
retTabSepStrBuff.append("<Detail2 domID=\""+cnt+"\" selected=\""+"Y"+"\" > \r\n");
retTabSepStrBuff.append("<attribute selected=\""+"Y"+"\" updateFlag=\"\" status=\"N\" pkNames=\"\" />\r\n");
......@@ -185,6 +194,10 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
pstmt.close();
pstmt = null;
if(!"R-ADV".equalsIgnoreCase(tranSer.trim()))
{
getDataSql1 = "select ref_no,tran_ser, adj_amt,tot_amt from receivables "
+ " where tran_ser in ('CRNRCP','MDRCRC', 'R-ADV') and ref_no not in ( ? ) "
+ " and tot_amt - adj_amt < 0 and (fin_scheme is null or fin_scheme = ' ') "
......@@ -228,6 +241,7 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
//while
rs.close();rs = null;
pstmt.close();pstmt = null;
}
retTabSepStrBuff.append("</Header0>\r\n");
retTabSepStrBuff.append("</group0>\r\n");
retTabSepStrBuff.append("</DocumentRoot>\r\n");
......@@ -276,7 +290,7 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
String retStr = "",tranType="";
Document detailDom = null;
Document headerDom = null;
System.out.println("xmlString :::"+ xmlString);
......@@ -296,10 +310,20 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom " + detailDom);
}
tranType = checkNullAndTrim(genericUtility.getColumnValue("tran_type", headerDom));
System.out.println("windowName" + windowName);
System.out.println("xtraParams" + xtraParams);
System.out.println("TranType" + tranType);
if("R-ADV".equalsIgnoreCase(tranType.trim()))
{
retStr = processAdv(headerDom, detailDom, windowName, xtraParams);
}
else
{
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
}
catch (Exception e)
{
System.out.println("Exception :UndoRecievableAdjPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
......@@ -1037,6 +1061,199 @@ public class UndoRecievableAdjPrc extends ProcessEJB implements UndoRecievableAd
//System.out.println("errString: "+errString);
return errString;
}
public String processAdv(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 = "",sundryCode="",tranSer="",sTranDate="",refNo="",sRefDate="",sTotAmt="",sAdjAmt="",acctCode="",status="";
String cctrCode = "",currCode="",sExchRate="",sDueDate="",finEntity="",bankCode="",refSerPay="",keyString="",recvTranID="";
double totAmt=0,adjAmt=0,fTotAmt=0,fAdjAmt=0,trfAmt=0;
String errCode = "";
String errString = "";
String insertSql = "",sql="";
String tranId = null,paytoRecAutoConf="";
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;
StringBuffer xmlBuff = null;
int lineNo = 0;
int updCnt = 0,cnt=0;
int parentNodeListLength = 0;
int childNodeListLength = 0;
String refNoHeader="",tranType="",remarks="";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
boolean flag = false;
boolean UndoRcpDisAdj = false;
Timestamp tranDate = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
System.out.println("Inside ProcessAdv");
conn = getConnection();
sTranDate = checkNull(genericUtility.getColumnValue("tran_date", headerDom));
tranType= checkNull(genericUtility.getColumnValue("tran_type", headerDom));
siteCode=checkNull(genericUtility.getColumnValue("site_code", headerDom));
refNoHeader= checkNull(genericUtility.getColumnValue("ref_no", headerDom));
custCode= checkNull(genericUtility.getColumnValue("cust_code", headerDom));
if(sTranDate != null && sTranDate.trim().length() > 0){
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(sTranDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
//UndoRcpDisAdj ="R-ADV".equalsIgnoreCase(tranType.trim())? true:false;
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("ParentNodeListLength ..........."+parentNodeListLength);
if( xmlBuff == null )
{
xmlBuff = new StringBuffer();
}
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
tranSer=checkNull(genericUtility.getColumnValueFromNode("ref_ser", parentNode));
refNo=checkNull(genericUtility.getColumnValueFromNode("ref_no", parentNode));
adjAmt=checkDoubleNull(genericUtility.getColumnValueFromNode("adj_amt", parentNode));
xmlBuff = null;
xmlBuff = new StringBuffer();
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("undo_rec_adj").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 dbID=\"\" domID=\"1\" objName=\"undo_rec_adj\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sTranDate +"]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<tran_type><![CDATA["+ "S-INV" +"]]></tran_type>");
xmlBuff.append("<cust_code><![CDATA["+custCode+"]]></cust_code>");
xmlBuff.append("<ref_no><![CDATA["+refNo+"]]></ref_no>");
xmlBuff.append("</Detail1>");
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"undo_rec_adj\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
lineNo++;
xmlBuff.append("<line_no><![CDATA["+ lineNo +"]]></line_no>");
xmlBuff.append("<ref_no><![CDATA["+ refNoHeader +"]]></ref_no>");
xmlBuff.append("<ref_ser><![CDATA["+"R-ADV"+"]]></ref_ser>");
xmlBuff.append("<adj_amt><![CDATA["+ adjAmt +"]]></adj_amt>");
xmlBuff.append("</Detail2>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
errString=saveData(xtraParams,siteCode, xmlBuff.toString(), conn);
if( errString.indexOf("Success") == -1 )
{
return errString;
}
String[] arrayForTranId = errString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
tranId= arrayForTranId[1].substring(0,endIndex);
if(tranId != null && tranId.trim().length() > 0)
{
System.out.println("tran_id [" + tranId + "]");
errString = null;
}
UndoRecievableAdjConf undoRecAdjConf = new UndoRecievableAdjConf();
String forcedFlag="N";
errString=undoRecAdjConf.confirm(tranId, xtraParams, forcedFlag,conn);
undoRecAdjConf = null;
if( errString.indexOf("VTCNFSUCC") == -1)
{
return errString;
}
}
if( errString.indexOf("VTCNFSUCC") > -1)
{
errString = itmDBAccessEJB.getErrorString("","VTCOMPL","","",conn);
if(conn != null){
conn.commit();
System.out.println("commited....!!!");
}
return errString;
}
else
{
if(conn != null){
conn.rollback();
System.out.println("rollback....!!!");
}
return errString;
}
}//try end
catch(Exception e)
{
System.out.println("Exception :UndoRecievableAdjPrc ::" + e.getMessage() + ":");
try
{
conn.rollback();
} catch (Exception d)
{
System.out.println("Exception : UndoRecievableAdjPrc =>"+ 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 saveData(String xtraParams,String siteCode, String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
......
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