Commit 28c6a731 authored by msharma's avatar msharma

Consider Foreign exch rate in Bill discounting


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96022 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 266bc6b9
......@@ -3308,7 +3308,8 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
if ((billDisc.equals("Y")) && (bdFluctuationCf.equals("Y")))
{
valueXmlString.append("<exch_rate>").append("<![CDATA[" + discExchRate + "]]>").append("</exch_rate>"); // change by ritesh on 25/05/13 as per discussion with pravin
diffAmtExch = rcpAmt * exchRate - rcpAmt * discExchRate;
//diffAmtExch = (rcpAmt * exchRate - rcpAmt * discExchRate)-((Double.parseDouble(lcBillDescAmt) * exchRate) - (Double.parseDouble(lcBillDescAmt) * discExchRate));
diffAmtExch = (rcpAmt * exchRate - rcpAmt * discExchRate)+((Double.parseDouble(lcBillDescAmt)-rcpAmt)*(exchRate-discExchRate));//Changed by Manoj dtd 22/08/2014 to Consider Bill Discount Exchrate difference
valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
}
else
......@@ -3316,6 +3317,7 @@ public class ReceiptAdv extends ValidatorEJB implements ReceiptAdvLocal, Receipt
diffAmtExch = rcpAmt * exchRate - rcpAmt * hexchRate;
valueXmlString.append("<diff_amt__exch>").append("<![CDATA[" + diffAmtExch + "]]>").append("</diff_amt__exch>");
}
System.out.println("rcpAmt["+rcpAmt+"]exchRate["+exchRate+"]discExchRate["+discExchRate+"]diffAmtExch["+diffAmtExch+"]");
valueXmlString.append("<site_code protect = \"1\" >").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<cust_code protect = \"1\">").append("<![CDATA[" + custCode + "]]>").append("</cust_code>");
......
......@@ -74,6 +74,8 @@ public class ReceiptAdvPostSave extends ValidatorEJB implements ReceiptAdvPostSa
String cctrFinS = "";
String acctFin = "";
String acctFinS = "";
String bdFluctuationCf="";
double rcpAmt=0,finChg=0, diffAmtExchDet = 0, diffAmtExchAdv = 0, diffAmtExchEpc = 0, newAdvAmt = 0;
double billAmtDet = 0, advAmtHdr = 0, adjAmtAdv = 0, bdAmt =0, advAmtRact = 0, othAmt =0,exchRateHdr = 0, taxAmt = 0;
int cnt=0;
......@@ -101,26 +103,36 @@ public class ReceiptAdvPostSave extends ValidatorEJB implements ReceiptAdvPostSa
rs = null;
pstmt.close();
pstmt = null;
sql="UPDATE rcpdet set exch_rate = ? "
+" WHERE tran_id = ? "
+ " and (curr_code = ? or exch_rate is null) ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,exchRateHdr );
pstmt.setString(2,tranId );
pstmt.setString(3,currCode );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
bdFluctuationCf=checkNull(finCommon.getFinparams("999999","BD_FLUCTUATION_CF",conn));//added by sagar on 21/08/14..
System.out.println(">>>>>>>>>>>>>>Finparam varValue:"+varValue);
if(bdFluctuationCf == null || bdFluctuationCf.trim().equalsIgnoreCase("NULLFOUND"))
{
bdFluctuationCf="N";
}
if("N".equals(bdFluctuationCf.trim())) //Condition added by sagar on 21/08/14..
{
sql="UPDATE rcpdet set exch_rate = ? "
+" WHERE tran_id = ? "
+ " and (curr_code = ? or exch_rate is null) ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,exchRateHdr );
pstmt.setString(2,tranId );
pstmt.setString(3,currCode );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
sql="UPDATE rcpdet set diff_amt__exch = (rcp_amt * EXCH_RATE__RCV) - (rcp_amt * exch_rate) "
+" WHERE tran_id = ? "
+ " and (curr_code = ? or exch_rate is null) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
pstmt.setString(2,currCode );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
sql="UPDATE rcpdet set diff_amt__exch = (rcp_amt * EXCH_RATE__RCV) - (rcp_amt * exch_rate) "
+" WHERE tran_id = ? "
+ " and (curr_code = ? or exch_rate is null) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
pstmt.setString(2,currCode );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
sql="select sum(diff_amt__exch), sum(tax_amt) from rcpdet WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
......@@ -194,13 +206,27 @@ public class ReceiptAdvPostSave extends ValidatorEJB implements ReceiptAdvPostSa
pstmt.close();
pstmt = null;
sql="select sum(d.rcp_amt * d.exch_rate / h.exch_rate), sum(case when r.bill_disc = 'Y' then d.BILL_DISC_AMT + d. FIN_CHG else 0 end ) "
+ " from receipt h, rcpdet d, receivables r "
+ " WHERE h.tran_id = d.tran_id "
+ " and r.tran_ser = d.ref_ser "
+ " and r.ref_no = d.ref_no "
+ " and r.line_no__ref = d.line_no__ref "
+ " and h.tran_id = ? " ;
if("N".equals(bdFluctuationCf.trim())) //Condition added by Manoj on 22/08/14..
{
sql="select sum(d.rcp_amt * d.exch_rate / h.exch_rate), sum(case when r.bill_disc = 'Y' then d.BILL_DISC_AMT + d. FIN_CHG else 0 end ) "
+ " from receipt h, rcpdet d, receivables r "
+ " WHERE h.tran_id = d.tran_id "
+ " and r.tran_ser = d.ref_ser "
+ " and r.ref_no = d.ref_no "
+ " and r.line_no__ref = d.line_no__ref "
+ " and h.tran_id = ? " ;
}
else
{
sql="select sum(d.rcp_amt * d.exch_rate__rcv / h.exch_rate), sum(case when r.bill_disc = 'Y' then d.BILL_DISC_AMT + d. FIN_CHG else 0 end ) "
+ " from receipt h, rcpdet d, receivables r "
+ " WHERE h.tran_id = d.tran_id "
+ " and r.tran_ser = d.ref_ser "
+ " and r.ref_no = d.ref_no "
+ " and r.line_no__ref = d.line_no__ref "
+ " and h.tran_id = ? " ;
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
......@@ -213,7 +239,7 @@ public class ReceiptAdvPostSave extends ValidatorEJB implements ReceiptAdvPostSa
rs = null;
pstmt.close();
pstmt = null;
billAmtDet=roundVal(billAmtDet, 3);
//chqAmt = billAmtDet + bdAmt + adjAmtAdv; // 21/01/14 bd amount removed from bill_amt
chqAmt = billAmtDet ;//+ adjAmtAdv;
// 25/02/14 manoharan if all details are dropped t6he bill_amt should be 0
......@@ -361,4 +387,12 @@ public class ReceiptAdvPostSave extends ValidatorEJB implements ReceiptAdvPostSa
{
return Math.round(round*Math.pow(10, scale))/Math.pow(10, scale);
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
}
\ 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