Commit 208c7f71 authored by vkadam's avatar vkadam

Change on post save Advance and Details.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96877 ce508802-f39f-4f6c-b175-0d175dae99d5
parent dc9c31e8
......@@ -3,11 +3,15 @@ import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import org.w3c.dom.Document;
@javax.ejb.Stateless
......@@ -27,19 +31,21 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
System.out.println("In VoucherPostSave ... ");
PreparedStatement pstmt = null;
PreparedStatement pstmt = null,pstmt1=null;
Document dom = null;
ResultSet rs =null;
ResultSet rs =null,rs1=null;
boolean isError = false;
String tranId = "";
String sql = null;
String sql = null,sql1=null;
double diffAmtExch = 0, adjAmt = 0, netAmt = 0, netAmtBc = 0, vouchAmt = 0, billAmt = 0, taxAmt = 0, totAmt = 0;
double diffAmtExchLine=0.0;
double netAmtRcp = 0, advAmt = 0, netAmtDet = 0, netAmtBcRcp = 0, taxAmtDet = 0, totAmtDet = 0, netAmtBcDet = 0 ;
double advAmtAdj = 0, taxedAdjAmt = 0, advAmtDet = 0, taxAmtAdv = 0;
String hdrVoucherType="",exchRate="";
int cnt=0;
int cnt=0,cnt1=0,listCnt=1;
try
{
......@@ -48,14 +54,41 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
tranId = GenericUtility.getInstance().getColumnValue("tran_id",dom);
// Advance Screen Cross Update
sql="select coalesce(((mvadv.adj_amt * mvadv.exch_rate__vouch) - (mvadv.adj_amt * mv.exch_rate)),0) " +
" from misc_vouchadv mvadv join misc_voucher mv on mvadv.tran_id = mv.tran_id WHERE mvadv.tran_id = ? " ;
sql="select exch_rate from misc_voucher where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if(rs.next()){
exchRate=rs.getString("exch_rate");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//To update diff_amt__exch for every line_no
sql="update misc_vouchadv set diff_amt__exch=((coalesce(adj_amt,0) * coalesce(exch_rate__vouch,0))-(coalesce(adj_amt,0)*?))"
+ " where tran_id= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,exchRate);
pstmt.setString(2,tranId);
cnt1 = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
/**Commented by Vallabh Kadam 28/NOV/14*/
// sql="select coalesce(((mvadv.adj_amt * mvadv.exch_rate__vouch) - (mvadv.adj_amt * mv.exch_rate)),0) " +
// " from misc_vouchadv mvadv join misc_voucher mv on mvadv.tran_id = mv.tran_id WHERE mvadv.tran_id = ? " ;
/**Commented by Vallabh Kadam 28/NOV/14 END*/
//SUM of all diff_amt__exch to update in header
sql="select coalesce(sum(diff_amt__exch),o) from misc_vouchadv where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
diffAmtExch = rs.getDouble(1);
diffAmtExch = rs.getDouble(1);
}
rs.close();
rs = null;
......@@ -64,7 +97,7 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
sql="select coalesce(sum(adj_amt),0), coalesce(sum(taxed_adj_amt),0), coalesce(sum(tax_amt),0) from misc_vouchadv WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
......@@ -93,20 +126,21 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
pstmt.close();
pstmt = null;
sql="UPDATE misc_vouchadv set diff_amt__exch = ? "
+" WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,diffAmtExch );
pstmt.setString(2,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
/**Commented on 28/NOV/14 Vallabh Kadam */
// sql="UPDATE misc_vouchadv set diff_amt__exch = ? "
// +" WHERE tran_id = ? ";
// pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1,diffAmtExch );
// pstmt.setString(2,tranId );
// cnt = pstmt.executeUpdate();
// pstmt.close();
// pstmt = null;
if( cnt > 0)
{
System.out.println("update of advance Screen success ["+cnt+"]");
}
// if( cnt > 0)
// {
// System.out.println("update of advance Screen success ["+cnt+"]");
// }
/**Commented on 28/NOV/14 Vallabh Kadam END */
sql="UPDATE misc_voucher set adv_amt__adj = ?, adv_amt = ?, taxed_adj_amt = ?, diff_amt__exch = ?, net_amt = ?, net_amt__bc = ? "
+" WHERE tran_id = ? ";
......@@ -129,8 +163,16 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
// End Of advance Screen cross Update
//Detail Screen Cross Update
sql="select case when mv.vouch_type = 'A' Then coalesce(sum(mvdet.amount),0) ELSE 0 END, case when mv.vouch_type != 'A' Then coalesce(sum(mvdet.amount),0) ELSE 0 END, coalesce(sum(mvdet.tax_amt),0) from misc_vouchdet mvdet join misc_voucher mv on mvdet.tran_id = mv.tran_id WHERE mvdet.tran_id = ? group by mv.vouch_type" ;
sql="select case when mv.vouch_type = 'A' "
+ "Then coalesce(sum(mvdet.amount),0) "
+ "ELSE 0 END, "
+ "case when mv.vouch_type != 'A' "
+ "Then coalesce(sum(mvdet.amount),0) "
+ "ELSE 0 END,"
+ " coalesce(sum(mvdet.tax_amt),0) "
+ "from misc_vouchdet mvdet join misc_voucher mv "
+ "on mvdet.tran_id = mv.tran_id "
+ "WHERE mvdet.tran_id = ? group by mv.vouch_type" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
......@@ -179,7 +221,7 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
pstmt = null;
System.out.println("Taxy Amt = "+ taxAmt + " totAmt = "+ totAmt);
sql="UPDATE misc_voucher set adv_amt__det = ?, bill_amt = ?, adv_amt = ?, tax_amt = ?, tot_amt = ?, net_amt = ?, net_amt__bc = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,advAmtDet );
......
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