Commit 21c62d40 authored by mchaudhari's avatar mchaudhari

Solve tax amount issues


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95592 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c6e6ec92
...@@ -28,12 +28,13 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -28,12 +28,13 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
System.out.println("In VoucherPostSave ... "); System.out.println("In VoucherPostSave ... ");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement pstmt2 = null;
Document dom = null; Document dom = null;
ResultSet rs =null; ResultSet rs =null;
boolean isError = false; boolean isError = false;
String tranId = ""; String tranId = "";
String sql = null; String sql = null, sql2 = null;
double diffAmtExch = 0, adjAmt = 0, netAmt = 0, netAmtBc = 0, vouchAmt = 0, billAmt = 0, taxAmt = 0, totAmt = 0; double diffAmtExch = 0, adjAmt = 0, netAmt = 0, netAmtBc = 0, vouchAmt = 0, billAmt = 0, taxAmt = 0, totAmt = 0;
double netAmtRcp = 0, advAmt = 0, netAmtDet = 0, netAmtBcRcp = 0, taxAmtDet = 0, totAmtDet = 0, netAmtBcDet = 0 ; double netAmtRcp = 0, advAmt = 0, netAmtDet = 0, netAmtBcRcp = 0, taxAmtDet = 0, totAmtDet = 0, netAmtBcDet = 0 ;
...@@ -95,25 +96,43 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -95,25 +96,43 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
// End Of advance Screen cross Update // End Of advance Screen cross Update
//Receipt Screen Cross Update //Receipt Screen Cross Update
sql="select line_no, coalesce(vouch_qty,0) * coalesce(vouch_rate,0), coalesce(((coalesce(vouch_qty,0) * coalesce(vouch_rate,0)) + tax_amt + disc_amt),0) from vouchrcp WHERE tran_id = ? " ;
sql="select coalesce(vouch_qty,0) * coalesce(vouch_rate,0), coalesce((? + tax_amt - disc_amt),0) from vouchrcp WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,vouchAmt); //pstmt.setDouble(1,vouchAmt);
pstmt.setString(2,tranId); pstmt.setString(1,tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) while (rs.next())
{ {
vouchAmt = rs.getDouble(1); sql2="UPDATE vouchrcp set vouch_amt = ?, net_amt = ? WHERE tran_id = ? and line_no = ?";
netAmtRcp = rs.getDouble(2); pstmt2 = conn.prepareStatement(sql2);
pstmt2.setDouble(1,rs.getDouble(2));
pstmt2.setDouble(2,rs.getDouble(3));
pstmt2.setString(3,tranId);
pstmt2.setLong(4,rs.getLong(1));
pstmt2.executeUpdate();
pstmt2.close();
pstmt2 = null;
/* System.out.println("vouchAmt Inner ====>>>>> "+vouchAmt);
System.out.println("netAmtRcp Inner ====>>>>> "+vouchAmt);*/
vouchAmt = vouchAmt + rs.getDouble(2);
netAmtRcp = netAmtRcp + rs.getDouble(3);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql="select coalesce(sum(vouch_amt),0) - coalesce(sum(disc_amt),0), coalesce(sum(tax_amt),0) from vouchrcp WHERE tran_id = ? " ; /*System.out.println("vouchAmt ====>>>>> "+vouchAmt);
System.out.println("netAmtRcp ====>>>>> "+netAmtRcp);*/
sql="select ? - coalesce(sum(disc_amt),0), coalesce(sum(tax_amt),0) from vouchrcp WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId ); pstmt.setDouble(1,vouchAmt );
pstmt.setString(2,tranId );
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
...@@ -127,6 +146,10 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -127,6 +146,10 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
totAmt = billAmt + taxAmt; totAmt = billAmt + taxAmt;
/*System.out.println("billAmt Receipt ====>>>>> "+billAmt);
System.out.println("taxAmt Receipt ====>>>>> "+taxAmt);
System.out.println("totAmt Receipt ====>>>>> "+totAmt);*/
sql="select ? * coalesce(sum(exch_rate),0) from voucher WHERE tran_id = ? " ; sql="select ? * coalesce(sum(exch_rate),0) from voucher WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,netAmtRcp ); pstmt.setDouble(1,netAmtRcp );
...@@ -142,7 +165,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -142,7 +165,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
pstmt = null; pstmt = null;
sql="UPDATE vouchrcp set vouch_amt = ?, net_amt = ? WHERE tran_id = ? "; /* sql="UPDATE vouchrcp set vouch_amt = ?, net_amt = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,vouchAmt ); pstmt.setDouble(1,vouchAmt );
pstmt.setDouble(2,netAmtRcp); pstmt.setDouble(2,netAmtRcp);
...@@ -154,7 +177,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -154,7 +177,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
if( cnt > 0) if( cnt > 0)
{ {
System.out.println("update of Receipt Screen success ["+cnt+"]"); System.out.println("update of Receipt Screen success ["+cnt+"]");
} }*/
sql="UPDATE voucher set bill_amt = ?, tax_amt = ?, tot_amt = ? , net_amt = ?, net_amt__bc = ? " sql="UPDATE voucher set bill_amt = ?, tax_amt = ?, tot_amt = ? , net_amt = ?, net_amt__bc = ? "
+" WHERE tran_id = ? "; +" WHERE tran_id = ? ";
...@@ -163,7 +186,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -163,7 +186,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
pstmt.setDouble(2,taxAmt ); pstmt.setDouble(2,taxAmt );
pstmt.setDouble(3,totAmt ); pstmt.setDouble(3,totAmt );
pstmt.setDouble(4,netAmtRcp ); pstmt.setDouble(4,netAmtRcp );
pstmt.setDouble(5,netAmtBc ); pstmt.setDouble(5,netAmtBcRcp );
pstmt.setString(6,tranId ); pstmt.setString(6,tranId );
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
...@@ -187,7 +210,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -187,7 +210,7 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
{ {
advAmt = rs.getDouble(1); advAmt = rs.getDouble(1);
taxAmtDet = rs.getDouble(2); taxAmtDet = rs.getDouble(2);
taxAmtDet = taxAmtDet + taxAmt;
advAmt = advAmt + adjAmt; advAmt = advAmt + adjAmt;
} }
rs.close(); rs.close();
...@@ -195,12 +218,17 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -195,12 +218,17 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql="select coalesce((sum(bill_amt) + ?),0), coalesce(sum(tot_amt + ?),0), coalesce(coalesce(sum(tot_amt + ?),0) + sum(exch_rate),0) from voucher WHERE tran_id = ? " ; //System.out.println("taxAmtDet ====>>>>> "+taxAmtDet);
//System.out.println("advAmt ====>>>>> "+advAmt);
sql="select coalesce((bill_amt + ?),0), coalesce((coalesce((bill_amt + ?),0) + ?),0), coalesce((coalesce((bill_amt + ?),0) + ?),0) * coalesce(exch_rate,0) from voucher WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,taxAmt); pstmt.setDouble(1,taxAmtDet);
pstmt.setDouble(2,advAmt); pstmt.setDouble(2,taxAmtDet);
pstmt.setDouble(3,advAmt); pstmt.setDouble(3,advAmt);
pstmt.setString(4,tranId); pstmt.setDouble(4,taxAmtDet);
pstmt.setDouble(5,advAmt);
pstmt.setString(6,tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
...@@ -217,10 +245,6 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -217,10 +245,6 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
sql="UPDATE voucher set adv_amt = ?, tax_amt = ?, tot_amt = ?, net_amt = ?, net_amt__bc = ? WHERE tran_id = ? "; sql="UPDATE voucher set adv_amt = ?, tax_amt = ?, tot_amt = ?, net_amt = ?, net_amt__bc = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,advAmt ); pstmt.setDouble(1,advAmt );
/* pstmt.setDouble(2,(taxAmt + taxAmtDet) );
pstmt.setDouble(3,(totAmt + totAmtDet) );
pstmt.setDouble(4,(netAmt + netAmtRcp + netAmtDet));
pstmt.setDouble(5,(netAmtBc + netAmtBcRcp + netAmtDet));*/
pstmt.setDouble(2,taxAmtDet); pstmt.setDouble(2,taxAmtDet);
pstmt.setDouble(3,totAmtDet); pstmt.setDouble(3,totAmtDet);
pstmt.setDouble(4,netAmtDet); pstmt.setDouble(4,netAmtDet);
...@@ -273,6 +297,11 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca ...@@ -273,6 +297,11 @@ public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLoca
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
} }
catch(Exception e) catch(Exception e)
{ {
......
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