Commit 7f421521 authored by pshinde's avatar pshinde

Changes in Automatic Payment Scheduler


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98034 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8dc3b7ba
...@@ -12,12 +12,14 @@ import java.util.Date; ...@@ -12,12 +12,14 @@ import java.util.Date;
import java.sql.*; import java.sql.*;
import java.text.*; import java.text.*;
import java.io.*; import java.io.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import javax.ejb.*; import javax.ejb.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.system.config.*; import ibase.system.config.*;
import java.util.*; import java.util.*;
import javax.naming.InitialContext; import javax.naming.InitialContext;
//import ibase.webitm.ejb.MasterStateful;// comented for ejb3 //import ibase.webitm.ejb.MasterStateful;// comented for ejb3
...@@ -51,7 +53,10 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -51,7 +53,10 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
String Sql1=""; String Sql1="";
java.sql.Timestamp dateTo = null; java.sql.Timestamp dateTo = null;
java.sql.Timestamp dateFr = null; java.sql.Timestamp dateFr = null;
String startDateStr = null;
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
/*static void writeLog(File f,String Msg,boolean flag) /*static void writeLog(File f,String Msg,boolean flag)
{ {
try try
...@@ -195,22 +200,30 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -195,22 +200,30 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} }
sundryType = genericUtility.getColumnValue("sundry_type",headerDom); sundryType = genericUtility.getColumnValue("sundry_type",headerDom);
//writeLog(filePtr,"sundryType -->"+sundryType ,true); //writeLog(filePtr,"sundryType -->"+sundryType ,true);
if ( sundryType == null ) System.out.println("sundryType in getData======"+sundryType);
//if (sundryType == null||sundryType.trim().length()==0)
if(("null".equals(sundryType))|| sundryType == null)
{ {
System.out.println("If sundryType11 == null");
sundryType = "%"; sundryType = "%";
} }
else else
{ {
System.out.println("If sundryType11 Not == null");
sundryType =sundryType.trim()+"%"; sundryType =sundryType.trim()+"%";
} }
sundryCode = genericUtility.getColumnValue("sundry_code",headerDom); sundryCode = genericUtility.getColumnValue("sundry_code",headerDom);
System.out.println("sundryCode in getData======"+sundryCode);
//writeLog(filePtr,"sundryCode -->"+sundryCode ,true); //writeLog(filePtr,"sundryCode -->"+sundryCode ,true);
if ( sundryCode == null) if(("null".equals(sundryCode))|| sundryCode == null)
{ {
System.out.println("If sundryCode11 == null");
sundryCode = "%"; sundryCode = "%";
} }
else else
{ {
System.out.println("If sundryCode11 Not == null");
sundryCode = sundryCode.trim()+"%"; sundryCode = sundryCode.trim()+"%";
} }
payMode = genericUtility.getColumnValue("pay_mode",headerDom); payMode = genericUtility.getColumnValue("pay_mode",headerDom);
...@@ -290,6 +303,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -290,6 +303,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
while(rs.next()) while(rs.next())
{ {
//Added below by Raj (FI78DIS032)- 29/12/2007 //Added below by Raj (FI78DIS032)- 29/12/2007
System.out.println("Inside while loop");
tranSer = rs.getString("tran_ser"); tranSer = rs.getString("tran_ser");
refNo = rs.getString("ref_no"); refNo = rs.getString("ref_no");
payAmt = rs.getDouble("pay_amt"); payAmt = rs.getDouble("pay_amt");
...@@ -551,21 +565,40 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -551,21 +565,40 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
Date effDate=null,billDt=null,ldStartDate=null,reDate1=null; Date effDate=null,billDt=null,ldStartDate=null,reDate1=null;
Date ldStartDate1=null,payDate1=null,mPayDate=null; Date ldStartDate1=null,payDate1=null,mPayDate=null;
String transactionDate="";//added by priyanka String transactionDate="";//added by priyanka
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
java.util.Date endDate = new java.util.Date(System.currentTimeMillis());
String strToWrite = "";
String endDateStr = null;
//added on 13/05/15
String splitCode = "", tempSplitCode ="";
HashMap splitCodeWiseMap = new HashMap(), tempMap = null;
ArrayList tempList = null;
long datediff=0; long datediff=0;
int cntXml=1;
String itemSer1="";
String sysDate ="";
java.util.Date today=new java.util.Date();
Timestamp currDate=null,maxRefDt=null;
Date refrdate=null;
Date maxRefDate=null;
FinCommon fin=new FinCommon(); FinCommon fin=new FinCommon();
DistCommon dist=new DistCommon(); DistCommon dist=new DistCommon();
try try
{ { System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
retBuf = new StringBuffer(); retBuf = new StringBuffer();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
System.out.println("AutoPmtGenPrcEJB ejbCreate called........."); System.out.println("process starts---------");
Date currentDate = new Date(); Date currentDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
Calendar c = Calendar.getInstance();
c.setTime(today);
today = c.getTime();
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate=sdf.format(today);
System.out.println("sysDate****=========="+sysDate);
System.out.println("Getting winName============"+windowName);
//writeLog(filePtr,"AutoPmtGenPrcEJB ejbCreate called.........",true); //writeLog(filePtr,"AutoPmtGenPrcEJB ejbCreate called.........",true);
//For logonoff //For logonoff
sql = "select var_value from finparm where prd_code='999999' and var_name='AUTOPAYGEN_LOG_FLAG'"; sql = "select var_value from finparm where prd_code='999999' and var_name='AUTOPAYGEN_LOG_FLAG'";
...@@ -751,81 +784,19 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -751,81 +784,19 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
System.out.println("ExcRate from getDailyExchRateSellBuy========="+mexrate); System.out.println("ExcRate from getDailyExchRateSellBuy========="+mexrate);
//End by Jaimin 25/07/2007 //changes for grouping on 25/05/15
xmlString = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlString.append("<DocumentRoot><description>Datawindow Root</description><group0><description>Group0 escription</description>");
xmlString.append("<Header0>");
xmlString.append("<description>Header0 members</description>");
xmlString.append("<objName><![CDATA[").append("misc_pay").append("]]></objName>");//"auto_pay" Added by Jaimin 25/07/2007
xmlString.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlString.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlString.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlString.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlString.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlString.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlString.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlString.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlString.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlString.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlString.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlString.append("<Detail1 dbID='' domID=\"1\" objName=\"misc_pay\" objContext=\"1\">");//"auto_pay" Added by Jaimin 25/07/2007
xmlString.append("<attribute pkNames=\"tran_id:\" status=\"N\" updateFlag=\"A\" selected=\"N\" />");
xmlString.append("<tran_id><![CDATA[]]></tran_id>");
xmlString.append("<tran_date><![CDATA[" + checkNull(payDate) + "]]></tran_date>");
xmlString.append("<tran_type><![CDATA[" + checkNull(tranType) + "]]></tran_type>");
xmlString.append("<sundry_type><![CDATA[" + checkNull(sundryType) + "]]></sundry_type>");
xmlString.append("<sundry_code><![CDATA[" + checkNull(sundryCode) + "]]></sundry_code>");
xmlString.append("<pay_mode><![CDATA[" + payMode + "]]></pay_mode>");
xmlString.append("<bank_code><![CDATA[" + checkNull(bankCode) + "]]></bank_code>");
xmlString.append("<ref_no><![CDATA[" + checkNull(refNo) + "]]></ref_no>");
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>");
xmlString.append("<net_amt><![CDATA[" + 0 + "]]></net_amt>");
xmlString.append("<curr_code><![CDATA[" + checkNull(currCode) + "]]></curr_code>");
xmlString.append("<exch_rate><![CDATA[" + mexrate + "]]></exch_rate>");
xmlString.append("<net_amt__bc><![CDATA[" + 0 + "]]></net_amt__bc>");
xmlString.append("<site_code><![CDATA[" + checkNull(siteCode) + "]]></site_code>");
xmlString.append("<site_descr><![CDATA[" + checkNull(siteDescr) + "]]></site_descr>");//Added by Jaimin 25/07/2007
xmlString.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlString.append("<finent_descr><![CDATA[" + checkNull(finentDescr) + "]]></finent_descr>");//Added by Jaimin 25/07/2007
xmlString.append("<acct_code__bal><![CDATA[" + checkNull(acctCodeBal) + "]]></acct_code__bal>");
xmlString.append("<cctr_code__bal><![CDATA[" + checkNull(cctrCodeBal) + "]]></cctr_code__bal>");
xmlString.append("<auto_paid><![CDATA[" + "Y" + "]]></auto_paid>");
xmlString.append("<bank_charges><![CDATA[" + 0 + "]]></bank_charges>");
xmlString.append("<acct_code__bc><![CDATA[" + checkNull(acctCodeBc) + "]]></acct_code__bc>");
xmlString.append("<cctr_code__bc><![CDATA[" + checkNull(cctrCodeBc) + "]]></cctr_code__bc>");
xmlString.append("<curr_code__bc><![CDATA[" + checkNull(currCodeBc) + "]]></curr_code__bc>");
xmlString.append("<exch_rate__bc><![CDATA[" + excRateBc + "]]></exch_rate__bc>");
xmlString.append("<acct_code__cf><![CDATA[" + checkNull(acctCodeCf)+ "]]></acct_code__cf>");
xmlString.append("<cctr_code__cf><![CDATA[" + checkNull(cctrCodeCf) + "]]></cctr_code__cf>");
xmlString.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>");
xmlString.append("<tax_date><![CDATA[" + checkNull(payDate) + "]]></tax_date>");
xmlString.append("<WF_STATUS ><![CDATA[" + checkNull(wfStatus) + "]]></WF_STATUS >");
xmlString.append("<bank_name><![CDATA[" + checkNull(bankName) + "]]></bank_name>");//Added by Jaimin 25/07/2007
if (bankCodeAdd==null)
{bankCodeAdd = "";}
xmlString.append("<bank_code__add><![CDATA[" + bankCodeAdd + "]]></bank_code__add>");
xmlString.append("<confirmed><![CDATA[N]]></confirmed>");
xmlString.append("<emp_code__conf><![CDATA[]]></emp_code__conf>");
xmlString.append("<conf_date><![CDATA[]]></conf_date>");
xmlString.append("<chg_user><![CDATA[" + chgUser + "]]></chg_user>");
xmlString.append("<chg_term><![CDATA[" + chgTerm + "]]></chg_term>");
xmlString.append("<chg_date><![CDATA[" + chgDate + "]]></chg_date>");
//xmlString.append("<chq_no__fr><![CDATA[" + chgFrm + "]]></chq_no__fr>");
//xmlString.append("<chq_no__to><![CDATA[" + chgTo + "]]></chq_no__to>");
xmlString.append("</Detail1>");
System.out.println("XmlString Header======"+xmlString.toString());
System.out.println("for detail data");
parentNodeList = detailDom.getElementsByTagName("Detail2"); parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength:::::::::"+parentNodeListLength); System.out.println("parentNodeListLength:::::::::"+parentNodeListLength);
//writeLog(filePtr,"parentNodeListLength-->"+parentNodeListLength,true); //writeLog(filePtr,"parentNodeListLength-->"+parentNodeListLength,true);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++) for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{ {
System.out.println("Enter in first for loop for Detail2###########");
System.out.println("For row selectedRow !!!!!!!! "+selectedRow);
parentNode = parentNodeList.item(selectedRow); parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
...@@ -833,6 +804,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -833,6 +804,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
//writeLog(filePtr,"childNodeListLength-->"+childNodeListLength,true); //writeLog(filePtr,"childNodeListLength-->"+childNodeListLength,true);
for (int childRow = 0; childRow < childNodeListLength; childRow++) for (int childRow = 0; childRow < childNodeListLength; childRow++)
{ {
System.out.println("Enter in 22222222 for loop for Detail2###########");
childNode = childNodeList.item(childRow); childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equals("ref_no")) if (childNodeName.equals("ref_no"))
...@@ -940,6 +912,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -940,6 +912,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
if(childNode.getFirstChild()!=null) if(childNode.getFirstChild()!=null)
{ {
sundryType = childNode.getFirstChild().getNodeValue(); sundryType = childNode.getFirstChild().getNodeValue();
} }
} }
if (childNodeName.equals("pay_mode")) if (childNodeName.equals("pay_mode"))
...@@ -1026,7 +999,26 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1026,7 +999,26 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} // For inner loop } // For inner loop
//if (Double.parseDouble(netPayable) != 0 ) // Condition added by jaimin 16/08/2007 // Remarked by Raj - 29/12/2007 //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;
System.out.println("Getting combination As====="+tempSplitCode);
if(splitCodeWiseMap.containsKey(tempSplitCode))
{
System.out.println("*****Combination Exist*****");
tempList = (ArrayList) splitCodeWiseMap.get(tempSplitCode);
System.out.println("Combination Exist TempList======"+tempList);
}
else
{
System.out.println("*****Combination Not Exist*****");
tempList = new ArrayList();
System.out.println("Combination Not $$ Exist TempList======"+tempList);
}
System.out.println("tempList======"+tempList);
//added on 30/mar by priyanka //added on 30/mar by priyanka
tempMap = new HashMap();
System.out.println("Getting RefNo Detail================="+refNo); System.out.println("Getting RefNo Detail================="+refNo);
System.out.println("Getting tranDate================"+tranDate); System.out.println("Getting tranDate================"+tranDate);
...@@ -1169,15 +1161,6 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1169,15 +1161,6 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} }
if (Double.parseDouble(payAmt) != 0 ) // Condition added by jaimin 16/08/2007 // Changed by Raj - 29/12/2007
{
System.out.println("--------------> if payAmt>0 :: "+payAmt);
System.out.println("--------------> if netPayable>0 :: "+netPayable);
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)) )
{ // End by Jaimin 16/08/2007
System.out.println("----------------In condition--------------");
System.out.println("vouch_no============"+refNo); System.out.println("vouch_no============"+refNo);
System.out.println("vouch_date============"+refDate); System.out.println("vouch_date============"+refDate);
System.out.println("payAmt============"+payAmt); System.out.println("payAmt============"+payAmt);
...@@ -1189,58 +1172,324 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1189,58 +1172,324 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
diffAmt=((payAmount * exchRate1)-(payAmount*mexrate)); diffAmt=((payAmount * exchRate1)-(payAmount*mexrate));
System.out.println("diff_amt__exch========="+diffAmt); System.out.println("diff_amt__exch========="+diffAmt);
tempMap.put("tran_id", tranId);
tempMap.put("tran_ser", tranSer);
tempMap.put("line_no", lineNo);
tempMap.put("vouch_no", refNo);
if(refDate!=null)
{
tempMap.put("vouch_date", refDate);
}
tempMap.put("net_amt", payAmt);
tempMap.put("pay_amt", payAmt);
tempMap.put("curr_code", currCodeBc);
tempMap.put("exch_rate__vouch", exchRate);
tempMap.put("diff_amt__exch", payAmt);
tempMap.put("acct_code__ap", acctCode);
tempMap.put("cctr_code__ap", cctrCode);
tempMap.put("sundry_type", sundryType);
tempMap.put("sundry_code", sundryCode);
tempMap.put("bank_charges", 0);
tempMap.put("stan_code", stanCode);
tempMap.put("drawn_at", drawnAt);
tempMap.put("tax_amt", 0);
tempMap.put("net_pay_amt", payAmt);
tempMap.put("acct_code__disc", acctCodeDisc);
tempMap.put("cctr_code__disc", cctrCodeDisc);
tempMap.put("bill_no", billNo);
tempMap.put("bill_date", billDate);
tempMap.put("exch_rate", exchRate);
tempMap.put("discount_amt", disAmt);
tempMap.put("discount", discount);
tempMap.put("tot_amt", totAmt);
System.out.println("Getting value in Map======"+tempMap);
tempList.add(tempMap);
System.out.println("Getting tempList value after ading in list ======"+tempList);
System.out.println("Sundry Type@@@@"+sundryType);
if(splitCodeWiseMap.containsKey(tempSplitCode))
{
System.out.println("splitCodeWiseMap.containsKey(tempSplitCode)");
splitCodeWiseMap.put(tempSplitCode,tempList);
}
else
{
System.out.println("else*************");
splitCodeWiseMap.put(tempSplitCode,tempList);
}
}
double sumNetAmt=0.0;
String autoPaymTranId="";
Set setItem = splitCodeWiseMap.entrySet();
System.out.println("getting set item====="+setItem);
tempList = null;
Iterator itrItem = setItem.iterator();
int testCnt=0;
while(itrItem.hasNext())
{
testCnt++;
System.out.println("while loop@@@@@@@ "+testCnt);
Map.Entry itemMapEntry = (Map.Entry)itrItem.next();
splitCode = (String)itemMapEntry.getKey();
System.out.println("splitCode---"+splitCode);
System.out.println("Length---"+splitCode.split("@").length);
tempList = (ArrayList)splitCodeWiseMap.get(splitCode);
if(splitCode.split("@").length != 0)
{
sundryCode = checkNull(splitCode.split("@")[0]);
payMode = checkNull(splitCode.split("@")[1]);
}
System.out.println("sundryCode after spilt ======="+sundryCode);
System.out.println("payMode after spilt ======="+payMode);
System.out.println("Sundry TYPEEEEEEEE" +sundryType);
System.out.println("TempList Inside While======="+tempList);
sundryType=(String)tempMap.get("sundry_type");
System.out.println("Sundry Type from Map ======="+sundryType);
System.out.println("sundryCode before setting ref date ======="+sundryCode);
System.out.println("payMode before setting ref date ======="+payMode);
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);
pstmt1.setString(2,payMode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
maxRefDate = rs1.getDate( "ref_date" );
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("maxRefDate ref date ======="+maxRefDate);
String maxDate= sdf.format(maxRefDate);
System.out.println("Max Date========="+maxDate);
Date currentDate1 = new Date();
System.out.println("Current date111111111111===="+currentDate1);
if(maxRefDate!=null && maxRefDate.compareTo(currentDate1)>0)
{
refrdate=maxRefDate;
}
else
{
refrdate=currentDate1;
}
System.out.println("Getting ref Date for header===="+refrdate);
System.out.println("sfld1========="+sfld1);
//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);
pstmt1.setDate(1,(java.sql.Date) maxRefDate);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
refNo = rs1.getString( "ref_no" );
}
rs1.close();
rs1 = null;
pstmt1.close();
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);
System.out.println("<!@#> payAmt "+(String)tempMap.get("pay_amt"));
sumNetAmt+=Double.parseDouble((String)tempMap.get("pay_amt"));
System.out.println("PayAmt for Combonation"+payMode+"=====Total Of Pay Amt===="+sumNetAmt);
}
//creating Header
System.out.println("Creating Header$$$$$$");
xmlString = null;
xmlString = new StringBuffer();
xmlString.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlString.append("<DocumentRoot>");
xmlString.append("<description>").append("Datawindow Root").append("</description>");
xmlString.append("<group0>");
xmlString.append("<description>").append("Group0 description").append("</description>");
xmlString.append("<Header0>");
xmlString.append("<objName><![CDATA[").append("misc_pay").append("]]></objName>");//"auto_pay" Added by Jaimin 25/07/2007
xmlString.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlString.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlString.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlString.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlString.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlString.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlString.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlString.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlString.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlString.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlString.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlString.append("<Detail1 dbID='' domID=\"1\" objName=\"misc_pay\" objContext=\"1\">");//"auto_pay" Added by Jaimin 25/07/2007
xmlString.append("<attribute pkNames=\"tran_id:\" status=\"N\" updateFlag=\"A\" selected=\"N\" />");
xmlString.append("<tran_id><![CDATA[]]></tran_id>");
xmlString.append("<tran_date><![CDATA[" + checkNull(payDate) + "]]></tran_date>");
xmlString.append("<tran_type><![CDATA[" + checkNull(tranType) + "]]></tran_type>");
// xmlString.append("<sundry_type><![CDATA[" + checkNull(sundryType) + "]]></sundry_type>");
xmlString.append("<sundry_type><![CDATA[" + tempMap.get("sundry_type") + "]]></sundry_type>");
xmlString.append("<sundry_code><![CDATA[" + checkNull(sundryCode) + "]]></sundry_code>");
xmlString.append("<pay_mode><![CDATA[" + payMode + "]]></pay_mode>");
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>").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>");
xmlString.append("<net_amt><![CDATA[" + 0 + "]]></net_amt>");
xmlString.append("<curr_code><![CDATA[" + checkNull(currCode) + "]]></curr_code>");
xmlString.append("<exch_rate><![CDATA[" + mexrate + "]]></exch_rate>");
xmlString.append("<net_amt__bc><![CDATA[" + 0 + "]]></net_amt__bc>");
xmlString.append("<site_code><![CDATA[" + checkNull(siteCode) + "]]></site_code>");
xmlString.append("<site_descr><![CDATA[" + checkNull(siteDescr) + "]]></site_descr>");//Added by Jaimin 25/07/2007
xmlString.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlString.append("<finent_descr><![CDATA[" + checkNull(finentDescr) + "]]></finent_descr>");//Added by Jaimin 25/07/2007
xmlString.append("<acct_code__bal><![CDATA[" + checkNull(acctCodeBal) + "]]></acct_code__bal>");
xmlString.append("<cctr_code__bal><![CDATA[" + checkNull(cctrCodeBal) + "]]></cctr_code__bal>");
xmlString.append("<auto_paid><![CDATA[" + "Y" + "]]></auto_paid>");
xmlString.append("<bank_charges><![CDATA[" + 0 + "]]></bank_charges>");
xmlString.append("<acct_code__bc><![CDATA[" + checkNull(acctCodeBc) + "]]></acct_code__bc>");
xmlString.append("<cctr_code__bc><![CDATA[" + checkNull(cctrCodeBc) + "]]></cctr_code__bc>");
xmlString.append("<curr_code__bc><![CDATA[" + checkNull(currCodeBc) + "]]></curr_code__bc>");
xmlString.append("<exch_rate__bc><![CDATA[" + excRateBc + "]]></exch_rate__bc>");
xmlString.append("<acct_code__cf><![CDATA[" + checkNull(acctCodeCf)+ "]]></acct_code__cf>");
xmlString.append("<cctr_code__cf><![CDATA[" + checkNull(cctrCodeCf) + "]]></cctr_code__cf>");
xmlString.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>");
xmlString.append("<tax_date><![CDATA[" + checkNull(payDate) + "]]></tax_date>");
xmlString.append("<WF_STATUS ><![CDATA[" + checkNull(wfStatus) + "]]></WF_STATUS >");
xmlString.append("<bank_name><![CDATA[" + checkNull(bankName) + "]]></bank_name>");//Added by Jaimin 25/07/2007
if (bankCodeAdd==null)
{bankCodeAdd = "";}
xmlString.append("<bank_code__add><![CDATA[" + bankCodeAdd + "]]></bank_code__add>");
xmlString.append("<confirmed><![CDATA[N]]></confirmed>");
xmlString.append("<emp_code__conf><![CDATA[]]></emp_code__conf>");
xmlString.append("<conf_date><![CDATA[]]></conf_date>");
xmlString.append("<chg_user><![CDATA[" + chgUser + "]]></chg_user>");
xmlString.append("<chg_term><![CDATA[" + chgTerm + "]]></chg_term>");
xmlString.append("<chg_date><![CDATA[" + chgDate + "]]></chg_date>");
//xmlString.append("<chq_no__fr><![CDATA[" + chgFrm + "]]></chq_no__fr>");
//xmlString.append("<chq_no__to><![CDATA[" + chgTo + "]]></chq_no__to>");
xmlString.append("</Detail1>");
System.out.println("Creating Header====$$$$$="+xmlString.toString());
System.out.println("End Header$$$$$$");
System.out.println("Size of TempList====="+tempList.size());
System.out.println("Line No before========"+ lineNo);
lineNo = 0;
for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++)
{
lineNo++; lineNo++;
xmlString.append("<Detail2 dbID=':' domID='1' objName='misc_pay' objContext='2'>"); System.out.println("Line No after increament=========="+lineNo);
tempMap = (HashMap)tempList.get(itemCtr);
payAmt=(String)tempMap.get("pay_amt") ;
System.out.println("Get PayAmount Value from Map==========="+payAmt);
netPayable=(String)tempMap.get("net_pay_amt") ;
System.out.println("Get netPayable Value from Map==========="+netPayable);
System.out.println("Get SumAmt of PayAmt==========="+sumNetAmt);
//if (Double.parseDouble(payAmt) != 0 ) //
if(sumNetAmt>0)
{
System.out.println("--------------> if payAmt>0 :: "+payAmt);
System.out.println("--------------> if netPayable>0 :: "+netPayable);
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)) )
{ // End by Jaimin 16/08/2007
System.out.println("----------------In condition---1111-----------");
System.out.println("temp tran_id========"+(String)tempMap.get("tran_id"));
System.out.println("temp tran_ser========"+(String)tempMap.get("tran_ser"));
System.out.println("temp vouch_no========"+(String)tempMap.get("vouch_no"));
System.out.println("temp vouch_date========"+(String)tempMap.get("vouch_date"));
System.out.println("temp vouch_date========"+(String)tempMap.get("vouch_date"));
System.out.println("temp net_amt========"+(String)tempMap.get("net_amt"));
System.out.println("temp pay_amt========"+(String)tempMap.get("pay_amt"));
System.out.println("temp curr_code========"+(String)tempMap.get("curr_code"));
System.out.println("temp exch_rate__vouch========"+(String)tempMap.get("exch_rate__vouch"));
System.out.println("temp diff_amt__exch========"+(String)tempMap.get("diff_amt__exch"));
System.out.println("temp acct_code__ap========"+(String)tempMap.get("acct_code__ap"));
System.out.println("temp sundry type======="+(String)tempMap.get("sundry_type"));
System.out.println("temp cctr_code__ap========"+(String)tempMap.get("cctr_code__ap"));
System.out.println("temp tax_env========"+(String)tempMap.get("tax_env"));
System.out.println("temp bill_no========"+(String)tempMap.get("bill_no"));
System.out.println("temp bill_date========"+(String)tempMap.get("bill_date"));
System.out.println("temp exch_rate========"+(String)tempMap.get("exch_rate"));
System.out.println("temp discount_amt========"+(Double)tempMap.get("discount_amt"));
System.out.println("temp discount========"+(Double)tempMap.get("discount"));
System.out.println("temp tot_amt========"+(String)tempMap.get("tot_amt"));
xmlString.append("<Detail2 dbID=':' domID=\"1\" objName='misc_pay' objContext='2'>");
xmlString.append("<attribute pkNames='tran_id:line_no:' status='N' updateFlag='A' selected='N' />"); xmlString.append("<attribute pkNames='tran_id:line_no:' status='N' updateFlag='A' selected='N' />");
xmlString.append("<tran_id><![CDATA[]]></tran_id>"); xmlString.append("<tran_id><![CDATA[]]></tran_id>");
xmlString.append("<tran_ser><![CDATA["+checkNull(tranSer)+"]]></tran_ser>");
//xmlString.append("<tran_id><![CDATA["+ tempMap.get("tran_id") +"]]></tran_id>");
xmlString.append("<line_no><![CDATA["+lineNo+"]]></line_no>"); xmlString.append("<line_no><![CDATA["+lineNo+"]]></line_no>");
xmlString.append("<vouch_no><![CDATA["+checkNull(refNo)+"]]></vouch_no>"); xmlString.append("<tran_ser><![CDATA["+ tempMap.get("tran_ser") +"]]></tran_ser>");
xmlString.append("<vouch_date><![CDATA[" + checkNull(refDate) + "]]></vouch_date>");//Added by Jaimin 25/07/2007 xmlString.append("<vouch_no><![CDATA["+ tempMap.get("vouch_no") +"]]></vouch_no>");
xmlString.append("<net_amt><![CDATA["+checkNull(payAmt)+"]]></net_amt>"); xmlString.append("<vouch_date><![CDATA["+ tempMap.get("vouch_date") +"]]></vouch_date>");
xmlString.append("<pay_amt><![CDATA["+checkNull(payAmt)+"]]></pay_amt>");
xmlString.append("<curr_code><![CDATA["+checkNull(currCodeBc)+"]]></curr_code>");
xmlString.append("<exch_rate__vouch><![CDATA["+checkNull(exchRate)+"]]></exch_rate__vouch>"); xmlString.append("<net_amt><![CDATA["+ tempMap.get("net_amt") +"]]></net_amt>");
xmlString.append("<diff_amt__exch><![CDATA["+diffAmt+"]]></diff_amt__exch>"); xmlString.append("<pay_amt><![CDATA["+ tempMap.get("pay_amt") +"]]></pay_amt>");
xmlString.append("<acct_code__ap><![CDATA["+checkNull(acctCode)+"]]></acct_code__ap>");// xmlString.append("<curr_code><![CDATA["+ tempMap.get("curr_code") +"]]></curr_code>");
xmlString.append("<cctr_code__ap><![CDATA["+checkNull(cctrCode)+"]]></cctr_code__ap>");// xmlString.append("<exch_rate__vouch><![CDATA["+ tempMap.get("exch_rate__vouch") +"]]></exch_rate__vouch>");
xmlString.append("<sundry_type><![CDATA["+checkNull(sundryType)+"]]></sundry_type>");//
xmlString.append("<sundry_code><![CDATA["+checkNull(sundryCode)+"]]></sundry_code>");// xmlString.append("<diff_amt__exch><![CDATA["+ tempMap.get("diff_amt__exch") +"]]></diff_amt__exch>");
xmlString.append("<bank_charges><![CDATA["+0+"]]></bank_charges>");// xmlString.append("<acct_code__ap><![CDATA["+ tempMap.get("acct_code__ap") +"]]></acct_code__ap>");
xmlString.append("<stan_code><![CDATA["+checkNull(stanCode)+"]]></stan_code>"); xmlString.append("<cctr_code__ap><![CDATA["+ tempMap.get("cctr_code__ap") +"]]></cctr_code__ap>");
xmlString.append("<drawn_at><![CDATA["+drawnAt+"]]></drawn_at>"); xmlString.append("<sundry_type><![CDATA["+ tempMap.get("sundry_type") +"]]></sundry_type>");
xmlString.append("<tax_amt><![CDATA["+0+"]]></tax_amt>");// xmlString.append("<sundry_code><![CDATA["+ tempMap.get("sundry_code") +"]]></sundry_code>");
xmlString.append("<net_pay_amt><![CDATA["+payAmt+"]]></net_pay_amt>");// xmlString.append("<bank_charges><![CDATA["+ tempMap.get("bank_charges") +"]]></bank_charges>");
xmlString.append("<acct_code__disc><![CDATA["+checkNull(acctCodeDisc)+"]]></acct_code__disc>");// xmlString.append("<stan_code><![CDATA["+ tempMap.get("stan_code") +"]]></stan_code>");
xmlString.append("<cctr_code__disc><![CDATA["+checkNull(cctrCodeDisc)+"]]></cctr_code__disc>");// xmlString.append("<drawn_at><![CDATA["+ tempMap.get("drawn_at") +"]]></drawn_at>");
//xmlString.append("<tax_env><![CDATA["+exchRate+"]]></tax_env>");//doubtremaining
xmlString.append("<bill_no><![CDATA["+billNo+"]]></bill_no>"); xmlString.append("<tax_amt><![CDATA["+ tempMap.get("tax_amt") +"]]></tax_amt>");
xmlString.append("<bill_date><![CDATA["+billDate+"]]></bill_date>"); xmlString.append("<net_pay_amt><![CDATA["+tempMap.get("net_pay_amt") +"]]></net_pay_amt>");
xmlString.append("<exch_rate><![CDATA["+exchRate+"]]></exch_rate>"); xmlString.append("<acct_code__disc><![CDATA["+ tempMap.get("acct_code__disc") +"]]></acct_code__disc>");
xmlString.append("<cctr_code__disc><![CDATA["+ tempMap.get("cctr_code__disc") +"]]></cctr_code__disc>");
xmlString.append("<discount_amt><![CDATA["+disAmt+"]]></discount_amt>"); xmlString.append("<tax_env><![CDATA["+ tempMap.get("tax_env") +"]]></tax_env>");
xmlString.append("<discount><![CDATA["+discount+"]]></discount>"); // remaining xmlString.append("<bill_no><![CDATA["+ tempMap.get("bill_no") +"]]></bill_no>");
xmlString.append("<bill_date><![CDATA["+ tempMap.get("bill_date") +"]]></bill_date>");
xmlString.append("<tot_amt><![CDATA["+totAmt+"]]></tot_amt>"); xmlString.append("<exch_rate><![CDATA["+ tempMap.get("exch_rate") +"]]></exch_rate>");
//xmlString.append("<pay_mode><![CDATA["+payMode+"]]></pay_mode>"); xmlString.append("<discount_amt><![CDATA["+ tempMap.get("discount_amt") +"]]></discount_amt>");
//xmlString.append("<adv_amt><![CDATA["+advAmt+"]]></adv_amt>"); xmlString.append("<discount><![CDATA["+ tempMap.get("discount") +"]]></discount>");
//xmlString.append("<adj_amt><![CDATA["+adjAmt+"]]></adj_amt>"); xmlString.append("<tot_amt><![CDATA["+ tempMap.get("tot_amt") +"]]></tot_amt>");
//xmlString.append("<hold_amt><![CDATA["+holdAmt+"]]></hold_amt>");
//xmlString.append("<net_payable><![CDATA["+netPayable+"]]></net_payable>");
//xmlString.append("<curr_code><![CDATA["+currCode+"]]></curr_code>");
//xmlString.append("<exch_rate><![CDATA["+exchRate+"]]></exch_rate>");
//xmlString.append("<acct_code><![CDATA["+acctCode+"]]></acct_code>");
//xmlString.append("<cctr_code><![CDATA["+cctrCode+"]]></cctr_code>");
//xmlString.append("<due_date><![CDATA["+dueDate+"]]></due_date>");
//xmlString.append("<pay_amt><![CDATA["+payAmt+"]]></pay_amt>");
//xmlString.append("<tran_id__pay><![CDATA[]]></tran_id__pay>");
//xmlString.append("<tran_id__miscpay><![CDATA["+tranId+"]]></tran_id__miscpay>");
//xmlString.append("<sundry_name><![CDATA["+sundryName+"]]></sundry_name>");*/
xmlString.append("</Detail2>"); xmlString.append("</Detail2>");
System.out.println("XmlString Detail======"+xmlString.toString()); System.out.println("XmlString Detail======"+xmlString.toString());
} }
}///add
else else
{//case added by Jaimin 17/08/2007 {//case added by Jaimin 17/08/2007
System.out.println("--------------> Error<---------------------"+refNo); System.out.println("--------------> Error<---------------------"+refNo);
...@@ -1253,40 +1502,69 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1253,40 +1502,69 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} }
} }
} //}
System.out.println("XmlString ======"+xmlString.toString());
System.out.println("Getting erroe-------"+errString);
//FOR OUTER LOOP System.out.println("Processing DATA *****");
if (errString.trim().length()>0 ) startDate = new java.util.Date(System.currentTimeMillis());
{ calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
err = errMsg("","","",errString); startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
}//End by Jaimin 17/08/2007 strToWrite=strToWrite+startDateStr+",";
else
{ System.out.println("STARTING DATE"+startDateStr +"STRING TO WRITE"+strToWrite);
xmlString.append("</Header0></group0></DocumentRoot>"); xmlString.append("</Header0></group0></DocumentRoot>");
xmlOutString = xmlString.toString(); xmlOutString = xmlString.toString();
System.out.println("Counter before save data==="+cntXml);
System.out.println("xmlOutString============="+xmlOutString); System.out.println("xmlOutString============="+xmlOutString);
//writeLog(filePtr,"xmlString-->\n"+xmlString,true);
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
InitialContext ctx = null;
MasterStatefulLocal masterStateful = null;
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");// added for ejb3
//MasterStateful masterStateful = masterStatefulHome.create(); //commented for ejb3
retString = masterStateful.processRequest(authencate, siteCode, true,xmlOutString);
System.out.println("After save data ======================="+retString); retString = saveData(siteCode, xmlOutString, conn);
//Added - Gulzar - 25/01/08 if (retString != null && retString.trim().length() > 0)
if ( retString.indexOf("Success") > 0 )
{ {
retString = itmDBAccessEJB.getErrorString("","VTCOMPL","userId"); System.out.println("Result string not null++++++++");
System.out.println("--going to commit tranaction--");
if (retString.indexOf("Success") > -1)
{
conn.commit();
System.out.println("--transaction commited--");
}
else
{
conn.rollback();
System.out.println("--transaction rollback--");
} }
//End Added - Gulzar - 25/01/08
} }
cntXml++;
System.out.println("After Save======"+retString.toString());
String[] arrayForTranId = retString.split("<TranID>");
System.out.println(">>>In AutoPmtGenPrc arrayForTranId:["+arrayForTranId.toString()+"]arrayForTranId.length["+arrayForTranId.length+"]");
if( arrayForTranId.length > 1 )
{
int endIndex = arrayForTranId[1].indexOf("</TranID>");
autoPaymTranId = arrayForTranId[1].substring(0,endIndex);
}
System.out.println(">>>In autoPaym Generated new Tran ID:"+autoPaymTranId);
System.out.println("**********SUCCESS***********");
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);
strToWrite=strToWrite+endDateStr+",";
strToWrite = strToWrite + retString+"\r\n\r\n";
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
strToWrite="";
} //end of while loop
System.out.println("retString:: "+ retString); System.out.println("retString:: "+ retString);
System.out.println("Transaction Id===="+tranId);
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -1295,10 +1573,21 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1295,10 +1573,21 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} }
finally finally
{ {
try try
{ {
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close(); conn.close();
conn = null;
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1497,6 +1786,36 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1497,6 +1786,36 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
} }
private String saveData(String siteCode, String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
} catch (ITMException itme)
{
System.out.println("ITMException :AutoPmtGenPrc :saveData :==>");
throw itme;
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :AutoPmtGenPrc :saveData :==>");
throw new ITMException(e);
}
return retString;
}
public String getStanDraw(String sundryType ,String sundryCode,Connection conn) throws ITMException public String getStanDraw(String sundryType ,String sundryCode,Connection conn) throws ITMException
{ {
...@@ -1966,4 +2285,45 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -1966,4 +2285,45 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
return dueDate; return dueDate;
} }
private String intializingLog(String fileName)
{
String log="intializingLog_Failed";
String strToWrite = "";
String currTime = null;
try{
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
log ="intializingLog_Successesfull";
return log;
}
} }
\ No newline at end of file
...@@ -39,10 +39,11 @@ public class AutoPmtPrcSch implements Schedule ...@@ -39,10 +39,11 @@ public class AutoPmtPrcSch implements Schedule
String sysDate =""; String sysDate ="";
String retString=""; String retString="";
String xtraParams = "",siteCode="",sundryType="",sundryCode=""; String xtraParams = "",siteCode="",sundryType="",sundryCode="",currCode="",payMode="",bankCode="",spiltChq="";
String actualLoginSiteCode=""; String actualLoginSiteCode="";
String getString=""; String getString="";
String due_date_from="",wfStatus=""; String due_date_from="",wfStatus="";
String noOfDays="";
try try
{ {
...@@ -100,22 +101,50 @@ public class AutoPmtPrcSch implements Schedule ...@@ -100,22 +101,50 @@ public class AutoPmtPrcSch implements Schedule
} }
if(ctr==3) if(ctr==3)
{ {
sundryType = childNode.getFirstChild().getNodeValue(); sundryType = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("sundryType======"+sundryType); System.out.println("sundryType======"+sundryType);
} }
if(ctr==4) if(ctr==4)
{ {
sundryCode = childNode.getFirstChild().getNodeValue(); sundryCode = checkNull(childNode.getFirstChild().getNodeValue());
System.out.println("sundryCode======"+sundryCode); System.out.println("sundryCode======"+sundryCode);
} }
//added on 12/MAY/15
if(ctr==5)
{
currCode = childNode.getFirstChild().getNodeValue();
System.out.println("currCode======"+currCode);
}
if(ctr==6)
{
payMode = childNode.getFirstChild().getNodeValue();
System.out.println("payMode======"+payMode);
}
if(ctr==7)
{
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);
}
} }
} }
System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log")); //System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
getString= autoPayment(actualLoginSiteCode,sundryType,due_date_from,wfStatus,sundryCode,scheduleParamXML); getString= autoPayment(actualLoginSiteCode,sundryType,due_date_from,wfStatus,sundryCode,currCode,payMode,bankCode,noOfDays,scheduleParamXML);
} }
...@@ -141,7 +170,7 @@ public class AutoPmtPrcSch implements Schedule ...@@ -141,7 +170,7 @@ public class AutoPmtPrcSch implements Schedule
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
public String autoPayment(String siteCode,String sundryType,String dueDateFrom,String wfStatus,String sundryCodeParam,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 scheduleParamXML ) throws Exception
{ {
Connection conn = null; Connection conn = null;
...@@ -152,10 +181,10 @@ public class AutoPmtPrcSch implements Schedule ...@@ -152,10 +181,10 @@ public class AutoPmtPrcSch implements Schedule
boolean isError = false; boolean isError = false;
String retString=""; String retString="";
String sql=""; String sql="";
String sundryFieldName="",sundryTableName="",sundryCode=""; String sundryFieldName="",sundryTableName="";
String tranId="",loginSiteCode="",xtraParams = ""; String tranId="",loginSiteCode="",xtraParams = "";
String vouchurNo=""; String vouchurNo="",currCode="";
String miscPaytranDate="",effDate="",billNo="",billDate="",currCode="",exchRate="",acctrCode="",cctrCode=""; String miscPaytranDate="",effDate="",billNo="",billDate="",currCode1="",exchRate="",acctrCode="",cctrCode="";
String dueOn="",finEntity="",siteCd="",totAmt="",sundryTyp="",bankCode="",payMode=""; 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="";
String xmlString4="", retString1=""; String xmlString4="", retString1="";
...@@ -184,14 +213,19 @@ public class AutoPmtPrcSch implements Schedule ...@@ -184,14 +213,19 @@ public class AutoPmtPrcSch implements Schedule
loginSiteCode = userInfo.getSiteCode(); loginSiteCode = userInfo.getSiteCode();
String windowName="w_miscpay_auto,"; String windowName="w_miscpay_auto,";
xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode(); xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode();
String autoPaym="";
java.util.Date today=new java.util.Date(); java.util.Date today=new java.util.Date();
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
c.setTime(today); c.setTime(today);
today = c.getTime(); today = c.getTime();
SimpleDateFormat sdf=new SimpleDateFormat(e12GenericUtility.getApplDateFormat()); SimpleDateFormat sdf=new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
sysDate=sdf.format(today); sysDate=sdf.format(today);
System.out.println("sysDate****=========="+sysDate);
int graceDay=Integer.parseInt(noOfDays);
System.out.println("No of aGrace Days=========="+graceDay);
c.add(Calendar.DATE, graceDay);
String getdays=sdf.format(c.getTime());
System.out.println("getdays================"+getdays);
Date currentDate = new Date(); Date currentDate = new Date();
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getApplDateFormat()); SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
...@@ -246,14 +280,14 @@ public class AutoPmtPrcSch implements Schedule ...@@ -246,14 +280,14 @@ public class AutoPmtPrcSch implements Schedule
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
currCode=rs.getString("curr_code"); currCode1=rs.getString("curr_code");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("currCode========="+currCode); System.out.println("currCode========="+currCode1);
trantype=fin.getFinparams("999999", "TRAN_TYPE_AUTO_PAY", conn); trantype=fin.getFinparams("999999", "TRAN_TYPE_AUTO_PAY", conn);
System.out.println("trantype========="+trantype); System.out.println("trantype========="+trantype);
...@@ -262,88 +296,19 @@ public class AutoPmtPrcSch implements Schedule ...@@ -262,88 +296,19 @@ public class AutoPmtPrcSch implements Schedule
trantype="O"; trantype="O";
} }
if(sundryType!=null && sundryType.trim().length()>0 &&("C".equalsIgnoreCase(sundryType)))
{
sundryTableName="customer";
sundryFieldName="cust_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("S".equalsIgnoreCase(sundryType)))
{
sundryTableName="supplier";
sundryFieldName="supp_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("B".equalsIgnoreCase(sundryType)))
{
sundryTableName="bank";
sundryFieldName="bank_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("T".equalsIgnoreCase(sundryType)))
{
sundryTableName="transporter";
sundryFieldName="tran_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("E".equalsIgnoreCase(sundryType)))
{
sundryTableName="employee";
sundryFieldName="emp_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("L".equalsIgnoreCase(sundryType)))
{
sundryTableName="loanparty";
sundryFieldName="party_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("P".equalsIgnoreCase(sundryType)))
{
sundryTableName="sales_pers";
sundryFieldName="sales_pers";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("R".equalsIgnoreCase(sundryType)))
{
sundryTableName="strg_customer";
sundryFieldName="sc_code";
}
else if(sundryType!=null && sundryType.trim().length()>0 &&("X".equalsIgnoreCase(sundryType)))
{
sundryTableName="tax_authority";
sundryFieldName="tauth_code";
}
if(("null".equals(sundryCodeParam) || sundryCodeParam.trim().length() == 0 ))
{
sql="select "+sundryFieldName+" from "+sundryTableName;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
sundryCode = rs.getString(1);
//System.out.println("sundryCode>>..>>>>>"+sundryCode);
sundryCodeList.add(sundryCode);
}
}
else
{
String[] arrStr =sundryCodeParam.split(",");
int len =arrStr.length;
for(int i =0;i<len;i++)
{
sundryCode =arrStr[i];
// System.out.println("sundryCode>>>>>>>>"+sundryCode);
sundryCodeList.add(sundryCode);
}
}
System.out.println("list Size========="+sundryCodeList.size());
int itr=0; int itr=0;
while(itr < sundryCodeList.size())
{
sundryCode = sundryCodeList.get(itr);
System.out.println("------------->sundryCode" +sundryCode); System.out.println("------------->sundryCode" +sundryCode);
payMode="%"; // payMode="%";
String xmlString1=" <Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"+ String xmlString1=" <Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"miscpay_auto\"><attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"+
"<date__pay><![CDATA["+sdf1.format(currentDate).toString()+"]]></date__pay>" + "<date__pay><![CDATA["+sdf1.format(currentDate).toString()+"]]></date__pay>" +
"<vouch_no__fr><![CDATA[]]></vouch_no__fr>" + "<vouch_no__fr><![CDATA[]]></vouch_no__fr>" +
"<vouch_no__to><![CDATA[]]></vouch_no__to>" + "<vouch_no__to><![CDATA[]]></vouch_no__to>" +
"<date__fr><![CDATA["+dueDateFrom+"]]></date__fr>" + "<date__fr><![CDATA["+dueDateFrom+"]]></date__fr>" +
"<date__to><![CDATA["+sysDate+"]]></date__to>" + //"<date__to><![CDATA["+sysDate+"]]></date__to>" +
"<date__to><![CDATA["+getdays+"]]></date__to>" +
"<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" + "<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" +
"<bank_code><![CDATA["+bankCode+"]]></bank_code>" + "<bank_code><![CDATA["+bankCode+"]]></bank_code>" +
"<ref_no><![CDATA["+refNo+"]]></ref_no>" + "<ref_no><![CDATA["+refNo+"]]></ref_no>" +
...@@ -362,7 +327,7 @@ public class AutoPmtPrcSch implements Schedule ...@@ -362,7 +327,7 @@ public class AutoPmtPrcSch implements Schedule
"<noof_rejected><![CDATA[]]></noof_rejected>" + "<noof_rejected><![CDATA[]]></noof_rejected>" +
"<tax_env><![CDATA[]]></tax_env>" + "<tax_env><![CDATA[]]></tax_env>" +
"<tran_type><![CDATA["+trantype+"]]></tran_type>" + "<tran_type><![CDATA["+trantype+"]]></tran_type>" +
"<curr_code><![CDATA["+currCode+"]]></curr_code>" + "<curr_code><![CDATA["+curCode+"]]></curr_code>" +
"<bank_flag><![CDATA[]]></bank_flag>"+ "<bank_flag><![CDATA[]]></bank_flag>"+
"<wf_status><![CDATA["+wfStatus+"]]></wf_status></Detail1>"; "<wf_status><![CDATA["+wfStatus+"]]></wf_status></Detail1>";
...@@ -372,7 +337,8 @@ public class AutoPmtPrcSch implements Schedule ...@@ -372,7 +337,8 @@ public class AutoPmtPrcSch implements Schedule
"<vouch_no__fr><![CDATA[]]></vouch_no__fr>" + "<vouch_no__fr><![CDATA[]]></vouch_no__fr>" +
"<vouch_no__to><![CDATA[]]></vouch_no__to>" + "<vouch_no__to><![CDATA[]]></vouch_no__to>" +
"<date__fr><![CDATA["+sysDate+"]]></date__fr>" + "<date__fr><![CDATA["+sysDate+"]]></date__fr>" +
"<date__to><![CDATA["+sysDate+"]]></date__to>" + //"<date__to><![CDATA["+sysDate+"]]></date__to>" +
"<date__to><![CDATA["+getdays+"]]></date__to>" +
"<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" + "<site_code__fr><![CDATA["+siteCode+"]]></site_code__fr>" +
"<bank_code><![CDATA["+bankCode+"]]></bank_code>" + "<bank_code><![CDATA["+bankCode+"]]></bank_code>" +
"<ref_no><![CDATA["+refNo+"]]></ref_no>" + "<ref_no><![CDATA["+refNo+"]]></ref_no>" +
...@@ -391,7 +357,7 @@ public class AutoPmtPrcSch implements Schedule ...@@ -391,7 +357,7 @@ public class AutoPmtPrcSch implements Schedule
"<noof_rejected><![CDATA[]]></noof_rejected>" + "<noof_rejected><![CDATA[]]></noof_rejected>" +
"<tax_env><![CDATA[]]></tax_env>" + "<tax_env><![CDATA[]]></tax_env>" +
"<tran_type><![CDATA["+trantype+"]]></tran_type>" + "<tran_type><![CDATA["+trantype+"]]></tran_type>" +
"<curr_code><![CDATA["+currCode+"]]></curr_code>" + "<curr_code><![CDATA["+curCode+"]]></curr_code>" +
"<bank_flag><![CDATA[]]></bank_flag></Detail1></Header0></group0></DocumentRoot>"; "<bank_flag><![CDATA[]]></bank_flag></Detail1></Header0></group0></DocumentRoot>";
...@@ -405,16 +371,11 @@ public class AutoPmtPrcSch implements Schedule ...@@ -405,16 +371,11 @@ public class AutoPmtPrcSch implements Schedule
/** /**
* Check for Null return * Check for Null return
* */ * */
if(retString!=null && retString.trim().length()>0) //if(retString!=null && retString.trim().length()>0)
{ //{
// Start Process // Start Process
System.out.println("Processing DATA *****"); System.out.println("Processing DATA *****");
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strToWrite=strToWrite+startDateStr+",";
System.out.println("STARTING DATE"+startDateStr +"STRING TO WRITE"+strToWrite);
System.out.println("getData Method Finished@@@@@@@@@@@2"); System.out.println("getData Method Finished@@@@@@@@@@@2");
...@@ -489,47 +450,14 @@ public class AutoPmtPrcSch implements Schedule ...@@ -489,47 +450,14 @@ public class AutoPmtPrcSch implements Schedule
System.out.println("Calling process() Method@@@@@@@@@@@@"); System.out.println("Calling process() Method@@@@@@@@@@@@");
retString1 = aPayPrc.process(xmlString1, xmlString4, windowName, xtraParams); retString1 = aPayPrc.process(xmlString1, xmlString4, windowName, xtraParams);
endDate = new java.util.Date(System.currentTimeMillis()); System.out.println("retString1 in Scheduler====="+retString1);
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strToWrite=strToWrite+endDateStr+",";
strToWrite = strToWrite + retString+"\r\n\r\n"+xmlString1+"\r\n\r\n"+xmlString4+"\r\n\r\n"+retString1+"\r\n\r\n";
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
System.out.println("ResultString1....." + retString1);
System.out.println("-----Process() called successfully-------"); System.out.println("-----Process() called successfully-------");
strToWrite="";
//Increment itr
itr++;
}
else
{
//Increment itr
System.out.println("*******No data found GOING ahead*******");
itr++;
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);
strToWrite=strToWrite+endDateStr+",";
strToWrite = strToWrite + "No Data Found"+"\r\n\r\n"+xmlString1+"\r\n\r\n";
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
System.out.println("ResultString1....." + retString1);
System.out.println("-----No data found------");
strToWrite="";
}
System.out.println("Iteration COUNT :- ["+itr+"]");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} }
catch(SQLException se) catch(SQLException se)
...@@ -579,40 +507,6 @@ public class AutoPmtPrcSch implements Schedule ...@@ -579,40 +507,6 @@ public class AutoPmtPrcSch implements Schedule
} }
private String intializingLog(String fileName)
{
String log="intializingLog_Failed";
String strToWrite = "";
String currTime = null;
try{
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
log ="intializingLog_Successesfull";
return log;
}
} }
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