Commit 1802b860 authored by arawankar's avatar arawankar

UpDated code of asset sales confirm


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187311 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0cf1268e
......@@ -48,7 +48,7 @@ public class AssetSalesConf extends ActionHandlerEJB implements
AssetSalesConfLocal,AssetSalesConfRemote
{
// GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
......@@ -113,7 +113,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
//Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start
java.sql.Timestamp salesTranDate = null;
String salesAcPeriod = "", sqlTemp1 = "", salesPeriod = "" ;//Added salesPeriod on 02JUL18
int detRowNo = 0;
int detRowNo = 0, lineNoInt = 0;
ResultSet rsTemp1 = null;
PreparedStatement pstmtTemp1 = null;
//Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start
......@@ -160,6 +160,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
acctCdLoss = rs.getString(9) == null ? "":rs.getString(9);
cctrCdLoss = rs.getString(10) == null ? "":rs.getString(10);
lineNo = rs.getString(11) == null ? "":rs.getString(11);
lineNoInt = rs.getInt(11); // Modified by Piyush on 05/07/2018
//Added by sarita to get tax_amt on 06 JUN 2018
taxAmt = rs.getDouble(12);
......@@ -784,7 +785,11 @@ AssetSalesConfLocal,AssetSalesConfRemote
//sql = "select code from period where fr_date = (select fr_date from period where code = (select acct_prd from period where '"+currAppdate+"' between fr_date and to_date))";
//changes by sarita on 03 JUL 2018 as getting account period not defined in period masted [START]
//sql4 = "select code from period where fr_date = (select fr_date from period where code = (select acct_prd from period where ? between fr_date and to_date))";
sql4 = "select code from period where fr_date = (select fr_date from period where code = (select code from period where ? between fr_date and to_date))";
// Modified by Piyush on 03/07/2018 [To correct same as PB Code].Start
//sql4 = "select code from period where fr_date = (select fr_date from period where code = (select code from period where ? between fr_date and to_date))";
sql4 = "select code from period where fr_date = (select fr_date from acctprd where code = (select acct_prd from period where ? between fr_date and to_date))";
// Modified by Piyush on 03/07/2018 [To correct same as PB Code].End
//changes by sarita on 03 JUL 2018 as getting account period not defined in period masted [END]
pstmt4=conn.prepareStatement(sql4);
//Added by sarita on 06 JUN 2018
......@@ -1086,10 +1091,19 @@ AssetSalesConfLocal,AssetSalesConfRemote
} while (true);
System.out.println("loop exit>>cnt val"+cnt);
// Modified by Piyush on 03/07/2018 [To make compitable with PB Asset sales Single Posting].Start
/*
modVat = ((totval * 2.5) / 100) * cnt;
System.out.println("((totval * 2.5) / 100) * cnt = "+ modVat);
modVat = totval - modVat;
System.out.println("totval - modVat = "+ modVat);
*/
modVat = ((exciseAmt * 2.5) / 100) * cnt;
System.out.println("((exciseAmt * 2.5) / 100) * cnt = "+ modVat);
modVat = exciseAmt - modVat;
System.out.println("exciseAmt - modVat = "+ modVat);
// Modified by Piyush on 03/07/2018 [To make compitable with PB Asset sales Single Posting].End
sql11 = "select rtrim(var_value) from finparm where prd_code = ? and var_name = ?";
......@@ -1138,11 +1152,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
}
}
proLoss = (saleAmt + depramt + depramtrevl) - (totval + modVat + taxAmt);
// Modified by Anjali on 05/07/2018 [Tax Amount should not be consider for calculation of Profit/Loss should]
// proLoss = (saleAmt + depramt + depramtrevl) - (totval + modVat + taxAmt);
proLoss = (saleAmt + depramt + depramtrevl) - (totval + modVat);
System.out.println("(saleAmt + depramt + depramtrevl) - (totval + modVat + taxAmt) = "+proLoss);
if(proLoss > 0)
//if(proLoss > 0) // Modified by Piyush on 03/07/2018
if(proLoss > 0d)
{
if(acctCdPl != null && acctCdPl.trim().length() > 0)
{
......@@ -1165,6 +1182,23 @@ AssetSalesConfLocal,AssetSalesConfRemote
cctrCode = acctCctr[1];
}
}
// Modified by Piyush on 03/07/2018 [To make compitable with PB Logic of Asses Sales Single].Start
sql13 = "update asset_sales_det set acct_code__pl = ?, cctr_code__pl = ?, amount_profit = ? , amount_loss = 0 where tran_id = ? and line_no = ?";
pstmt13=conn.prepareStatement(sql13);
pstmt13.setString(1, acctCode);
pstmt13.setString(2, cctrCode);
pstmt13.setDouble(3, proLoss);
pstmt13.setString(4, tranId);
// Modified by Piyush on 05/07/2018
// pstmt13.setInt(5, lineNo);
pstmt13.setInt(5, lineNoInt);
pstmt13.executeUpdate();
if (pstmt13 != null)
{
pstmt13.close();
pstmt13 = null;
}
// Modified by Piyush on 03/07/2018 [To make compitable with PB Logic of Asses Sales Single].End
}
else
{
......@@ -1188,6 +1222,23 @@ AssetSalesConfLocal,AssetSalesConfRemote
cctrCode = acctCctr[1];
}
}
// Modified by Piyush on 03/07/2018 [To make compitable with PB Logic of Asses Sales Single].Start
sql13 = "update asset_sales_det set acct_code__loss = ?, cctr_code__loss = ?, amount_profit = 0 , amount_loss = 0 - ? where tran_id = ? and line_no = ?";
pstmt13=conn.prepareStatement(sql13);
pstmt13.setString(1, acctCode);
pstmt13.setString(2, cctrCode);
pstmt13.setDouble(3, proLoss);
pstmt13.setString(4, tranId);
// Modified by Piyush on 05/07/2018
// pstmt13.setInt(5, lineNo);
pstmt13.setInt(5, lineNoInt);
pstmt13.executeUpdate();
if (pstmt13 != null)
{
pstmt13.close();
pstmt13 = null;
}
// Modified by Piyush on 03/07/2018 [To make compitable with PB Logic of Asses Sales Single].End
}
String errshow = gbfAssetSalePost(tranId, transer, lineNo, conn);
......@@ -1241,15 +1292,50 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt = null;
rs = null;*/
//Commented by sarita on 26 JUN 18 to use if condition to close rs and pstmt[END]
//Modified by Anjali R. [04/06/18][Start]
//Modified by Anjali R. [05/07/18][Start]
if(errString != null && errString.trim().length() > 0 )
{
return errString;
}
//if(proLoss > 0)
//{
/*
if(proLoss > 0)
{
sql= "update asset_sales_hdr set amount_profit = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(proLoss));
pstmt.setString(2, tranId);
pstmt.executeUpdate();
//Added and Commented by sarita on 26 JUN 18 [START]
//pstmt.close();
//pstmt = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added and Commented by sarita on 26 JUN 18 [START]
}
else
{
sql = "update asset_sales_hdr set amount_loss = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(proLoss));
pstmt.setString(2, tranId);
pstmt.executeUpdate();
//Added and Commented by sarita on 26 JUN 18 [START]
//pstmt.close();
//pstmt = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added and Commented by sarita on 26 JUN 18 [START]
}
*/
double profit = 0.0,loss = 0.0;
int updCount = 0;
sql = "select sum(amount_profit) as profit ,sum(amount_loss) as loss from asset_sales_det where tran_id = ?";
......@@ -1272,18 +1358,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt.close();
pstmt = null;
}
//sql = "update asset_sales_hdr set amount_profit = ? where tran_id = ?";
sql = "update asset_sales_hdr set amount_profit = ? ,amount_loss = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(profit));
pstmt.setDouble(2,Math.abs( loss));
pstmt.setString(3, tranId);
//pstmt.executeUpdate();
updCount = pstmt.executeUpdate();
System.out.println(updCount + "Rows updated in asset_sales_hdr table against tran id --["+tranId +"] ");
//Added and Commented by sarita on 26 JUN 18 [START]
/*pstmt.close();
pstmt = null;*/
if(pstmt != null)
{
pstmt.close();
......@@ -1306,26 +1388,8 @@ AssetSalesConfLocal,AssetSalesConfRemote
errString = itmdbAccess.getErrorString("",errCode , "", "", conn);
return errString;
}
//Added and Commented by sarita on 26 JUN 18 [End]
//}
//else
//{
/*sql = "update asset_sales_hdr set amount_loss = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(proLoss));
pstmt.setString(2, tranId);
pstmt.executeUpdate();
//Added and Commented by sarita on 26 JUN 18 [START]
pstmt.close();
pstmt = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}*/
//Added and Commented by sarita on 26 JUN 18 [End]
//}
//Modified by Anjali R. [04/06/18][End]
//Modified by Anjali R. [05/07/18][End]
sql = "update asset_sales_hdr set confirmed = ?,conf_date = ?,emp_code__aprv = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
......@@ -1399,6 +1463,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
}
}
//changes to check errString on 29 JUN 18 [END]
// Modified by Piyush on 03/07/2018[To commit in case of error string is null or blank].Start
else
{
conn.commit();
System.out.println("--transaction commited--");
}
// Modified by Piyush on 03/07/2018[To commit in case of error string is null or blank].End
if (rs != null) {
rs.close();
rs = null;
......@@ -1541,9 +1613,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
return calculatedDate;
}
public String gbfAssetSalePost(String asTranId, String asTranser, String lineNo, Connection conn)
{
public String gbfAssetSalePost(String asTranId, String asTranser, String lineNo, Connection conn){
String lsErrcode = "", lsConfirm = "", lsTranId = "", lsAssetCode = "", lsSiteCode = "", lsFinEntity = "";
String lsCurrCode = "", lsItemSer = "", lsGrpCode = "", lsItemCode = "", lsRemarks = "", lsCustCode = "";
String lsBankCode = "", lsCrTerm = "", lsAcctCode = "", lsCctrCode1 = "", lsCctrCode = "", lsAcctAccCode = "";
......@@ -1597,15 +1667,19 @@ AssetSalesConfLocal,AssetSalesConfRemote
//Modified by Anjali R. on[04/07/2018][Changes made in below query ,total amount will be summation of each line tax amount and amount,
//sale_amt,tax_amt and excreco_amt will be taken from detail table][Start]
/*String sql = "select a.tran_date , a.confirmed, a.total_amt, "+
/*
String sql = "select a.tran_date , a.confirmed, a.total_amt, "+
" a.sale_amt , a.tax_amt , a.cust_code, "+
" (case when a.amount_profit = 0 then 0 - a.amount_loss else a.amount_profit end ), "+
" a.excreco_amt, b.asset_code, b.depr_amt_del, b.acct_code__ar , b.cctr_code__ar , b.deletion_amt, b.depr_amt_delrevl, "+
" b.acct_code__mod, b.cctr_code__mod, b.sale_type, b.deletion_amt_revl, "+
" (case when b.amount_profit = 0 then b.acct_code__loss else b.acct_code__pl end ), "+
" (case when b.amount_profit = 0 then b.cctr_code__loss else b.cctr_code__pl end ) "
+ "from asset_sales_hdr a,asset_sales_det b where a.tran_id = b.tran_id and b.tran_id = ? and b.line_no = ?";*/
String sql = "select a.tran_date , a.confirmed, \n "+
+ "from asset_sales_hdr a,asset_sales_det b where a.tran_id = b.tran_id and b.tran_id = ? and b.line_no = ?";
*/
String sql = "select a.tran_date , a.confirmed, "+
"(case when b.tax_amt is null then 0 else b.tax_amt end + case when b.amount is null then 0 else b.amount end ) as total_amt, "+
"b.sale_amt , b.tax_amt , a.cust_code, "+
" (case when b.amount_profit = 0 then 0 - b.amount_loss else b.amount_profit end ), "+
......@@ -2099,11 +2173,12 @@ AssetSalesConfLocal,AssetSalesConfRemote
return lsErrcode;
}
//Modified by Anjali R. on[04/07/2018][Receivables and tax will insert at header level only][Start]
// Debiting the Customer for Receivables
/* glReceivables = new HashMap();
//Modified by Anjali R. on [05/07/2018][receivables and tax posting will be done at header level only][Start]
/*
glReceivables = new HashMap();
glReceivables.put("tran_ser",asTranser);
......@@ -2137,13 +2212,20 @@ AssetSalesConfLocal,AssetSalesConfRemote
glReceivables.put("cust_ref_amt","");
lsErrcode = finCommon.gbfReceivablesUpd(glReceivables,conn);
if(lsErrcode.trim().length() > 0){
// Modified by Piyush on 03/07/2018
// if(lsErrcode.trim().length() > 0)
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
// Credit Sales Tax A/c
if(lcTaxAmt != 0){
//
//sql = "select acct_code, cctr_code, sum(case when tax_amt is null then 0 else tax_amt end)" +
//" from taxtran where tran_code = ? and tran_id = ? group BY acct_code,cctr_code";
//
sql = "select acct_code, cctr_code, sum(case when tax_amt is null then 0 else tax_amt end)" +
" from taxtran where tran_code = ? and tran_id = ? group BY acct_code,cctr_code";
......@@ -2219,8 +2301,11 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt = null;
}
//Added by sarita on 26 JUN 18 [END]
}*/
//Modified by Anjali R. on[04/07/2018][Receivables and tax will insert at header level only][Start]
}
*/
//Modified by Anjali R. on [05/07/2018][receivables and tax posting will be done at header level only][End]
if(lcDeprAmtRevl2 != 0){
//Get Depr. reserv revalue account code
lsCctrCodeDrrev = finCommon.getAcctDetrTtype(lsItemCode,lsItemSer,"DRREV",lsGrpCode,conn);
......@@ -2332,6 +2417,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
e1.printStackTrace();
}
isError = true;
lsErrcode = "VTFASL0001";
System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace();
//throw new ITMException(e);
......@@ -2344,6 +2430,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
if( conn != null )
{
//Modified by Anjali R. on [04/07/2018][Should not commit in this method. Also should check error code][Start]
/*
if( isError )
{
conn.rollback();
......@@ -2352,6 +2441,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
{
conn.commit();
}
*/
if( isError || (lsErrcode != null && lsErrcode.trim().length() > 0))
{
conn.rollback();
}
//Modified by Anjali R. on [04/07/2018][Should not commit in this method. Also should check error code][End]
}
if(pstmt != null)
{
......@@ -2369,6 +2466,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
System.out.println("Exception : : :==>\n"+e.getMessage());
try
{
lsErrcode = "VTFASL0001";
System.out.println("Before rollback");
conn.rollback();
}
......@@ -2382,778 +2480,757 @@ AssetSalesConfLocal,AssetSalesConfRemote
}
return lsErrcode;
}
//Added by Anjali R. on[04/06/18][Added method to post hdr level data only once][Start]
public String gbfAssetSaleHDRPost(String asTranId, String asTranser , Connection conn)
private String saveData(String siteCode, String xmlString, Connection conn,String xtraParams) throws ITMException
{
String lsTranId = "" , lsBankCode = "", lsCrTerm = "" ,lsErrcode = "" ,lsFinEntity = "", lsCreditPrd = "";
String lsRemarks= "" ,lsCustCode = "" ,lsAcctCodeAr ="",lsCctrCodeAr = "" , lsCurrCode = "" ,
lsAcctCodeTax = "",lsCctrCodeTax = "" ,lsItemSer = "",lsSiteCode ="",lsAssetCode = "";
Timestamp ldTranDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldEffDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldUseDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
ResultSet rs = null;
PreparedStatement pstmt = null;
ResultSet rs2 = null;
PreparedStatement pstmt2 = null;
String sql = "";
double lcTotalAmt = 0, lcSaleAmt = 0,lcTaxAmt = 0 ,lcProfitLoss = 0 ,lcExcrecoAmt = 0 , lcExchRate = 0 ,lnAmountTax = 0;
long llCnt = 0, llCreditPrd = 0;
Calendar calendarInstance = Calendar.getInstance();
Calendar calendarInstance2 = Calendar.getInstance();
HashMap<String, Comparable> glTrace = null;
HashMap glReceivables = null;
boolean isError = false;
System.out.println(siteCode+"enter in save data xtra params in sitecode"+siteCode);
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null;
try
{
lsTranId = asTranId;
sql = "SELECT a.tran_date , a.total_amt, a.sale_amt , a.tax_amt ,\n"
+ " a.cust_code, c.acct_code__ar, c.cctr_code__ar, \n"
+ " a.excreco_amt ,b.asset_code FROM asset_sales_hdr a,customer c ,asset_sales_det b"
+ " WHERE a.cust_code = c.cust_code and b.tran_id = a.tran_id and a.tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,asTranId);
rs = pstmt.executeQuery();
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
if(rs.next())
{
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString :::: " + xmlString);
ldTranDate = rs.getTimestamp(1);
lcTotalAmt = rs.getDouble(2);
lcSaleAmt = rs.getDouble(3);
lcTaxAmt = rs.getDouble(4);
lsCustCode = rs.getString(5);
lsAcctCodeAr = rs.getString(6);
lsCctrCodeAr = rs.getString(7);
lcExcrecoAmt = rs.getDouble(8);
lsAssetCode = rs.getString(9);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
lsRemarks = "On Sale of Asset :- " + asTranId;
ldEffDate = ldTranDate;
ValidatorEJB validatorEJB = new ValidatorEJB();
String userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
// siteCode = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
DBAccessLocal dbAccess = (DBAccessLocal) ctx.lookup("ibase/DBAccessEJB/local");
String[] userInfoArray = dbAccess.getEmpInfo(userId, siteCode);
System.out.println("^^^^^^^ UserInfo ..> " + Arrays.toString(userInfoArray));
UserInfoBean userInfoBean = new UserInfoBean();
userInfoBean.setLoginCode(userId);
userInfoBean.setEmpCode(userInfoArray[0]);
userInfoBean.setEmpName(userInfoArray[1]);
userInfoBean.setReportTo(userInfoArray[2]);
userInfoBean.setDeptCode(userInfoArray[3]);
userInfoBean.setDeptDescr(userInfoArray[4]);
userInfoBean.setSiteCode(siteCode);
userInfoBean.setSiteDescr(userInfoArray[6]);
userInfoBean.setUserLevel(userInfoArray[7]);
userInfoBean.setUserType(userInfoArray[8]);
userInfoBean.setEntityCode(userInfoArray[9]);
userInfoBean.setProfileId(userInfoArray[10]);
userInfoBean.setItemSer(userInfoArray[11]);
userInfoBean.setEmailIdOff(userInfoArray[12]);
userInfoBean.setLoggerType(userInfoArray[13]);
userInfoBean.setStanCode(userInfoArray[14]);
userInfoBean.setDesignation(userInfoArray[15]);
userInfoBean.setDateJoin(userInfoArray[16]);
userInfoBean.setDivision(userInfoArray[17]);
userInfoBean.setUserLanguage(userInfoArray[18]);
userInfoBean.setUserCountry(userInfoArray[19]);
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
retString = masterStateful.processRequest(userInfoBean, xmlString, true, conn);
// Modified by Piyush on 03/07/2018
//sql = "select coalesce(credit_prd,0), bank_code, cr_term from customer where cust_code = ?";
sql = "select coalesce(credit_prd, -99), bank_code, cr_term from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsCustCode);
rs = pstmt.executeQuery();
System.out.println("masterstatefull,dbaccess and ctx will be null here");
//retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
masterStateful = null;
// dbAccess = null;
// ctx = null;
if(rs.next())
{
llCreditPrd = rs.getLong(1);
lsBankCode = rs.getString(2);
lsCrTerm = rs.getString(3);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Modified by Piyush on 03/07/2018
//if(llCreditPrd == 0)
if(llCreditPrd == -99)
{
lsCreditPrd = finCommon.getFinparams("999999","DEF_CR_TERM", conn);
lsCreditPrd = lsCreditPrd == null ? "" : lsCreditPrd.trim();
if("NULLFOUND".equals(lsCreditPrd))
catch(ITMException itme)
{
lsErrcode = "VSENVAR1";
System.out.println("ITMException :PosConfirm :saveData :==>");
throw itme;
}
else
catch(Exception e)
{
llCreditPrd = Integer.parseInt(lsCreditPrd);
System.out.println("Exception :PosConfirm :saveData :==>");
throw new ITMException(e);
}
return retString;
}
// Due Date calculation
calendarInstance.setTime(ldTranDate);
calendarInstance.add(Calendar.DATE, (int) llCreditPrd);
ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
// Taking Original Value,Excise,WDV Amount from Asset Register
sql = "select item_ser, site_code, grp_code, item_code, total_value, excise_amt, wdv_amt_2, depr_amt_2, " +
" use_date, cctr_code, depr_amt_revl_2 from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsAssetCode);
rs = pstmt.executeQuery();
if(rs.next())
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [START]
//public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) throws ITMException
public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String xmlTabString, String finalXmlString, Connection conn) throws ITMException
{
lsItemSer = rs.getString(1).trim();
lsSiteCode = rs.getString(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [END]
String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String compType = "",argName = "",argName1 = ""; //Added by sarita on 14 JUN 18
HashMap<String , String> getArgName = new HashMap<String , String>();
int i = 0;
//System.out.println("confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>>");
// Checking Financial Entity
sql = "select fin_entity from site where site_code = ?";
try
{
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
//Commented by sarita on 19 JUN 18 as methodName will come from table. [START]
//methodName = "gbf_post";
//actionURI = "http://NvoServiceurl.org/" + methodName;
//Commented by sarita on 19 JUN 18 as methodName will come from table. [END]
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsSiteCode);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if(rs.next())
if ( rs.next() )
{
lsFinEntity = rs.getString(1);
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
else
//System.out.println("serviceCode = "+serviceCode+" compName "+compName);
System.out.println("serviceCode = "+serviceCode+" compName "+compName + "compType "+compType);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (rs !=null)
{
lsErrcode = "VTFINENT";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Modified by Piyush on 03/07/2018[Error handling].Start
if (lsErrcode != null && lsErrcode.trim().length() > 0)
rs=null;
}
if (pstmt != null)
{
return lsErrcode;
pstmt.close();
pstmt=null;
}
// Modified by Piyush on 03/07/2018[Error handling].End
// Checking Currency Code
sql = "select curr_code from finent where fin_entity = ?";
// Changed by Manish on 01/04/16 for max cursor issue [end]
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [END]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
sql = "SELECT SERVICE_URI,METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsFinEntity);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if(rs.next())
if ( rs.next() )
{
lsCurrCode = rs.getString(1);
serviceURI = rs.getString("SERVICE_URI");
methodName = rs.getString("METHOD_NAME");
}
else
//System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
System.out.println("serviceURI = "+serviceURI+" compName = "+compName+" methodName ="+methodName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (rs !=null)
{
lsErrcode = "VTCURFIN";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Modified by Piyush on 03/07/2018[Error handling].Start
if (lsErrcode != null && lsErrcode.trim().length() > 0)
rs=null;
}
if (pstmt != null)
{
return lsErrcode;
pstmt.close();
pstmt=null;
}
// Modified by Piyush on 03/07/2018[Error handling].End
// Changed by Manish on 01/04/16 for max cursor issue [end]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [END]
// Checking Exchange Rate
sql = "select std_exrt from currency where curr_code = ?";
//Commented and Added by sarita on 19 JUN 18 to dynamic call [START]
actionURI = "http://NvoServiceurl.org/" + methodName;
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[5];
if("WSR".equalsIgnoreCase(compType))
{
sql = "SELECT ARG_NAME FROM SYSTEM_SERVICE_ARGS WHERE SERVICE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsCurrCode);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if(rs.next())
while ( rs.next() )
{
lcExchRate = rs.getDouble(1);
argName = rs.getString("ARG_NAME"); argName1 = argName.toLowerCase().trim();
if("COMPONENT_TYPE".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compType);
}
else
else if("COMPONENT_NAME".equalsIgnoreCase(argName))
{
lsErrcode = "VTSRET2";
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compName);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Modified by Piyush on 03/07/2018[Error Hndeling].Start
if (lsErrcode != null && lsErrcode.trim().length() > 0)
else if(argName.startsWith("TAB_"))
{
return lsErrcode;
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xmlTabString);
}
// Modified by Piyush on 03/07/2018[Error Hndeling].End
if(lcExchRate == 0)
else if("DUMMY".equalsIgnoreCase(argName))
{
lsErrcode = "VTEXCHRATE";
return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling]
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String("");
}
// Counting the Modvat Period
ldDate = ldUseDate;
do{
calendarInstance2.setTime(ldDate);
calendarInstance2.add(Calendar.MONTH, 3);
ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
llCnt = llCnt + 1;
if(ldDate.after(ldTranDate) || ldDate == ldTranDate)
else if("XTRA_PARAMS".equalsIgnoreCase(argName))
{
break;
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xtraParams);;
}
}while(true);
System.out.println(" Values in aobj[i] : ["+aobj[i]+"] \t For Argument is ["+argName1+"] \t value of i is ["+i+"] ");
i++;
}//end of while loop
if (rs !=null)
{
rs.close();
rs=null;
}
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].Start
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
// Modified by Piyush on 03/07/2018[To update sundry bal same as PB code of asset single confirmation].Start
retString = (String)call.invoke(aobj);
glTrace = new HashMap();
System.out.println("Returned from Depreciation process WSR called from Confirmation of Asset Sales :==>["+retString+"]");
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].End
}//end of if for comp_type [WSR]
glTrace.put("tran_date",ldTranDate);
glTrace.put("eff_date",ldEffDate);
glTrace.put("fin_entity",lsFinEntity);
glTrace.put("site_code",lsSiteCode);
glTrace.put("sundry_type","C");
glTrace.put("sundry_code",lsCustCode);
glTrace.put("acct_code",lsAcctCodeAr);
glTrace.put("cctr_code",lsCctrCodeAr);
glTrace.put("curr_code",lsCurrCode);
glTrace.put("exch_rate",lcExchRate);
/*call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
if(lcTotalAmt >= 0)
aobj[0] = new String(compName);
aobj[1] = new String(tranIdFr);
aobj[2] = new String(xtraParams);
aobj[3] = new String(forcedFlag);*/
//System.out.println("@@@@@@@@@@loginEmpCode:" +genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode")+":");
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].Start
/*
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
*/
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].End
// System.out.println("Confirm Complete @@@@@@@@@@@ Return string from NVO is:==>["+retString+"]");
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
}
catch(Exception e)
{
glTrace.put("dr_amt",lcTotalAmt);
glTrace.put("cr_amt",0.0);
e.printStackTrace();
throw new ITMException(e);
}
else
finally
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",0.0 - lcTotalAmt);
try{
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
glTrace.put("adv_amt",0.0);
if (rs !=null)
{
rs.close();
rs=null;
}
/*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
{
System.out.println("Exception inCalling confirmed");
e.printStackTrace();
try{
conn.rollback();
String lsContCode = finCommon.getContactCode("C" , lsCustCode , conn);
lsErrcode = finCommon.gbf_sundrybal_upd(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
}catch (Exception s)
{
return lsErrcode;
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
// Modified by Piyush on 03/07/2018[To update sundry bal same as PB code of asset single confirmation].End
// Debiting the Customer for Receivables
glReceivables = new HashMap();
glReceivables.put("tran_ser",asTranser);
glReceivables.put("tran_date",ldTranDate);
glReceivables.put("eff_date",ldEffDate);
glReceivables.put("fin_entity",lsFinEntity);
glReceivables.put("site_code",lsSiteCode);
glReceivables.put("ref_no",lsTranId);
glReceivables.put("ref_date",ldTranDate);
glReceivables.put("due_date",ldDueDate);
glReceivables.put("curr_code",lsCurrCode);
glReceivables.put("exch_rate",lcExchRate);
glReceivables.put("cust_code",lsCustCode);
glReceivables.put("acct_code",lsAcctCodeAr);
glReceivables.put("cctr_code",lsCctrCodeAr);
glReceivables.put("tax_amt",lcTaxAmt);
glReceivables.put("discount",0);
glReceivables.put("tot_amt",lcTotalAmt);
glReceivables.put("bank_code",lsBankCode);
glReceivables.put("cr_term",lsCrTerm);
glReceivables.put("sales_pers","");
glReceivables.put("item_ser",lsItemSer);
glReceivables.put("mrp_value",0);
glReceivables.put("gp_no","");
//changes by sarita on 28 JUN 18 to set gp_date to ldEffDate[START]
//glReceivables.put("gp_date","");
glReceivables.put("gp_date",ldEffDate);
//changes by sarita on 28 JUN 18 to set gp_date to ldEffDate[END]
glReceivables.put("cust_ref_no","");
glReceivables.put("cust_ref_date","");
glReceivables.put("cust_ref_amt","");
lsErrcode = finCommon.gbfReceivablesUpd(glReceivables,conn);
// Modified by Piyush on 03/07/2018
// if(lsErrcode.trim().length() > 0)
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
return retString;
}
// Credit Sales Tax A/c
if(lcTaxAmt != 0)
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [Start]
private HashMap<String,String> getErrorTypeVal(String retString)
{
sql = "select acct_code, cctr_code, sum(case when tax_amt is null then 0 else tax_amt end)" +
" from taxtran where tran_code = ? and tran_id = ? group BY acct_code,cctr_code";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,asTranser);
pstmt.setString(2,lsTranId);
rs = pstmt.executeQuery();
HashMap<String,String> sh = new HashMap<String,String>();
Document dom = null;
NodeList parentNodeList = null,childNodeList = null;
Node childNode = null;
String errotType = "", errorCode = "";
try
{
dom = genericUtility.parseString(retString);
parentNodeList = dom.getElementsByTagName("Errors");
System.out.println("parentNodeList is ["+parentNodeList+"] \t length ["+parentNodeList.getLength()+"]");
while(rs.next())
for(int ctr = 0; ctr < parentNodeList.getLength(); ctr++)
{
lsAcctCodeTax = rs.getString(1);
lsCctrCodeTax = rs.getString(2);
lnAmountTax = rs.getDouble(3);
childNodeList = parentNodeList.item(ctr).getChildNodes();
int childNodeListlen = childNodeList.getLength();
if(lnAmountTax != 0)
for(int ctrD = 0; ctrD < childNodeListlen ; ctrD++)
{
if(lsAcctCodeTax == null || lsAcctCodeTax.length() == 0)
childNode = childNodeList.item(ctrD);
if("error".equalsIgnoreCase(childNode.getNodeName()))
{
sql = "select itemser.acct_code__sal, itemser.cctr_code__sal from itemser " +
" where item_ser = ?";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1,lsItemSer);
rs2 = pstmt2.executeQuery();
if(rs2.next())
errotType = childNode.getAttributes().getNamedItem("type").getNodeValue();
errorCode = childNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("Post Save Status for Detail2["+errotType+"\t errorCode ["+errorCode+"]");
sh.put(errotType, errorCode);
}
}
}
}
catch(Exception e)
{
lsAcctCodeTax = rs2.getString(1);
lsCctrCodeTax = rs2.getString(2);
e.printStackTrace();
System.out.println("Error Inside Method [getErrorTypeVal] is "+e);
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
return sh;
}
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [End]
glTrace = new HashMap();
//Added by Anjali R. on[04/06/18][Added method to post hdr level data only once][Start]
public String gbfAssetSaleHDRPost(String asTranId, String asTranser , Connection conn)
{
String lsTranId = "" , lsBankCode = "", lsCrTerm = "" ,lsErrcode = "" ,lsFinEntity = "", lsCreditPrd = "";
String lsRemarks= "" ,lsCustCode = "" ,lsAcctCodeAr ="",lsCctrCodeAr = "" , lsCurrCode = "" ,
lsAcctCodeTax = "",lsCctrCodeTax = "" ,lsItemSer = "",lsSiteCode ="",lsAssetCode = "";
glTrace.put("tran_date",ldTranDate);
glTrace.put("eff_date",ldEffDate);
glTrace.put("fin_entity",lsFinEntity);
glTrace.put("site_code",lsSiteCode);
glTrace.put("sundry_type","O");
glTrace.put("sundry_code","");
glTrace.put("acct_code",lsAcctCodeTax);
glTrace.put("cctr_code",lsCctrCodeTax);
glTrace.put("emp_code","");
glTrace.put("anal_code","");
glTrace.put("curr_code",lsCurrCode);
glTrace.put("exch_rate",lcExchRate);
Timestamp ldTranDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldEffDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldUseDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
Timestamp ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
if(lnAmountTax >= 0)
ResultSet rs = null;
PreparedStatement pstmt = null;
ResultSet rs2 = null;
PreparedStatement pstmt2 = null;
String sql = "";
double lcTotalAmt = 0, lcSaleAmt = 0,lcTaxAmt = 0 ,lcProfitLoss = 0 ,lcExcrecoAmt = 0 , lcExchRate = 0 ,lnAmountTax = 0;
long llCnt = 0, llCreditPrd = 0;
Calendar calendarInstance = Calendar.getInstance();
Calendar calendarInstance2 = Calendar.getInstance();
HashMap<String, Comparable> glTrace = null;
HashMap glReceivables = null;
boolean isError = false;
try
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",lnAmountTax);
}
else
lsTranId = asTranId;
sql = "SELECT a.tran_date , a.total_amt, a.sale_amt , a.tax_amt ,"
+ " a.cust_code, c.acct_code__ar, c.cctr_code__ar, "
+ " a.excreco_amt ,b.asset_code FROM asset_sales_hdr a,customer c ,asset_sales_det b"
+ " WHERE a.cust_code = c.cust_code and b.tran_id = a.tran_id and a.tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,asTranId);
rs = pstmt.executeQuery();
if(rs.next())
{
glTrace.put("dr_amt",0.0 - lnAmountTax);
glTrace.put("cr_amt", 0.0);
ldTranDate = rs.getTimestamp(1);
lcTotalAmt = rs.getDouble(2);
lcSaleAmt = rs.getDouble(3);
lcTaxAmt = rs.getDouble(4);
lsCustCode = rs.getString(5);
lsAcctCodeAr = rs.getString(6);
lsCctrCodeAr = rs.getString(7);
lcExcrecoAmt = rs.getDouble(8);
lsAssetCode = rs.getString(9);
}
glTrace.put("ref_type","F");
glTrace.put("remarks",lsRemarks);
glTrace.put("ref_ser",asTranser);
glTrace.put("ref_id",lsTranId);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
lsErrcode = finCommon.glTraceUpdate(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
lsRemarks = "Asset Sales TranID :- " + asTranId;
ldEffDate = ldTranDate;
sql = "select coalesce(credit_prd, -99), bank_code, cr_term from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsCustCode);
rs = pstmt.executeQuery();
if(rs.next())
{
return lsErrcode;
}
}
llCreditPrd = rs.getLong(1);
lsBankCode = rs.getString(2);
lsCrTerm = rs.getString(3);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
catch(Exception e)
if(llCreditPrd == -99)
{
try
lsCreditPrd = finCommon.getFinparams("999999","DEF_CR_TERM", conn);
lsCreditPrd = lsCreditPrd == null ? "" : lsCreditPrd.trim();
if("NULLFOUND".equals(lsCreditPrd))
{
conn.rollback();
lsErrcode = "VSENVAR1";
}
catch (SQLException e1)
else
{
e1.printStackTrace();
llCreditPrd = Integer.parseInt(lsCreditPrd);
}
isError = true;
System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
// Due Date calculation
calendarInstance.setTime(ldTranDate);
calendarInstance.add(Calendar.DATE, (int) llCreditPrd);
ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
// Taking Original Value,Excise,WDV Amount from Asset Register
sql = "select item_ser, site_code from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsAssetCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if( isError )
lsItemSer = rs.getString(1).trim();
lsSiteCode = rs.getString(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Checking Financial Entity
sql = "select fin_entity from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsSiteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
conn.rollback();
lsFinEntity = rs.getString(1);
}
else
{
conn.commit();
}
lsErrcode = "VTFINENT";
}
if(pstmt != null)
{
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if(pstmt2 != null)
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{
pstmt2.close();
pstmt2 = null;
}
return lsErrcode;
}
catch(Exception e)
// Checking Currency Code
sql = "select curr_code from finent where fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsFinEntity);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Exception : : :==>\n"+e.getMessage());
try
lsCurrCode = rs.getString(1);
}
else
{
System.out.println("Before rollback");
conn.rollback();
lsErrcode = "VTCURFIN";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
catch(SQLException sqle)
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{
System.out.println(sqle);
return lsErrcode;
}
//throw new ITMException(e);
// Checking Exchange Rate
sql = "select std_exrt from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsCurrCode);
rs = pstmt.executeQuery();
if(rs.next())
{
lcExchRate = rs.getDouble(1);
}
else
{
lsErrcode = "VTSRET2";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
//Added by Anjali R. on[04/06/18][Added method to post hdr level data only once][End]
private String saveData(String siteCode, String xmlString, Connection conn,String xtraParams) throws ITMException
{
System.out.println(siteCode+"enter in save data xtra params in sitecode"+siteCode);
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null;
try
if(lcExchRate == 0)
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString :::: " + xmlString);
lsErrcode = "VTEXCHRATE";
return lsErrcode;
}
// Counting the Modvat Period
ldDate = ldUseDate;
do{
calendarInstance2.setTime(ldDate);
calendarInstance2.add(Calendar.MONTH, 3);
ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
llCnt = llCnt + 1;
ValidatorEJB validatorEJB = new ValidatorEJB();
String userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
// siteCode = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
DBAccessLocal dbAccess = (DBAccessLocal) ctx.lookup("ibase/DBAccessEJB/local");
String[] userInfoArray = dbAccess.getEmpInfo(userId, siteCode);
System.out.println("^^^^^^^ UserInfo ..> " + Arrays.toString(userInfoArray));
UserInfoBean userInfoBean = new UserInfoBean();
userInfoBean.setLoginCode(userId);
userInfoBean.setEmpCode(userInfoArray[0]);
userInfoBean.setEmpName(userInfoArray[1]);
userInfoBean.setReportTo(userInfoArray[2]);
userInfoBean.setDeptCode(userInfoArray[3]);
userInfoBean.setDeptDescr(userInfoArray[4]);
userInfoBean.setSiteCode(siteCode);
userInfoBean.setSiteDescr(userInfoArray[6]);
userInfoBean.setUserLevel(userInfoArray[7]);
userInfoBean.setUserType(userInfoArray[8]);
userInfoBean.setEntityCode(userInfoArray[9]);
userInfoBean.setProfileId(userInfoArray[10]);
userInfoBean.setItemSer(userInfoArray[11]);
userInfoBean.setEmailIdOff(userInfoArray[12]);
userInfoBean.setLoggerType(userInfoArray[13]);
userInfoBean.setStanCode(userInfoArray[14]);
userInfoBean.setDesignation(userInfoArray[15]);
userInfoBean.setDateJoin(userInfoArray[16]);
userInfoBean.setDivision(userInfoArray[17]);
userInfoBean.setUserLanguage(userInfoArray[18]);
userInfoBean.setUserCountry(userInfoArray[19]);
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
retString = masterStateful.processRequest(userInfoBean, xmlString, true, conn);
if(ldDate.after(ldTranDate) || ldDate == ldTranDate)
{
break;
}
}while(true);
glTrace = new HashMap();
System.out.println("masterstatefull,dbaccess and ctx will be null here");
//retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
masterStateful = null;
// dbAccess = null;
// ctx = null;
glTrace.put("tran_date",ldTranDate);
glTrace.put("eff_date",ldEffDate);
glTrace.put("fin_entity",lsFinEntity);
glTrace.put("site_code",lsSiteCode);
glTrace.put("sundry_type","C");
glTrace.put("sundry_code",lsCustCode);
glTrace.put("acct_code",lsAcctCodeAr);
glTrace.put("cctr_code",lsCctrCodeAr);
glTrace.put("curr_code",lsCurrCode);
glTrace.put("exch_rate",lcExchRate);
}
catch(ITMException itme)
if(lcTotalAmt >= 0)
{
System.out.println("ITMException :PosConfirm :saveData :==>");
throw itme;
glTrace.put("dr_amt",lcTotalAmt);
glTrace.put("cr_amt",0.0);
}
catch(Exception e)
else
{
System.out.println("Exception :PosConfirm :saveData :==>");
throw new ITMException(e);
}
return retString;
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",0.0 - lcTotalAmt);
}
glTrace.put("adv_amt",0.0);
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [START]
//public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) throws ITMException
public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String xmlTabString, String finalXmlString, Connection conn) throws ITMException
String lsContCode = finCommon.getContactCode("C" , lsCustCode , conn);
lsErrcode = finCommon.gbf_sundrybal_upd(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [END]
String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String compType = "",argName = "",argName1 = ""; //Added by sarita on 14 JUN 18
HashMap<String , String> getArgName = new HashMap<String , String>();
int i = 0;
//System.out.println("confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>>");
return lsErrcode;
}
try
{
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
//Commented by sarita on 19 JUN 18 as methodName will come from table. [START]
//methodName = "gbf_post";
//actionURI = "http://NvoServiceurl.org/" + methodName;
//Commented by sarita on 19 JUN 18 as methodName will come from table. [END]
// Debiting the Customer for Receivables
glReceivables = new HashMap();
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
//System.out.println("serviceCode = "+serviceCode+" compName "+compName);
System.out.println("serviceCode = "+serviceCode+" compName "+compName + "compType "+compType);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (rs !=null)
{
rs.close();
rs=null;
}
if (pstmt != null)
glReceivables.put("tran_ser",asTranser);
glReceivables.put("tran_date",ldTranDate);
glReceivables.put("eff_date",ldEffDate);
glReceivables.put("fin_entity",lsFinEntity);
glReceivables.put("site_code",lsSiteCode);
glReceivables.put("ref_no",lsTranId);
glReceivables.put("ref_date",ldTranDate);
glReceivables.put("due_date",ldDueDate);
glReceivables.put("curr_code",lsCurrCode);
glReceivables.put("exch_rate",lcExchRate);
glReceivables.put("cust_code",lsCustCode);
glReceivables.put("acct_code",lsAcctCodeAr);
glReceivables.put("cctr_code",lsCctrCodeAr);
glReceivables.put("tax_amt",lcTaxAmt);
glReceivables.put("discount",0);
glReceivables.put("tot_amt",lcTotalAmt);
glReceivables.put("bank_code",lsBankCode);
glReceivables.put("cr_term",lsCrTerm);
glReceivables.put("sales_pers","");
glReceivables.put("item_ser",lsItemSer);
glReceivables.put("mrp_value",0);
glReceivables.put("gp_no","");
glReceivables.put("gp_date",ldEffDate);
glReceivables.put("cust_ref_no","");
glReceivables.put("cust_ref_date","");
glReceivables.put("cust_ref_amt","");
lsErrcode = finCommon.gbfReceivablesUpd(glReceivables,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
pstmt.close();
pstmt=null;
return lsErrcode;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
//Commented and Added by sarita to add comp_type in query on 19 JUN 18 [END]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [START]
//sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
sql = "SELECT SERVICE_URI,METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
// Credit Sales Tax A/c
if(lcTaxAmt != 0)
{
sql = "select acct_code, cctr_code, sum(case when tax_amt is null then 0 else tax_amt end)" +
" from taxtran where tran_code = ? and tran_id = ? group BY acct_code,cctr_code";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
pstmt.setString(1,asTranser);
pstmt.setString(2,asTranId);
rs = pstmt.executeQuery();
if ( rs.next() )
while(rs.next())
{
serviceURI = rs.getString("SERVICE_URI");
methodName = rs.getString("METHOD_NAME");
}
//System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
System.out.println("serviceURI = "+serviceURI+" compName = "+compName+" methodName ="+methodName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (rs !=null)
lsAcctCodeTax = rs.getString(1);
lsCctrCodeTax = rs.getString(2);
lnAmountTax = rs.getDouble(3);
if(lnAmountTax != 0)
{
rs.close();
rs=null;
}
if (pstmt != null)
if(lsAcctCodeTax == null || lsAcctCodeTax.length() == 0)
{
pstmt.close();
pstmt=null;
sql = "select itemser.acct_code__sal, itemser.cctr_code__sal from itemser " +
" where item_ser = ?";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1,lsItemSer);
rs2 = pstmt2.executeQuery();
if(rs2.next())
{
lsAcctCodeTax = rs2.getString(1);
lsCctrCodeTax = rs2.getString(2);
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
}
// Changed by Manish on 01/04/16 for max cursor issue [end]
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [END]
//Commented and Added by sarita on 19 JUN 18 to dynamic call [START]
actionURI = "http://NvoServiceurl.org/" + methodName;
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[5];
glTrace = new HashMap();
if("WSR".equalsIgnoreCase(compType))
{
sql = "SELECT ARG_NAME FROM SYSTEM_SERVICE_ARGS WHERE SERVICE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
while ( rs.next() )
{
argName = rs.getString("ARG_NAME"); argName1 = argName.toLowerCase().trim();
if("COMPONENT_TYPE".equalsIgnoreCase(argName))
glTrace.put("tran_date",ldTranDate);
glTrace.put("eff_date",ldEffDate);
glTrace.put("fin_entity",lsFinEntity);
glTrace.put("site_code",lsSiteCode);
glTrace.put("sundry_type","O");
glTrace.put("sundry_code","");
glTrace.put("acct_code",lsAcctCodeTax);
glTrace.put("cctr_code",lsCctrCodeTax);
glTrace.put("emp_code","");
glTrace.put("anal_code","");
glTrace.put("curr_code",lsCurrCode);
glTrace.put("exch_rate",lcExchRate);
if(lnAmountTax >= 0)
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compType);
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",lnAmountTax);
}
else if("COMPONENT_NAME".equalsIgnoreCase(argName))
else
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compName);
glTrace.put("dr_amt",0.0 - lnAmountTax);
glTrace.put("cr_amt", 0.0);
}
else if(argName.startsWith("TAB_"))
glTrace.put("ref_type","F");
glTrace.put("remarks",lsRemarks);
glTrace.put("ref_ser",asTranser);
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xmlTabString);
return lsErrcode;
}
else if("DUMMY".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String("");
}
else if("XTRA_PARAMS".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xtraParams);;
}
System.out.println(" Values in aobj[i] : ["+aobj[i]+"] \t For Argument is ["+argName1+"] \t value of i is ["+i+"] ");
i++;
}//end of while loop
if (rs !=null)
if(rs != null)
{
rs.close();
rs=null;
rs = null;
}
if (pstmt != null)
if(pstmt != null)
{
pstmt.close();
pstmt=null;
pstmt = null;
}
}
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].Start
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println("Returned from Depreciation process WSR called from Confirmation of Asset Sales :==>["+retString+"]");
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].End
}//end of if for comp_type [WSR]
/*call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tran_id"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "forced_flag"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compName);
aobj[1] = new String(tranIdFr);
aobj[2] = new String(xtraParams);
aobj[3] = new String(forcedFlag);*/
//System.out.println("@@@@@@@@@@loginEmpCode:" +genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode")+":");
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].Start
/*
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
*/
// Modified by Piyush on 30/06/2018 [Web service should be called in case of WSR hence shifted above].End
// System.out.println("Confirm Complete @@@@@@@@@@@ Return string from NVO is:==>["+retString+"]");
System.out.println("@@@@@@ call.setReturnType(XMLType.XSD_STRING) executed........");
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
isError = true;
lsErrcode = "VTFASL0002";
System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
try
{
pstmt.close();
pstmt = null;
}
if (rs !=null)
System.out.println("isError ["+isError+"]");
if( conn != null )
{
rs.close();
rs=null;
}
/*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
if( isError || (lsErrcode != null && lsErrcode.trim().length() > 0))
{
System.out.println("Exception inCalling confirmed");
e.printStackTrace();
try{
conn.rollback();
}catch (Exception s)
{
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
return retString;
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [Start]
private HashMap<String,String> getErrorTypeVal(String retString)
}
catch(Exception e)
{
HashMap<String,String> sh = new HashMap<String,String>();
Document dom = null;
NodeList parentNodeList = null,childNodeList = null;
Node childNode = null;
String errotType = "", errorCode = "";
System.out.println("Exception : : :==>\n"+e.getMessage());
try
{
dom = genericUtility.parseString(retString);
parentNodeList = dom.getElementsByTagName("Errors");
System.out.println("parentNodeList is ["+parentNodeList+"] \t length ["+parentNodeList.getLength()+"]");
for(int ctr = 0; ctr < parentNodeList.getLength(); ctr++)
{
childNodeList = parentNodeList.item(ctr).getChildNodes();
int childNodeListlen = childNodeList.getLength();
for(int ctrD = 0; ctrD < childNodeListlen ; ctrD++)
{
childNode = childNodeList.item(ctrD);
System.out.println("Before rollback");
conn.rollback();
}
if("error".equalsIgnoreCase(childNode.getNodeName()))
catch(SQLException sqle)
{
errotType = childNode.getAttributes().getNamedItem("type").getNodeValue();
errorCode = childNode.getAttributes().getNamedItem("id").getNodeValue();
System.out.println("Post Save Status for Detail2["+errotType+"\t errorCode ["+errorCode+"]");
sh.put(errotType, errorCode);
}
}
System.out.println(sqle);
}
//throw new ITMException(e);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error Inside Method [getErrorTypeVal] is "+e);
}
return sh;
return lsErrcode;
}
//Added by sarita on 19 JUN 18 to get store errorType and errCode in HashMap and Return [End]
//Added by Anjali R. on[04/06/18][Added method to post hdr level data only once][End]
//Added by sarita to get Error Code from errorString on 03 JUL 18 [START]
private String getErrorId(String retXml)
......
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