Commit 2898aae0 authored by asikarwar's avatar asikarwar

change for check bill disc amt is not set automatically


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93438 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9a46e826
...@@ -2652,6 +2652,7 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2652,6 +2652,7 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
billDisc = "N"; billDisc = "N";
refNo = genericUtility.getColumnValue("ref_no", dom); refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom); refSer = genericUtility.getColumnValue("ref_ser", dom);
sql = "select count(*) from receivables where tran_ser = ? and ref_no = ?"; sql = "select count(*) from receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer); pstmt.setString(1, refSer);
...@@ -2667,6 +2668,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2667,6 +2668,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
} }
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((lineNoRef != null) || (lineNoRef.trim().length() > 0)) if ((lineNoRef != null) || (lineNoRef.trim().length() > 0))
{ {
if (!refSer.equals("E-FUND")) if (!refSer.equals("E-FUND"))
...@@ -2696,6 +2702,10 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2696,6 +2702,10 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
adjAmt = rs.getDouble(14); adjAmt = rs.getDouble(14);
badDebtAmt = rs.getDouble(15); badDebtAmt = rs.getDouble(15);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} }
hexchRate = doublevalue(genericUtility.getColumnValue("exch_rate", dom1)); hexchRate = doublevalue(genericUtility.getColumnValue("exch_rate", dom1));
sql = "select descr from currency where currency.curr_code = ?"; sql = "select descr from currency where currency.curr_code = ?";
...@@ -2706,6 +2716,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2706,6 +2716,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{ {
currDescr = rs.getString(1); currDescr = rs.getString(1);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from accounts where accounts.acct_code = ?"; sql = "select descr from accounts where accounts.acct_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCode); pstmt.setString(1, acctCode);
...@@ -2714,6 +2729,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2714,6 +2729,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{ {
accDescr = rs.getString(1); accDescr = rs.getString(1);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select receivables.bill_disc from receivables where tran_ser = ? and ref_no = ? "; sql = "select receivables.bill_disc from receivables where tran_ser = ? and ref_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer); pstmt.setString(1, refSer);
...@@ -2723,8 +2743,17 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2723,8 +2743,17 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{ {
billDisc = rs.getString(1); billDisc = rs.getString(1);
} }
if ((billDisc == null) || (billDisc.trim().length() == 0)) rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(billDisc == null || billDisc.trim().length() == 0)
{
billDisc = "N"; billDisc = "N";
}
System.out.println("bill disc ------ > "+billDisc);
if (billDisc.trim().equalsIgnoreCase("Y")) if (billDisc.trim().equalsIgnoreCase("Y"))
{ //added by ritesh { //added by ritesh
sql = "select export_fund.exch_rate,export_fundet.amount from export_fund, export_fundet where ( export_fund.tran_id = export_fundet.tran_id ) and ( export_fund.confirmed = 'Y' ) and ( ( export_fundet.ref_ser = ? ) and ( export_fundet.ref_no = ? ) )"; sql = "select export_fund.exch_rate,export_fundet.amount from export_fund, export_fundet where ( export_fund.tran_id = export_fundet.tran_id ) and ( export_fund.confirmed = 'Y' ) and ( ( export_fundet.ref_ser = ? ) and ( export_fundet.ref_no = ? ) )";
...@@ -2738,6 +2767,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2738,6 +2767,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
discExchRate = rs.getDouble(1); // change by ritesh on 25/05/13 discExchRate = rs.getDouble(1); // change by ritesh on 25/05/13
lcBillDescAmt = rs.getString(2); lcBillDescAmt = rs.getString(2);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("bill disc 1 ------ > "+billDisc);
valueXmlString.append("<bill_disc_amt>").append("<![CDATA[" + lcBillDescAmt + "]]>").append("</bill_disc_amt>"); //added by ritesh as per discussion with pravin valueXmlString.append("<bill_disc_amt>").append("<![CDATA[" + lcBillDescAmt + "]]>").append("</bill_disc_amt>"); //added by ritesh as per discussion with pravin
} }
valueXmlString.append("<bill_disc>").append("<![CDATA[" + billDisc + "]]>").append("</bill_disc>"); valueXmlString.append("<bill_disc>").append("<![CDATA[" + billDisc + "]]>").append("</bill_disc>");
...@@ -2811,6 +2845,12 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2811,6 +2845,12 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{ {
ctr = rs.getInt(1); ctr = rs.getInt(1);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((tranSer == "S-INV") || (ctr == 1)) if ((tranSer == "S-INV") || (ctr == 1))
{ {
sql = "select due_date,cr_term from invoice where invoice_id = ?"; sql = "select due_date,cr_term from invoice where invoice_id = ?";
...@@ -2822,6 +2862,13 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2822,6 +2862,13 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
dueDate = rs.getDate(1); dueDate = rs.getDate(1);
crTrem = rs.getString(2); crTrem = rs.getString(2);
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom)); tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom));
if (tranDate.before(dueDate)) if (tranDate.before(dueDate))
{ {
...@@ -2853,138 +2900,163 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt ...@@ -2853,138 +2900,163 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
discountLc = Math.round(discountLc) * -1L; discountLc = Math.round(discountLc) * -1L;
valueXmlString.append("<fin_chg>").append("<![CDATA[" + discountLc + "]]>").append("</fin_chg>"); valueXmlString.append("<fin_chg>").append("<![CDATA[" + discountLc + "]]>").append("</fin_chg>");
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} }
} }
} }
} }
} }
else if ((currentColumn.trim().equalsIgnoreCase("exch_rate")) || (currentColumn.trim().equalsIgnoreCase("rcp_amt"))) }
else if ((currentColumn.trim().equalsIgnoreCase("exch_rate")) || (currentColumn.trim().equalsIgnoreCase("rcp_amt")))
{
System.out.println("exch_rate ::::::::");
billDisc = "N";
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
sql = "select bill_disc FROM receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
billDisc = rs.getString(1);
}
if (billDisc == null) billDisc = "N";
if ("Y".equals(billDisc))
{ {
billDisc = "N"; sql = "select export_fund.exch_rate from export_fund, export_fundet where ( export_fund.tran_id = export_fundet.tran_id ) and ( export_fund.confirmed = 'Y') and( ( export_fundet.ref_ser = ? ) and ( export_fundet.ref_no = ?) )";
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
sql = "select bill_disc FROM receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer); pstmt.setString(1, refSer);
pstmt.setString(2, refNo); pstmt.setString(2, refNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
billDisc = rs.getString(1); exchRate = rs.getDouble(1);
} }
if (billDisc == null) billDisc = "N"; rs.close();
if (billDisc == "Y") rs = null;
{ pstmt.close();
sql = "select export_fund.exch_rate from export_fund, export_fundet where ( export_fund.tran_id = export_fundet.tran_id ) and ( export_fund.confirmed = 'Y') and( ( export_fundet.ref_ser = ? ) and ( export_fundet.ref_no = ?) )"; pstmt = null;
pstmt = conn.prepareStatement(sql); rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom));
pstmt.setString(1, refSer); hexchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom));
pstmt.setString(2, refNo); exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom));
rs = pstmt.executeQuery(); }
if (rs.next()) bdFluctuationCf = getfinparm("999999", "BD_FLUCTUATION_CF" ,conn);
{ if (bdFluctuationCf.equals("") || bdFluctuationCf == null)
exchRate = rs.getDouble(1); {
} bdFluctuationCf = "Y";
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom)); }
hexchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom)); if ((billDisc.equals("Y")) && (bdFluctuationCf.equals("Y")))
exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom)); {
} diffAmtExch = rcpAmt * exchRate - rcpAmt * exchRate;
bdFluctuationCf = getfinparm("999999", "BD_FLUCTUATION_CF" ,conn); valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
if (bdFluctuationCf.equals("") || bdFluctuationCf == null) }
{ else
bdFluctuationCf = "Y"; {
} diffAmtExch = rcpAmt * exchRate - rcpAmt * hexchRate;
if ((billDisc.equals("Y")) && (bdFluctuationCf.equals("Y"))) valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
{ }
diffAmtExch = rcpAmt * exchRate - rcpAmt * exchRate;
valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
}
else
{
diffAmtExch = rcpAmt * exchRate - rcpAmt * hexchRate;
valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
}
valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA[" + siteCode + "]]>").append("</site_code>"); //valueXmlString.append("<site_code protect = \"1\">").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<cust_code protect = \"1\">").append("<![CDATA[" + custCode + "]]>").append("</cust_code>"); //valueXmlString.append("<cust_code protect = \"1\">").append("<![CDATA[" + custCode + "]]>").append("</cust_code>");
valueXmlString.append("<curr_code protect = \"1\">").append("<![CDATA[" + currCode + "]]>").append("</curr_code>"); //valueXmlString.append("<curr_code protect = \"1\">").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
valueXmlString.append("<sale_order protect = \"1\">").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>"); //valueXmlString.append("<sale_order protect = \"1\">").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>");
errCode = checkBadDebtAmt(0, conn, dom);
if(errCode == null && errCode.trim().length() == 0) errCode = checkBadDebtAmt(0, conn, dom);
{ if(errCode == null && errCode.trim().length() == 0)
errList.add(errCode); {
errFields.add(childNodeName.toLowerCase()); errList.add(errCode);
} errFields.add(childNodeName.toLowerCase());
rcpAutoFinchg = getfinparm("999999", "RCP_AUTO_FINCHG", conn); }
if (rcpAutoFinchg.equals("") || rcpAutoFinchg == null) rcpAutoFinchg = getfinparm("999999", "RCP_AUTO_FINCHG", conn);
if (rcpAutoFinchg.equals("") || rcpAutoFinchg == null)
{
rcpAutoFinchg = "N";
}
if (rcpAutoFinchg.equals("Y"))
{
sql = "select count(*) from receivables where tran_ser = ? and ref_ser__org = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "R-IBCA");
pstmt.setString(2, "S-INV");
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{ {
rcpAutoFinchg = "N"; ctr = rs.getInt(1);
} }
if (rcpAutoFinchg.equals("Y")) rs.close();
rs = null;
pstmt.close();
pstmt = null;
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom));
if ((tranSer == "S-INV") || (ctr == 1))
{ {
sql = "select count(*) from receivables where tran_ser = ? and ref_ser__org = ? and ref_no = ?"; sql = "select due_date,cr_term from invoice where invoice_id = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "R-IBCA"); pstmt.setString(1, refNo);
pstmt.setString(2, "S-INV");
pstmt.setString(3, refNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
ctr = rs.getInt(1); dueDate = rs.getDate(1);
crTrem = rs.getString(2);
} }
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom)); rs.close();
if ((tranSer == "S-INV") || (ctr == 1)) rs = null;
pstmt.close();
pstmt = null;
tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom));
if (tranDate.before(dueDate))
{ {
sql = "select due_date,cr_term from invoice where invoice_id = ?"; days = (int)(dueDate.getTime() - tranDate.getTime()) / 361440000;
pstmt = conn.prepareStatement(sql); if (days > 0)
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{ {
dueDate = rs.getDate(1); sql = "select fchg_type,case when fin_chg is null then 0 else fin_chg end from crtermfc where (min_day <= ? and max_day >= ? ) and cr_term = ?";
crTrem = rs.getString(2);
} pstmt = conn.prepareStatement(sql);
tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom)); pstmt.setInt(1, days);
if (tranDate.before(dueDate)) pstmt.setInt(2, days);
{ pstmt.setString(3, crTrem);
days = (int)(dueDate.getTime() - tranDate.getTime()) / 361440000; rs = pstmt.executeQuery();
if (days > 0) if (rs.next())
{ {
sql = "select fchg_type,case when fin_chg is null then 0 else fin_chg end from crtermfc where (min_day <= ? and max_day >= ? ) and cr_term = ?"; finChg = rs.getDouble(1);
fchgType = rs.getString(2);
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, days);
pstmt.setInt(2, days);
pstmt.setString(3, crTrem);
rs = pstmt.executeQuery();
if (rs.next())
{
finChg = rs.getDouble(1);
fchgType = rs.getString(2);
if (finChg == 0.0D) finChg = 0.0D;
if (discountLc == 0.0D) discountLc = 0.0D;
if (fchgType == "P")
{
discountLc = rcpAmt * (finChg / 36500.0D) * days;
}
else
{
discountLc = finChg;
}
discountLc = Math.round(discountLc) * -1L;
valueXmlString.append("<fin_chg>").append("<![CDATA[" + discountLc + "]]>").append("</fin_chg>");
}
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (finChg == 0.0D) finChg = 0.0D;
if (discountLc == 0.0D) discountLc = 0.0D;
if (fchgType == "P")
{
discountLc = rcpAmt * (finChg / 36500.0D) * days;
}
else
{
discountLc = finChg;
}
discountLc = Math.round(discountLc) * -1L;
valueXmlString.append("<fin_chg>").append("<![CDATA[" + discountLc + "]]>").append("</fin_chg>");
} }
} }
} }
} }
pstmt.close();
pstmt = null;
rs.close();
rs = null;
} }
else if (currentColumn.trim().equalsIgnoreCase("bad_debt_amt")) else if (currentColumn.trim().equalsIgnoreCase("bad_debt_amt"))
{ {
errCode = checkBadDebtAmt(1, conn, dom); errCode = checkBadDebtAmt(1, conn, dom);
......
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