Commit 719c6105 authored by pshinde's avatar pshinde

Source Code for Automatic Payment Scheduler


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98076 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b337e34d
......@@ -142,6 +142,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
String sql= null ;
ResultSet rs = null;
ResultSet rs1 = null;
String spiltChq="";
PreparedStatement pstmt = null,pstmt1=null;
//Statement st = null; // Remarked - Rej - Asnot used - 29/12/2007
......@@ -241,7 +242,9 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
else
{
entryBatchNo = entryBatchNo.trim()+"%";
}
}
spiltChq = genericUtility.getColumnValue("chq_split",headerDom);
fromDate=genericUtility.getValidDateString(fromDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
//writeLog(filePtr,"fromDate -->"+fromDate ,true);
toDate=genericUtility.getValidDateString(toDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
......@@ -332,6 +335,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
rsTemp.close();
rsTemp=null;
System.out.println("Un confirmed Amt==="+unapprovedPayAmt+"Ref No===="+refNo);
/*
tempSql= "SELECT sum(case when auto_pay_det.pay_amt is null then 0 else auto_pay_det.pay_amt end) as pay_amt "
+"FROM auto_pay_hdr, auto_pay_det "
......@@ -430,11 +435,13 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
retTabSepStrBuff.append((rs.getString(25)==null)?" " :rs.getString(25)).append("\t");
//net_payable
retTabSepStrBuff.append(rs.getDouble(26)).append("\t");
//unapproved_amt
retTabSepStrBuff.append(unapprovedPayAmt).append("\r\n");//Added by Raj (FI78DIS032)- 29/12/2007
//unapproved_amt unapprovedPayAmt
retTabSepStrBuff.append(unapprovedPayAmt).append("\t");//Added by Raj (FI78DIS032)- 29/12/2007
//retTabSepStrBuff.append(rs.getDouble(26)).append("\n");
////writeLog(filePtr,"Data Feched -->"+retTabSepStrBuff ,true);
////writeLog(filePtr,"----------------------------------------------------------------" ,true);
retTabSepStrBuff.append(spiltChq).append("\r\n");
}
rs.close();
pstmt.close();
......@@ -487,6 +494,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
//writeLog(filePtr,"detailDom-->"+detailDom,true);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
System.out.println("xmlString*********"+xmlString);
System.out.println("xmlString2*********"+xmlString2);
}
catch (Exception e)
{
......@@ -551,6 +560,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
String xmlOutString = "";
String payDate = "";
String wfStatus="";
String spiltChq="";
String stanCode="";
String tranDate="";
double diffAmt=0;
......@@ -602,8 +612,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
String sysDate ="";
java.util.Date today=new java.util.Date();
Timestamp currDate=null,maxRefDt=null;
Date refrdate=null;
Date maxRefDate=null;
Date refrdate=null,dueMaxDate=null;
Date maxRefDate=null,maxDueDate=null;
FinCommon fin=new FinCommon();
DistCommon dist=new DistCommon();
double unconfirmAmt=0; // cpatil
......@@ -690,6 +700,8 @@ System.out.println("Getting winName============"+windowName);
wfStatus = genericUtility.getColumnValue("wf_status",headerDom);
System.out.println("Getting wfStatus=============="+wfStatus);
spiltChq = genericUtility.getColumnValue("chq_split",headerDom);
System.out.println("Getting spiltChq=============="+spiltChq);
/* acctCode = genericUtility.getColumnValue("acct_code",headerDom);
System.out.println("Getting acct_code__bal================"+acctCode);*/
//writeLog(filePtr,"uptoChq-->"+uptoChq,true);
......@@ -917,7 +929,7 @@ System.out.println("Getting winName============"+windowName);
System.out.println("before tmpDate==========="+tmpDate);
if (tmpDate.length()>10)
{
tmpDate = tmpDate.substring(0,9);
tmpDate = tmpDate.substring(0,10);
}
System.out.println("after tmpDate==========="+tmpDate);
//dueDate = childNode.getFirstChild().getNodeValue();
......@@ -1026,6 +1038,7 @@ System.out.println("Getting winName============"+windowName);
if(childNode.getFirstChild()!=null)
{
unconfirmAmt = Double.valueOf(childNode.getFirstChild().getNodeValue());
System.out.println("UnConfirm Amount from node====="+unconfirmAmt);
}
}
......@@ -1034,7 +1047,16 @@ System.out.println("Getting winName============"+windowName);
//if (Double.parseDouble(netPayable) != 0 ) // Condition added by jaimin 16/08/2007 // Remarked by Raj - 29/12/2007
//changes for grouping on 21/05/15
tempSplitCode = sundryCode+"@"+payMode+"@"+dueDate; //added duaDate by cpatil in sun on 06/06/15
if(spiltChq!=null && "Y".equalsIgnoreCase(spiltChq))
{
tempSplitCode = sundryCode+"@"+payMode+"@"+dueDate; //added duaDate by cpatil in sun on 06/06/15
}
else
{
tempSplitCode = sundryCode+"@"+payMode;
}
System.out.println("Getting combination As====="+tempSplitCode);
if(splitCodeWiseMap.containsKey(tempSplitCode))
{
......@@ -1167,7 +1189,7 @@ System.out.println("Getting winName============"+windowName);
{
payDate1 = sdf.parse(payDate);
if((payDate1.compareTo(ldStartDate)>0)&& payDate1.compareTo(discdt)<0)
if((payDate1!=null && payDate1.compareTo(ldStartDate)>0)&& payDate1.compareTo(discdt)<0)
{
if(discount!=0)
{System.out.println("Discount not equals to Zerooooooooooooo");
......@@ -1298,6 +1320,41 @@ System.out.println("Sundry Type@@@@"+sundryType);
System.out.println("sundryCode before setting ref date ======="+sundryCode);
System.out.println("payMode before setting ref date ======="+payMode);
//set max due_date as ref_date in header
Date currentDate1 = new Date();
sql="select max(due_date) as due_date from misc_payables where sundry_code =? and pay_mode=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,sundryCode);
pstmt1.setString(2,payMode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
maxDueDate = rs1.getDate( "due_date" );
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("maxDueDate ref date ======="+maxDueDate);
String maxDatedue= sdf.format(maxDueDate);
System.out.println("Max Date========="+maxDatedue);
// Date currentDate1 = new Date();
System.out.println("Current date111111111111===="+currentDate1);
if(maxRefDate!=null && maxRefDate.compareTo(currentDate1)>0)
{
dueMaxDate=maxDueDate;
}
else
{
dueMaxDate=currentDate1;
}
System.out.println("Getting ref due Date for header===="+dueMaxDate);
System.out.println("sfld1========="+sfld1);
//set max ref_date as voch_date in detail
sql="select max(ref_date) as ref_date from misc_payables where sundry_code =? and pay_mode=?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,sundryCode);
......@@ -1311,11 +1368,11 @@ System.out.println("Sundry Type@@@@"+sundryType);
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("maxRefDate ref date ======="+maxRefDate);
System.out.println("Getting ref Date for detail=="+maxRefDate);
String maxDate= sdf.format(maxRefDate);
System.out.println("Max Date========="+maxDate);
Date currentDate1 = new Date();
//Date currentDate1 = new Date();
System.out.println("Current date111111111111===="+currentDate1);
if(maxRefDate!=null && maxRefDate.compareTo(currentDate1)>0)
......@@ -1326,9 +1383,11 @@ System.out.println("Sundry Type@@@@"+sundryType);
{
refrdate=currentDate1;
}
System.out.println("Getting ref Date for header===="+refrdate);
System.out.println("sfld1========="+sfld1);
System.out.println("Getting ref Date for detail===="+refrdate);
//set Ref No in header whose date is maximum against combination
sql="select ref_no from misc_payables where ref_date= ?";
pstmt1 = conn.prepareStatement(sql);
......@@ -1344,6 +1403,11 @@ System.out.println("Sundry Type@@@@"+sundryType);
pstmt1 = null;
System.out.println("Ref No aginst maxRefDate ref date ======="+refNo);
for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++)
{
tempMap = (HashMap)tempList.get(itemCtr);
......@@ -1387,7 +1451,7 @@ System.out.println("Sundry Type@@@@"+sundryType);
xmlString.append("<bank_code><![CDATA[" + checkNull(bankCode) + "]]></bank_code>");
xmlString.append("<ref_no><![CDATA[" + checkNull(refNo) + "]]></ref_no>");
xmlString.append("<ref_date><![CDATA[" +sdf.format(refrdate).toString() + "]]></ref_date>");
xmlString.append("<ref_date><![CDATA[" +sdf.format(dueMaxDate).toString() + "]]></ref_date>");
//xmlString.append("<ref_date>").append("<![CDATA[").append(sdf.format(currentDate).toString()).append("]]></ref_date>\r\n");
//xmlString.append("<ref_date><![CDATA[" + dueDate + "]]></ref_date>");
xmlString.append("<remarks><![CDATA[" + "Generate Automatic payment from scheduler" + "]]></remarks>");
......@@ -1435,8 +1499,8 @@ System.out.println("Sundry Type@@@@"+sundryType);
lineNo = 0;
for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++)
{
lineNo++; // doubt
System.out.println("Line No after increament=========="+lineNo);
/*lineNo++; // doubt
System.out.println("Line No after increament=========="+lineNo);*/
tempMap = (HashMap)tempList.get(itemCtr);
payAmt=(String)tempMap.get("pay_amt") ;
......@@ -1454,15 +1518,17 @@ System.out.println("Sundry Type@@@@"+sundryType);
//if (Double.parseDouble(payAmt) != 0 ) //
if(sumNetAmt>0)
{
System.out.println("--------------> if payAmt>0 :: "+payAmt);
System.out.println("--------------> if netPayable>0 :: "+netPayable);
System.out.println("--------------> totUnconfAmt :: "+totUnconfAmt);
if (( (Double.parseDouble(netPayable) > 0 && Double.parseDouble(payAmt) <= Double.parseDouble(netPayable) && Double.parseDouble(payAmt) >=0)
|| (Double.parseDouble(netPayable) < 0 && Double.parseDouble(payAmt) <= 0 && Double.parseDouble(payAmt) >= Double.parseDouble(netPayable)) )
&& ( Double.parseDouble(payAmt) + totUnconfAmt < Double.parseDouble(netPayable) ) ) // added by cpatil @sun on 06/06/15
&& ( (Double.parseDouble(payAmt) + totUnconfAmt) <= Double.parseDouble(netPayable) ) ) // added by cpatil @sun on 06/06/15
{ // End by Jaimin 16/08/2007
System.out.println("----------------In condition---1111-----------");
lineNo++; // doubt
System.out.println("Line No after increament=========="+lineNo);
System.out.println("temp tran_id========"+(String)tempMap.get("tran_id"));
System.out.println("temp tran_ser========"+(String)tempMap.get("tran_ser"));
......@@ -1501,9 +1567,9 @@ System.out.println("Sundry Type@@@@"+sundryType);
xmlString.append("<line_no><![CDATA["+lineNo+"]]></line_no>");
xmlString.append("<tran_ser><![CDATA["+ tempMap.get("tran_ser") +"]]></tran_ser>");
xmlString.append("<vouch_no><![CDATA["+ tempMap.get("vouch_no") +"]]></vouch_no>");
xmlString.append("<vouch_date><![CDATA["+ tempMap.get("vouch_date") +"]]></vouch_date>");
//xmlString.append("<vouch_date><![CDATA["+ tempMap.get("vouch_date") +"]]></vouch_date>");
xmlString.append("<vouch_date><![CDATA["+ sdf.format(refrdate).toString() +"]]></vouch_date>");
xmlString.append("<net_amt><![CDATA["+ tempMap.get("net_amt") +"]]></net_amt>");
xmlString.append("<pay_amt><![CDATA["+ tempMap.get("pay_amt") +"]]></pay_amt>");
xmlString.append("<curr_code><![CDATA["+ tempMap.get("curr_code") +"]]></curr_code>");
......@@ -1563,14 +1629,18 @@ System.out.println("Sundry Type@@@@"+sundryType);
System.out.println("Counter before save data==="+cntXml);
System.out.println("xmlOutString============="+xmlOutString);
System.out.println("-lineNo before commit--"+lineNo);
if(lineNo>0)
{
retString = saveData(siteCode, xmlOutString, conn);
if (retString != null && retString.trim().length() > 0)
{
System.out.println("Result string not null++++++++");
System.out.println("--going to commit tranaction--");
if (retString.indexOf("Success") > -1)
System.out.println("tranId before commit--"+tranId);
if (retString.indexOf("Success") > -1 )
{
conn.commit();
System.out.println("--transaction commited--");
......@@ -1581,7 +1651,7 @@ System.out.println("Sundry Type@@@@"+sundryType);
System.out.println("--transaction rollback--");
}
}
}
cntXml++;
System.out.println("After Save======"+retString.toString());
String[] arrayForTranId = retString.split("<TranID>");
......
......@@ -43,7 +43,7 @@ public class AutoPmtPrcSch implements Schedule
String actualLoginSiteCode="";
String getString="";
String due_date_from="",wfStatus="";
String noOfDays="";
String noOfDays="",dueDat="";
try
{
......@@ -127,24 +127,29 @@ public class AutoPmtPrcSch implements Schedule
{
bankCode = childNode.getFirstChild().getNodeValue();
System.out.println("bankCode======"+bankCode);
}
}
/*if(ctr==8)
{
spiltChq = childNode.getFirstChild().getNodeValue();
System.out.println("spiltChq======"+spiltChq);
}*/
if(ctr==8)
{
noOfDays = childNode.getFirstChild().getNodeValue();
System.out.println("noOfDays======"+noOfDays);
}
/*if(ctr==9)
{
dueDat = childNode.getFirstChild().getNodeValue();
System.out.println("DueDate======"+dueDat);
}*/
if(ctr==9)
{
spiltChq = childNode.getFirstChild().getNodeValue();
System.out.println("spiltChq======"+spiltChq);
}
}
}
//System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
getString= autoPayment(actualLoginSiteCode,sundryType,due_date_from,wfStatus,sundryCode,currCode,payMode,bankCode,noOfDays,scheduleParamXML);
getString= autoPayment(actualLoginSiteCode,sundryType,due_date_from,wfStatus,sundryCode,currCode,payMode,bankCode,noOfDays,spiltChq,scheduleParamXML);
}
......@@ -170,7 +175,7 @@ public class AutoPmtPrcSch implements Schedule
// TODO Auto-generated method stub
return null;
}
public String autoPayment(String siteCode,String sundryType,String dueDateFrom,String wfStatus,String sundryCode,String curCode,String payMod,String bankCod,String noOfDays,String scheduleParamXML ) throws Exception
public String autoPayment(String siteCode,String sundryType,String dueDateFrom,String wfStatus,String sundryCode,String curCode,String payMod,String bankCod,String noOfDays,String spiltChq,String scheduleParamXML ) throws Exception
{
Connection conn = null;
......@@ -186,7 +191,7 @@ public class AutoPmtPrcSch implements Schedule
String vouchurNo="",currCode="";
String miscPaytranDate="",effDate="",billNo="",billDate="",currCode1="",exchRate="",acctrCode="",cctrCode="";
String dueOn="",finEntity="",siteCd="",totAmt="",sundryTyp="",bankCode="",payMode="";
String advAmt="",tranSer="",adjAmt="",holdAmt="",userName="",payAmt="",sundryName="",netPay="";
String advAmt="",tranSer="",adjAmt="",holdAmt="",userName="",payAmt="",sundryName="",netPay="",unConfAmt="";
String xmlString4="", retString1="";
String bankName = "",refNo="",refNoupto="";
String sysDate ="";
......@@ -319,7 +324,7 @@ public class AutoPmtPrcSch implements Schedule
"<ref_no__upto><![CDATA["+refNoupto+"]]></ref_no__upto>" +
"<pay_mode><![CDATA["+payMode+"]]></pay_mode>" +
"<entry_batch_no><![CDATA[]]></entry_batch_no>" +
"<chq_split><![CDATA[]]></chq_split>" +
"<chq_split><![CDATA["+spiltChq+"]]></chq_split>" +
"<bank_code__add><![CDATA[]]></bank_code__add>" +
"<bank_name__add><![CDATA[]]></bank_name__add>" +
"<exch_rate><![CDATA[]]></exch_rate>" +
......@@ -329,6 +334,7 @@ public class AutoPmtPrcSch implements Schedule
"<tran_type><![CDATA["+trantype+"]]></tran_type>" +
"<curr_code><![CDATA["+curCode+"]]></curr_code>" +
"<bank_flag><![CDATA[]]></bank_flag>"+
//"<due_date><![CDATA[]]></due_date>"+
"<wf_status><![CDATA["+wfStatus+"]]></wf_status></Detail1>";
String xmlString2="<DocumentRoot><description>Datawindow Root</description><group0><description>Group0 description</description><Header0><description>Header0 members</description>" +
......@@ -349,7 +355,7 @@ public class AutoPmtPrcSch implements Schedule
"<ref_no__upto><![CDATA["+refNoupto+"]]></ref_no__upto>" +
"<pay_mode><![CDATA["+payMode+"]]></pay_mode>" +
"<entry_batch_no><![CDATA[]]></entry_batch_no>" +
"<chq_split><![CDATA[]]></chq_split>" +
"<chq_split><![CDATA["+spiltChq+"]]></chq_split>" +
"<bank_code__add><![CDATA[]]></bank_code__add>" +
"<bank_name__add><![CDATA[]]></bank_name__add>" +
"<exch_rate><![CDATA[]]></exch_rate>" +
......@@ -357,7 +363,8 @@ public class AutoPmtPrcSch implements Schedule
"<noof_rejected><![CDATA[]]></noof_rejected>" +
"<tax_env><![CDATA[]]></tax_env>" +
"<tran_type><![CDATA["+trantype+"]]></tran_type>" +
"<curr_code><![CDATA["+curCode+"]]></curr_code>" +
"<curr_code><![CDATA["+curCode+"]]></curr_code>" +
// "<due_date><![CDATA[]]></due_date>"+
"<bank_flag><![CDATA[]]></bank_flag></Detail1></Header0></group0></DocumentRoot>";
......@@ -412,7 +419,10 @@ public class AutoPmtPrcSch implements Schedule
payAmt=arr[23];
sundryName=arr[24];
netPay=arr[25];
unConfAmt=arr[26];
spiltChq=arr[27];
System.out.println("Unconfirmed Amt from Array==="+unConfAmt+"Spilt cheque variable===="+spiltChq);
xmlString4=xmlString4+"<Detail2 dbID=\"\" domID='"+ctr+"' objContext=\"2\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>null"+
"<ref_no><![CDATA["+vouchurNo+"]]></ref_no>"+
"<tran_date><![CDATA["+miscPaytranDate+"]]></tran_date>"+
......@@ -439,7 +449,9 @@ public class AutoPmtPrcSch implements Schedule
"<username><![CDATA["+userName+"]]></username>"+
"<pay_amt><![CDATA["+payAmt+"]]></pay_amt>"+
"<sundry_name><![CDATA["+sundryName+"]]></sundry_name>"+
"<net_payable><![CDATA["+netPay+"]]></net_payable>"+
"<net_payable><![CDATA["+netPay+"]]></net_payable>"+
"<unconfirm_amt><![CDATA["+unConfAmt+"]]></unconfirm_amt>"+
"<chq_split><![CDATA["+spiltChq+"]]></chq_split>"+
"</Detail2>";
}
......
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