Commit b0e3c53d authored by mchaudhari's avatar mchaudhari

Post Save Voucher


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95564 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 091d41ab
package ibase.webitm.ejb.fin;
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 org.w3c.dom.Document;
@javax.ejb.Stateless
public class VoucherPostSave extends ValidatorEJB implements VoucherPostSaveLocal, VoucherPostSaveRemote
{
FinCommon finCommon = new FinCommon();
DistCommon distCommon = new DistCommon();
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave( String domString, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
System.out.println("In VoucherPostSave ... ");
PreparedStatement pstmt = null;
Document dom = null;
ResultSet rs =null;
boolean isError = false;
String tranId = "";
String sql = null;
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 ;
int cnt=0;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
dom = genericUtility.parseString(domString);
tranId = GenericUtility.getInstance().getColumnValue("tran_id",dom);
// Advance Screen Cross Update
sql="select coalesce(adj_amt,0), coalesce(diff_amt__exch,0) from vouchadv WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
adjAmt = rs.getDouble(1);
diffAmtExch = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="select coalesce(sum(tot_amt),0) + coalesce(sum(adv_amt),0), coalesce(sum(net_amt),0) * coalesce(sum(exch_rate),0) from voucher WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
netAmt = rs.getDouble(1);
netAmtBc = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("In netAmtBc = "+netAmtBc);
sql="UPDATE voucher set adv_amt = ?, diff_amt__exch = ?, net_amt = ? , net_amt__bc = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,adjAmt );
pstmt.setDouble(2,diffAmtExch );
pstmt.setDouble(3,netAmt );
pstmt.setDouble(4,netAmtBc );
pstmt.setString(5,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if( cnt > 0)
{
System.out.println("update of advance Screen success ["+cnt+"]");
}
// End Of advance Screen cross Update
//Receipt Screen Cross Update
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.setDouble(1,vouchAmt);
pstmt.setString(2,tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
vouchAmt = rs.getDouble(1);
netAmtRcp = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="select coalesce(sum(vouch_amt),0) - coalesce(sum(disc_amt),0), coalesce(sum(tax_amt),0) from vouchrcp WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
billAmt = rs.getDouble(1);
taxAmt = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
totAmt = billAmt + taxAmt;
sql="select ? * coalesce(sum(exch_rate),0) from voucher WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,netAmtRcp );
pstmt.setString(2,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
netAmtBcRcp = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="UPDATE vouchrcp set vouch_amt = ?, net_amt = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,vouchAmt );
pstmt.setDouble(2,netAmtRcp);
pstmt.setString(3,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if( cnt > 0)
{
System.out.println("update of Receipt Screen success ["+cnt+"]");
}
sql="UPDATE voucher set bill_amt = ?, tax_amt = ?, tot_amt = ? , net_amt = ?, net_amt__bc = ? "
+" WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,billAmt );
pstmt.setDouble(2,taxAmt );
pstmt.setDouble(3,totAmt );
pstmt.setDouble(4,netAmtRcp );
pstmt.setDouble(5,netAmtBc );
pstmt.setString(6,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if( cnt > 0)
{
System.out.println("update of Vouche Screen from Receipt success ["+cnt+"]");
}
//End Of Receipt Screen Cross Update
// Cross Update of Detail Screen
sql="select coalesce(sum(amount),0), coalesce(sum(tax_amt),0) from vouchdet WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
advAmt = rs.getDouble(1);
taxAmtDet = rs.getDouble(2);
advAmt = advAmt + adjAmt;
}
rs.close();
rs = null;
pstmt.close();
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 = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,taxAmt);
pstmt.setDouble(2,advAmt);
pstmt.setDouble(3,advAmt);
pstmt.setString(4,tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
totAmtDet = rs.getDouble(1);
netAmtDet = rs.getDouble(2);
netAmtBcDet = rs.getDouble(3);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//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 = ? WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
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.setString(5,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if( cnt > 0)
{
System.out.println("update of Detail Screen success ["+cnt+"]");
}
// End of Cross update of Detail Screen
}
catch(Exception e)
{
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
isError = true;
System.out.println("Exception :VoucherPostSaveEJB : :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
if( isError )
{
conn.rollback();
}
else
{
conn.commit();
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception :VoucherPostSaveEJB : :==>\n"+e.getMessage());
try
{
System.out.println("Before rollback");
conn.rollback();
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
throw new ITMException(e);
}
}
System.out.println("Out VoucherPostSaveEJB ... ");
return "";
}
/* private java.math.BigDecimal round(int scale ,double round)
{
return new java.math.BigDecimal(round).setScale(scale, java.math.BigDecimal.ROUND_UP);
}
private double roundVal(double round,int scale)
{
return Math.round(round*Math.pow(10, scale))/Math.pow(10, scale);
}*/
}
\ No newline at end of file
/*
* PURPOSE : Local interface for Voucher Post Save to lookup Localy
*/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface VoucherPostSaveLocal extends ValidatorLocal
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
/*
* PURPOSE : Remote interface for Voucher Post Save to lookup remotely
*/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface VoucherPostSaveRemote extends ValidatorRemote
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ 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