Commit b0288273 authored by cpatil's avatar cpatil

modify code for payment scheduler


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98487 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1d947c1a
......@@ -177,13 +177,13 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
//writeLog(filePtr,"vouchNoTo -->"+vouchNoTo ,true);
if(vouchNoTo == null || vouchNoTo.trim().length() == 0)
{
vouchNoTo = "z";
vouchNoTo = "zz";
}
sundryType = genericUtility.getColumnValue("sundry_type",headerDom);
//writeLog(filePtr,"sundryType -->"+sundryType ,true);
System.out.println("sundryType in getData======"+sundryType);
//if (sundryType == null||sundryType.trim().length()==0)
if(("null".equals(sundryType))|| sundryType == null)
/*if(("null".equals(sundryType))|| sundryType == null)
{
System.out.println("If sundryType11 == null");
sundryType = "%";
......@@ -193,7 +193,7 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
System.out.println("If sundryType11 Not == null");
sundryType =sundryType.trim()+"%";
}
}*/
sundryCode = genericUtility.getColumnValue("sundry_code",headerDom);
System.out.println("sundryCode in getData======"+sundryCode);
//writeLog(filePtr,"sundryCode -->"+sundryCode ,true);
......@@ -263,10 +263,18 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
+"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 ( misc_payables.site_code = '"+siteCode+"' ) AND "
+"( misc_payables.sundry_type like '"+sundryType+"' ) AND "
+"( misc_payables.sundry_code like '"+sundryCode+"' ) AND "
+"( misc_payables.due_date >= ? ) AND "
+"WHERE ( misc_payables.site_code = '"+siteCode+"' ) AND ";
if(sundryType!=null && !"null".equalsIgnoreCase(sundryType) && sundryType.trim().length()>0)
{
getSql+="( misc_payables.sundry_type = '"+sundryType+"' ) AND ";
}
if(sundryCode!=null && !"null".equalsIgnoreCase(sundryCode) && sundryCode.trim().length()>0)
{
getSql+="( misc_payables.sundry_code LIKE '"+sundryCode+"' ) AND ";
}
getSql+="( misc_payables.due_date >= ? ) AND "
+"( misc_payables.due_date <= ? ) AND "
+"( misc_payables.ref_no >= '" + vouchNoFrom + "' ) AND "
+"( misc_payables.ref_no <= '" + vouchNoTo + "' ) AND "
......@@ -277,7 +285,8 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
+"case when misc_payables.entry_batch_no is null then ' ' else"
+" misc_payables.entry_batch_no end like '"+entryBatchNo+"' AND "
+" curr_code ='"+ currCode + "'AND"
+" tran_ser NOT in('P-ADV ','M-ADV ')"
+" tran_ser NOT in('P-ADV','M-ADV')"
+" and 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)>0"
+" ORDER BY misc_payables.sundry_type ASC,"
+"misc_payables.sundry_code ASC,"
+"misc_payables.ref_no ASC";
......@@ -299,12 +308,14 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
tempSql= " select sum(b.net_amt) as unconfirm_amt from misc_payment a,misc_paydet b "+
" where a.tran_id=b.tran_id and "+
" b.tran_ser=? and "+
" b.vouch_no= ? "+
" and a.confirmed='N' ";
System.out.println("SQL==>"+tempSql);
// stmtTemp = conn.prepareStatement(tempSql);
pstmt1 = conn.prepareStatement(tempSql);
pstmt1.setString(1, refNo);
pstmt1.setString(1, tranSer);
pstmt1.setString(2, refNo);
rsTemp = pstmt1.executeQuery();
if (rsTemp.next())
{
......@@ -320,45 +331,6 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
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 "
+"WHERE ( auto_pay_det.tran_ser = '" + tranSer + "') AND "
+"( auto_pay_det.ref_no = '" + refNo + "' ) AND "
+"( auto_pay_hdr.tran_id = auto_pay_det.tran_id ) AND "
+"case when auto_pay_det.tran_id__pay is null then ' ' else "
+" auto_pay_det.tran_id__pay end = ' ' ";
System.out.println("SQL==>"+tempSql);
rsTemp = stmtTemp.executeQuery(tempSql);
if (rsTemp.next())
{
unapprovedPayAmt = rsTemp.getDouble("pay_amt");
}
else
{
unapprovedPayAmt = 0d;
}
rsTemp.close();
if (netPayable < 0 && netPayable > unapprovedPayAmt)
{
unapprovedPayAmt = netPayable;
}
else
{
if (netPayable > 0 && unapprovedPayAmt > netPayable)
{
unapprovedPayAmt = netPayable;
}
//payAmt = netPayable - unapprovedPayAmt;
}*/
payAmt = netPayable;
System.out.println("");
payAmt = payAmt - unapprovedPayAmt;
System.out.println("PayAmt Value===="+payAmt+"UnApproved Amt====="+unapprovedPayAmt);
......@@ -625,6 +597,9 @@ public class AutoPmtGenPrc extends ProcessEJB implements AutoPmtGenPrcLocal,Auto
String billNoNeg="";
Date billDateNeg=null;
double balanceAmt=0;
String sundryCodeList="";
double unAppNegativeAmt=0;
try
{ System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("Gen_bank_payment_log"));
......@@ -796,10 +771,9 @@ System.out.println("Getting winName============"+windowName);
System.out.println("Site Code>>>>>>>>>>"+siteCode);
sql="select curr_code from site, finent " +
"where site.fin_entity = finent.fin_entity and site_code =?";
sql="select curr_code from bank where bank_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -1060,7 +1034,7 @@ 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
sundryCodeList+="'"+sundryCode+"',";
if(spiltChq!=null && "Y".equalsIgnoreCase(spiltChq))
{
tempSplitCode = sundryCode+"@"+payMode+"@"+dueDate; //added duaDate by cpatil in sun on 06/06/15
......@@ -1270,7 +1244,7 @@ System.out.println("Getting winName============"+windowName);
tempMap.put("net_amt", payAmt);
tempMap.put("pay_amt", payAmt);
tempMap.put("curr_code", currCodeBc);
tempMap.put("curr_code", currCode);
tempMap.put("exch_rate__vouch", exchRate);
tempMap.put("diff_amt__exch", payAmt);
......@@ -1315,112 +1289,10 @@ System.out.println("Getting winName============"+windowName);
}
sundryCodeList=sundryCodeList.substring(0,sundryCodeList.length()-1);
System.out.println("1319Sundry Code===="+sundryCode);
ArrayList<String > sundryCodeList=new ArrayList<String>();
double sumNetAmtDummy=0;
double sumNetAmt=0.0,totUnconfAmt=0;
String autoPaymTranId="";
Set setItem = splitCodeWiseMap.entrySet();
System.out.println("1327getting set item====="+setItem);
tempList = null;
Iterator itrItem = setItem.iterator();
int testCnt=0;
while(itrItem.hasNext())
{
testCnt++;
//sumNetAmt=0;
System.out.println("1335while 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);
System.out.println("TempList Inside While======="+tempList);
if(splitCode.split("@").length != 0)
{
sundryCode = checkNull(splitCode.split("@")[0]);
payMode = checkNull(splitCode.split("@")[1]);
if("Y".equalsIgnoreCase(spiltChq))
{
dueDate = checkNull(splitCode.split("@")[2]);
}
// added by cpatil @sun on 06/06/15
}
System.out.println("sundryCode after spilt ======="+sundryCode);
System.out.println("payMode after spilt ======="+payMode);
System.out.println("Sundry TYPEEEEEEEE" +sundryType);
System.out.println("dueDate after spilt ======="+dueDate); // added by cpatil @sun on 06/06/15
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);
Date currentDate1 = new Date();
System.out.println("Current date111111111111===="+currentDate1);
String maxDateRef=maxDateMap.get(splitCode);
System.out.println("Max Due Date from MAp=="+maxDateRef+"splitCode==="+splitCode);
if(maxDateRef!=null && sdf.parse(maxDateRef).compareTo(currentDate1)>0)
{
dueMaxDate=sdf.parse(maxDateRef);
}
else
{
dueMaxDate=currentDate1;
}
System.out.println("1384Getting ref due Date for header===="+dueMaxDate);
System.out.println("1385sfld1========="+sfld1);
sql = "SELECT chq1,chq2 FROM BANK WHERE BANK_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
chq1= checkNull(rs.getString(1));
chq2= checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Chq1========="+chq1);
System.out.println("chq2========="+chq2);
String maxRefNo="0";
if(chq1!=null & chq1.trim().length()>0 && chq2!=null & chq2.trim().length()>0)
{
if(Integer.parseInt(chq1)>Integer.parseInt(chq2))
{
maxRefNo=""+Integer.parseInt(chq1)+1;
}
}
System.out.println("1416Currency_code==================="+currCode);
System.out.println("Site_code==================="+siteCode);
//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," +
......@@ -1432,16 +1304,17 @@ System.out.println("Getting winName============"+windowName);
"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 " +
" curr_code= ? " +
" FROM misc_payables WHERE ";
sql+="( misc_payables.sundry_code in ("+sundryCodeList+") ) AND ";
sql+=" curr_code= ? " +
"and site_code= ? " +
"and tot_amt - adj_amt < 0 order by due_date";
"and 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) < 0 order by due_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sundryCode);
pstmt.setString(2,currCode);
pstmt.setString(3,siteCode);
pstmt.setString(1,currCode);
pstmt.setString(2,siteCode);
rs = pstmt.executeQuery();
while (rs.next())
{
......@@ -1461,19 +1334,45 @@ System.out.println("Getting winName============"+windowName);
billNo=rs.getString("bill_no");
billDateNeg=rs.getDate("bill_date");
// pay_amt=rs.getDouble(3);
unAppNegativeAmt=0;
System.out.println("1465Sundry Code===="+sundryCode+"Refr No===="+refNo+"Due Date===="+dueDatediff+"pay_amt==="+pay_amt);
sql= " select sum(b.net_amt) as unconfirm_amt from misc_payment a,misc_paydet b "+
" where a.tran_id=b.tran_id and "+
" b.tran_ser=? and "+
" b.vouch_no= ? "+
" and a.confirmed='N' ";
System.out.println("SQL==>"+sql);
// stmtTemp = conn.prepareStatement(tempSql);
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranSer);
pstmt1.setString(2, refNo);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
unAppNegativeAmt = rs1.getDouble("unconfirm_amt");
}
else
{
unAppNegativeAmt = 0d;
}
pstmt1.close();
pstmt1=null;
rs1.close();
rs1=null;
System.out.println("Unconfirmed Negative Amt==="+unAppNegativeAmt+"Ref No===="+refNo);
pay_amt = pay_amt - unAppNegativeAmt;
totamount=totamount-unAppNegativeAmt;
//sundryCdSpilt=sundryCodeNeg;
//System.out.println("Getting sundryCdSpilt===== "+sundryCdSpilt);
System.out.println("splitCodeWiseNegMap@@@@@"+splitCodeWiseNegMap);
if(splitCodeWiseNegMap.containsKey(sundryCode))
if(splitCodeWiseNegMap.containsKey(sundryCodeNeg))
{
System.out.println("* Exist for SundryCd Spilt combo*");
tempListNeg = (ArrayList) splitCodeWiseNegMap.get(sundryCode);
tempListNeg = (ArrayList) splitCodeWiseNegMap.get(sundryCodeNeg);
System.out.println("Exist for SundryCd Spilt combo======"+tempListNeg);
}
else
......@@ -1591,7 +1490,7 @@ System.out.println("Getting winName============"+windowName);
ldStartDate=billDt;
}
if((payDate!=null && payDate.trim().length()>0) && ldStartDate!=null)
/*if((payDate!=null && payDate.trim().length()>0) && ldStartDate!=null)
{
payDate1 = sdf.parse(payDate);
System.out.println("@@@1597payDate1["+payDate1+"]ldStartDate["+ldStartDate+"]discdt["+discdt+"]");
......@@ -1604,7 +1503,7 @@ System.out.println("Getting winName============"+windowName);
disAmt= payAmt1 *(discount/100);
}
}
}
}*/
System.out.println("1610disAmount=========="+disAmt);
......@@ -1613,14 +1512,14 @@ System.out.println("Getting winName============"+windowName);
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode))
{
System.out.println("1615payMode<<<<<<<<");
drawnAt=checkNull(getpayablesAt(sundryType, sundryCode, bankCode, conn));
drawnAt=checkNull(getpayablesAt(sundryType, sundryCodeNeg, bankCode, conn));
}
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode)||"T".equalsIgnoreCase(payMode)||"N".equalsIgnoreCase(payMode))
{
System.out.println("1622payMode========>>>>");
stanCode=checkNull(getStanDraw(sundryType, sundryCode, conn));
stanCode=checkNull(getStanDraw(sundryType, sundryCodeNeg, conn));
System.out.println("Getting stanCode=============="+stanCode);
}
......@@ -1681,15 +1580,15 @@ System.out.println("Getting winName============"+windowName);
tempListNeg.add(tempMapNeg);
System.out.println("Getting tempList value after ading in list ======"+tempListNeg);
if(splitCodeWiseNegMap.containsKey(sundryCode))
if(splitCodeWiseNegMap.containsKey(sundryCodeNeg))
{
System.out.println("splitCodeWiseNegMap.containsKey(sundryCdSpilt)");
splitCodeWiseNegMap.put(sundryCode,tempListNeg);
splitCodeWiseNegMap.put(sundryCodeNeg,tempListNeg);
}
else
{
System.out.println("else*************");
splitCodeWiseNegMap.put(sundryCode,tempListNeg);
splitCodeWiseNegMap.put(sundryCodeNeg,tempListNeg);
}
......@@ -1699,13 +1598,115 @@ System.out.println("Getting winName============"+windowName);
pstmt.close();
pstmt = null;
System.out.println("1319Sundry Code===="+sundryCode);
//ArrayList<String > sundryCodeList=new ArrayList<String>();
double sumNetAmtDummy=0;
double sumNetAmt=0.0,totUnconfAmt=0;
String autoPaymTranId="";
Set setItem = splitCodeWiseMap.entrySet();
System.out.println("1327getting set item====="+setItem);
tempList = null;
Iterator itrItem = setItem.iterator();
int testCnt=0;
while(itrItem.hasNext())
{
testCnt++;
//sumNetAmt=0;
System.out.println("1335while 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);
System.out.println("TempList Inside While======="+tempList);
if(splitCode.split("@").length != 0)
{
sundryCode = checkNull(splitCode.split("@")[0]);
payMode = checkNull(splitCode.split("@")[1]);
if("Y".equalsIgnoreCase(spiltChq))
{
dueDate = checkNull(splitCode.split("@")[2]);
}
// added by cpatil @sun on 06/06/15
}
System.out.println("sundryCode after spilt ======="+sundryCode);
System.out.println("payMode after spilt ======="+payMode);
System.out.println("Sundry TYPEEEEEEEE" +sundryType);
System.out.println("dueDate after spilt ======="+dueDate); // added by cpatil @sun on 06/06/15
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);
Date currentDate1 = new Date();
System.out.println("Current date111111111111===="+currentDate1);
String maxDateRef=maxDateMap.get(splitCode);
System.out.println("Max Due Date from MAp=="+maxDateRef+"splitCode==="+splitCode);
if(maxDateRef!=null && sdf.parse(maxDateRef).compareTo(currentDate1)>0)
{
dueMaxDate=sdf.parse(maxDateRef);
}
else
{
dueMaxDate=currentDate1;
}
System.out.println("1384Getting ref due Date for header===="+dueMaxDate);
System.out.println("1385sfld1========="+sfld1);
sql = "SELECT chq1,chq2 FROM BANK WHERE BANK_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode);
rs = pstmt.executeQuery();
if (rs.next())
{
chq1= checkNull(rs.getString(1));
chq2= checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Chq1========="+chq1);
System.out.println("chq2========="+chq2);
String maxRefNo="0";
if(chq1!=null & chq1.trim().length()>0 && chq2!=null & chq2.trim().length()>0)
{
if(Integer.parseInt(chq1)>Integer.parseInt(chq2))
{
maxRefNo=""+Integer.parseInt(chq1)+1;
}
}
System.out.println("1416Currency_code==================="+currCode);
System.out.println("Site_code==================="+siteCode);
System.out.println("Final Negative List====="+splitCodeWiseNegMap);
System.out.println("Ref No To be set in Header ======="+maxRefNo);
sumNetAmt=0.0;
System.out.println("Sum Amount 1 @@@==="+sumNetAmt);
balanceAmt=0;
for (int itemCtr = 0; itemCtr < tempList.size(); itemCtr++)
{
tempMap = (HashMap)tempList.get(itemCtr);
......@@ -1717,7 +1718,7 @@ System.out.println("Getting winName============"+windowName);
}
//creating Header
System.out.println("Sum Amount 2 @@@==="+sumNetAmt);
//sumNetAmt=0.0;
tempListNeg = (ArrayList)splitCodeWiseNegMap.get(sundryCode);
System.out.println("Creating Header$$$$$$");
xmlString = null;
xmlString = new StringBuffer();
......@@ -1820,13 +1821,13 @@ System.out.println("Getting winName============"+windowName);
System.out.println("Get netPayable Value from Map==========="+netPayable);
System.out.println("Get SumAmt of PayAmt==========="+sumNetAmt);
totUnconfAmt=Double.valueOf(tempMap.get("unconfirm_amt").toString()) ;
//totUnconfAmt=Double.valueOf(tempMap.get("unconfirm_amt").toString()) ;
System.out.println("Get totUnconfAmt Value from Map==========="+totUnconfAmt);
//if (Double.parseDouble(payAmt) != 0 ) //
if(sumNetAmt>0)
{
//if(sumNetAmt>0)
//{
System.out.println("--------------> if payAmt>0 :: "+payAmt);
System.out.println("--------------> if netPayable>0 :: "+netPayable);
......@@ -1884,7 +1885,7 @@ System.out.println("Getting winName============"+windowName);
xmlString.append("<curr_code><![CDATA["+ tempMap.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("<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["+ tempMap.get("sundry_type") +"]]></sundry_type>");
......@@ -1894,7 +1895,7 @@ System.out.println("Getting winName============"+windowName);
xmlString.append("<drawn_at><![CDATA["+ tempMap.get("drawn_at") +"]]></drawn_at>");
xmlString.append("<tax_amt><![CDATA["+ tempMap.get("tax_amt") +"]]></tax_amt>");
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("<cctr_code__disc><![CDATA["+ tempMap.get("cctr_code__disc") +"]]></cctr_code__disc>");
......@@ -1912,7 +1913,7 @@ System.out.println("Getting winName============"+windowName);
}
//}
sumNetAmtDummy=0;
sumNetAmtDummy=sumNetAmt;
......@@ -1920,13 +1921,16 @@ System.out.println("Getting winName============"+windowName);
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);
//tempListNeg = (ArrayList)splitCodeWiseNegMap.get(sundryCode);
System.out.println("1898TempList negative Inside While======="+tempListNeg);
//System.out.println("tempListNeg.size() "+tempListNeg.size());
System.out.println("Testtttttttttttt");
// lineNo = 0;
System.out.println("tempListNeg.size()===="+tempListNeg);
if(tempListNeg!=null && itemCtr== tempList.size()-1)
//System.out.println("tempListNeg.size()===="+tempListNeg);
//if(tempListNeg!=null && itemCtr== tempList.size()-1)
//{
if(tempListNeg!=null)
{
System.out.println("IFFFFFFFFFFFFFFFFFFFfffffffffffff%%%%%%%");
for (int itemCtr1 = 0; itemCtr1 < tempListNeg.size(); itemCtr1++)
......@@ -1960,37 +1964,46 @@ System.out.println("Getting winName============"+windowName);
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["+ 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))
{
balanceAmt=Double.parseDouble(""+tempMapNeg.get("pay_amt"))+sumNetAmtDummy;
xmlString.append("<pay_amt><![CDATA["+ sumNetAmtDummy*(-1) +"]]></pay_amt>");
xmlString.append("<net_amt><![CDATA["+ sumNetAmtDummy*(-1) +"]]></net_amt>");
xmlString.append("<tot_amt><![CDATA["+ sumNetAmtDummy*(-1) +"]]></tot_amt>");
//xmlString.append("<net_pay_amt><![CDATA["+sumNetAmtDummy*(-1) +"]]></net_pay_amt>");
sumNetAmtDummy=0;
}
else
{
balanceAmt=Double.parseDouble(""+tempMapNeg.get("pay_amt"))-payAmt1;
xmlString.append("<pay_amt><![CDATA["+ tempMapNeg.get("pay_amt") +"]]></pay_amt>");
xmlString.append("<net_amt><![CDATA["+ tempMapNeg.get("pay_amt") +"]]></net_amt>");
xmlString.append("<tot_amt><![CDATA["+ tempMapNeg.get("pay_amt") +"]]></tot_amt>");
sumNetAmtDummy=sumNetAmtDummy+payAmt1;
//xmlString.append("<net_pay_amt><![CDATA["+tempMapNeg.get("pay_amt") +"]]></net_pay_amt>");
}
System.out.println("Sum of net pay dummy after================"+sumNetAmtDummy);
HashMap tempMapNegNew=new HashMap();
tempMapNegNew=tempMapNeg;
tempMapNegNew.put("pay_amt", balanceAmt);
System.out.println("Balance Amount==="+balanceAmt+""+"tempMapNegNew before=== "+tempMapNegNew);
//tempListNeg.add(itemCtr1, tempMapNeg);
tempListNeg.set(itemCtr1, tempMapNegNew);
System.out.println("tempListNeg.size() after==== "+tempListNeg);
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("<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>");
......@@ -1999,8 +2012,8 @@ System.out.println("Getting winName============"+windowName);
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("<tax_amt><![CDATA["+ tempMapNeg.get("tax_amt") +"]]></tax_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>");
......@@ -2008,10 +2021,10 @@ System.out.println("Getting winName============"+windowName);
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("<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());
......@@ -2019,81 +2032,6 @@ System.out.println("Getting winName============"+windowName);
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);
}
// }
......@@ -2110,6 +2048,7 @@ System.out.println("Getting winName============"+windowName);
}
}
//}
......@@ -2168,7 +2107,7 @@ System.out.println("Getting winName============"+windowName);
conn.rollback();
System.out.println("--transaction rollback--");
// sundryCodeList.remove(sundryCode);
System.out.println("sundryCodeList after rollback===="+sundryCodeList);
//System.out.println("sundryCodeList after rollback===="+sundryCodeList);
//sumNetAmtDummy=sumNetAmt;
//System.out.println("sumNetAmtDummy after rollback====="+sumNetAmtDummy);
}
......
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