Commit 06ccbcbc authored by jshinde's avatar jshinde

Request Id:[W16CKAT001]Creating post_save component for purchase receipt &...

Request Id:[W16CKAT001]Creating post_save component for purchase receipt & implement logic from cross update.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101769 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d30d836a
package ibase.webitm.ejb.wms;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
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 PoRcpPostSave extends ValidatorEJB implements PoRcpPostSaveLocal, PoRcpPostSaveRemote
{
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 PoRcpPostSave ... ");
PreparedStatement pstmt = null;
Document dom = null;
ResultSet rs =null;
boolean isError = false;
String tranId = "",sqlP ="",sql="";
double quantity=0,rate =0,discount =0,taxAmt = 0,netAmt = 0,frtAmt = 0,exchRateFrt = 0
,insuranceAmt = 0,exchRateIns = 0,clearingCharges = 0,exchRateClr = 0
,otherCharges = 0,exchRateOthch = 0,netAmtCal=0,tax=0,amt=0,discountCal=0,totalAddlCost=0 ;
int updtdet=0,updtPorcp=0;
try
{
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(domString);
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
tranId = genericUtility.getColumnValue("tran_id",dom);
sql="SELECT SUM(QUANTITY__STDUOM) ,SUM(RATE__STDUOM),SUM(DISCOUNT),SUM(TAX_AMT) FROM PORCPDET WHERE TRAN_ID= ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
quantity = rs.getDouble(1);
rate = rs.getDouble(2);
discount = rs.getDouble(3);
taxAmt = rs.getDouble(4);
/*System.out.println("quantity::::::"+quantity);
System.out.println("rate:::::"+rate);
System.out.println("discount:::::"+discount);
System.out.println("taxAmt:::::"+taxAmt);*/
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
sqlP=" SELECT FRT_AMT,EXCH_RATE__FRT,INSURANCE_AMT,EXCH_RATE__INS,CLEARING_CHARGES, EXCH_RATE__CLR, OTHER_CHARGES, EXCH_RATE__OTHCH FROM PORCP WHERE TRAN_ID= ? " ;
pstmt = conn.prepareStatement(sqlP);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
if (rs.next())
{
frtAmt = rs.getDouble("FRT_AMT");
exchRateFrt = rs.getDouble("EXCH_RATE__FRT");
insuranceAmt = rs.getDouble("INSURANCE_AMT");
exchRateIns = rs.getDouble("EXCH_RATE__INS");
clearingCharges = rs.getDouble("CLEARING_CHARGES");
exchRateClr = rs.getDouble("EXCH_RATE__CLR");
otherCharges = rs.getDouble("OTHER_CHARGES");
exchRateOthch = rs.getDouble("EXCH_RATE__OTHCH");
/*System.out.println("frtAmt:::"+frtAmt);
System.out.println("exchRateFrt:::::"+exchRateFrt);
System.out.println("insuranceAmt:::::"+insuranceAmt);
System.out.println("exchRateIns:::"+exchRateIns);
System.out.println("clearingCharges:::::"+clearingCharges);
System.out.println("exchRateClr:::::"+exchRateClr);
System.out.println("otherCharges::::::"+otherCharges);
System.out.println("exchRateOthch::::"+exchRateOthch);*/
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
netAmtCal=(( quantity * rate )-(( quantity * rate * discount )/100 )+ taxAmt );
tax=taxAmt;
//amt=netAmt;
discountCal =(( quantity * rate * discount )/100 );
totalAddlCost=( frtAmt * exchRateFrt )+( insuranceAmt * exchRateIns )+( clearingCharges * exchRateClr )+( otherCharges * exchRateOthch );
sql=" UPDATE PORCPDET SET NET_AMT = ? WHERE TRAN_ID=? ";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1,netAmtCal);
pstmt.setString(2,tranId);
updtdet = pstmt.executeUpdate();
System.out.println("Update Record for PORCPDET["+updtdet+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sqlP=" UPDATE PORCP SET TAX = ? ,AMOUNT = ? ,DISCOUNT = ?,TOTAL_ADDITIONAL_COST = ? "
+" WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sqlP);
pstmt.setDouble(1,tax );
pstmt.setDouble(2,netAmtCal );
pstmt.setDouble(3,discountCal);
pstmt.setDouble(4,totalAddlCost);
pstmt.setString(5,tranId);
updtPorcp = pstmt.executeUpdate();
System.out.println("Update Record for PORCP["+updtPorcp+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("net_amt:::"+netAmtCal);
System.out.println("tax:::::"+tax);
System.out.println("amount:::"+netAmtCal);
System.out.println("discount::::"+discountCal);
System.out.println("totalAddlCost:::"+totalAddlCost);
}
catch(Exception e)
{
isError = true;
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError="+isError);
if(isError)
{
conn.rollback();
}
else
{
conn.commit();
}
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
if(rs != null)
{
rs.close();
rs=null;
}
}
catch(Exception e1)
{
throw new ITMException(e1);
}
}
System.out.println("Out PoRcpPostSave ... ");
return "";
}
}
\ No newline at end of file
package ibase.webitm.ejb.wms;
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 PoRcpPostSaveLocal extends ValidatorLocal
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface PoRcpPostSaveRemote extends ValidatorRemote
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
insert into system_events (obj_name,event_code,event_context,service_code,
chg_date,chg_user,chg_term,result_handle,overwrite_core,comp_type,comp_name)
values ('porcp','post_save','1','post_save_porcp',
SYSDATE,'base','base','2','0','EJB','PoRcpPostSave');
insert into system_event_services (service_code,service_descr,service_uri,service_provider,
method_name,return_value,return_type,chg_date,chg_user,chg_term)
values ('post_save_porcp','Post save for purchase receipt',
'http://localhost/axis/services/ValidatorService','Base Information',
'postSave','String','S',SYSDATE,'BASE','BASE');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,descr,arg_type,
chg_date,chg_user,chg_term,arg_value) values
('post_save_porcp',1,'COMPONENT_TYPE','I','Component Type','S',
SYSDATE,'BASE','BASE','EJB');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,descr,arg_type,
chg_date,chg_user,chg_term,arg_value) values
('post_save_porcp',2,'COMPONENT_NAME','I','Component Name','S',
sysdate,'BASE','BASE','MiscPayPostSave');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,
arg_type,chg_date,chg_user,chg_term) values
('post_save_porcp',3,'XML_DATA_ALL','I','S',
SYSDATE,'BASE','BASE');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,arg_type,
chg_date,chg_user,chg_term)
values ('post_save_porcp',4,'EDIT_FLAG','I','S',
SYSDATE,'BASE','BASE');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,arg_type,
CHG_DATE,CHG_USER,CHG_TERM) values
('post_save_porcp',5,'XTRA_PARAMS','I','S',SYSDATE,
'BASE','BASE');
insert into system_service_args (service_code,line_no,arg_name,arg_mode,arg_type,
chg_date,chg_user,chg_term) values ('post_save_porcp'
,6,'DB_CONN','I','S.Connection',SYSDATE,
'BASE','BASE');
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