Commit e4421ebe authored by pshinde's avatar pshinde

Changes in Automatic payment scheduler


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98316 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 67d1ac51
...@@ -13,6 +13,7 @@ import java.sql.*; ...@@ -13,6 +13,7 @@ import java.sql.*;
import java.text.*; import java.text.*;
import java.io.*; import java.io.*;
import org.apache.poi.hssf.record.formula.functions.Abs;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import javax.ejb.*; import javax.ejb.*;
...@@ -267,7 +268,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -267,7 +268,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
+"( misc_payables.ref_no >= '" + vouchNoFrom + "' ) AND " +"( misc_payables.ref_no >= '" + vouchNoFrom + "' ) AND "
+"( misc_payables.ref_no <= '" + vouchNoTo + "' ) AND " +"( misc_payables.ref_no <= '" + vouchNoTo + "' ) AND "
+"( misc_payables.auto_pay = 'Y' ) AND " +"( misc_payables.auto_pay = 'Y' ) AND "
+"(misc_payables.tot_amt - misc_payables.adj_amt <> 0 ) AND " +"(misc_payables.tot_amt - misc_payables.adj_amt > 0 ) AND "
+"(misc_payables.hold_amt is null or misc_payables.tot_amt - misc_payables.adj_amt - misc_payables.hold_amt <> 0 ) AND " +"(misc_payables.hold_amt is null or misc_payables.tot_amt - misc_payables.adj_amt - misc_payables.hold_amt <> 0 ) AND "
+"misc_payables.pay_mode like '" + payMode + "' AND " +"misc_payables.pay_mode like '" + payMode + "' AND "
+"case when misc_payables.entry_batch_no is null then ' ' else" +"case when misc_payables.entry_batch_no is null then ' ' else"
...@@ -353,8 +354,15 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -353,8 +354,15 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
payAmt = netPayable; payAmt = netPayable;
//Add ended by Raj (FI78DIS032)- 29/12/2007 System.out.println("");
payAmt = payAmt - unapprovedPayAmt;
System.out.println("PayAmt Value===="+payAmt+"UnApproved Amt====="+unapprovedPayAmt);
//Add ended by Raj (FI78DIS032)- 29/12/2007
System.out.println("");
if( payAmt > 0 )
{
//Refno //Refno
retTabSepStrBuff.append((rs.getString(1)==null)?" " :rs.getString(1)).append("\t"); retTabSepStrBuff.append((rs.getString(1)==null)?" " :rs.getString(1)).append("\t");
//tran_date //tran_date
...@@ -422,6 +430,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -422,6 +430,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
////writeLog(filePtr,"----------------------------------------------------------------" ,true); ////writeLog(filePtr,"----------------------------------------------------------------" ,true);
retTabSepStrBuff.append(spiltChq).append("\r\n"); retTabSepStrBuff.append(spiltChq).append("\r\n");
}
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
...@@ -498,8 +507,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -498,8 +507,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
//writeLog(filePtr,"xtraParams-->"+xtraParams,true); //writeLog(filePtr,"xtraParams-->"+xtraParams,true);
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
ResultSet rs = null; ResultSet rs = null,rs1=null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null,pstmt1=null;
String refNo = ""; String refNo = "";
// String miscPayablesTranDate = ""; // String miscPayablesTranDate = "";
String chgDate = ""; String chgDate = "";
...@@ -601,6 +610,19 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto ...@@ -601,6 +610,19 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
HashMap<String,String> maxDateMap=new HashMap<String, String>(); HashMap<String,String> maxDateMap=new HashMap<String, String>();
String chq1="",chq2=""; String chq1="",chq2="";
String refDate1=""; String refDate1="";
String sundryCdSpilt="";
HashMap splitCodeWiseNegMap = new HashMap();
HashMap tempMapNeg = null;
ArrayList tempListNeg = null;
Date dueDatediff=null;
double pay_amt=0,totamount=0,totAmtRem=0;
String sundryCodeNeg="";
Date refdateNeg=null;
String billNoNeg="";
Date billDateNeg=null;
try try
{ System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log")); { System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
retBuf = new StringBuffer(); retBuf = new StringBuffer();
...@@ -1063,6 +1085,7 @@ System.out.println("Getting winName============"+windowName); ...@@ -1063,6 +1085,7 @@ System.out.println("Getting winName============"+windowName);
System.out.println("Getting combination As====="+tempSplitCode); System.out.println("Getting combination As====="+tempSplitCode);
System.out.println("Getting splitCodeWiseMap====="+splitCodeWiseMap);
if(splitCodeWiseMap.containsKey(tempSplitCode)) if(splitCodeWiseMap.containsKey(tempSplitCode))
{ {
System.out.println("*****Combination Exist*****"); System.out.println("*****Combination Exist*****");
...@@ -1275,7 +1298,7 @@ System.out.println("Getting winName============"+windowName); ...@@ -1275,7 +1298,7 @@ System.out.println("Getting winName============"+windowName);
System.out.println("Getting value in Map======"+tempMap); System.out.println("Getting value in Map======"+tempMap);
tempList.add(tempMap); tempList.add(tempMap);
System.out.println("Getting tempList value after ading in list ======"+tempList); System.out.println("Getting tempList value after ading in list ======"+tempList);
System.out.println("Sundry Type@@@@"+sundryType);
if(splitCodeWiseMap.containsKey(tempSplitCode)) if(splitCodeWiseMap.containsKey(tempSplitCode))
{ {
System.out.println("splitCodeWiseMap.containsKey(tempSplitCode)"); System.out.println("splitCodeWiseMap.containsKey(tempSplitCode)");
...@@ -1287,9 +1310,14 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1287,9 +1310,14 @@ System.out.println("Sundry Type@@@@"+sundryType);
splitCodeWiseMap.put(tempSplitCode,tempList); splitCodeWiseMap.put(tempSplitCode,tempList);
} }
} }
System.out.println("Sundry Code===="+sundryCode);
ArrayList<String > sundryCodeList=new ArrayList<String>();
double sumNetAmt=0.0,totUnconfAmt=0; double sumNetAmt=0.0,totUnconfAmt=0;
String autoPaymTranId=""; String autoPaymTranId="";
Set setItem = splitCodeWiseMap.entrySet(); Set setItem = splitCodeWiseMap.entrySet();
...@@ -1381,6 +1409,290 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1381,6 +1409,290 @@ System.out.println("Sundry Type@@@@"+sundryType);
} }
} }
//addd on 10/07/15***FIRST NEGATIVE MAP CREATED HERE ENDED HERE AND ENDED HERE
if(!sundryCodeList.contains(sundryCode))
{
sundryCodeList.add(sundryCode);
sql= "SELECT misc_payables.ref_no,misc_payables.tran_date,misc_payables.ref_date,misc_payables.bill_no," +
"misc_payables.bill_date,misc_payables.curr_code," +
"misc_payables.exch_rate,misc_payables.sundry_code,misc_payables.acct_code,misc_payables.cctr_code," +
"misc_payables.due_date,misc_payables.site_code,misc_payables.fin_entity," +
"misc_payables.tot_amt,misc_payables.sundry_type," +
"misc_payables.bank_code,misc_payables.pay_mode,misc_payables.adv_amt," +
"misc_payables.tran_id,misc_payables.tran_ser," +
"misc_payables.adj_amt,misc_payables.hold_amt,fn_confirmed_by(misc_payables.tran_ser, misc_payables.ref_no) as username," +
"misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as pay_amt," +
"fn_sundry_name(misc_payables.sundry_type,misc_payables.sundry_code,'') as sundry_name," +
"misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as net_payable " +
" FROM misc_payables WHERE sundry_code= ? and tot_amt - adj_amt < 0 order by due_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sundryCode);
rs = pstmt.executeQuery();
while (rs.next())
{
tranId=rs.getString("tran_id");
tranSer=rs.getString("tran_ser");
refNo=rs.getString("ref_no");
refdateNeg=rs.getDate("ref_date");
currCode=rs.getString("curr_code");
exchRate=rs.getString("exch_rate");
pay_amt=rs.getDouble("pay_amt");
sundryType=rs.getString("sundry_type");
acctCode=rs.getString("acct_code");
cctrCode=rs.getString("cctr_code");
sundryCodeNeg= checkNull(rs.getString("sundry_code"));
dueDatediff= rs.getDate("due_date");
totamount=rs.getDouble("tot_amt");
billNo=rs.getString("bill_no");
billDateNeg=rs.getDate("bill_date");
// pay_amt=rs.getDouble(3);
System.out.println("Sundry Code===="+sundryCode+"Refr No===="+refNo+"Due Date===="+dueDatediff+"pay_amt==="+pay_amt);
//sundryCdSpilt=sundryCodeNeg;
//System.out.println("Getting sundryCdSpilt===== "+sundryCdSpilt);
System.out.println("splitCodeWiseNegMap@@@@@"+splitCodeWiseNegMap);
if(splitCodeWiseNegMap.containsKey(sundryCode))
{
System.out.println("* Exist for SundryCd Spilt combo*");
tempListNeg = (ArrayList) splitCodeWiseNegMap.get(sundryCode);
System.out.println("Exist for SundryCd Spilt combo======"+tempListNeg);
}
else
{
System.out.println("***Not Exist for SundryCd Spilt combo*****");
tempListNeg = new ArrayList();
System.out.println("Not Exist for SundryCd Spilt combo======"+tempListNeg);
}
System.out.println(" records in tempListNeg======"+tempListNeg);
sql="select purc_order,eff_date,bill_date from voucher where tran_id = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,refNo);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
porder=checkNull(rs1.getString("purc_order"));
effDate=rs1.getDate("eff_date");
billDt=rs1.getDate("bill_date");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("Purchase order========="+porder);
System.out.println("effDate========="+effDate);
System.out.println("billDt========="+billDt);
sql="select cr_term from porder where purc_order =?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,porder);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
sfld1=checkNull(rs1.getString("cr_term"));
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("sfld1========="+sfld1);
sql="select crtermfc.fin_chg,crterm.acct_code__disc,crterm.cctr_code__disc,crterm.start_from from crterm,crtermfc " +
"where crtermfc.cr_term = crterm.cr_term and crterm.cr_term = ? and trim(crtermfc.line_no) = '1'";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,sfld1);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
discount=rs1.getDouble("fin_chg");
acctCodeDisc=checkNull(rs1.getString("acct_code__disc"));
cctrCodeDisc=checkNull(rs1.getString("cctr_code__disc"));
startFrom=checkNull(rs1.getString("start_from"));
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("discount========="+discount);
System.out.println("acctCodeDisc========="+acctCodeDisc);
System.out.println("cctrCodeDisc========="+cctrCodeDisc);
System.out.println("startFrom========="+startFrom);
reDate1 = sdf.parse(refDate);
Date discdt=getDiscountdate(sfld1, reDate1, effDate, billDt, conn);
System.out.println("Getting discdt======"+discdt);
if(discdt!=null)
{
System.out.println("Getting discdt not null==");
String discdt1=sdf.format(discdt);
System.out.println("Getting discdt================"+discdt1);
mPayDate=sdf.parse(transactionDate);
System.out.println("mPayDate============"+mPayDate);
long diff = discdt.getTime() - mPayDate.getTime();
datediff = diff / (24 * 60 * 60 * 1000);
System.out.println("CurrDtae======================="+datediff);
}
sql="select fin_chg from crtermfc where ? between min_day and max_day and cr_term = ? and trim(line_no) = '1'";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setLong(1,datediff);
pstmt1.setString(2,sfld1);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
discount=rs1.getDouble("fin_chg");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("Get Discount======="+discount);
if(discount==0)
{
discount=0;
}
System.out.println(">>>>>>>>startFrom==="+startFrom);
if((startFrom!=null && startFrom.trim().length()>0) && "R".equalsIgnoreCase(startFrom))
{
ldStartDate=reDate1;
}
else if((startFrom!=null && startFrom.trim().length()>0) && "D".equalsIgnoreCase(startFrom) && "Q".equalsIgnoreCase(startFrom))
{
ldStartDate=effDate;
}
else if((startFrom!=null && startFrom.trim().length()>0) && "B".equalsIgnoreCase(startFrom) )
{
ldStartDate=billDt;
}
if((payDate!=null && payDate.trim().length()>0) && ldStartDate!=null)
{
payDate1 = sdf.parse(payDate);
if((payDate1!=null && payDate1.compareTo(ldStartDate)>0)&& payDate1.compareTo(discdt)<0)
{
if(discount!=0)
{System.out.println("Discount not equals to Zerooooooooooooo");
payAmt1=Double.parseDouble(payAmt);
disAmt= payAmt1 *(discount/100);
}
}
}
System.out.println("disAmount=========="+disAmt);
System.out.println("PayMAode======="+payMode);
System.out.println("BankCode>>>>>==="+bankCode);
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode))
{
System.out.println("payMode<<<<<<<<");
drawnAt=checkNull(getpayablesAt(sundryType, sundryCode, bankCode, conn));
}
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode)||"T".equalsIgnoreCase(payMode)||"N".equalsIgnoreCase(payMode))
{
System.out.println("payMode========>>>>");
stanCode=checkNull(getStanDraw(sundryType, sundryCode, conn));
System.out.println("Getting stanCode=============="+stanCode);
}
System.out.println("vouch_no============"+refNo);
System.out.println("vouch_date============"+refDate);
System.out.println("payAmt============"+payAmt);
System.out.println("acct_code__ap========="+acctCode);
System.out.println("cctr_code__ap========="+cctrCode);
double payAmount=Double.parseDouble(payAmt);
double exchRate1=Double.parseDouble(exchRate);
diffAmt=((payAmount * exchRate1)-(payAmount*mexrate));
System.out.println("diff_amt__exch========="+diffAmt);
//added by priyanka on 09/07/15
tempMapNeg = new HashMap();
tempMapNeg.put("tran_id", tranId);
tempMapNeg.put("tran_ser", tranSer);
tempMapNeg.put("line_no", lineNo);
tempMapNeg.put("vouch_no", refNo);
if(refdateNeg!=null)
{
tempMapNeg.put("vouch_date", refdateNeg);
}
tempMapNeg.put("net_amt", pay_amt);
tempMapNeg.put("pay_amt", pay_amt);
tempMapNeg.put("curr_code", currCode);
tempMapNeg.put("exch_rate__vouch", exchRate);
tempMapNeg.put("diff_amt__exch", pay_amt);
tempMapNeg.put("acct_code__ap", acctCode);
tempMapNeg.put("cctr_code__ap", cctrCode);
tempMapNeg.put("sundry_type", sundryType);
tempMapNeg.put("sundry_code", sundryCodeNeg);
tempMapNeg.put("bank_charges", 0);
tempMapNeg.put("stan_code", stanCode);
tempMapNeg.put("drawn_at", drawnAt);
tempMapNeg.put("tax_amt", 0);
tempMapNeg.put("net_pay_amt", pay_amt);
tempMapNeg.put("acct_code__disc", acctCodeDisc);
tempMapNeg.put("cctr_code__disc", cctrCodeDisc);
tempMapNeg.put("bill_no", billNo);
tempMapNeg.put("bill_date", billDate);
tempMapNeg.put("exch_rate", exchRate);
tempMapNeg.put("discount_amt", disAmt);
tempMapNeg.put("discount", discount);
tempMapNeg.put("tot_amt", totamount);
//tempMapNeg.put("unconfirm_amt", unconfirmAmt); // cpatil
System.out.println("Getting value in Negative Map======"+tempMapNeg);
tempListNeg.add(tempMapNeg);
System.out.println("Getting tempList value after ading in list ======"+tempListNeg);
if(splitCodeWiseNegMap.containsKey(sundryCode))
{
System.out.println("splitCodeWiseNegMap.containsKey(sundryCdSpilt)");
splitCodeWiseNegMap.put(sundryCode,tempListNeg);
}
else
{
System.out.println("else*************");
splitCodeWiseNegMap.put(sundryCode,tempListNeg);
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
System.out.println("Final Negative List====="+splitCodeWiseNegMap);
System.out.println("Ref No To be set in Header ======="+maxRefNo); System.out.println("Ref No To be set in Header ======="+maxRefNo);
sumNetAmt=0.0; sumNetAmt=0.0;
System.out.println("Sum Amount 1 @@@==="+sumNetAmt); System.out.println("Sum Amount 1 @@@==="+sumNetAmt);
...@@ -1485,6 +1797,7 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1485,6 +1797,7 @@ System.out.println("Sundry Type@@@@"+sundryType);
lineNo = 0; lineNo = 0;
for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++) for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++)
{ {
System.out.println("Main Iten Conter==="+itemCtr);
/*lineNo++; // doubt /*lineNo++; // doubt
System.out.println("Line No after increament=========="+lineNo);*/ System.out.println("Line No after increament=========="+lineNo);*/
tempMap = (HashMap)tempList.get(itemCtr); tempMap = (HashMap)tempList.get(itemCtr);
...@@ -1509,8 +1822,8 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1509,8 +1822,8 @@ System.out.println("Sundry Type@@@@"+sundryType);
System.out.println("--------------> if netPayable>0 :: "+netPayable); System.out.println("--------------> if netPayable>0 :: "+netPayable);
System.out.println("--------------> totUnconfAmt :: "+totUnconfAmt); System.out.println("--------------> totUnconfAmt :: "+totUnconfAmt);
if (( (Double.parseDouble(netPayable) > 0 && Double.parseDouble(payAmt) <= Double.parseDouble(netPayable) && Double.parseDouble(payAmt) >=0) 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(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) ) && Double.parseDouble(payAmt)>0) // added by cpatil @sun on 06/06/15
{ // End by Jaimin 16/08/2007 { // End by Jaimin 16/08/2007
System.out.println("----------------In condition---1111-----------"); System.out.println("----------------In condition---1111-----------");
lineNo++; // doubt lineNo++; // doubt
...@@ -1574,7 +1887,8 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1574,7 +1887,8 @@ System.out.println("Sundry Type@@@@"+sundryType);
xmlString.append("<net_pay_amt><![CDATA["+tempMap.get("net_pay_amt") +"]]></net_pay_amt>"); xmlString.append("<net_pay_amt><![CDATA["+tempMap.get("net_pay_amt") +"]]></net_pay_amt>");
xmlString.append("<acct_code__disc><![CDATA["+ tempMap.get("acct_code__disc") +"]]></acct_code__disc>"); 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("<cctr_code__disc><![CDATA["+ tempMap.get("cctr_code__disc") +"]]></cctr_code__disc>");
xmlString.append("<tax_env><![CDATA["+ tempMap.get("tax_env") +"]]></tax_env>");
xmlString.append("<tax_env><![CDATA["+ checkNull(tempMap.get("tax_env")==null ? "":tempMap.get("tax_env").toString())+"]]></tax_env>");
xmlString.append("<bill_no><![CDATA["+ tempMap.get("bill_no") +"]]></bill_no>"); xmlString.append("<bill_no><![CDATA["+ tempMap.get("bill_no") +"]]></bill_no>");
xmlString.append("<bill_date><![CDATA["+ tempMap.get("bill_date") +"]]></bill_date>"); xmlString.append("<bill_date><![CDATA["+ tempMap.get("bill_date") +"]]></bill_date>");
...@@ -1585,7 +1899,209 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1585,7 +1899,209 @@ System.out.println("Sundry Type@@@@"+sundryType);
xmlString.append("</Detail2>"); xmlString.append("</Detail2>");
System.out.println("XmlString Detail======"+xmlString.toString()); System.out.println("XmlString Detail======"+xmlString.toString());
}
}
double sumNetAmtDummy=0;
sumNetAmtDummy=sumNetAmt;
System.out.println("Positive of Sum amount==="+sumNetAmtDummy);
System.out.println("Sundry Code &&&==="+sundryCode);
System.out.println("Sundry Code @@@@@2=="+sundryCdSpilt);
tempListNeg = (ArrayList)splitCodeWiseNegMap.get(sundryCode);
System.out.println("TempList negative Inside While======="+tempListNeg);
// lineNo = 0;
System.out.println("tempListNeg.size()===="+tempListNeg);
if(itemCtr== tempList.size()-1)
{
for (int itemCtr1 = 0; itemCtr1 < tempListNeg.size(); itemCtr1++)
{
//System.out.println("Inside for loop====="+tempMapNeg);
System.out.println("itemCtr1()===="+itemCtr1);
tempMapNeg = (HashMap)tempListNeg.get(itemCtr1);
System.out.println("tempMapNeg>>>>>>>>===="+tempMapNeg);
payAmt1=(Double) tempMapNeg.get("pay_amt");
String refNoupd="",sundryCd="";
refNoupd=(String) tempMapNeg.get("vouch_no");
sundryCd=(String) tempMapNeg.get("sundry_code");
System.out.println("Get PayAmount Value from Map==========="+payAmt1);
System.out.println("Get refNoupd Value from Map==========="+refNoupd);
System.out.println("PayAmt absolute value===="+Math.abs((payAmt1)));
System.out.println("SumNetAmtDummy===@@@=="+sumNetAmtDummy);
//if(sumNetAmtDummy >= Math.abs((payAmt1)))
if(sumNetAmtDummy> 0 && Math.abs(payAmt1)> 0)
{
lineNo++;
System.out.println("Line No after increament=========="+lineNo);
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("<tran_id><![CDATA[]]></tran_id>");
System.out.println("11111111111111");
//xmlString.append("<tran_id><![CDATA["+ tempMap.get("tran_id") +"]]></tran_id>");
xmlString.append("<line_no><![CDATA["+lineNo+"]]></line_no>");
System.out.println("222222222222222");
xmlString.append("<tran_ser><![CDATA["+ tempMapNeg.get("tran_ser") +"]]></tran_ser>");
System.out.println("333333333");
xmlString.append("<vouch_no><![CDATA["+ tempMapNeg.get("vouch_no") +"]]></vouch_no>");
System.out.println("44444444444");
xmlString.append("<vouch_date><![CDATA["+ tempMapNeg.get("vouch_date") +"]]></vouch_date>");
xmlString.append("<vouch_date><![CDATA["+ sdf.format(refdateNeg).toString() +"]]></vouch_date>");
//xmlString.append("<net_amt><![CDATA["+ tempMapNeg.get("net_amt") +"]]></net_amt>");
if(sumNetAmtDummy<Math.abs(payAmt1))
{
System.out.println("sumNetAmtDummy<Math.abs(payAmt1)========");
xmlString.append("<pay_amt><![CDATA["+ sumNetAmtDummy*(-1) +"]]></pay_amt>");
}
else
{
System.out.println("sumNetAmtDummy<Math.abs(payAmt1) else ========");
xmlString.append("<pay_amt><![CDATA["+ tempMapNeg.get("pay_amt") +"]]></pay_amt>");
}
if(sumNetAmtDummy<Math.abs(payAmt1))
{
xmlString.append("<net_amt><![CDATA["+ sumNetAmtDummy*(-1) +"]]></net_amt>");
}
else
{
xmlString.append("<net_amt><![CDATA["+ tempMapNeg.get("pay_amt") +"]]></net_amt>");
}
xmlString.append("<curr_code><![CDATA["+ tempMapNeg.get("curr_code") +"]]></curr_code>");
xmlString.append("<exch_rate__vouch><![CDATA["+ tempMap.get("exch_rate__vouch") +"]]></exch_rate__vouch>");
xmlString.append("<diff_amt__exch><![CDATA["+ tempMap.get("diff_amt__exch") +"]]></diff_amt__exch>");
xmlString.append("<acct_code__ap><![CDATA["+ tempMap.get("acct_code__ap") +"]]></acct_code__ap>");
xmlString.append("<cctr_code__ap><![CDATA["+ tempMap.get("cctr_code__ap") +"]]></cctr_code__ap>");
xmlString.append("<sundry_type><![CDATA["+ tempMapNeg.get("sundry_type") +"]]></sundry_type>");
xmlString.append("<sundry_code><![CDATA["+ tempMapNeg.get("sundry_code") +"]]></sundry_code>");
xmlString.append("<bank_charges><![CDATA["+ tempMapNeg.get("bank_charges") +"]]></bank_charges>");
xmlString.append("<stan_code><![CDATA["+ tempMap.get("stan_code") +"]]></stan_code>");
xmlString.append("<drawn_at><![CDATA["+ tempMapNeg.get("drawn_at") +"]]></drawn_at>");
xmlString.append("<tax_amt><![CDATA["+ tempMapNeg.get("tax_amt") +"]]></tax_amt>");
xmlString.append("<net_pay_amt><![CDATA["+tempMapNeg.get("net_pay_amt") +"]]></net_pay_amt>");
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("<tax_env><![CDATA["+ checkNull(tempMap.get("tax_env")==null ? "":tempMap.get("tax_env").toString())+"]]></tax_env>");
xmlString.append("<bill_no><![CDATA["+ tempMap.get("bill_no") +"]]></bill_no>");
xmlString.append("<bill_date><![CDATA["+ tempMap.get("bill_date") +"]]></bill_date>");
xmlString.append("<exch_rate><![CDATA["+ tempMapNeg.get("exch_rate") +"]]></exch_rate>");
xmlString.append("<discount_amt><![CDATA["+ tempMapNeg.get("discount_amt") +"]]></discount_amt>");
xmlString.append("<discount><![CDATA["+ tempMapNeg.get("discount") +"]]></discount>");
xmlString.append("<tot_amt><![CDATA["+ tempMapNeg.get("tot_amt") +"]]></tot_amt>");
xmlString.append("</Detail2>");
System.out.println("XmlString Detail of Negative values======"+xmlString.toString());
System.out.println("sumNetAmtDummy before update====="+sumNetAmtDummy);
System.out.println("payAmt1 before update====="+payAmt1);
sql = "select tot_amt from misc_payables where ref_no= ? and sundry_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNoupd);
pstmt.setString(2,sundryCd);
rs = pstmt.executeQuery();
if (rs.next())
{
totAmtRem=rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Total Amt==="+totAmtRem);
/*if(Math.abs(totAmtRem)>0))
{
*/
if((sumNetAmtDummy <= Math.abs(payAmt1)) )
{
System.out.println("Inside IFFFFFFFFFFFF");
System.out.println("Update sumNetAmtDummyt========");
sql="update misc_payables set tot_amt=(tot_amt -(?)) where ref_no=? and sundry_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,sumNetAmtDummy*(-1));
pstmt.setString(2,refNoupd);
pstmt.setString(3,sundryCd);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("@@@updCnt========["+updCnt+"]payAmt1-sumNetAmtDummy["+(payAmt1-sumNetAmtDummy*(-1))+"]tempMapNeg["+tempMapNeg+"]");
System.out.println("itemCtr1 ======="+itemCtr1);
System.out.println("tempMapNeg1111@@@before==="+tempMapNeg);
tempMapNeg.put("pay_amt",payAmt1-(sumNetAmtDummy * -1));
System.out.println("tempMapNeg1111@@@ after==="+tempMapNeg);
System.out.println("tempListNeg111@@@before==="+tempListNeg);
tempListNeg.set(itemCtr1, tempMapNeg);
System.out.println("tempListNeg1111@@@ after==="+tempListNeg);
System.out.println("splitCodeWiseNegMap before====="+splitCodeWiseNegMap);
splitCodeWiseNegMap.put(sundryCode, tempListNeg);
System.out.println("splitCodeWiseNegMap after====="+splitCodeWiseNegMap);
sumNetAmtDummy=sumNetAmtDummy-sumNetAmtDummy;
System.out.println("sumNetAmtDummy Remaining==="+sumNetAmtDummy);
}
else
{
System.out.println("Inside ELSEEEEEEEEEEE");
System.out.println("Update payAmt1========");
sql="update misc_payables set tot_amt=(tot_amt -(?)) where ref_no=? and sundry_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,payAmt1);
//pstmt.setDouble(1,payAmt1);
pstmt.setString(2,refNoupd);
pstmt.setString(3,sundryCd);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("@@@updCnt========["+updCnt+"]");
sumNetAmtDummy=sumNetAmtDummy-Math.abs(payAmt1);
System.out.println("sumNetAmtDummy Remaining==="+sumNetAmtDummy);
System.out.println("splitCodeWiseNegMap====="+splitCodeWiseNegMap);
tempListNeg.remove(itemCtr1);
itemCtr1=itemCtr1-1;
System.out.println("Counter after itemCtr1-1"+itemCtr1);
//tempListNeg.add(itemCtr1, 0);
splitCodeWiseNegMap.put(sundryCode, tempListNeg);
System.out.println("splitCodeWiseNegMap after====="+splitCodeWiseNegMap);
}
// }
// System.out.println("Map after removing records===="+tempMapNeg);
}
else
{
System.out.println("Sum Amt less than pay amt");
sumNetAmt=0;
System.out.println("Break*********");
}
}
}
}///add }///add
else else
{//case added by Jaimin 17/08/2007 {//case added by Jaimin 17/08/2007
...@@ -1598,10 +2114,15 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1598,10 +2114,15 @@ System.out.println("Sundry Type@@@@"+sundryType);
+"\n"+"[pay_Amt ::"+payAmt+"]"+"\n"; +"\n"+"[pay_Amt ::"+payAmt+"]"+"\n";
} }
}
//}
System.out.println("itemCtr=====-=="+itemCtr);
System.out.println("tempList.size()=====-=="+tempList.size());
}//end of for loop(commented)
//}
System.out.println("Processing DATA *****"); System.out.println("Processing DATA *****");
startDate = new java.util.Date(System.currentTimeMillis()); startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis())); calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
...@@ -1661,11 +2182,19 @@ System.out.println("Sundry Type@@@@"+sundryType); ...@@ -1661,11 +2182,19 @@ System.out.println("Sundry Type@@@@"+sundryType);
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite); System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
strToWrite=""; strToWrite="";
} //end of while loop // } //end of while loop commenteed
System.out.println("retString:: "+ retString); System.out.println("retString:: "+ retString);
System.out.println("Transaction Id===="+tranId); System.out.println("Transaction Id===="+tranId);
}//end of while loop
} }
catch(Exception e) catch(Exception e)
{ {
......
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