Commit c4f49f22 authored by arawankar's avatar arawankar

Office_sql.txt

PoRcpRetPostSave.java
PoRcpRetPostSaveLocal.java
PoRcpRetPostSaveRemote.java
- Create post save component to update detail amount in header

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@196099 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f4dda0d9
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class PoRcpRetPostSave extends ValidatorEJB implements PoRcpRetPostSaveLocal,PoRcpRetPostSaveRemote
{
boolean isError = false;
public String postSave(String xmlString,String tranId ,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
String retString = "";
Document dom = null;
E12GenericUtility genericUtility = null;
try
{
System.out.println("tranId--["+tranId+"]");
genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(xmlString);
retString = postSave(dom,tranId,editFlag,xtraParams,conn);
}
catch(Exception e )
{
e.getMessage();
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
finally
{
try
{
if(!isError)
{
conn.commit();
}
else
{
conn.rollback();
}
}
catch(Exception e)
{
e.getMessage();
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
}
return retString;
}
public String postSave(Document dom,String tranId,String editFlag,String xtraParams,Connection conn) throws ITMException
{
String retString = "";
String chgUser = "";
String chgTerm = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql1 = "";
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
Timestamp currDate = null;
String errString = "";
double amount = 0.0;
double taxAmt = 0.0;
int count = 0;
String tranSer = "";
E12GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
SimpleDateFormat sdf = null;
double frtAmt = 0.0,exchRateFrt = 0.0,insuranceAmt = 0.0,exchRateIns = 0.0,clearingCharges = 0.0,exchRateClr = 0.0,otherCharges = 0.0,exchRateOthch = 0.0;
double totAddlCost = 0.0;
try
{
genericUtility = new E12GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
tranId = genericUtility.getColumnValue("tran_id",dom);
System.out.println("Tran id :- ["+tranId+"]");
sql = "select tran_ser from porcp where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
tranSer = rs.getString("tran_ser");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("P-RCP".equalsIgnoreCase(tranSer))
{
double quantityStduom = 0.0,rateStduom = 0.0,discount = 0.0,taxAmtDetail = 0.0,netAmtDetail = 0.0,netAmtHdr = 0.0,detailQty = 0.0;
double totQty = 0.0;
double frtAmount = 0.0;
double totDiscount = 0.0;
double totTaxAmt = 0.0;
String lineNo = "";
sql = "select quantity__stduom,rate__stduom,discount,tax_amt,line_no,quantity from porcpdet where tran_id = ? order by line_no";
pstmt = conn.prepareStatement(sql);
sql1 = "update porcpdet set net_amt = ? where tran_id = ? and line_no = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
netAmtDetail = 0.0;
detailQty = 0.0;
discount = 0.0;
taxAmtDetail = 0.0;
quantityStduom = rs.getDouble("quantity__stduom");
rateStduom = rs.getDouble("rate__stduom");
discount = rs.getDouble("discount");
taxAmtDetail = rs.getDouble("tax_amt");
lineNo = rs.getString("line_no");
detailQty = rs.getDouble("quantity");
totQty = totQty + detailQty;
netAmtDetail = (quantityStduom*rateStduom)-((quantityStduom*rateStduom*discount)/100)+taxAmtDetail;
totDiscount = totDiscount + (((quantityStduom*rateStduom*discount)/100));
totTaxAmt = totTaxAmt + taxAmtDetail;
System.out.println("netAmtDetail --["+netAmtDetail+"]");
netAmtHdr = netAmtHdr + netAmtDetail;
pstmt1.setDouble(1, netAmtDetail);
pstmt1.setString(2, tranId);
pstmt1.setString(3, lineNo);
count = pstmt1.executeUpdate();
pstmt1.clearParameters();
}
System.out.println("netAmtHdr---["+netAmtHdr+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
String frtType = "";
double frtRate = 0.0;
sql = "select FRT_AMT,EXCH_RATE__FRT,INSURANCE_AMT,EXCH_RATE__INS,CLEARING_CHARGES,EXCH_RATE__CLR,OTHER_CHARGES,EXCH_RATE__OTHCH,frt_rate ,frt_type from porcp where tran_id = ?";
pstmt = conn.prepareStatement(sql);
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("EXCH_RATE__INS");
exchRateClr = rs.getDouble("EXCH_RATE__CLR");
otherCharges = rs.getDouble("OTHER_CHARGES");
exchRateOthch = rs.getDouble("EXCH_RATE__OTHCH");
frtType = rs.getString("frt_type");
frtRate = rs.getDouble("frt_rate");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
frtAmount = totQty * frtRate *("Q".equalsIgnoreCase(frtType) ? 1 : 0);
totAddlCost = (frtAmount*exchRateFrt)+(insuranceAmt*exchRateIns)+(clearingCharges*exchRateClr)+(otherCharges*exchRateOthch);
System.out.println("totAddlCost--["+totAddlCost+"]");
sql = "update porcp set frt_amt = ?,tax = ?,amount = ?,discount=?,total_additional_cost= ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1,frtAmount );
pstmt.setDouble(2, totTaxAmt);
pstmt.setDouble(3, netAmtHdr);
pstmt.setDouble(4, totDiscount);
pstmt.setDouble(5, totAddlCost);
pstmt.setString(6, tranId);
count = pstmt.executeUpdate();
System.out.println("count--["+count+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if("P-RET".equalsIgnoreCase(tranSer))
{
double quantityStduom = 0.0 ,rateStduom = 0.0,discount = 0.0,taxAmountDetail = 0.0;
String lineNo = "";
double netAmtDetail = 0.0;
double netAmtHdr = 0.0;
double totTaxAmt = 0.0;
double totDiscount = 0.0;
sql = "select quantity__stduom,rate__stduom,discount,tax_amt,line_no from porcpdet where tran_id = ? order by line_no";
pstmt = conn.prepareStatement(sql);
sql1 = "update porcpdet set net_amt = ? where tran_id = ? and line_no = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
quantityStduom = 0.0 ;
rateStduom = 0.0;
discount = 0.0;
taxAmountDetail = 0.0;
netAmtDetail = 0.0;
quantityStduom = rs.getDouble("quantity__stduom");
rateStduom = rs.getDouble("rate__stduom");
discount = rs.getDouble("discount");
taxAmountDetail = rs.getDouble("tax_amt");
lineNo = rs.getString("line_no");
netAmtDetail = (quantityStduom*rateStduom)-((quantityStduom*rateStduom*discount)/100)+taxAmountDetail;
netAmtHdr = netAmtHdr + netAmtDetail;
totTaxAmt = totTaxAmt + taxAmountDetail;
totDiscount = totDiscount + discount;
pstmt1.setDouble(1, netAmtDetail);
pstmt1.setString(2, tranId);
pstmt1.setString(3, lineNo);
count = pstmt1.executeUpdate();
pstmt1.clearParameters();
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
sql = "update porcp set tax = ?,amount = ?,discount = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, totTaxAmt);
pstmt.setDouble(2, netAmtHdr);
pstmt.setDouble(3, totDiscount);
pstmt.setString(4, tranId);
count = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
catch(Exception e )
{
e.getMessage();
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
}
catch(Exception e)
{
e.getMessage();
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
}
return retString;
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
import ibase.webitm.utility.ITMException;
@Local
public interface PoRcpRetPostSaveLocal
{
public String postSave(String xmlString,String tranId ,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
import ibase.webitm.utility.ITMException;
@Remote
public interface PoRcpRetPostSaveRemote
{
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
...@@ -152,3 +152,25 @@ insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,E ...@@ -152,3 +152,25 @@ insert into MESSAGES (MSG_NO,MSG_STR,MSG_DESCR,MSG_TYPE,MSG_OPT,MSG_TIME,ALARM,E
('VTSORDPT04','Order Posted!','Sale Order posting done successfully','P','Y',null,null,null,TO_DATE('22-10-00','DD-MM-RR'),'SUN ','HDP ',null,null); ('VTSORDPT04','Order Posted!','Sale Order posting done successfully','P','Y',null,null,null,TO_DATE('22-10-00','DD-MM-RR'),'SUN ','HDP ',null,null);
----------added by Varsha V. on 23-01-19[End]------------ ----------added by Varsha V. on 23-01-19[End]------------
------------ Added by Anjali R. on 23-01-2019 [Start]
insert into system_events (obj_name,event_code,event_context,service_code,method_rule,overwrite_core,chg_date,chg_user,chg_term,result_handle,comp_type,comp_name,comm_format)
values ('porcp','post_save','1','porcp_post_save',null,'0',sysdate,'BASE','BASE','2','JB','ibase.webitm.ejb.dis.PoRcpRetPostSave',null);
insert into system_events (obj_name,event_code,event_context,service_code,method_rule,overwrite_core,chg_date,chg_user,chg_term,result_handle,comp_type,comp_name,comm_format)
values ('preturn','post_save','1','porcp_post_save',null,'0',sysdate,'BASE','BASE','2','JB','ibase.webitm.ejb.dis.PoRcpRetPostSave',null);
insert into system_event_services (service_code,service_descr,service_uri,service_provider,method_name,return_value,return_type,return_descr,return_xfrm,chg_date,chg_user,chg_term,service_namespace,res_elem,soap_action)
values ('porcp_post_save','Action To update PURCHASE RECEIPT AND RETURN details in Header ','http://localhost:9090/axis/services/ActionHandlerService','Base Information','postSave','String','S',null,null,SYSDATE,'Base','Base',null,null,null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',1,'COMPONENT_TYPE','I','Component Type','S',null,SYSDATE,'BASE','Base','JB');
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',2,'COMPONENT_NAME','I','Component name','S',null,SYSDATE,'BASE','Base','ibase.webitm.ejb.dis.PoRcpRetPostSave');
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',3,'XML_DATA_ALL','I','XML data','S',null,SYSDATE,'BASE','Base',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',4,'<tran_id>','I','tran id','S',null,SYSDATE,'BASE','Base',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',5,'EDIT_FLAG','I','edit flag','S',null,SYSDATE,'BASE','Base',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE) values ('porcp_post_save',6,'XTRA_PARAMS','I','Xtra params','S',null,SYSDATE,'BASE','Base',null);
insert into system_service_args (service_code,line_no,arg_name,arg_mode,descr,arg_type,arg_xfrm,chg_date,chg_user,chg_term,arg_value) values ('porcp_post_save',7,'DB_CONN','I','db conn','S.Connection',null,SYSDATE,'BASE','Base',null);
COMMIT;
------------ Added by Anjali R. on 23-01-2019 [End]
\ 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