Commit b3974d73 authored by vkadam's avatar vkadam

Changes add formula for [net_tot_amt] in Header and Detail both.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98335 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5322c690
......@@ -53,14 +53,16 @@ public class SaleOrderPostSave extends ValidatorEJB implements SaleOrderPostSave
PreparedStatement pstmt=null,pstmt1=null;
String sql="",sql1="",errorString="";
double quantityStduom = 0,rateStduom=0,discount=0,taxAmt=0,netAmt=0,taxAmtH=0,totAmtH=0,
ordAmtH=0,ordValueH=0,ordValue=0,totOrdValueH=0;
ordAmtH=0,ordValueH=0,ordValue=0,totOrdValueH=0,
billBackAmt=0,offInvAmt=0,netTotAmtDet=0,netTotAmtHdr=0,ordBillBackAmt=0,ordOffInvAmt=0,lineBillBackAmt=0,lineOffInvAmt=0;
int count=0,lineNo=0;
try{
GenericUtility genericUtility = GenericUtility.getInstance();
tranId = GenericUtility.getInstance().getColumnValue("sale_order",dom);
System.out.println("sale_order--->>["+tranId+"]");
sql="select quantity__stduom,rate__stduom,discount,tax_amt,line_no,ord_value "
sql="select quantity__stduom,rate__stduom,discount,tax_amt,line_no,ord_value,"
+ "billback_amt,offinv_amt " //VALLABH KADAM [20/JUL/15] find billback_amt,offinv_amt
+ "from sorddet where sale_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId);
......@@ -72,6 +74,9 @@ public class SaleOrderPostSave extends ValidatorEJB implements SaleOrderPostSave
taxAmt=rs.getDouble(4);
lineNo=rs.getInt(5);
ordValue=rs.getDouble(6);
billBackAmt=rs.getDouble(7); //VALLABH KADAM [20/JUL/15] find billback_amt
offInvAmt=rs.getDouble(8); //VALLABH KADAM [20/JUL/15] find offinv_amt
System.out.println("quantityStduom-->["+quantityStduom+"]");
System.out.println("rateStduom-->["+rateStduom+"]taxAmt-->["+taxAmt+"]");
System.out.println("discount-->["+discount+"] lineNo-->["+lineNo+"]");
......@@ -79,12 +84,20 @@ public class SaleOrderPostSave extends ValidatorEJB implements SaleOrderPostSave
netAmt=(quantityStduom*rateStduom)-((quantityStduom*rateStduom*discount)/100)+taxAmt;
System.out.println("NetAmt--->>["+netAmt+"]");
/**
* VALLABH KADAM [20/JUL/15]
* Calculate net_tot_det
* for every detail
* */
netTotAmtDet=netAmt-billBackAmt-offInvAmt;
System.out.println("Nte Total Amt:- ["+netTotAmtDet+"]");
sql1="update sorddet set net_amt = ? where sale_order = ? and line_no = ?";
sql1="update sorddet set net_amt = ?,net_tot_amt=? where sale_order = ? and line_no = ?";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setDouble(1, netAmt);
pstmt1.setString(2, tranId);
pstmt1.setInt(3, lineNo);
pstmt1.setDouble(2, netTotAmtDet); //VALLABH KADAM [20/JUL/15]set net_tot_amt for every detail
pstmt1.setString(3, tranId);
pstmt1.setInt(4, lineNo);
count=pstmt1.executeUpdate();
if (pstmt1 != null){
pstmt1.close();
......@@ -110,14 +123,39 @@ public class SaleOrderPostSave extends ValidatorEJB implements SaleOrderPostSave
System.out.println("pre count---->>["+count+"]");
System.out.println("taxAmtH-->["+taxAmtH+"] totAmtH-->["+totAmtH+"]");
System.out.println("ordAmtH-->["+ordAmtH+"] totOrdValueH-->["+totOrdValueH+"]");
/**
* VALLABH KADAM [20/JUL/15]
* find ord_billback_amt, ord_offinv_amt, line_billback_amt, line_offinv_amt
* to calculate net_tot_amt
* */
sql="SELECT ORD_BILLBACK_AMT,ORD_OFFINV_AMT, LINE_BILLBACK_AMT,LINE_OFFINV_AMT FROM SORDER WHERE SALE_ORDER=?";
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
if(rs.next())
{
ordBillBackAmt=rs.getDouble("ORD_BILLBACK_AMT");
ordOffInvAmt=rs.getDouble("ORD_OFFINV_AMT");
lineBillBackAmt=rs.getDouble("LINE_BILLBACK_AMT");
lineOffInvAmt=rs.getDouble("LINE_OFFINV_AMT");
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
netTotAmtHdr=totAmtH-ordBillBackAmt-ordOffInvAmt-lineBillBackAmt-lineOffInvAmt;
if(count >0){
sql="update sorder set tax_amt = ? ,tot_amt= ? ,ord_amt = ?,tot_ord_value= ? where sale_order = ?";
sql="update sorder set tax_amt = ? ,tot_amt= ? ,ord_amt = ?,tot_ord_value= ?,net_tot_amt=? where sale_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, taxAmtH);
pstmt.setDouble(2, totAmtH);
pstmt.setDouble(3, ordAmtH);
pstmt.setDouble(4, totOrdValueH);
pstmt.setString(5, tranId);
pstmt.setDouble(5, netTotAmtHdr); // VALLABH KADAM [20/JUL/15] net_tot_amt for header
pstmt.setString(6, tranId);
count=pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]");
if(count >0 ){
......@@ -127,6 +165,7 @@ public class SaleOrderPostSave extends ValidatorEJB implements SaleOrderPostSave
conn.rollback();
}
}
catch(Exception e){
System.out.println("Exception : SaleOrderPostSave -->["+e.getMessage()+"]");
......
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