Commit f0502528 authored by msalla's avatar msalla

Invoice cancellation testing with sales return.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@215436 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 959f5b89
......@@ -24,10 +24,12 @@ import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.adv.SalesReturnConfirm;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.fin.adv.UndoRecievableAdjConfLocal;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.wms.CommonWmsUtil;
@Stateless
......@@ -38,7 +40,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance();
MasterStatefulLocal masterStatefulLocal = null;
DistCommon distComm = new DistCommon();
String userId = "",loginSiteCode = "",chgTerm = "";
@Override
......@@ -52,30 +54,50 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
ResultSet rs = null,rs1=null;
int cnt = 0;
String confirmed = "",userInfo = "",orderDate = "";
String itemSer="",custCode="",lotNo="",rate="",lotSl="",locCode="",despID="",despLineNo="";
String itemSer="",custCode="",lotNo="",rate="",lotSl="",locCode="",despID="",sretFullRetType="",despLineNo="";
double refBalAmount = 0,totAmt = 0, adjAmt = 0;
//added by monika 25 nov
FinCommon finCommon = new FinCommon();
PreparedStatement pstmtHdr = null,pstmtDet = null;
String ediOption = "",invIbcaGen = "",siteCode = "",siteCodeRcv = "",keyStr = "",finEntityFrom = "",finEntityTo = "",
linkType = "",cctrCodePay = "",acctCodeRcp = "",cctrCodeRcp = "",acctCodePay = "",ibcaID = "",remarks = "";
Timestamp refDate = null,dueDate = null,custRefDate = null,gpDate = null;
String currCode = "",statusIBCA="",status="",acctCode = "",cctrCode = "",autoRcp = "",bankCode = "",recd = "",refType = "",tranSer = "",tranType = "",
crTerm = "",salesPers = "",salesPers1 = "",salesPers2 = "",custRefNo = "",gpNo = "",chgUser = "",chgTerm = "";
double exchRate = 0,discount = 0,adjamount=0,taxAmount = 0,custRefAmount = 0,amountBc = 0,amount = 0,totAMt=0,totAMtIBCA=0,adjamountIBCA=0;
String gs_run_mode = "",tranSerRcb="";
Timestamp tranDate = null,discountDate = null;
String tranidCrn="";
//end by monika 25 nov
try
{
System.out.println("Inside invoiceCancelEJB \n invoiceID["+invoiceID+"] \n xtraParams["+xtraParams+"] \n forcedFlag["+forcedFlag+"]");
//System.out.println("Inside invoiceCancelEJB \n invoiceID["+invoiceID+"] \n xtraParams["+xtraParams+"] \n forcedFlag["+forcedFlag+"]");
AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
conn = getConnection();
sql = " SELECT CONFIRMED FROM INVOICE WHERE INVOICE_ID = ? ";
sql = " SELECT CONFIRMED,cust_code,site_code FROM INVOICE WHERE INVOICE_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = checkNullAndTrim(rs.getString("CONFIRMED"));
custCode=checkNullAndTrim(rs.getString("cust_code"));
siteCode=checkNullAndTrim(rs.getString("site_code"));
}
if(pstmt != null)
{
......@@ -85,13 +107,13 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
if(!"Y".equalsIgnoreCase(confirmed))
{
retString = itmDBAccessEJB.getErrorString("","VTINVCANC","","",conn);
return retString;
}
sql = " SELECT COUNT(*) FROM SRETURN WHERE INVOICE_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
......@@ -108,7 +130,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
if(cnt > 0)
{
System.out.println("Sales Return already created for this invoice");
......@@ -116,23 +138,435 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
return retString;
}
cnt = 0;
if(!"Y".equalsIgnoreCase(confirmed))
{
retString = itmDBAccessEJB.getErrorString("","VTINVCANC","","",conn);
return retString;
}
//monika
gs_run_mode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "runMode");
//System.out.println("gs run mode----"+gs_run_mode);
chgUser = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "termId" );
//System.out.println("Inside createRIBCA----->["+invoiceID+"]");
tranDate = new java.sql.Timestamp(System.currentTimeMillis());
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
String currDateStr = sdfAppl.format(tranDate);
//System.out.println("Run mode--->["+gs_run_mode+"]");
if("I".equals(gs_run_mode))
{
//System.out.println("Inside createRIBCA----->2["+gs_run_mode+"]");
invIbcaGen = finCommon.getFinparams("999999","INV_IBCA_GEN",conn);
//System.out.println("createRIBCA--->INV_IBCA_GEN["+invIbcaGen+"]");
if("NULLFOUND".equals(invIbcaGen))
{
//invIbcaGen = "Y";
invIbcaGen = "N";
}
if("Y".equals(invIbcaGen))
{
sql = " select site_customer.site_code__rcp from site_customer "
+ " where ( site_customer.site_code = ? ) and ( site_customer.cust_code = ? ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);//S0001
pstmt.setString(2,custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCodeRcv = rs.getString("site_code__rcp");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
//System.out.println("site code ----->2["+siteCodeRcv+"]");
if(siteCodeRcv == null || siteCodeRcv.trim().length() == 0)
{
sql = " select site_code__rcp from customer where cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCodeRcv = rs.getString("site_code__rcp");//S0002
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
//System.out.println(" siteCodeRcv Inside createRIBCA----->3["+siteCodeRcv+"]");
}
//System.out.println(" siteCodeRcv Inside createRIBCA----->4["+siteCodeRcv+"]");
if(siteCodeRcv == null || siteCodeRcv.trim().length() == 0)
{
siteCodeRcv = siteCode ;
}
if(!siteCodeRcv.equals(siteCode))
{
/* System.out.println(" siteCodeRcv Inside createRIBCA----->2["+siteCodeRcv+"]");
sql = " select key_string from transetup where upper(tran_window) = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"W_RCP_IBCA");
rs = pstmt.executeQuery();
if(rs.next())
{
keyStr = rs.getString("key_string");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
sql = " select fin_entity from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
finEntityFrom = rs.getString("fin_entity");//sitecode:s0001
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
System.out.println(" finEntityFrom Inside createRIBCA----->2["+finEntityFrom+"]");
sql = "select fin_entity from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCodeRcv);//sitecode:s0002
rs = pstmt.executeQuery();
if(rs.next())
{
finEntityTo = rs.getString("fin_entity");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
System.out.println(" finEntityFrom Inside createRIBCA----->2["+finEntityTo+"]");
sql = "select link_type, acct_code__pay, cctr_code__pay, acct_code__rcp, cctr_code__rcp "
+" from ibca_rcp_ctrl where site_code__from = ? and site_code__to = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCodeRcv);
pstmt.setString(2,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
linkType = rs.getString("link_type");
acctCodePay = rs.getString("acct_code__pay");
cctrCodePay = rs.getString("cctr_code__pay");
acctCodeRcp = rs.getString("acct_code__rcp");
cctrCodeRcp = rs.getString("cctr_code__rcp");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
System.out.println(" linkType Inside createRIBCA----->2["+linkType+"]");
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id/>";
xmlValues = xmlValues + "<site_code__from>" + siteCodeRcv + "</site_code__from>";
xmlValues = xmlValues + "<site_code__to>" + siteCode + "</site_code__to>";
xmlValues = xmlValues + "<tran_date>"+ currDateStr + "</tran_date>";
xmlValues = xmlValues + "<link_type>"+linkType+"</link_type>";
xmlValues = xmlValues + "</Detail1></Root>";
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
ibcaID = tg.generateTranSeqID("R-IBCA", "tran_id", keyStr, conn);
if("ERROR".equalsIgnoreCase(ibcaID))
{
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
retString = itmDBAccessLocal.getErrorString("", "VTTRANID", "", "",conn);
return retString;
}
remarks = "Auto reversal IBCA due to invoice calcellation"+ custCode;*/
/*
sql = "select tot_amt, adj_amt,status from receivables where tran_ser ='S-INV' and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,invoiceID);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Inside createRIBCA----->rs.Next()");
totAmt = rs.getDouble("tot_amt");
adjamount = rs.getDouble("adj_amt");
status=rs.getString("status");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}*/
/*System.out.println("Inside createRIBCA----->amount["+adjamount+"] * exchRate["+exchRate+"]*" +"Inside createRIBCA----->amount["+totAmt+"] ");
sql = " select ref_date, curr_code, exch_rate, cust_code, acct_code, "
+" cctr_code, due_date, (tot_amt),(adj_amt) , discount, tax_amt, auto_rcp, "
+" bank_code, recd, ref_type, cr_term, item_ser, sales_pers, "
+" sales_pers__1, sales_pers__2, tran_date,cust_ref_no,cust_ref_date,cust_ref_amt,gp_no,gp_date,discount_dt,status,tran_ser"
+" from receivables where tran_ser like 'R-IBC%' and ref_no = ? and (tot_amt-adj_amt<>0)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,invoiceID);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Inside createRIBCA----->rs.Next()");
refDate = rs.getTimestamp("ref_date");
currCode = rs.getString("curr_code");
exchRate = rs.getDouble("exch_rate");
custCode = rs.getString("cust_code");
acctCode = rs.getString("acct_code");
cctrCode = rs.getString("cctr_code");
dueDate = rs.getTimestamp("due_date");
totAmt = rs.getDouble("tot_amt");
adjamount = rs.getDouble("adj_amt");
discount = rs.getDouble("discount");
taxAmount = rs.getDouble("tax_amt");
autoRcp = rs.getString("auto_rcp");
bankCode = rs.getString("bank_code");
recd = rs.getString("recd");
refType = rs.getString("ref_type");
crTerm = rs.getString("cr_term");
itemSer = rs.getString("item_ser");
salesPers = rs.getString("sales_pers");
salesPers1 = rs.getString("sales_pers__1");
salesPers2 = rs.getString("sales_pers__2");
tranDate = rs.getTimestamp("tran_date");
custRefNo = rs.getString("cust_ref_no");
custRefDate = rs.getTimestamp("cust_ref_date");
custRefAmount = rs.getDouble("cust_ref_amt");
gpNo = rs.getString("gp_no");
gpDate = rs.getTimestamp("gp_date");
discountDate = rs.getTimestamp("discount_dt");
statusIBCA=rs.getString("status");
tranSerRcb=rs.getString("tran_ser");
}
System.out.println("tran_ser in ibca--->"+tranSerRcb);
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
amount=totAmt-adjamount;
System.out.println("tot_amt ["+totAmt+"]adj_amt ["+adjamount+"]Inside createRIBCA----->amount"+(totAmt-adjamount)+"["+amount+"] * exchRate["+exchRate+"]* ");
amountBc = amount * exchRate ;
System.out.println("Inside createRIBCA----->transer rcv--["+amountBc+"]");*/
// if(amountBc != 0)
/* if(!"A".equalsIgnoreCase(statusIBCA))//--monika
{
System.out.println("Inside createRIBCA----->amountBc--["+tranSerRcb+"]");
sql = " insert into rcp_ibca (tran_id, tran_date, eff_date, site_code__from, fin_entity__from, "
+" site_code__to, fin_entity__to, amount, curr_code, exch_rate, confirmed, acct_code__ifr,"
+" cctr_code__ifr, acct_code__ito, cctr_code__ito, chg_date, chg_user, chg_term, amount__bc, "
+" tran_type, tran_ser, link_type, remarks) " //23
+" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ibcaID);
pstmt.setTimestamp(2, tranDate);
pstmt.setTimestamp(3, tranDate);
pstmt.setString(4, siteCodeRcv);
pstmt.setString(5, finEntityFrom);
pstmt.setString(6, siteCode);
pstmt.setString(7, finEntityTo);
pstmt.setDouble(8, amount);
pstmt.setString(9, currCode);
pstmt.setDouble(10, exchRate);
pstmt.setString(11, "N");
pstmt.setString(12, acctCodePay);
pstmt.setString(13, cctrCodePay);
pstmt.setString(14, acctCodeRcp);
pstmt.setString(15, cctrCodeRcp);
pstmt.setTimestamp(16, tranDate);
pstmt.setString(17, chgUser);
pstmt.setString(18, chgTerm);
pstmt.setDouble(19, amountBc);
pstmt.setString(20, tranType);
System.out.println("rcp_ibca tran_ser inside ibca--->"+tranSerRcb);
pstmt.setString(21,"I");
pstmt.setString(22, linkType);
pstmt.setString(23, remarks);
pstmt.executeUpdate();
pstmt.close();//added by Pavan R 10oct18[to handle open cursor issue]
pstmt = null;
sql = " insert into rcp_ibca_det (tran_id, ref_ser, ref_no, ref_date, curr_code, exch_rate, "
+" cust_code, acct_code, cctr_code, due_date, tot_amt, discount,tax_amt, bank_code, "
+" ref_type, auto_rcp, sales_pers, item_ser, sales_pers__1, sales_pers__2, cr_term, "
+" recd, ref_ser__org, line_no__ref, cust_ref_no, cust_ref_date, cust_ref_amt, gp_no, gp_date,discount_dt) " //30
+" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ibcaID);
pstmt.setString(2, tranSerRcb);
pstmt.setString(3, invoiceID);
pstmt.setTimestamp(4, refDate);
pstmt.setString(5, currCode);
pstmt.setDouble(6, exchRate);
pstmt.setString(7, custCode);
pstmt.setString(8, acctCode);
pstmt.setString(9, cctrCode);
pstmt.setTimestamp(10, dueDate);
pstmt.setDouble(11, amount);
pstmt.setDouble(12, discount);
pstmt.setDouble(13, taxAmount);
pstmt.setString(14, bankCode);
pstmt.setString(15, refType);
pstmt.setString(16, autoRcp);
pstmt.setString(17, salesPers);
pstmt.setString(18, itemSer);
pstmt.setString(19, salesPers1);
pstmt.setString(20, salesPers2);
pstmt.setString(21, crTerm);
pstmt.setString(22, recd);
System.out.println("rcp_ibcadet tran_ser inside ibca--->"+tranSerRcb);
pstmt.setString(23, tranSerRcb);
pstmt.setString(24, "1");
pstmt.setString(25, custRefNo);
pstmt.setTimestamp(26, custRefDate);
pstmt.setDouble(27, custRefAmount);
pstmt.setString(28, gpNo);
pstmt.setTimestamp(29, gpDate);
pstmt.setTimestamp(30, discountDate);
pstmt.executeUpdate();
pstmt.close();//Changed by Pavan R 10oct18[to handle open cursor issue]
pstmt = null;
RcvIbcaConf ibcaObj = new RcvIbcaConf();
// retString = ibcaObj.retreiveRibca (ibcaID, siteCode, xtraParams,conn);
retString = ibcaObj.retreiveRibca (ibcaID, siteCodeRcv, xtraParams,conn);
if(retString != null && retString.trim().length() > 0)
{
return retString;
}
}//
*/ }
/* sql = "select tot_amt, adj_amt,status from receivables where tran_ser ='R-IBCA' and ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,invoiceID);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Inside createRIBCA----->rs.Next()");
totAMtIBCA = rs.getDouble("tot_amt");
adjamountIBCA = rs.getDouble("adj_amt");
statusIBCA=rs.getString("status");
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
if("U".equals(statusIBCA))
{
sql="update receivables set adj_amt = ? where tran_ser ='R-IBCA' and ref_no = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setDouble(1,adjamount);
pstmt1.setString(2,invoiceID);
cnt=pstmt1.executeUpdate();
pstmt1.close();
pstmt1=null;
if(cnt <=0)
{
return retString;
}
}
System.out.println("Inside createRIBCA----->amountBc--["+cnt+"]");
}*/
}
}//end
//end monika 25 nov 2019
//ADDED BY MONIKA 0N 12 DEC 19 TO GET TRAN_TYOPE FROM FUNCTION
sretFullRetType = checkNullAndTrim(distComm.getDisparams("999999","SRET_FULL_TRANTYPE",conn));
if(sretFullRetType != null || sretFullRetType.trim().length()> 0)
{
sretFullRetType=sretFullRetType;
}
else
{
sretFullRetType="IC";
}
//System.out.println("sretFullRetType["+sretFullRetType+"]");
//END
confirmed = "";
sql = " SELECT H.CONFIRMED FROM RECEIPT H,RCPDET D WHERE H.TRAN_ID = D.TRAN_ID AND D.REF_NO = ? AND D.REF_SER = ?";
// sql = " SELECT H.CONFIRMED FROM RECEIPT H,RCPDET D WHERE H.TRAN_ID = D.TRAN_ID AND D.REF_NO = ? AND D.REF_SER = ?";
sql = "select status,adj_amt from receivables where ref_no= ? and tran_ser in('R-IBCA','S-INV') and adj_amt=0";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
pstmt.setString(2, "S-INV");
// pstmt.setString(2, "R-IBCA");
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = checkNullAndTrim(rs.getString("CONFIRMED"));
status = checkNullAndTrim(rs.getString("status"));
adjAmt=rs.getDouble("adj_amt");
}
if(pstmt != null)
{
......@@ -142,16 +576,17 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
if("Y".equalsIgnoreCase(confirmed))
//System.out.println("receivables invoice cancel ADJamt["+adjAmt+"] status["+status+"TRAN SER ");
if(adjAmt!=0)
{
retString = itmDBAccessEJB.getErrorString("","VTINVCCONF","","",conn);
//retString = itmDBAccessEJB.getErrorString("","VTINVCCONF","","",conn);
retString = itmDBAccessEJB.getErrorString("","VTINVCADJ","","",conn);
return retString;
}
else
{
orderDate = getCurrdateAppFormat();
retString = undoRecAdjustment(invoiceID, xtraParams,forcedFlag, conn);
sql = "Select item_ser,cust_code from invoice where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
......@@ -164,7 +599,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
pstmt.close();pstmt=null;
rs.close();rs=null;
StringBuffer xmlString = new StringBuffer();
StringBuffer xmlStringDet = new StringBuffer();
StringBuffer xmlStringHdr= new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
......@@ -172,51 +607,52 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
xmlStringHdr.append("<Header0>");
xmlStringHdr.append("<description>Header0 members</description>");
xmlStringHdr.append("<objName><![CDATA[").append("salesreturn_retn").append("]]></objName>");
xmlStringHdr.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlStringHdr.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlStringHdr.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlStringHdr.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlStringHdr.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlStringHdr.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlStringHdr.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlStringHdr.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlStringHdr.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlStringHdr.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlStringHdr.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlStringHdr.append("<Detail1 dbID='' domID=\"1\" objName=\"salesreturn_retn\" objContext=\"1\">");
xmlStringHdr.append("<attribute pkNames=\"tran_id:\" status=\"N\" updateFlag=\"A\" selected=\"N\" />");
xmlStringHdr.append("<tran_id><![CDATA[]]></tran_id>");
xmlStringHdr.append("<tran_date><![CDATA[").append(orderDate).append("]]></tran_date>");
xmlStringHdr.append("<tran_type><![CDATA[").append("FOR").append("]]></tran_type>");
xmlStringHdr.append("<invoice_id><![CDATA[").append(invoiceID).append("]]></invoice_id>");
xmlStringHdr.append("<item_ser><![CDATA[").append(itemSer).append("]]></item_ser>");
xmlStringHdr.append("<cust_code><![CDATA[").append(custCode).append("]]></cust_code>");
xmlStringHdr.append("<cust_ref><![CDATA[").append("TEST").append("]]></cust_ref>");
xmlStringHdr.append("<site_code><![CDATA[").append(loginSiteCode).append("]]></site_code>");
xmlStringHdr.append("<full_ret><![CDATA[").append("Y").append("]]></full_ret>");
xmlStringHdr.append("<udf_str1><![CDATA[").append("MIN_RATE_HIST_NO").append("]]></udf_str1>");
xmlStringHdr.append("</Detail1>");
String lineNoOrd = "",refSer = "",itemCode = "",quantity = "",lineNoInvoice = "";
int domID = 0;
//sql = " SELECT D.LINE_NO,D.ITEM_CODE,D.QUANTITY FROM INVOICE H,INVOICE_TRACE D WHERE H.INVOICE_ID = D.INVOICE_ID AND H.INVOICE_ID = ? ";
sql ="SELECT INV_LINE_NO, LOT_NO, LOT_SL, QUANTITY, ITEM_CODE, RATE, "+
" RATE__STDUOM, DISCOUNT, "+
" DESP_ID, DESP_LINE_NO, LINE_NO "+ //Added on 08/06/06 as code changes in PB
" FROM INVOICE_TRACE WHERE INVOICE_ID = ? ";
xmlStringHdr.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlStringHdr.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlStringHdr.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlStringHdr.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlStringHdr.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlStringHdr.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlStringHdr.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlStringHdr.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlStringHdr.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlStringHdr.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlStringHdr.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlStringHdr.append("<Detail1 dbID='' domID=\"1\" objName=\"salesreturn_retn\" objContext=\"1\">");
xmlStringHdr.append("<attribute pkNames=\"tran_id:\" status=\"N\" updateFlag=\"A\" selected=\"N\" />");
xmlStringHdr.append("<tran_id><![CDATA[]]></tran_id>");
xmlStringHdr.append("<tran_date><![CDATA[").append(orderDate).append("]]></tran_date>");
// xmlStringHdr.append("<tran_type><![CDATA[").append("FOR").append("]]></tran_type>");//commented by monika 12 dec 19
xmlStringHdr.append("<tran_type><![CDATA[").append(sretFullRetType).append("]]></tran_type>");
xmlStringHdr.append("<invoice_id><![CDATA[").append(invoiceID).append("]]></invoice_id>");
xmlStringHdr.append("<item_ser><![CDATA[").append(itemSer).append("]]></item_ser>");
xmlStringHdr.append("<cust_code><![CDATA[").append(custCode).append("]]></cust_code>");
xmlStringHdr.append("<cust_ref><![CDATA[").append("TEST").append("]]></cust_ref>");
xmlStringHdr.append("<site_code><![CDATA[").append(loginSiteCode).append("]]></site_code>");
xmlStringHdr.append("<full_ret><![CDATA[").append("Y").append("]]></full_ret>");
xmlStringHdr.append("<udf_str1><![CDATA[").append("MIN_RATE_HIST_NO").append("]]></udf_str1>");
xmlStringHdr.append("</Detail1>");
String lineNoOrd = "",refSer = "",itemCode = "",quantity = "",lineNoInvoice = "";
int domID = 0;
//sql = " SELECT D.LINE_NO,D.ITEM_CODE,D.QUANTITY FROM INVOICE H,INVOICE_TRACE D WHERE H.INVOICE_ID = D.INVOICE_ID AND H.INVOICE_ID = ? ";
sql ="SELECT INV_LINE_NO, LOT_NO, LOT_SL, QUANTITY, ITEM_CODE, RATE, "+
" RATE__STDUOM, DISCOUNT, "+
" DESP_ID, DESP_LINE_NO, LINE_NO "+ //Added on 08/06/06 as code changes in PB
" FROM INVOICE_TRACE WHERE INVOICE_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs = pstmt.executeQuery();
while(rs.next())
{
domID++;
lineNoInvoice = rs.getString("INV_LINE_NO");
itemCode = checkNullAndTrim(rs.getString("ITEM_CODE"));
quantity = checkNullAndTrim(rs.getString("QUANTITY"));
......@@ -225,24 +661,24 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
lotSl = rs.getString("LOT_SL");
despID = rs.getString("DESP_ID");
despLineNo = rs.getString("DESP_LINE_NO");
String sql1 = "SELECT LOC_CODE FROM DESPATCHDET WHERE DESP_ID = '"+despID+"' AND LTRIM(RTRIM(LINE_NO)) = LTRIM(RTRIM('"+despLineNo+"'))";
pstmt1 = conn.prepareStatement(sql1);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
locCode = rs1.getString("LOC_CODE");
}
pstmt1.close();pstmt1=null;
rs1.close();rs1=null;
xmlStringDet.append("<Detail2 dbID=':' domID='"+ domID +"' objName='salesreturn_retn' objContext='2'>");
xmlStringDet.append("<Detail2 dbID=':' domID='"+ domID +"' objName='salesreturn_retn' objContext='2'>");
xmlStringDet.append("<attribute pkNames='tran_id:line_no:' status='N' updateFlag='A' selected='N'/>");
lineNoOrd = " " + domID;
lineNoOrd = lineNoOrd.substring( lineNoOrd.length()-3 );
xmlStringDet.append("<tran_id><![CDATA[]]></tran_id>");
xmlStringDet.append("<line_no><![CDATA[").append(lineNoOrd).append("]]></line_no>");
xmlStringDet.append("<invoice_id><![CDATA[").append(invoiceID).append("]]></invoice_id>");
......@@ -255,10 +691,10 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
xmlStringDet.append("<lot_sl>").append("<![CDATA[").append(lotSl).append("]]>").append("</lot_sl>\r\n");
xmlStringDet.append("<loc_code>").append("<![CDATA[").append(locCode).append("]]>").append("</loc_code>\r\n");
xmlStringDet.append("<ret_rep_flag><![CDATA[").append("R").append("]]></ret_rep_flag>");
xmlStringDet.append("</Detail2>");
}
if(pstmt != null)
{
......@@ -268,15 +704,15 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
xmlString.append(xmlStringHdr);
xmlString.append(xmlStringDet);
xmlString.append("</Header0></group0></DocumentRoot>");
System.out.println("@@xmlString For generation Sales Return:: "+xmlString.toString());
/* masterStatefulLocal = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
//System.out.println("@@xmlString For generation Sales Return:: "+xmlString.toString());
/* masterStatefulLocal = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
if(xtraParams == null)
{
xtraParams = getXtraParams(userId,loginSiteCode,userId,conn);
......@@ -284,29 +720,152 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
userInfo = getUserInfo(xtraParams);
retString = masterStatefulLocal.processRequest(userInfo, xmlString.toString(), true, conn);*/
retString = saveData(xtraParams,loginSiteCode,xmlString.toString(),conn);
System.out.println("@@Sales Return return string"+retString);
if ( retString.indexOf("Success") > -1 && retString.indexOf("<TranID>") > 0 )
retString = saveData(xtraParams,loginSiteCode,xmlString.toString(),conn);
//System.out.println("@@Sales Return return string"+retString);
if ( retString.indexOf("Success") > -1 && retString.indexOf("<TranID>") > 0 )
{
String tranIDSreturn = retString.substring( retString.indexOf("<TranID>")+8, retString.indexOf("</TranID>"));
System.out.println("Sales Return Created :"+tranIDSreturn);
String tranIDSreturn = retString.substring( retString.indexOf("<TranID>")+8, retString.indexOf("</TranID>"));
//System.out.println("Sales Return Created :"+tranIDSreturn);
SalesReturnConfirm confObj = new SalesReturnConfirm();
retString = confObj.confirm(tranIDSreturn,xtraParams,forcedFlag,conn);
//added to adjust amount in receivables:/invoiceID
double totalAmount=0.0,totAdjAmount,amounthdr=0.0;
sql = "select tran_id__crn,net_amt from sreturn where tran_id=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIDSreturn);
rs = pstmt.executeQuery();
if(rs.next())
{
tranidCrn = rs.getString("tran_id__crn");
amounthdr=rs.getDouble("net_amt");
}
if(pstmt != null)
{
pstmt.close();pstmt=null;
}
if(rs != null)
{
rs.close();rs=null;
}
//System.out.println("tran_id crn ["+retString+"]");
// System.out.println("@@@1@@@update r-ibca1 "+amounthdr+"total adj "+totAdjAmount+ "ref_ser-"+refSer+" ref_no "+refNo);
sql = " select adj_amt, tot_amt from receivables where tran_ser = ? and ref_no = ? ";//for sreturn adj
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"R-IBCA");
pstmt.setString(2,tranidCrn);
rs = pstmt.executeQuery();
if(rs.next())
{
adjAmt = rs.getDouble("adj_amt");
totalAmount = rs.getDouble("tot_amt");
}
if(rs!=null)
{
rs.close();rs = null;
}
if(pstmt!=null)
{
pstmt.close();pstmt = null;
}
//System.out.println("@@@1@@@update crdrrcp "+adjAmt+"total adj "+totalAmount+ "ref_ser-"+refSer+" ref_no "+tranidCrn);
//added by monika to update status an adjamt in single query
/*totAdjAmount = adjAmt+amounthdr;
System.out.println("@@@2@@@@{totAdjAmount"+totAdjAmount+" ");
if((totalAmount-totAdjAmount)==0)
{
status = "A";
}
else
{
status = "P";
}*/
sql="update receivables set adj_amt = (case when adj_amt is null then 0 else adj_amt end + ? ),status=? where tran_ser = ? and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1,amount);//commented byb monika 19 dec 2019
pstmt.setDouble(1,totalAmount);//added to adjust amount in receivables 19 dec 2019
pstmt.setString(2,"A");
pstmt.setString(3,"R-IBCA");
pstmt.setString(4,tranidCrn);
pstmt.executeUpdate();
//System.out.println("@@@2@@@@ IF...");
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
//for invoice adj amt---
sql = " select adj_amt,tot_amt from receivables where tran_ser = ? and ref_no = ? ";//for sreturn adj
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,"R-IBCA");
pstmt.setString(2,invoiceID);
rs = pstmt.executeQuery();
if(rs.next())
{
adjAmt = rs.getDouble("adj_amt");
totalAmount = rs.getDouble("tot_amt");
}
if(rs!=null)
{
rs.close();rs = null;
}
if(pstmt!=null)
{
pstmt.close();pstmt = null;
}
//System.out.println("@@@1@@@update crdrrcp "+adjAmt+"total adj "+totalAmount+ "ref_ser-"+refSer+" ref_no "+tranidCrn);
//added by monika to update status an adjamt in single query
/*totAdjAmount = adjAmt+amounthdr;
System.out.println("@@@2@@@@{totAdjAmount"+totAdjAmount+" ");
if((totalAmount-totAdjAmount)==0)
{
status = "A";
}
else
{
status = "P";
}*/
sql="update receivables set adj_amt = (case when adj_amt is null then 0 else adj_amt end + ? ),status=? where tran_ser = ? and ref_no = ? ";
pstmt = conn.prepareStatement(sql);
// pstmt.setDouble(1,amount);//commented byb monika 19 dec 2019
pstmt.setDouble(1,totalAmount);//added to adjust amount in receivables 19 dec 2019
pstmt.setString(2,"A");
pstmt.setString(3,"R-IBCA");
pstmt.setString(4,invoiceID);
pstmt.executeUpdate();
//System.out.println("@@@2@@@@ IF...");
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
System.out.println("After confirming sales return ["+retString+"]");
if ( retString.indexOf("VTSRTRNCMP") > -1 || retString.indexOf("VTCICONF3") > -1)
//end
//System.out.println("After confirming sales return ["+retString+"]");
if (retString.indexOf("VTSRTRNCMP") > -1 || retString.indexOf("VTCICONF3") > -1)
{
System.out.println("Sales return confirm successfully");
//System.out.println("Sales return confirm successfully");
cnt = 0;
sql = " select tran_ser, (case when tot_amt is null then 0 else tot_amt end) as tot_amt ,(case when adj_amt is null then 0 else adj_amt end) as adj_amt "
+ " from receivables where ref_no = ? and tran_ser = 'S-INV' ";
+ " from receivables where ref_no = ? and tran_ser = 'S-INV' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
rs = pstmt.executeQuery();
......@@ -316,11 +875,11 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
refSer = rs.getString("tran_ser");
totAmt = rs.getDouble("tot_amt");
adjAmt = rs.getDouble("adj_amt");
System.out.println("@@TotAmt["+rs.getDouble("tot_amt")+"] @@AdjAmt["+rs.getDouble("adj_amt")+"] refSer["+refSer+"]");
//System.out.println("@@TotAmt["+rs.getDouble("tot_amt")+"] @@AdjAmt["+rs.getDouble("adj_amt")+"] refSer["+refSer+"]");
refBalAmount = totAmt - adjAmt;
sql = " insert into sreturn_inv (tran_id,line_no,ref_ser,ref_no,ref_bal_amt,adj_amt) values (?,?,?,?,?,?) ";
pstmtInsert = conn.prepareStatement(sql);
pstmtInsert.setString(1, tranIDSreturn);
......@@ -339,17 +898,17 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
pstmt.close();pstmt = null;
}
sql="Update invoice set status = 'X' where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
int updStatus=pstmt.executeUpdate();
if(updStatus>0)
{
}
retString = itmDBAccessEJB.getErrorString("","VTINVCNC","","",conn);
}
else
{
......@@ -357,12 +916,12 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
return retString;
}
}
else
{
isError=true;
return retString;
}
else
{
isError=true;
return retString;
}
}
}
catch(Exception e)
......@@ -377,7 +936,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
try
{
System.out.println("Inside Finally invoiceCancel isError="+isError);
if(isError)
{
System.out.println("Rollbacking Cancle Invoice.......");
......@@ -413,7 +972,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return retString;
}
public String undoRecAdjustment(String invoiceID, String xtraParams, String forcedFlag, Connection conn) throws RemoteException, ITMException
{
String retString = "",sql = "",custCode = "",tranDate = "",tranID = "";
......@@ -422,10 +981,10 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
ResultSet rs = null;
int cnt = 0;
Timestamp today = null;
try
{
sql=" select count(1) from receivables_adj where ref_no_adj= ? and ref_ser_adj= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
......@@ -443,18 +1002,18 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
System.out.println("receivables_adj-->Count ["+cnt+"]");
//System.out.println("receivables_adj-->Count ["+cnt+"]");
if(cnt > 0)
{
AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
today = getCurrtDate();
tranDate = getCurrdateAppFormat();
sql = " SELECT CUST_CODE FROM INVOICE WHERE INVOICE_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
......@@ -471,12 +1030,12 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
tranID = commonWmsUtility.generateTranTd("w_undo_rec_adj", tranDate, loginSiteCode, conn);
sql = " INSERT INTO UNDO_REC_ADJ (TRAN_ID,TRAN_DATE,SITE_CODE,CUST_CODE,REF_NO,EMP_CODE__APRV,CONFIRMED,CONF_DATE,ADD_DATE,ADD_USER," //10
+" ADD_TERM,CHG_DATE,CHG_USER,CHG_TERM,REMARKS,TRAN_TYPE) " //16
+" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+" ADD_TERM,CHG_DATE,CHG_USER,CHG_TERM,REMARKS,TRAN_TYPE) " //16
+" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranID);
pstmt.setTimestamp(2, today);
......@@ -494,17 +1053,17 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
pstmt.setString(14, chgTerm);
pstmt.setString(15, "");
pstmt.setString(16, "S-INV");
int result = pstmt.executeUpdate();
System.out.println("Header result="+result);
//System.out.println("Header result="+result);
UndoRecievableAdjConf undoRcvAdjCnf = null;
undoRcvAdjCnf = new UndoRecievableAdjConf();
retString = undoRcvAdjCnf.confirm(tranID, xtraParams,forcedFlag,conn);
System.out.println("Return String confirm UndoRecievableAdjConf ["+retString+"]");
//System.out.println("Return String confirm UndoRecievableAdjConf ["+retString+"]");
if (retString.indexOf("VTCNFSUCC") > -1)
{
System.out.println("Successfully reverted Receivable Adjustment");
......@@ -537,7 +1096,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
try
{
System.out.println("Inside Finally undoRecAdjustment isError="+isError);
if(pstmt != null)
{
pstmt.close();pstmt=null;
......@@ -554,30 +1113,30 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return retString;
}
/*public String createSalesReturn(String invoiceID, String xtraParams,Connection conn) throws RemoteException, ITMException
{
String retString = "",sql = "";
boolean isError = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
String confirmed = "",userInfo = "",userId = "",loginSiteCode = "",orderDate = "";
try
{
System.out.println("Inside createSalesReturn \n tranId["+invoiceID+"] \n xtraParams["+xtraParams+"] \n");
AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
orderDate = getCurrdateAppFormat();
StringBuffer xmlString = new StringBuffer();
StringBuffer xmlStringDet = new StringBuffer();
StringBuffer xmlStringHdr= new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
......@@ -596,22 +1155,22 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
xmlStringHdr.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlStringHdr.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlStringHdr.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlStringHdr.append("<Detail1 dbID='' domID=\"1\" objName=\"salesreturn_retn\" objContext=\"1\">");
xmlStringHdr.append("<attribute pkNames=\"tran_id:\" status=\"N\" updateFlag=\"A\" selected=\"N\" />");
xmlStringHdr.append("<tran_id><![CDATA[]]></tran_id>");
xmlStringHdr.append("<tran_date><![CDATA[").append(orderDate).append("]]></tran_date>");
xmlStringHdr.append("<tran_type><![CDATA[").append("FOR").append("]]></tran_type>");
xmlStringHdr.append("<invoice_id><![CDATA[").append(invoiceID).append("]]></invoice_id>");
xmlStringHdr.append("<site_code><![CDATA[").append(loginSiteCode).append("]]></site_code>");
xmlStringHdr.append("<full_ret><![CDATA[").append("Y").append("]]></full_ret>");
xmlStringHdr.append("</Detail1>");
String lineNoOrd = "",refSer = "",itemCode = "",quantity = "",lineNoInvoice = "";
int domID = 0;
sql = " SELECT D.LINE_NO,D.ITEM_CODE,D.QUANTITY FROM INVOICE H,INVOICE_TRACE D WHERE H.INVOICE_ID = D.INVOICE_ID AND H.INVOICE_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceID);
......@@ -619,26 +1178,26 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
while(rs.next())
{
domID++;
lineNoInvoice = rs.getString("LINE_NO");
itemCode = checkNullAndTrim(rs.getString("ITEM_CODE"));
quantity = checkNullAndTrim(rs.getString("QUANTITY"));
xmlStringDet.append("<Detail2 dbID=':' domID='"+ domID +"' objName='salesreturn_retn' objContext='2'>");
xmlStringDet.append("<attribute pkNames='tran_id:line_no:' status='N' updateFlag='A' selected='N'/>");
lineNoOrd = " " + domID;
lineNoOrd = lineNoOrd.substring( lineNoOrd.length()-3 );
xmlStringDet.append("<tran_id><![CDATA[]]></tran_id>");
xmlStringDet.append("<line_no><![CDATA[").append(lineNoOrd).append("]]></line_no>");
xmlStringDet.append("<invoice_id><![CDATA[").append(invoiceID).append("]]></invoice_id>");
xmlStringDet.append("<line_no__invtrace><![CDATA[").append(lineNoInvoice).append("]]></line_no__invtrace>");
xmlStringDet.append("<item_code><![CDATA[").append(itemCode).append("]]></item_code>");
xmlStringDet.append("<quantity><![CDATA[").append(quantity).append("]]></quantity>");
xmlStringDet.append("</Detail2>");
}
if(pstmt != null)
{
......@@ -648,14 +1207,14 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
{
rs.close();rs=null;
}
xmlString.append(xmlStringHdr);
xmlString.append(xmlStringDet);
xmlString.append("</Header0></group0></DocumentRoot>");
System.out.println("@@xmlString For generation Sales Return:: "+xmlString.toString());
masterStatefulLocal = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
if(xtraParams == null)
{
xtraParams = getXtraParams(userId,loginSiteCode,userId,conn);
......@@ -663,14 +1222,14 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
userInfo = getUserInfo(xtraParams);
retString = masterStatefulLocal.processRequest(userInfo, xmlString.toString(), true, conn);
System.out.println("@@Sales Return return string"+retString);
if ( retString.indexOf("Success") > -1 && retString.indexOf("<TranID>") > 0 )
{
String tranIDSreturn = retString.substring( retString.indexOf("<TranID>")+8, retString.indexOf("</TranID>"));
System.out.println("Sales Return Created :"+tranIDSreturn);
retString = itmDBAccessEJB.getErrorString("","VTSRTRNCMP","","",conn);
}
else
......@@ -689,7 +1248,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
try
{
System.out.println("Inside Finally createSalesReturn isError="+isError);
if(pstmt != null)
{
pstmt.close();pstmt=null;
......@@ -706,7 +1265,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return retString;
}*/
public String getUserInfo( String xtraParams )throws ITMException
{
StringBuffer userInfoStr = new StringBuffer();
......@@ -716,7 +1275,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
String entityCode = "";
String profileId = "";
String userType = "";
String chgTerm = "";
try
{
......@@ -727,10 +1286,10 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
entityCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"entityCode");
profileId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"profileId");
userType = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userType");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgTerm");
System.out.println("xtraParams is @@@@@ " + xtraParams);
//System.out.println("xtraParams is @@@@@ " + xtraParams);
userInfoStr.append("<UserInfo>");
userInfoStr.append("<loginCode>").append("<![CDATA["+userId+"]]>").append("</loginCode>\r\n");
......@@ -739,7 +1298,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
userInfoStr.append("<entityCode>").append("<![CDATA["+entityCode+"]]>").append("</entityCode>\r\n");
userInfoStr.append("<profileId>").append("<![CDATA["+profileId+"]]>").append("</profileId>\r\n");
userInfoStr.append("<userType>").append("<![CDATA["+userType+"]]>").append("</userType>\r\n");
userInfoStr.append("<remoteHost>").append("<![CDATA["+chgTerm+"]]>").append("</remoteHost>\r\n");
userInfoStr.append("</UserInfo>");
}
......@@ -749,7 +1308,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return userInfoStr.toString();
}
public String getXtraParams( String loginCode, String siteCode,String empCode,Connection conn)throws Exception
{
String remotehost = "";
......@@ -759,58 +1318,58 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
String userLang = "";
String userCountry = "";
StringBuffer xtraParamsBuff = new StringBuffer();
String sql = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
sql = "SELECT USR_LEV,USER_TYPE,ENTITY_CODE,PROFILE_ID,LOGGER_TYPE,USER_LANG,"+
"USER_COUNTRY,TRANS_DB, USER_THEME FROM USERS WHERE CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginCode);
rs = pstmt.executeQuery();
while(rs.next())
{
entityCode = rs.getString("ENTITY_CODE");
profileId = rs.getString("PROFILE_ID");
userType = rs.getString("USER_TYPE");
userLang = rs.getString("USER_LANG");
userCountry= rs.getString("USER_COUNTRY");
}
remotehost = InetAddress.getLocalHost().getHostAddress();
String XTRA_PARAMS_SEPARATOR = "~~";
xtraParamsBuff.append("loginCode=" + loginCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginEmpCode=" + empCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginSiteCode=" + siteCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("entityCode=" + entityCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("profileId=" + profileId);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("userType=" + userType);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("runMode=I");
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_lang=" + userLang);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_country=" + userCountry);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("charEnc=" + CommonConstants.ENCODING);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("termId="+remotehost);
String chgTerm = remotehost;
if( chgTerm != null && chgTerm.length() > 15 )
{
chgTerm = chgTerm.substring(0, 15);
}
else if( chgTerm == null || chgTerm.length() == 0 )
{
chgTerm = remotehost;
}
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("chgTerm=" + chgTerm );
System.out.println("xtraParamsBuff ["+xtraParamsBuff+"]");
sql = "SELECT USR_LEV,USER_TYPE,ENTITY_CODE,PROFILE_ID,LOGGER_TYPE,USER_LANG,"+
"USER_COUNTRY,TRANS_DB, USER_THEME FROM USERS WHERE CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginCode);
rs = pstmt.executeQuery();
while(rs.next())
{
entityCode = rs.getString("ENTITY_CODE");
profileId = rs.getString("PROFILE_ID");
userType = rs.getString("USER_TYPE");
userLang = rs.getString("USER_LANG");
userCountry= rs.getString("USER_COUNTRY");
}
remotehost = InetAddress.getLocalHost().getHostAddress();
String XTRA_PARAMS_SEPARATOR = "~~";
xtraParamsBuff.append("loginCode=" + loginCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginEmpCode=" + empCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginSiteCode=" + siteCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("entityCode=" + entityCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("profileId=" + profileId);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("userType=" + userType);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("runMode=I");
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_lang=" + userLang);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_country=" + userCountry);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("charEnc=" + CommonConstants.ENCODING);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("termId="+remotehost);
String chgTerm = remotehost;
if( chgTerm != null && chgTerm.length() > 15 )
{
chgTerm = chgTerm.substring(0, 15);
}
else if( chgTerm == null || chgTerm.length() == 0 )
{
chgTerm = remotehost;
}
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("chgTerm=" + chgTerm );
System.out.println("xtraParamsBuff ["+xtraParamsBuff+"]");
}
catch(Exception e)
{
......@@ -838,7 +1397,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return xtraParamsBuff.toString();
}
private static String checkNullAndTrim(String input)
{
if (input==null)
......@@ -847,7 +1406,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return input.trim();
}
private java.sql.Timestamp getCurrtDate() throws RemoteException,ITMException
{
String currAppdate = "";
......@@ -867,7 +1426,7 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return (currDate);
}
private String getCurrdateAppFormat()
{
String s = "";
......@@ -897,33 +1456,33 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
MasterStatefulLocal masterStateful = null; // for ejb3
E12GenericUtility genericUtility=new E12GenericUtility();
ibase.utility.UserInfoBean userInfoBean=new UserInfoBean();
try
{
//Added By PriyankaC on 15/03/2018. [START]
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("userId" + userId + "]");
//System.out.println("userId" + userId + "]");
//Added By PriyankaC on 15/03/2018. [END]
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
//System.out.println("-----------masterStateful------- " + masterStateful);
String[] authencate = new String[2];
//authencate[0] = "";
authencate[0] = userId; //Changed By PriynkaC on 15/03/2018
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
//System.out.println("xmlString to masterstateful [" + xmlString + "]");
userInfoBean.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
userInfoBean.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
userInfoBean.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
userInfoBean.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
userInfoBean.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
} catch (ITMException itme)
{
System.out.println("ITMException :CreateDistOrder :saveData :==>");
......@@ -936,4 +1495,4 @@ public class InvoiceCancelEJB extends ActionHandlerEJB implements InvoiceCancelE
}
return retString;
}
}
}
\ 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