Commit f6fa476b authored by msalla's avatar msalla

On confirmation of bill dicounting transaction, coin difference error is...

On confirmation of bill dicounting transaction, coin difference error is coming.  This bill discounting includes packing credit adjustment and amount in accounts detail

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@210875 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3ed6d4c0
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.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.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 BillDiscountingPostSave extends ValidatorEJB implements BillDiscountingPostSaveRemote,BillDiscountingPostSaveLocal
{
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 ReceiptAdvPostSave ... ");
PreparedStatement pstmt = null;
Document dom = null;
ResultSet rs =null;
boolean isError = false;
String tranIdRcp = "";
String tranId = "",lineNo="";
String errString ="";
String xmlString =null;
String bdFluctuationCf = "";
String sql = null;
String sqlC=null;
StringBuffer xmlBuff = new StringBuffer();
String errorString="";
String cctrFin = "";
String cctrFins = "";
String rcpType = "";
String ledgPostConf = "";
String acctFin = "";
String acctFins = "";
double amtdet=0,amtBcDet=0,totnetAmtBc=0,amtBc=0,amountBchdr=0,totnetAmt=0,amountbcDet=0,amtHdr=0,netAmtdet=0,amtdetepc=0,amountBC=0,netAmtBcdet=0,exchrateIntHdr=0,amountBcdet=0, intAmtdet=0,exchrateIntdet=0,diffAmtExchDet = 0, diffAmtExchAdv = 0, diffAmtExchEpc = 0, newAdvAmt = 0,epcAdjAmount=0;
double billAmtDet = 0,totAmtBc=0,amthdrepc=0,netAmtBcHdr=0,netAmtBcEpcdet=0,intAmtHdr=0, advAmtHdr = 0, adjAmtAdv = 0, bdAmt =0, advAmtRact = 0, othAmt = 0.0,exchRateHdr = 0.0, taxAmt = 0,amount = 0.0,othAmttemp =0.0;
double amtBcEpcdet=0,amtepcdet=0,diffexchepcdet=0,netAmtDet=0,totamtbc=0;
double amtAcct=0,netamountBcdet=0,exchrateAcct=0,netAmtAcct=0,cnt=0,totNetAmt=0,totNetAmtBc=0,amtdetbd=0;
FinCommon finCommon = null;
DistCommon disCommon = null;
double amountMap = 0;
try
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(domString);
tranId = genericUtility.getColumnValue("tran_id",dom);
//select data form export_fund.
sql="select exch_rate,amount,int_amt,exch_rate__int,net_amt__bc,amt_advbkadj__bc,amount__epcadj from export_fund WHERE tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
exchRateHdr = rs.getDouble("exch_rate");
amtHdr = rs.getDouble("amount");
intAmtHdr = rs.getDouble("int_amt");
exchrateIntHdr = rs.getDouble("exch_rate__int");
netAmtBcHdr=rs.getDouble("net_amt__bc");
amountBchdr = rs.getDouble("amt_advbkadj__bc");
amthdrepc=rs.getDouble("amount__epcadj");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//select data from export_fund detail
sql="select sum(amount),sum(int_amt),sum(amount__bc),sum(amount) from export_fundet where tran_id = ? ";//net amt=?
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
amtdet = rs.getDouble(1);
intAmtdet = rs.getDouble(2);
amountBcdet = rs.getDouble(3);
amtdetbd= rs.getDouble(4);
}
//System.out.println( "amount with exchrate ["+amtdet+"] interest amount--["+intAmtdet+"] amout_bc---["+amountBcdet);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
amountBcdet=amtdet*exchRateHdr;
sql="update export_fundet set amount__bc=? where tran_id=? " ;//end
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,amountBcdet );
pstmt.setString(2,tranId );
rs = pstmt.executeQuery();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//System.out.println("amount bc det["+amountBcdet);
//select from export_fundadj
sql="select sum(amount__bc),sum(amount),sum(diff_amt__exch) from export_fundadj where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
amtBcEpcdet = rs.getDouble(1);
amtepcdet= rs.getDouble(2);
diffexchepcdet = rs.getDouble(3);
}
//System.out.println("export_fundadj det data netAMt--"+amtepcdet+"amount bc detial--["+amtBcEpcdet+"diff_amt_exch__"+diffexchepcdet);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//update
sql="update export_fundet set amount__bc=? where tran_id=? " ;//end
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,amtBcEpcdet );
pstmt.setString(2,tranId );
rs = pstmt.executeQuery();
//System.out.println("amount bc det["+amtBcEpcdet);
//select from export_fundacct
sql="select (amount),exch_rate from export_fundacct where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
amtAcct = rs.getDouble("amount");
exchrateAcct= rs.getDouble("exch_rate");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//UPDATE EXPORT _FUND
// System.out.println(" totNetAmtBc det--"+amountBcdet+(amtBcEpcdet)+amtAcct+"WITH INT---["+amountBcdet+(amtBcEpcdet)+amtAcct+intAmtdet+"WITH-VE EPC--["+amountBcdet+(amtBcEpcdet)+amtAcct+intAmtdet);
// netAmtDet=amtdet+amtepcdet;
totamtbc=amountBcdet+amtBcEpcdet;//TO SET AMOUNT BC-AMTDET*EXCH+AMT
netamountBcdet=amountBcdet-(intAmtdet*exchRateHdr);//
totNetAmtBc=netamountBcdet+amtBcEpcdet+amtAcct;
totNetAmt=totNetAmtBc/exchRateHdr;
// System.out.println("AMOUNT ["+amtdetbd+" ] INTAMT ["+intAmtdet+"AMOUNT BC ["+totamtbc+" ] NETAMOUNT BCDET["+netamountBcdet+" ]TOTAL NET AMT BC ["+totNetAmtBc+" ] NET AMOT["+totNetAmt);
sql="update export_fund set amount=?,int_amt=?,amount__bc=?,diff_amt__exch=?,amount__epcadj=?,net_amt__bc=?,net_amt=? where tran_id=? " ;//end
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,amtdetbd );
pstmt.setDouble(2,intAmtdet );
pstmt.setDouble(3,totamtbc );
pstmt.setDouble(4,diffexchepcdet );
pstmt.setDouble(5,amtBcEpcdet );
pstmt.setDouble(6,totNetAmtBc );
pstmt.setDouble(7,totNetAmt );
pstmt.setString(8,tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
isError = true;
System.out.println("Exception :DcdetPostSaveEJB : :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
}
if(rs != null)
{
rs.close();
rs = null;
}
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 DcdetPostSaveEJB ... -");
return errorString;
}
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);
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
}
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