Commit 313e298d authored by vdhoble's avatar vdhoble

New Post Save for Amount exceed Generic utility


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101154 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 67d959e7
package ibase.webitm.ejb.fin;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.naming.InitialContext;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.Document;
@javax.ejb.Stateless
public class GenRcpPostSave extends ValidatorEJB implements GenRcpPostSaveLocal, GenRcpPostSaveRemote
{
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 GenRcpPostSave ... ");
PreparedStatement pstmt = null,pstmt1 = null;
Document dom = null;
ResultSet rs =null,rs1 = null;
boolean isError = false;
ITMDBAccessEJB itmDBAccessEJB = null;
String tranId = "";
String errString ="";
String xmlString =null;
String sql = null;
String siteCode = "";
String refSer = "",refNo = "";
double rcpAmt = 0, detAmt =0, rcpAmtVal = 0 ;
int cnt=0;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(domString);
tranId = genericUtility.getColumnValue("tran_id",dom);
System.out.println("Tran ID for Domestic Receipt Transaction:::::"+tranId);
sql="select b.ref_no,b.ref_ser,b.rcp_amt,a.site_code from receipt_form a,rcpdet_form b where a.tran_id = b.tran_id and a.tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
while(rs.next())
{
refSer = rs.getString("ref_ser");
refNo = rs.getString("ref_no");
rcpAmt = rs.getDouble("rcp_amt");
siteCode = rs.getString("site_code");
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE REF_NO = ? and tran_ser = ? and site_code=? " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,refNo);
pstmt1.setString(2,refSer);
pstmt1.setString(3,siteCode);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
rcpAmtVal=rs1.getDouble(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("rcpAmtVal :"+rcpAmtVal);
sql = "select sum(rcp_amt) from rcpdet_form where ref_no = ? and ref_ser = ? and tran_id in(select tran_id from receipt_form where confirmed='N') " ;
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,refNo);
pstmt1.setString(2,refSer);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
detAmt=rs1.getDouble(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("detAmt :"+detAmt);
if(detAmt > rcpAmtVal)
{
conn.rollback();
errString = itmDBAccessEJB.getErrorString("","VTAMTEXEED","","",conn);
return errString ;//amount exceeds than total amount in receivables
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
isError = true;
System.out.println("Exception :Domestic Receipt : :==>\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 :SavexPreSaveEJB : :==>\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 Domestic Receipt save logic ... ");
return errString;
}
}
\ No newline at end of file
/*
* PURPOSE : Local interface for MiscPay 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 GenRcpPostSaveLocal 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 MiscPay 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 GenRcpPostSaveRemote 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