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.vouch_no= ? "+
" 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,11 +1289,320 @@ System.out.println("Getting winName============"+windowName);
}
sundryCodeList=sundryCodeList.substring(0,sundryCodeList.length()-1);
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 ";
sql+="( misc_payables.sundry_code in ("+sundryCodeList+") ) AND ";
sql+=" curr_code= ? " +
"and site_code= ? " +
"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,currCode);
pstmt.setString(2,siteCode);
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);
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(sundryCodeNeg))
{
System.out.println("* Exist for SundryCd Spilt combo*");
tempListNeg = (ArrayList) splitCodeWiseNegMap.get(sundryCodeNeg);
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("1485: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("1502Purchase 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("1518sfld1========="+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("1546Getting discdt======"+discdt);
if(discdt!=null)
{
System.out.println("1549Getting 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("1574Get Discount======="+discount);
if(discount==0)
{
discount=0;
}
System.out.println("1580>>>>>>>>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);
System.out.println("@@@1597payDate1["+payDate1+"]ldStartDate["+ldStartDate+"]discdt["+discdt+"]");
if((payDate1!=null && payDate1.compareTo(ldStartDate)>0)&& ( discdt != null && payDate1.compareTo(discdt)<0))
{
if(discount!=0)
{
System.out.println("1602Discount not equals to Zerooooooooooooo");
payAmt1=Double.parseDouble(payAmt);
disAmt= payAmt1 *(discount/100);
}
}
}*/
System.out.println("1610disAmount=========="+disAmt);
System.out.println("PayMAode======="+payMode);
System.out.println("BankCode>>>>>==="+bankCode);
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode))
{
System.out.println("1615payMode<<<<<<<<");
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, sundryCodeNeg, conn));
System.out.println("Getting stanCode=============="+stanCode);
}
System.out.println("1628vouch_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("1637diff_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(sundryCodeNeg))
{
System.out.println("splitCodeWiseNegMap.containsKey(sundryCdSpilt)");
splitCodeWiseNegMap.put(sundryCodeNeg,tempListNeg);
}
else
{
System.out.println("else*************");
splitCodeWiseNegMap.put(sundryCodeNeg,tempListNeg);
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("1319Sundry Code===="+sundryCode);
ArrayList<String > sundryCodeList=new ArrayList<String>();
//ArrayList<String > sundryCodeList=new ArrayList<String>();
double sumNetAmtDummy=0;
double sumNetAmt=0.0,totUnconfAmt=0;
String autoPaymTranId="";
......@@ -1416,296 +1699,14 @@ System.out.println("Getting winName============"+windowName);
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," +
"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 " +
" curr_code= ? " +
"and site_code= ? " +
"and tot_amt - adj_amt < 0 order by due_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sundryCode);
pstmt.setString(2,currCode);
pstmt.setString(3,siteCode);
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("1465Sundry 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("1485: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("1502Purchase 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("1518sfld1========="+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("1546Getting discdt======"+discdt);
if(discdt!=null)
{
System.out.println("1549Getting 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("1574Get Discount======="+discount);
if(discount==0)
{
discount=0;
}
System.out.println("1580>>>>>>>>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);
System.out.println("@@@1597payDate1["+payDate1+"]ldStartDate["+ldStartDate+"]discdt["+discdt+"]");
if((payDate1!=null && payDate1.compareTo(ldStartDate)>0)&& ( discdt != null && payDate1.compareTo(discdt)<0))
{
if(discount!=0)
{
System.out.println("1602Discount not equals to Zerooooooooooooo");
payAmt1=Double.parseDouble(payAmt);
disAmt= payAmt1 *(discount/100);
}
}
}
System.out.println("1610disAmount=========="+disAmt);
System.out.println("PayMAode======="+payMode);
System.out.println("BankCode>>>>>==="+bankCode);
if("D".equalsIgnoreCase(payMode)||"P".equalsIgnoreCase(payMode))
{
System.out.println("1615payMode<<<<<<<<");
drawnAt=checkNull(getpayablesAt(sundryType, sundryCode, 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));
System.out.println("Getting stanCode=============="+stanCode);
}
System.out.println("1628vouch_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("1637diff_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);
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,14 +1921,17 @@ 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,82 +2032,7 @@ 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);
}
// }
// System.out.println("Map after removing records===="+tempMapNeg);
......@@ -2109,7 +2047,8 @@ 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);
}
......@@ -2971,4 +2910,4 @@ System.out.println("Getting winName============"+windowName);
}
\ No newline at end of file
}
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