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,13 +48,13 @@ public class AssetSalesConf extends ActionHandlerEJB implements ...@@ -48,13 +48,13 @@ public class AssetSalesConf extends ActionHandlerEJB implements
AssetSalesConfLocal,AssetSalesConfRemote AssetSalesConfLocal,AssetSalesConfRemote
{ {
// GenericUtility genericUtility = GenericUtility.getInstance(); // GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon(); FinCommon finCommon = new FinCommon();
public String confirm(String tranId,String xtraParams, String forcedFlag) public String confirm(String tranId,String xtraParams, String forcedFlag)
throws RemoteException, ITMException throws RemoteException, ITMException
{ {
System.out.println("in AssetSalesConf EJB confirm action"); System.out.println("in AssetSalesConf EJB confirm action");
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
...@@ -103,17 +103,17 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -103,17 +103,17 @@ AssetSalesConfLocal,AssetSalesConfRemote
double remValues = 0; double remValues = 0;
HashMap<String , String> retErrTypeValue = new HashMap<String,String>(); HashMap<String , String> retErrTypeValue = new HashMap<String,String>();
//Added by sarita on 19 JUN 18 to store values of asset_register [END] //Added by sarita on 19 JUN 18 to store values of asset_register [END]
//Added by sarita on 26 JUN 18 [START] //Added by sarita on 26 JUN 18 [START]
String sql1 = "", sql2 = "", sql3 = "", sql4 = "", sql5 = "", sql6 = "", sql7 = "", sql8 = "", sql9 = "", sql10 = "", sql11 = "", sql12 = "", sql13 = ""; String sql1 = "", sql2 = "", sql3 = "", sql4 = "", sql5 = "", sql6 = "", sql7 = "", sql8 = "", sql9 = "", sql10 = "", sql11 = "", sql12 = "", sql13 = "";
PreparedStatement pstmt1 = null,pstmt2 = null, pstmt3 = null, pstmt4 = null, pstmt5 = null, pstmt6 = null, pstmt7 = null, pstmt8 = null, pstmt9 = null, pstmt10 = null, pstmt11 = null, pstmt12 = null, pstmt13 = null; PreparedStatement pstmt1 = null,pstmt2 = null, pstmt3 = null, pstmt4 = null, pstmt5 = null, pstmt6 = null, pstmt7 = null, pstmt8 = null, pstmt9 = null, pstmt10 = null, pstmt11 = null, pstmt12 = null, pstmt13 = null;
ResultSet rs1 = null,rs2 = null, rs3 = null, rs4 = null, rs5 = null, rs6 = null, rs9 = null, rs10 = null, rs11 = null, rs12 = null; ResultSet rs1 = null,rs2 = null, rs3 = null, rs4 = null, rs5 = null, rs6 = null, rs9 = null, rs10 = null, rs11 = null, rs12 = null;
//Added by sarita on 26 JUN 18 [END] //Added by sarita on 26 JUN 18 [END]
//Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start //Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start
java.sql.Timestamp salesTranDate = null; java.sql.Timestamp salesTranDate = null;
String salesAcPeriod = "", sqlTemp1 = "", salesPeriod = "" ;//Added salesPeriod on 02JUL18 String salesAcPeriod = "", sqlTemp1 = "", salesPeriod = "" ;//Added salesPeriod on 02JUL18
int detRowNo = 0; int detRowNo = 0, lineNoInt = 0;
ResultSet rsTemp1 = null; ResultSet rsTemp1 = null;
PreparedStatement pstmtTemp1 = null; PreparedStatement pstmtTemp1 = null;
//Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start //Modified by Piyush on 30/06/2018 [To get sales transaction date & other values].Start
...@@ -136,7 +136,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -136,7 +136,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
+ " b.asset_code,b.acct_code__pl, b.cctr_code__pl, b.acct_code__loss, " + " b.asset_code,b.acct_code__pl, b.cctr_code__pl, b.acct_code__loss, "
+ "b.cctr_code__loss, b.line_no from asset_sales_hdr a,asset_sales_det b " + "b.cctr_code__loss, b.line_no from asset_sales_hdr a,asset_sales_det b "
+ "where a.tran_id = b.tran_id and b.tran_id = ?";*/ + "where a.tran_id = b.tran_id and b.tran_id = ?";*/
sql = "select a.confirmed, a.tran_date, a.sale_amt, a.tran_type, a.curr_code," sql = "select a.confirmed, a.tran_date, a.sale_amt, a.tran_type, a.curr_code,"
+ " b.asset_code,b.acct_code__pl, b.cctr_code__pl, b.acct_code__loss, " + " b.asset_code,b.acct_code__pl, b.cctr_code__pl, b.acct_code__loss, "
+ "b.cctr_code__loss, b.line_no,b.tax_amt from asset_sales_hdr a,asset_sales_det b " + "b.cctr_code__loss, b.line_no,b.tax_amt from asset_sales_hdr a,asset_sales_det b "
...@@ -160,13 +160,14 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -160,13 +160,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
acctCdLoss = rs.getString(9) == null ? "":rs.getString(9); acctCdLoss = rs.getString(9) == null ? "":rs.getString(9);
cctrCdLoss = rs.getString(10) == null ? "":rs.getString(10); cctrCdLoss = rs.getString(10) == null ? "":rs.getString(10);
lineNo = rs.getString(11) == null ? "":rs.getString(11); lineNo = rs.getString(11) == null ? "":rs.getString(11);
//Added by sarita to get tax_amt on 06 JUN 2018 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); taxAmt = rs.getDouble(12);
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ; currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = sdf.format(currDate); currAppdate = sdf.format(currDate);
//Added by sarita to get Current Date in dbformat [START] //Added by sarita to get Current Date in dbformat [START]
today = new java.sql.Timestamp(System.currentTimeMillis()) ; today = new java.sql.Timestamp(System.currentTimeMillis()) ;
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat()); SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
...@@ -198,7 +199,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -198,7 +199,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmtTemp1.close(); pstmtTemp1.close();
pstmtTemp1 = null; pstmtTemp1 = null;
} }
} }
// Modified by Piyush on 30/06/2018 [To fetch sales accounting period].Start // Modified by Piyush on 30/06/2018 [To fetch sales accounting period].Start
...@@ -316,7 +317,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -316,7 +317,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
rs = null; rs = null;
System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto); System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto);
//Added by sarita on 19 JUN 18 to store asset_register values before update [START] //Added by sarita on 19 JUN 18 to store asset_register values before update [START]
sql = "select rem_date , status , tran_id__rem, tran_ser__rem, rem_value from asset_register where asset_code = ?"; sql = "select rem_date , status , tran_id__rem, tran_ser__rem, rem_value from asset_register where asset_code = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
...@@ -342,7 +343,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -342,7 +343,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
rs=null; rs=null;
} }
//Added by sarita on 19 JUN 18 to store asset_register values before update [END] //Added by sarita on 19 JUN 18 to store asset_register values before update [END]
if(saleCd.compareTo(prdCdUpto) >= 0) if(saleCd.compareTo(prdCdUpto) >= 0)
{ {
...@@ -385,14 +386,14 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -385,14 +386,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
return errString; return errString;
} }
else*/ else*/
//Commented by sarita on 19 JUN 18 to comment errormessage and else statement[END] //Commented by sarita on 19 JUN 18 to comment errormessage and else statement[END]
/*if(calc_depreciation == true) /*if(calc_depreciation == true)
{ {
//Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [START] //Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [START]
conn.commit(); conn.commit();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
currentDateTime = sdf2.format(today); System.out.println("Current Date Time in Application Format : ["+currentDateTime+"]"); currentDateTime = sdf2.format(today); System.out.println("Current Date Time in Application Format : ["+currentDateTime+"]");
StringBuffer recTabStrBuff = new StringBuffer();//data from d_depr_proc_month.srd StringBuffer recTabStrBuff = new StringBuffer();//data from d_depr_proc_month.srd
recTabStrBuff.append(siteCode).append("\t"); //site_code recTabStrBuff.append(siteCode).append("\t"); //site_code
recTabStrBuff.append(itmSer).append("\t"); //item_ser__fr recTabStrBuff.append(itmSer).append("\t"); //item_ser__fr
...@@ -411,7 +412,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -411,7 +412,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
recTabStrBuff.append(assetSrc).append("\t"); //asset_source recTabStrBuff.append(assetSrc).append("\t"); //asset_source
recTabStrBuff.append(currentDateTime).append("\t"); //post_date with Application Date Format recTabStrBuff.append(currentDateTime).append("\t"); //post_date with Application Date Format
xmlTabString = recTabStrBuff.toString();System.out.println(">>>xmlTabString:"+xmlTabString); xmlTabString = recTabStrBuff.toString();System.out.println(">>>xmlTabString:"+xmlTabString);
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append("").append("</editFlag></header>"); valueXmlString.append("").append("</editFlag></header>");
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
...@@ -434,10 +435,10 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -434,10 +435,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
finalXmlString = valueXmlString.toString();System.out.println(">>>finalXmlString:"+finalXmlString); finalXmlString = valueXmlString.toString();System.out.println(">>>finalXmlString:"+finalXmlString);
retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, xmlTabString,finalXmlString, conn); retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, xmlTabString,finalXmlString, conn);
System.out.println("ReturnString of confirmJournalVoucher is :\n" +retString ); System.out.println("ReturnString of confirmJournalVoucher is :\n" +retString );
if((retString != null && retString.trim().length() > 0) && (retString.indexOf("Errors") > -1)) if((retString != null && retString.trim().length() > 0) && (retString.indexOf("Errors") > -1))
{ {
retErrTypeValue = getErrorTypeVal(retString); System.out.println("Values in HashMap[retErrTypeValue] are : ["+retErrTypeValue+"]"); retErrTypeValue = getErrorTypeVal(retString); System.out.println("Values in HashMap[retErrTypeValue] are : ["+retErrTypeValue+"]");
...@@ -456,7 +457,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -456,7 +457,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt.setDouble(5, remValues); pstmt.setDouble(5, remValues);
pstmt.setString(6, assetCode); pstmt.setString(6, assetCode);
int chkData = pstmt.executeUpdate(); int chkData = pstmt.executeUpdate();
if(chkData > 0) if(chkData > 0)
{ {
System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]"); System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
...@@ -477,7 +478,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -477,7 +478,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
} }
} }
} }
/*retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, "", conn); /*retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, "", conn);
if(retString.indexOf("Errors") > -1) if(retString.indexOf("Errors") > -1)
{ {
...@@ -486,10 +487,10 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -486,10 +487,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
System.out.println("errString :>>kkk"+errString); System.out.println("errString :>>kkk"+errString);
return errString; return errString;
}*/ }*/
//Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [END] //Added & Commented by sarita on 19 JUN 18 to commit transaction if calc_depreciation = true & create tabxml & xml file[nvo_business_object_fin_asset_sales] and pass to confirmJournalVoucher method [END]
//} //}
//commented below code for avoiding tax calculation by varsha v on 24-05-18 //commented below code for avoiding tax calculation by varsha v on 24-05-18
/*System.out.println("calling taxCalc"); /*System.out.println("calling taxCalc");
retString = taxCal.taxCalc(transer, tranId, currAppdate, "sale_amt", "", currCode, siteCode, "2"); retString = taxCal.taxCalc(transer, tranId, currAppdate, "sale_amt", "", currCode, siteCode, "2");
System.out.println("exit taxCalc>>"+retString); System.out.println("exit taxCalc>>"+retString);
...@@ -500,11 +501,11 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -500,11 +501,11 @@ AssetSalesConfLocal,AssetSalesConfRemote
System.out.println("errString :>>kkk"+errString); System.out.println("errString :>>kkk"+errString);
return errString; return errString;
}*/ }*/
//commented below line for avoiding tax calculation by varsha v on 24-05-18 //commented below line for avoiding tax calculation by varsha v on 24-05-18
/*sql = "select item_code, item_ser, total_value, excise_amt, wdv_amt_2, depr_amt_2, grp_code, depr_amt_revl_2 from asset_register where asset_code = ?"; /*sql = "select item_code, item_ser, total_value, excise_amt, wdv_amt_2, depr_amt_2, grp_code, depr_amt_revl_2 from asset_register where asset_code = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, assetCode); pstmt.setString(1, assetCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -548,7 +549,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -548,7 +549,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pdate = formatter.parse(procDate2d); //Jun 01 00:00:00 GMT+05:30 18 pdate = formatter.parse(procDate2d); //Jun 01 00:00:00 GMT+05:30 18
cdate = formatter.parse(currAppdate); cdate = formatter.parse(currAppdate);
System.out.println("procDate2d : ["+procDate2d+"] \t currAppdate : ["+currAppdate+"] \t pdate : ["+pdate+"] \t cdate ["+cdate+"]"); System.out.println("procDate2d : ["+procDate2d+"] \t currAppdate : ["+currAppdate+"] \t pdate : ["+pdate+"] \t cdate ["+cdate+"]");
do { do {
pdate = addMonths(pdate, 3); pdate = addMonths(pdate, 3);
...@@ -691,7 +692,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -691,7 +692,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
if(confirmed == "" || confirmed.equalsIgnoreCase("N")) if(confirmed == "" || confirmed.equalsIgnoreCase("N"))
{ {
sql1 = "select item_ser, item_code , grp_code, site_code, proc_date_2" sql1 = "select item_ser, item_code , grp_code, site_code, proc_date_2"
+ " from asset_register where asset_code = ?"; + " from asset_register where asset_code = ?";
pstmt1=conn.prepareStatement(sql1); pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1,assetCode); pstmt1.setString(1,assetCode);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
...@@ -720,14 +721,14 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -720,14 +721,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
procDate2d = sdf.format(procDate2ts); // procDate2d : [01/06/12] procDate2d = sdf.format(procDate2ts); // procDate2d : [01/06/12]
// Modified by Piyush on 30/06/2018 [To consider accounting period of sales] // Modified by Piyush on 30/06/2018 [To consider accounting period of sales]
/* /*
sql2 = "select prd_code__upto from asset_depr" sql2 = "select prd_code__upto from asset_depr"
+ " where asset_code = ? and item_ser = ? and grp_code= ? and site_code = ?"; + " where asset_code = ? and item_ser = ? and grp_code= ? and site_code = ?";
*/ */
sql2 = "select prd_code__upto from asset_depr" sql2 = "select prd_code__upto from asset_depr"
+ " where asset_code = ? and item_ser = ? and grp_code= ? and site_code = ? and acct_prd = ?"; + " where asset_code = ? and item_ser = ? and grp_code= ? and site_code = ? and acct_prd = ?";
pstmt2=conn.prepareStatement(sql2); pstmt2=conn.prepareStatement(sql2);
pstmt2.setString(1,assetCode); pstmt2.setString(1,assetCode);
pstmt2.setString(2,itmSer); pstmt2.setString(2,itmSer);
...@@ -756,7 +757,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -756,7 +757,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
if(prdCdUpto == "" || prdCdUpto.trim().length() == 0 ) if(prdCdUpto == "" || prdCdUpto.trim().length() == 0 )
{ {
//changes by sarita on 06 JUNE 2018 to add setTimestamp //changes by sarita on 06 JUNE 2018 to add setTimestamp
//sql = "select code from period where '"+procDate2d+"' between fr_date and to_date"; //sql = "select code from period where '"+procDate2d+"' between fr_date and to_date";
sql3 = "select code from period where ? between fr_date and to_date"; sql3 = "select code from period where ? between fr_date and to_date";
pstmt3=conn.prepareStatement(sql3); pstmt3=conn.prepareStatement(sql3);
...@@ -779,12 +780,16 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -779,12 +780,16 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt3.close(); pstmt3.close();
pstmt3 = null; pstmt3 = null;
} }
//changes by sarita on 06 JUN 2018 to set current date Timestamp parameter //changes by sarita on 06 JUN 2018 to set current date Timestamp parameter
//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))"; //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] //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 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] //changes by sarita on 03 JUL 2018 as getting account period not defined in period masted [END]
pstmt4=conn.prepareStatement(sql4); pstmt4=conn.prepareStatement(sql4);
//Added by sarita on 06 JUN 2018 //Added by sarita on 06 JUN 2018
...@@ -808,7 +813,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -808,7 +813,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt4.close(); pstmt4.close();
pstmt4 = null; pstmt4 = null;
} }
System.out.println("prdCdUpfr.compareTo(prdCdUpto) > 0 >>> prdCdUpfr "+prdCdUpfr+">>>>>prdCdUpto"+prdCdUpto); System.out.println("prdCdUpfr.compareTo(prdCdUpto) > 0 >>> prdCdUpfr "+prdCdUpfr+">>>>>prdCdUpto"+prdCdUpto);
if(prdCdUpfr.compareTo(prdCdUpto) > 0) if(prdCdUpfr.compareTo(prdCdUpto) > 0)
{ {
...@@ -816,7 +821,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -816,7 +821,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
} }
}//End of if block for prdCdUpto }//End of if block for prdCdUpto
//changes by sarita on 06 JUN 2018 to set current date Timestamp parameter //changes by sarita on 06 JUN 2018 to set current date Timestamp parameter
//sql = "select code from period where '"+currAppdate+"' between fr_date and to_date"; //sql = "select code from period where '"+currAppdate+"' between fr_date and to_date";
sql5 = "select code from period where ? between fr_date and to_date"; sql5 = "select code from period where ? between fr_date and to_date";
pstmt5=conn.prepareStatement(sql5); pstmt5=conn.prepareStatement(sql5);
...@@ -841,10 +846,10 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -841,10 +846,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt5.close(); pstmt5.close();
pstmt5 = null; pstmt5 = null;
} }
System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto); System.out.println("saleCd.compareTo(prdCdUpto) >= 0 >>> sale cd"+saleCd+">>>>>"+prdCdUpto);
//Added by sarita on 19 JUN 18 to store asset_register values before update [START] //Added by sarita on 19 JUN 18 to store asset_register values before update [START]
sql6 = "select rem_date , status , tran_id__rem, tran_ser__rem, rem_value from asset_register where asset_code = ?"; sql6 = "select rem_date , status , tran_id__rem, tran_ser__rem, rem_value from asset_register where asset_code = ?";
pstmt6=conn.prepareStatement(sql6); pstmt6=conn.prepareStatement(sql6);
...@@ -852,11 +857,11 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -852,11 +857,11 @@ AssetSalesConfLocal,AssetSalesConfRemote
rs6 = pstmt6.executeQuery(); rs6 = pstmt6.executeQuery();
if(rs6.next()) if(rs6.next())
{ {
remDate= rs6.getTimestamp("rem_date"); remDate= rs6.getTimestamp("rem_date");
status = rs6.getString("status"); status = rs6.getString("status");
tranIdRem = rs6.getString("tran_id__rem"); tranIdRem = rs6.getString("tran_id__rem");
tranSerRem = rs6.getString("tran_ser__rem"); tranSerRem = rs6.getString("tran_ser__rem");
remValues = rs6.getDouble("rem_value"); remValues = rs6.getDouble("rem_value");
} }
System.out.println("Origional Values of asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]"); System.out.println("Origional Values of asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
//done changes to close resultset and prepaestatement on 29JUN18 //done changes to close resultset and prepaestatement on 29JUN18
...@@ -871,9 +876,9 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -871,9 +876,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt6.close(); pstmt6.close();
pstmt6 = null; pstmt6 = null;
} }
//Added by sarita on 19 JUN 18 to store asset_register values before update [END] //Added by sarita on 19 JUN 18 to store asset_register values before update [END]
if(saleCd.compareTo(prdCdUpto) >= 0) if(saleCd.compareTo(prdCdUpto) >= 0)
{ {
sql7 = "update asset_register set rem_date = ?,status=?,tran_id__rem=?,tran_ser__rem=?,rem_value=? where asset_code = ?"; sql7 = "update asset_register set rem_date = ?,status=?,tran_id__rem=?,tran_ser__rem=?,rem_value=? where asset_code = ?";
...@@ -901,7 +906,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -901,7 +906,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt7 = null; pstmt7 = null;
} }
}//end of if for (saleCd.compareTo(prdCdUpto) >= 0) }//end of if for (saleCd.compareTo(prdCdUpto) >= 0)
calc_depreciation = false; calc_depreciation = false;
if(prdCdUpto.compareTo(saleCd) >= 0) if(prdCdUpto.compareTo(saleCd) >= 0)
...@@ -926,7 +931,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -926,7 +931,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
conn.commit(); conn.commit();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
currentDateTime = sdf2.format(today); System.out.println("Current Date Time in Application Format : ["+currentDateTime+"]"); currentDateTime = sdf2.format(today); System.out.println("Current Date Time in Application Format : ["+currentDateTime+"]");
StringBuffer recTabStrBuff = new StringBuffer();//data from d_depr_proc_month.srd StringBuffer recTabStrBuff = new StringBuffer();//data from d_depr_proc_month.srd
recTabStrBuff.append(siteCode).append("\t"); //site_code recTabStrBuff.append(siteCode).append("\t"); //site_code
recTabStrBuff.append(itmSer).append("\t"); //item_ser__fr recTabStrBuff.append(itmSer).append("\t"); //item_ser__fr
...@@ -947,7 +952,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -947,7 +952,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
recTabStrBuff.append(assetSrc).append("\t"); //asset_source recTabStrBuff.append(assetSrc).append("\t"); //asset_source
recTabStrBuff.append(currentDateTime).append("\t"); //post_date with Application Date Format recTabStrBuff.append(currentDateTime).append("\t"); //post_date with Application Date Format
xmlTabString = recTabStrBuff.toString();System.out.println(">>>xmlTabString:"+xmlTabString); xmlTabString = recTabStrBuff.toString();System.out.println(">>>xmlTabString:"+xmlTabString);
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append("").append("</editFlag></header>"); valueXmlString.append("").append("</editFlag></header>");
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
...@@ -972,10 +977,10 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -972,10 +977,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
finalXmlString = valueXmlString.toString();System.out.println(">>>finalXmlString:"+finalXmlString); finalXmlString = valueXmlString.toString();System.out.println(">>>finalXmlString:"+finalXmlString);
retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, xmlTabString,finalXmlString, conn); retString = confirmJournalVoucher("depr_proc_month", tranId, xtraParams, xmlTabString,finalXmlString, conn);
System.out.println("ReturnString of confirmJournalVoucher is :\n" +retString ); System.out.println("ReturnString of confirmJournalVoucher is :\n" +retString );
if((retString != null && retString.trim().length() > 0) && (retString.indexOf("Errors") > -1)) if((retString != null && retString.trim().length() > 0) && (retString.indexOf("Errors") > -1))
{ {
retErrTypeValue = getErrorTypeVal(retString); System.out.println("Values in HashMap[retErrTypeValue] are : ["+retErrTypeValue+"]"); retErrTypeValue = getErrorTypeVal(retString); System.out.println("Values in HashMap[retErrTypeValue] are : ["+retErrTypeValue+"]");
...@@ -994,7 +999,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -994,7 +999,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt8.setDouble(5, remValues); pstmt8.setDouble(5, remValues);
pstmt8.setString(6, assetCode); pstmt8.setString(6, assetCode);
int chkData = pstmt8.executeUpdate(); int chkData = pstmt8.executeUpdate();
conn.commit(); // done changes to commit transaction on 29 JUN 18 SARITA [START] conn.commit(); // done changes to commit transaction on 29 JUN 18 SARITA [START]
if(chkData > 0) if(chkData > 0)
{ {
System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]"); System.out.println("["+chkData+"] Updated Origional Values to asset_register are : rem_date["+remDate+"] \t status["+status+"] \t tran_id__rem["+tranIdRem+"] \t tran_ser__rem["+tranSerRem+"] \t rem_value["+remValues+"]");
...@@ -1040,7 +1045,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1040,7 +1045,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt9.close(); pstmt9.close();
pstmt9 = null; pstmt9 = null;
} }
sql10 = "select sum(case when revalue_amt is null then 0 else revalue_amt end) from asset_revalue where asset_code = ? and confirmed = ?"; sql10 = "select sum(case when revalue_amt is null then 0 else revalue_amt end) from asset_revalue where asset_code = ? and confirmed = ?";
pstmt10=conn.prepareStatement(sql10); pstmt10=conn.prepareStatement(sql10);
pstmt10.setString(1, assetCode); pstmt10.setString(1, assetCode);
...@@ -1062,7 +1067,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1062,7 +1067,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt10.close(); pstmt10.close();
pstmt10 = null; pstmt10 = null;
} }
// Total Cost is Total Value + Ravalued Amount // Total Cost is Total Value + Ravalued Amount
totval = totval + revalamt; totval = totval + revalamt;
...@@ -1071,7 +1076,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1071,7 +1076,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
pdate = formatter.parse(procDate2d); //Jun 01 00:00:00 GMT+05:30 18 pdate = formatter.parse(procDate2d); //Jun 01 00:00:00 GMT+05:30 18
cdate = formatter.parse(currAppdate); cdate = formatter.parse(currAppdate);
System.out.println("procDate2d : ["+procDate2d+"] \t currAppdate : ["+currAppdate+"] \t pdate : ["+pdate+"] \t cdate ["+cdate+"]"); System.out.println("procDate2d : ["+procDate2d+"] \t currAppdate : ["+currAppdate+"] \t pdate : ["+pdate+"] \t cdate ["+cdate+"]");
do do
{ {
pdate = addMonths(pdate, 3); pdate = addMonths(pdate, 3);
...@@ -1086,10 +1091,19 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1086,10 +1091,19 @@ AssetSalesConfLocal,AssetSalesConfRemote
} while (true); } while (true);
System.out.println("loop exit>>cnt val"+cnt); 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; modVat = ((totval * 2.5) / 100) * cnt;
System.out.println("((totval * 2.5) / 100) * cnt = "+ modVat); System.out.println("((totval * 2.5) / 100) * cnt = "+ modVat);
modVat = totval - modVat; modVat = totval - modVat;
System.out.println("totval - modVat = "+ 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 = ?"; sql11 = "select rtrim(var_value) from finparm where prd_code = ? and var_name = ?";
...@@ -1138,11 +1152,14 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -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); 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) if(acctCdPl != null && acctCdPl.trim().length() > 0)
{ {
...@@ -1165,6 +1182,23 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1165,6 +1182,23 @@ AssetSalesConfLocal,AssetSalesConfRemote
cctrCode = acctCctr[1]; 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 else
{ {
...@@ -1188,6 +1222,23 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1188,6 +1222,23 @@ AssetSalesConfLocal,AssetSalesConfRemote
cctrCode = acctCctr[1]; 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); String errshow = gbfAssetSalePost(tranId, transer, lineNo, conn);
...@@ -1241,15 +1292,50 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1241,15 +1292,50 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt = null; pstmt = null;
rs = null;*/ rs = null;*/
//Commented by sarita on 26 JUN 18 to use if condition to close rs and pstmt[END] //Commented by sarita on 26 JUN 18 to use if condition to close rs and pstmt[END]
//Modified by Anjali R. [05/07/18][Start]
//Modified by Anjali R. [04/06/18][Start]
if(errString != null && errString.trim().length() > 0 ) if(errString != null && errString.trim().length() > 0 )
{ {
return errString; 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; double profit = 0.0,loss = 0.0;
int updCount = 0; int updCount = 0;
sql = "select sum(amount_profit) as profit ,sum(amount_loss) as loss from asset_sales_det where tran_id = ?"; sql = "select sum(amount_profit) as profit ,sum(amount_loss) as loss from asset_sales_det where tran_id = ?";
...@@ -1272,23 +1358,19 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1272,23 +1358,19 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt.close(); pstmt.close();
pstmt = null; 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 = ?"; sql = "update asset_sales_hdr set amount_profit = ? ,amount_loss = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(profit)); pstmt.setDouble(1, Math.abs(profit));
pstmt.setDouble(2,Math.abs( loss)); pstmt.setDouble(2,Math.abs( loss));
pstmt.setString(3, tranId); pstmt.setString(3, tranId);
//pstmt.executeUpdate();
updCount = pstmt.executeUpdate(); updCount = pstmt.executeUpdate();
System.out.println(updCount + "Rows updated in asset_sales_hdr table against tran id --["+tranId +"] "); 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] if(pstmt != null)
/*pstmt.close(); {
pstmt = null;*/ pstmt.close();
if(pstmt != null) pstmt = null;
{ }
pstmt.close();
pstmt = null;
}
String errStr = gbfAssetSaleHDRPost(tranId , transer ,conn); String errStr = gbfAssetSaleHDRPost(tranId , transer ,conn);
System.out.println("errStr--["+errStr+"]"); System.out.println("errStr--["+errStr+"]");
if(errStr != null && errStr.trim().length() > 0) if(errStr != null && errStr.trim().length() > 0)
...@@ -1306,27 +1388,9 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1306,27 +1388,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
errString = itmdbAccess.getErrorString("",errCode , "", "", conn); errString = itmdbAccess.getErrorString("",errCode , "", "", conn);
return errString; return errString;
} }
//Added and Commented by sarita on 26 JUN 18 [End]
//} //Modified by Anjali R. [05/07/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]
sql = "update asset_sales_hdr set confirmed = ?,conf_date = ?,emp_code__aprv = ? where tran_id = ?"; sql = "update asset_sales_hdr set confirmed = ?,conf_date = ?,emp_code__aprv = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y"); pstmt.setString(1, "Y");
...@@ -1358,7 +1422,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1358,7 +1422,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
{ {
//done changes to rollback connection if exception occures on 29 JUN 18 SARITA[start] //done changes to rollback connection if exception occures on 29 JUN 18 SARITA[start]
System.out.println("AssetSalesConf:confirm..."+e.getMessage()); System.out.println("AssetSalesConf:confirm..."+e.getMessage());
e.printStackTrace(); e.printStackTrace();
try try
{ {
conn.rollback(); conn.rollback();
...@@ -1377,28 +1441,36 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1377,28 +1441,36 @@ AssetSalesConfLocal,AssetSalesConfRemote
+ e.getMessage()); + e.getMessage());
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e);*/ throw new ITMException(e);*/
} finally } finally
{ {
try { try {
//changes to check errString on 29 JUN 18 [START] //changes to check errString on 29 JUN 18 [START]
if (errString != null && errString.trim().length() > 0) if (errString != null && errString.trim().length() > 0)
{ {
System.out.println("--going to commit tranaction--"); System.out.println("--going to commit tranaction--");
if (errString.indexOf("VTCNFSUCC") > -1) if (errString.indexOf("VTCNFSUCC") > -1)
{ {
conn.commit(); conn.commit();
System.out.println("--transaction commited--"); System.out.println("--transaction commited--");
} }
else else
{ {
conn.rollback(); conn.rollback();
System.out.println("--transaction rollback--"); System.out.println("--transaction rollback--");
} }
} }
//changes to check errString on 29 JUN 18 [END] //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) { if (rs != null) {
rs.close(); rs.close();
rs = null; rs = null;
...@@ -1541,9 +1613,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1541,9 +1613,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
return calculatedDate; 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 lsErrcode = "", lsConfirm = "", lsTranId = "", lsAssetCode = "", lsSiteCode = "", lsFinEntity = "";
String lsCurrCode = "", lsItemSer = "", lsGrpCode = "", lsItemCode = "", lsRemarks = "", lsCustCode = ""; String lsCurrCode = "", lsItemSer = "", lsGrpCode = "", lsItemCode = "", lsRemarks = "", lsCustCode = "";
String lsBankCode = "", lsCrTerm = "", lsAcctCode = "", lsCctrCode1 = "", lsCctrCode = "", lsAcctAccCode = ""; String lsBankCode = "", lsCrTerm = "", lsAcctCode = "", lsCctrCode1 = "", lsCctrCode = "", lsAcctAccCode = "";
...@@ -1597,15 +1667,19 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -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, //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] //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, "+ " 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 ), "+ " (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, "+ " 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, "+ " 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.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 ) " " (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 = ?";*/ + "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 "+ */
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, "+ "(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, "+ "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 ), "+ " (case when b.amount_profit = 0 then 0 - b.amount_loss else b.amount_profit end ), "+
...@@ -1613,7 +1687,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1613,7 +1687,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
" b.acct_code__mod, b.cctr_code__mod, b.sale_type, b.deletion_amt_revl, "+ " 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.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 ) " " (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 = ?"; + "from asset_sales_hdr a,asset_sales_det b where a.tran_id = b.tran_id and b.tran_id = ? and b.line_no = ?";
//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, //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][End] //sale_amt,tax_amt and excreco_amt will be taken from detail table][End]
...@@ -1700,7 +1774,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1700,7 +1774,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
// Taking Original Value,Excise,WDV Amount from Asset Register // 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, " + 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 = ?"; " use_date, cctr_code, depr_amt_revl_2 from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lsAssetCode); pstmt.setString(1,lsAssetCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -1808,7 +1882,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -1808,7 +1882,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
lsAcctCode = lsAcctCode == null ? "" : lsAcctCode.trim(); lsAcctCode = lsAcctCode == null ? "" : lsAcctCode.trim();
System.out.println("lsCctrCode ["+lsCctrCode+"] \t lsAcctCode ["+lsAcctCode+"]"); System.out.println("lsCctrCode ["+lsCctrCode+"] \t lsAcctCode ["+lsAcctCode+"]");
if(lsAcctCode.length() == 0){ if(lsAcctCode.length() == 0){
lsErrcode = "VTACCTCD1"; lsErrcode = "VTACCTCD1";
return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling] return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling]
...@@ -2099,11 +2173,12 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2099,11 +2173,12 @@ AssetSalesConfLocal,AssetSalesConfRemote
return lsErrcode; 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 // 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 = new HashMap();
glReceivables.put("tran_ser",asTranser); glReceivables.put("tran_ser",asTranser);
...@@ -2137,13 +2212,20 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2137,13 +2212,20 @@ AssetSalesConfLocal,AssetSalesConfRemote
glReceivables.put("cust_ref_amt",""); glReceivables.put("cust_ref_amt","");
lsErrcode = finCommon.gbfReceivablesUpd(glReceivables,conn); 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; return lsErrcode;
} }
// Credit Sales Tax A/c // Credit Sales Tax A/c
if(lcTaxAmt != 0){ 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)" + 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"; " from taxtran where tran_code = ? and tran_id = ? group BY acct_code,cctr_code";
...@@ -2219,8 +2301,11 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2219,8 +2301,11 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt = null; pstmt = null;
} }
//Added by sarita on 26 JUN 18 [END] //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){ if(lcDeprAmtRevl2 != 0){
//Get Depr. reserv revalue account code //Get Depr. reserv revalue account code
lsCctrCodeDrrev = finCommon.getAcctDetrTtype(lsItemCode,lsItemSer,"DRREV",lsGrpCode,conn); lsCctrCodeDrrev = finCommon.getAcctDetrTtype(lsItemCode,lsItemSer,"DRREV",lsGrpCode,conn);
...@@ -2332,6 +2417,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2332,6 +2417,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
e1.printStackTrace(); e1.printStackTrace();
} }
isError = true; isError = true;
lsErrcode = "VTFASL0001";
System.out.println("Exception : : :==>\n"+e.getMessage()); System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
//throw new ITMException(e); //throw new ITMException(e);
...@@ -2344,6 +2430,9 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2344,6 +2430,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
if( conn != null ) 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 ) if( isError )
{ {
conn.rollback(); conn.rollback();
...@@ -2352,6 +2441,14 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2352,6 +2441,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
{ {
conn.commit(); 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) if(pstmt != null)
{ {
...@@ -2369,6 +2466,7 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2369,6 +2466,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
System.out.println("Exception : : :==>\n"+e.getMessage()); System.out.println("Exception : : :==>\n"+e.getMessage());
try try
{ {
lsErrcode = "VTFASL0001";
System.out.println("Before rollback"); System.out.println("Before rollback");
conn.rollback(); conn.rollback();
} }
...@@ -2382,462 +2480,18 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2382,462 +2480,18 @@ AssetSalesConfLocal,AssetSalesConfRemote
} }
return lsErrcode; return lsErrcode;
} }
//Added by Anjali R. on[04/06/18][Added method to post hdr level data only once][Start] private String saveData(String siteCode, String xmlString, Connection conn,String xtraParams) throws ITMException
public String gbfAssetSaleHDRPost(String asTranId, String asTranser , Connection conn) {
{ System.out.println(siteCode+"enter in save data xtra params in sitecode"+siteCode);
String lsTranId = "" , lsBankCode = "", lsCrTerm = "" ,lsErrcode = "" ,lsFinEntity = "", lsCreditPrd = ""; System.out.println("saving data...........");
String lsRemarks= "" ,lsCustCode = "" ,lsAcctCodeAr ="",lsCctrCodeAr = "" , lsCurrCode = "" , InitialContext ctx = null;
lsAcctCodeTax = "",lsCctrCodeTax = "" ,lsItemSer = "",lsSiteCode ="",lsAssetCode = ""; String retString = null;
MasterStatefulLocal masterStateful = null;
Timestamp ldTranDate = new java.sql.Timestamp(System.currentTimeMillis()) ; try
Timestamp ldEffDate = new java.sql.Timestamp(System.currentTimeMillis()) ; {
Timestamp ldUseDate = new java.sql.Timestamp(System.currentTimeMillis()) ; AppConnectParm appConnect = new AppConnectParm();
Timestamp ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ; ctx = new InitialContext(appConnect.getProperty());
Timestamp ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ; masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
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
{
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();
if(rs.next())
{
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;
// 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();
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))
{
lsErrcode = "VSENVAR1";
}
else
{
llCreditPrd = Integer.parseInt(lsCreditPrd);
}
}
// 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())
{
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())
{
lsFinEntity = rs.getString(1);
}
else
{
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)
{
return lsErrcode;
}
// Modified by Piyush on 03/07/2018[Error handling].End
// 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())
{
lsCurrCode = rs.getString(1);
}
else
{
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)
{
return lsErrcode;
}
// Modified by Piyush on 03/07/2018[Error handling].End
// 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;
// Modified by Piyush on 03/07/2018[Error Hndeling].Start
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
// Modified by Piyush on 03/07/2018[Error Hndeling].End
if(lcExchRate == 0)
{
lsErrcode = "VTEXCHRATE";
return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling]
}
// 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)
{
break;
}
}while(true);
// Modified by Piyush on 03/07/2018[To update sundry bal same as PB code of asset single confirmation].Start
glTrace = new HashMap();
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);
if(lcTotalAmt >= 0)
{
glTrace.put("dr_amt",lcTotalAmt);
glTrace.put("cr_amt",0.0);
}
else
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",0.0 - lcTotalAmt);
}
glTrace.put("adv_amt",0.0);
String lsContCode = finCommon.getContactCode("C" , lsCustCode , conn);
lsErrcode = finCommon.gbf_sundrybal_upd(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
// 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;
}
// 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,asTranser);
pstmt.setString(2,lsTranId);
rs = pstmt.executeQuery();
while(rs.next())
{
lsAcctCodeTax = rs.getString(1);
lsCctrCodeTax = rs.getString(2);
lnAmountTax = rs.getDouble(3);
if(lnAmountTax != 0)
{
if(lsAcctCodeTax == null || lsAcctCodeTax.length() == 0)
{
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;
}
glTrace = new HashMap();
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)
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",lnAmountTax);
}
else
{
glTrace.put("dr_amt",0.0 - lnAmountTax);
glTrace.put("cr_amt", 0.0);
}
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)
{
return lsErrcode;
}
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
isError = true;
System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
if( isError )
{
conn.rollback();
}
else
{
conn.commit();
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
}
catch(Exception e)
{
System.out.println("Exception : : :==>\n"+e.getMessage());
try
{
System.out.println("Before rollback");
conn.rollback();
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
//throw new ITMException(e);
}
}
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
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
String [] authencate = new String[2]; String [] authencate = new String[2];
authencate[0] = ""; authencate[0] = "";
...@@ -2896,265 +2550,688 @@ AssetSalesConfLocal,AssetSalesConfRemote ...@@ -2896,265 +2550,688 @@ AssetSalesConfLocal,AssetSalesConfRemote
} }
return retString; return retString;
} }
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [START] //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 forcedFlag, Connection conn) throws ITMException
public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String xmlTabString, String finalXmlString, Connection conn) throws ITMException public String confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String xmlTabString, String finalXmlString, Connection conn) throws ITMException
{
//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 >>>");
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,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)
{
pstmt.close();
pstmt=null;
}
// 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,serviceCode);
rs = pstmt.executeQuery();
if ( 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)
{
rs.close();
rs=null;
}
if (pstmt != null)
{
pstmt.close();
pstmt=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];
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))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compType);
}
else if("COMPONENT_NAME".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compName);
}
else if(argName.startsWith("TAB_"))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xmlTabString);
}
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)
{
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);
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)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
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();
}catch (Exception s)
{
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
}
return retString;
}
//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)
{
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()+"]");
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);
if("error".equalsIgnoreCase(childNode.getNodeName()))
{
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)
{
e.printStackTrace();
System.out.println("Error Inside Method [getErrorTypeVal] is "+e);
}
return sh;
}
//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][Start]
public String gbfAssetSaleHDRPost(String asTranId, String asTranser , Connection conn)
{ {
//Commented and added by sarita on 19 JUN 18 to add xmlTabString & finalXmlString parameter [END] String lsTranId = "" , lsBankCode = "", lsCrTerm = "" ,lsErrcode = "" ,lsFinEntity = "", lsCreditPrd = "";
String methodName = ""; String lsRemarks= "" ,lsCustCode = "" ,lsAcctCodeAr ="",lsCctrCodeAr = "" , lsCurrCode = "" ,
String compName = ""; lsAcctCodeTax = "",lsCctrCodeTax = "" ,lsItemSer = "",lsSiteCode ="",lsAssetCode = "";
String retString = "";
String serviceCode = ""; Timestamp ldTranDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
String serviceURI = ""; Timestamp ldEffDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
String actionURI = ""; Timestamp ldUseDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
String sql = ""; Timestamp ldDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
PreparedStatement pstmt = null; Timestamp ldDueDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
ResultSet rs = null; ResultSet rs = null;
String compType = "",argName = "",argName1 = ""; //Added by sarita on 14 JUN 18 PreparedStatement pstmt = null;
HashMap<String , String> getArgName = new HashMap<String , String>(); ResultSet rs2 = null;
int i = 0; PreparedStatement pstmt2 = null;
//System.out.println("confirmJournalVoucher(String businessObj, String tranIdFr,String xtraParams, String forcedFlag, Connection conn) called >>>"); 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 try
{ {
//ConnDriver connDriver = new ConnDriver(); lsTranId = asTranId;
//conn = connDriver.getConnectDB("DriverITM");
//Commented by sarita on 19 JUN 18 as methodName will come from table. [START] sql = "SELECT a.tran_date , a.total_amt, a.sale_amt , a.tax_amt ,"
//methodName = "gbf_post"; + " a.cust_code, c.acct_code__ar, c.cctr_code__ar, "
//actionURI = "http://NvoServiceurl.org/" + methodName; + " a.excreco_amt ,b.asset_code FROM asset_sales_hdr a,customer c ,asset_sales_det b"
//Commented by sarita on 19 JUN 18 as methodName will come from table. [END] + " WHERE a.cust_code = c.cust_code and b.tran_id = a.tran_id and a.tran_id = ?";
//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 = conn.prepareStatement(sql);
pstmt.setString(1,businessObj); pstmt.setString(1,asTranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() )
if(rs.next())
{ {
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME"); ldTranDate = rs.getTimestamp(1);
compType = rs.getString("COMP_TYPE"); lcTotalAmt = rs.getDouble(2);
} lcSaleAmt = rs.getDouble(3);
//System.out.println("serviceCode = "+serviceCode+" compName "+compName); lcTaxAmt = rs.getDouble(4);
System.out.println("serviceCode = "+serviceCode+" compName "+compName + "compType "+compType); lsCustCode = rs.getString(5);
// Changed by Manish on 01/04/16 for max cursor issue [start] lsAcctCodeAr = rs.getString(6);
if (rs !=null) lsCctrCodeAr = rs.getString(7);
lcExcrecoAmt = rs.getDouble(8);
lsAssetCode = rs.getString(9);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
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())
{ {
rs.close(); llCreditPrd = rs.getLong(1);
rs=null; lsBankCode = rs.getString(2);
lsCrTerm = rs.getString(3);
} }
if (pstmt != null) rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(llCreditPrd == -99)
{ {
pstmt.close(); lsCreditPrd = finCommon.getFinparams("999999","DEF_CR_TERM", conn);
pstmt=null; lsCreditPrd = lsCreditPrd == null ? "" : lsCreditPrd.trim();
} if("NULLFOUND".equals(lsCreditPrd))
// 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] lsErrcode = "VSENVAR1";
}
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [START] else
//sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; {
sql = "SELECT SERVICE_URI,METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; llCreditPrd = Integer.parseInt(lsCreditPrd);
}
}
// 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())
{
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 = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode); pstmt.setString(1,lsSiteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if ( rs.next() )
if(rs.next())
{ {
serviceURI = rs.getString("SERVICE_URI"); lsFinEntity = rs.getString(1);
methodName = rs.getString("METHOD_NAME");
} }
//System.out.println("serviceURI = "+serviceURI+" compName = "+compName); else
System.out.println("serviceURI = "+serviceURI+" compName = "+compName+" methodName ="+methodName);
// Changed by Manish on 01/04/16 for max cursor issue [start]
if (rs !=null)
{ {
rs.close(); lsErrcode = "VTFINENT";
rs=null;
} }
if (pstmt != null) rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{ {
pstmt.close(); return lsErrcode;
pstmt=null; }
}
// Changed by Manish on 01/04/16 for max cursor issue [end] // Checking Currency Code
//Commented and Added by sarita to add method_name in query on 19 JUN 18 [END] sql = "select curr_code from finent where fin_entity = ?";
//Commented and Added by sarita on 19 JUN 18 to dynamic call [START] pstmt = conn.prepareStatement(sql);
actionURI = "http://NvoServiceurl.org/" + methodName; pstmt.setString(1,lsFinEntity);
Service service = new Service(); rs = pstmt.executeQuery();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI)); if(rs.next())
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) ); {
call.setUseSOAPAction(true); lsCurrCode = rs.getString(1);
call.setSOAPActionURI(actionURI); }
Object[] aobj = new Object[5]; else
{
if("WSR".equalsIgnoreCase(compType)) lsErrcode = "VTCURFIN";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
// 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;
}
if(lcExchRate == 0)
{
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;
if(ldDate.after(ldTranDate) || ldDate == ldTranDate)
{
break;
}
}while(true);
glTrace = new HashMap();
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);
if(lcTotalAmt >= 0)
{
glTrace.put("dr_amt",lcTotalAmt);
glTrace.put("cr_amt",0.0);
}
else
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",0.0 - lcTotalAmt);
}
glTrace.put("adv_amt",0.0);
String lsContCode = finCommon.getContactCode("C" , lsCustCode , conn);
lsErrcode = finCommon.gbf_sundrybal_upd(glTrace,conn);
if(lsErrcode != null && lsErrcode.trim().length() > 0)
{
return lsErrcode;
}
// 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","");
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)
{
return lsErrcode;
}
// Credit Sales Tax A/c
if(lcTaxAmt != 0)
{ {
sql = "SELECT ARG_NAME FROM SYSTEM_SERVICE_ARGS WHERE SERVICE_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";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode); pstmt.setString(1,asTranser);
pstmt.setString(2,asTranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while ( rs.next() )
while(rs.next())
{ {
argName = rs.getString("ARG_NAME"); argName1 = argName.toLowerCase().trim(); lsAcctCodeTax = rs.getString(1);
if("COMPONENT_TYPE".equalsIgnoreCase(argName)) lsCctrCodeTax = rs.getString(2);
{ lnAmountTax = rs.getDouble(3);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compType); if(lnAmountTax != 0)
}
else if("COMPONENT_NAME".equalsIgnoreCase(argName))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(compName);
}
else if(argName.startsWith("TAB_"))
{
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN);
aobj[i] = new String(xmlTabString);
}
else if("DUMMY".equalsIgnoreCase(argName))
{ {
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", argName1), XMLType.XSD_STRING, ParameterMode.IN); if(lsAcctCodeTax == null || lsAcctCodeTax.length() == 0)
aobj[i] = new String(""); {
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;
}
glTrace = new HashMap();
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)
{
glTrace.put("dr_amt",0.0);
glTrace.put("cr_amt",lnAmountTax);
}
else
{
glTrace.put("dr_amt",0.0 - lnAmountTax);
glTrace.put("cr_amt", 0.0);
}
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)
{
return lsErrcode;
}
} }
else if("XTRA_PARAMS".equalsIgnoreCase(argName)) }
{ if(rs != null)
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)
{ {
rs.close(); rs.close();
rs=null; rs = null;
} }
if (pstmt != null) if(pstmt != null)
{ {
pstmt.close(); 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) catch(Exception e)
{ {
try
{
conn.rollback();
}
catch (SQLException e1)
{
e1.printStackTrace();
}
isError = true;
lsErrcode = "VTFASL0002";
System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e);
} }
finally finally
{ {
try{ try
{
System.out.println("isError ["+isError+"]");
if (pstmt != null ) if( conn != null )
{
if( isError || (lsErrcode != null && lsErrcode.trim().length() > 0))
{
conn.rollback();
}
}
if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if (rs !=null) if(pstmt2 != null)
{ {
rs.close(); pstmt2.close();
rs=null; pstmt2 = null;
} }
/*if( conn != null ){
conn.close();
conn = null;
}*/
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception inCalling confirmed"); System.out.println("Exception : : :==>\n"+e.getMessage());
e.printStackTrace(); try
try{
conn.rollback();
}catch (Exception s)
{ {
System.out.println("Unable to rollback"); System.out.println("Before rollback");
s.printStackTrace(); conn.rollback();
} }
throw new ITMException(e);
}
} catch(SQLException sqle)
return retString;
}
//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)
{
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()+"]");
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(sqle);
if("error".equalsIgnoreCase(childNode.getNodeName()))
{
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);
}
} }
} //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] //Added by sarita to get Error Code from errorString on 03 JUL 18 [START]
private String getErrorId(String retXml) 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