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
billDisc = "N";
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
sql = "select count(*) from receivables where tran_ser = ? and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
......@@ -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 (!refSer.equals("E-FUND"))
......@@ -2696,6 +2702,10 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
adjAmt = rs.getDouble(14);
badDebtAmt = rs.getDouble(15);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
hexchRate = doublevalue(genericUtility.getColumnValue("exch_rate", dom1));
sql = "select descr from currency where currency.curr_code = ?";
......@@ -2706,6 +2716,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{
currDescr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from accounts where accounts.acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCode);
......@@ -2714,6 +2729,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{
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 = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
......@@ -2723,8 +2743,17 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{
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";
}
System.out.println("bill disc ------ > "+billDisc);
if (billDisc.trim().equalsIgnoreCase("Y"))
{ //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 = ? ) )";
......@@ -2738,6 +2767,11 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
discExchRate = rs.getDouble(1); // change by ritesh on 25/05/13
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>").append("<![CDATA[" + billDisc + "]]>").append("</bill_disc>");
......@@ -2811,6 +2845,12 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
{
ctr = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((tranSer == "S-INV") || (ctr == 1))
{
sql = "select due_date,cr_term from invoice where invoice_id = ?";
......@@ -2822,6 +2862,13 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
dueDate = rs.getDate(1);
crTrem = rs.getString(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom));
if (tranDate.before(dueDate))
{
......@@ -2853,138 +2900,163 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
discountLc = Math.round(discountLc) * -1L;
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";
refNo = genericUtility.getColumnValue("ref_no", dom);
refSer = genericUtility.getColumnValue("ref_ser", dom);
sql = "select bill_disc FROM receivables where tran_ser = ? and ref_no = ?";
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 = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
billDisc = rs.getString(1);
exchRate = rs.getDouble(1);
}
if (billDisc == null) billDisc = "N";
if (billDisc == "Y")
{
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 = ?) )";
rs.close();
rs = null;
pstmt.close();
pstmt = null;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
pstmt.setString(2, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
exchRate = rs.getDouble(1);
}
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom));
hexchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom));
exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom));
}
bdFluctuationCf = getfinparm("999999", "BD_FLUCTUATION_CF" ,conn);
if (bdFluctuationCf.equals("") || bdFluctuationCf == null)
{
bdFluctuationCf = "Y";
}
if ((billDisc.equals("Y")) && (bdFluctuationCf.equals("Y")))
{
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>");
}
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom));
hexchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate", dom));
exchRate = Double.parseDouble(genericUtility.getColumnValue("exch_rate__rcv", dom));
}
bdFluctuationCf = getfinparm("999999", "BD_FLUCTUATION_CF" ,conn);
if (bdFluctuationCf.equals("") || bdFluctuationCf == null)
{
bdFluctuationCf = "Y";
}
if ((billDisc.equals("Y")) && (bdFluctuationCf.equals("Y")))
{
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("<cust_code protect = \"1\">").append("<![CDATA[" + custCode + "]]>").append("</cust_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>");
errCode = checkBadDebtAmt(0, conn, dom);
if(errCode == null && errCode.trim().length() == 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rcpAutoFinchg = getfinparm("999999", "RCP_AUTO_FINCHG", conn);
if (rcpAutoFinchg.equals("") || rcpAutoFinchg == null)
//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("<curr_code protect = \"1\">").append("<![CDATA[" + currCode + "]]>").append("</curr_code>");
//valueXmlString.append("<sale_order protect = \"1\">").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>");
errCode = checkBadDebtAmt(0, conn, dom);
if(errCode == null && errCode.trim().length() == 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
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.setString(1, "R-IBCA");
pstmt.setString(2, "S-INV");
pstmt.setString(3, refNo);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
ctr = rs.getInt(1);
dueDate = rs.getDate(1);
crTrem = rs.getString(2);
}
rcpAmt = Double.parseDouble(genericUtility.getColumnValue("rcp_amt", dom));
if ((tranSer == "S-INV") || (ctr == 1))
rs.close();
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 = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo);
rs = pstmt.executeQuery();
if (rs.next())
days = (int)(dueDate.getTime() - tranDate.getTime()) / 361440000;
if (days > 0)
{
dueDate = rs.getDate(1);
crTrem = rs.getString(2);
}
tranDate = dateFormat1.parse(genericUtility.getColumnValue("tran_date", dom));
if (tranDate.before(dueDate))
{
days = (int)(dueDate.getTime() - tranDate.getTime()) / 361440000;
if (days > 0)
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 = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, days);
pstmt.setInt(2, days);
pstmt.setString(3, crTrem);
rs = pstmt.executeQuery();
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 = ?";
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);
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"))
{
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