Commit 51018833 authored by arawankar's avatar arawankar

Added new method as gbfAssetSalesHDRPost to post header level data once.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187258 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e0156eee
......@@ -1241,13 +1241,46 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt = null;
rs = null;*/
//Commented by sarita on 26 JUN 18 to use if condition to close rs and pstmt[END]
if(proLoss > 0)
//Modified by Anjali R. [04/06/18][Start]
if(errString != null && errString.trim().length() > 0 )
{
sql= "update asset_sales_hdr set amount_profit = ? where tran_id = ?";
return errString;
}
//if(proLoss > 0)
//{
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 = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, Math.abs(proLoss));
pstmt.setString(2, tranId);
pstmt.executeUpdate();
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
profit = rs.getDouble("profit");
loss = rs.getDouble("loss");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
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;*/
......@@ -1256,25 +1289,43 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt.close();
pstmt = null;
}
//Added and Commented by sarita on 26 JUN 18 [START]
String errStr = gbfAssetSaleHDRPost(tranId , transer ,conn);
System.out.println("errStr--["+errStr+"]");
if(errStr != null && errStr.trim().length() > 0)
{
errString = itmdbAccess.getErrorString("", errStr, "", "", conn);
return errString;
}
else
errStr = finCommon.checkGlTranDrCr(transer, tranId, conn);
System.out.println("errCode---["+errStr+"]");
if(errStr != null && errStr.trim().length() > 0)
{
sql = "update asset_sales_hdr set amount_loss = ? where tran_id = ?";
errCode = getErrorId(errStr);
System.out.println("errCode--["+errCode+"]");
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;*/
pstmt.close();
pstmt = null;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added and Commented by sarita on 26 JUN 18 [START]
}
}*/
//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 = ?";
pstmt=conn.prepareStatement(sql);
......@@ -1490,7 +1541,9 @@ 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 = "";
......@@ -1542,14 +1595,27 @@ AssetSalesConfLocal,AssetSalesConfRemote
lsTranId = asTranId;
String sql = "select a.tran_date , a.confirmed, a.total_amt, "+
//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, "+
" 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 "+
"(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 ), "+
" b.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 = ?";
//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]
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,asTranId);
......@@ -1595,7 +1661,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
lsRemarks = "On Sale of Asset :- " + lsAssetCode;
ldEffDate = ldTranDate;
sql = "select coalesce(credit_prd,0), bank_code, cr_term from customer where cust_code = ?";
// Modified by Piyush on 03/07/201/
//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);
......@@ -1611,10 +1679,14 @@ AssetSalesConfLocal,AssetSalesConfRemote
pstmt.close();
pstmt = null;
if(llCreditPrd == 0){
// 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)){
if("NULLFOUND".equals(lsCreditPrd))
{
lsErrcode = "VSENVAR1";
}else{
llCreditPrd = Integer.parseInt(lsCreditPrd);
......@@ -1668,6 +1740,13 @@ AssetSalesConfLocal,AssetSalesConfRemote
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
// Checking Currency Code
sql = "select curr_code from finent where fin_entity = ?";
......@@ -1685,6 +1764,13 @@ AssetSalesConfLocal,AssetSalesConfRemote
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
// Checking Exchange Rate
sql = "select std_exrt from currency where curr_code = ?";
......@@ -1702,8 +1788,16 @@ AssetSalesConfLocal,AssetSalesConfRemote
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]
}
lsCctrCode = finCommon.getAcctDetrTtype(lsItemCode,lsItemSer,"FA",lsGrpCode,conn);
......@@ -1717,6 +1811,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
if(lsAcctCode.length() == 0){
lsErrcode = "VTACCTCD1";
return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling]
}
if(lsCctrCode1.length() > 0){
......@@ -1731,6 +1826,7 @@ AssetSalesConfLocal,AssetSalesConfRemote
if(lsAcctAccCode.length() == 0){
lsErrcode = "VTACCTCD1";
return lsErrcode; // Modified by Piyush on 03/07/2018[Error Hndeling]
}
if(lsCctrCode1.trim().length() > 0){
......@@ -1792,9 +1888,17 @@ AssetSalesConfLocal,AssetSalesConfRemote
lcModAmt = lcExcrecoAmt;
}
if(lsCctrCode1.length() > 0){
// Modified by Piyush on 03/07/2018
// if(lsCctrCode1.length() > 0)
if(lsCctrCode1 != null && lsCctrCode1.trim().length() > 0)
{
lsCctrCodeAr = lsCctrCode1;
}else if(lsCctrCodeAr == null || lsCctrCodeAr.length() == 0){
}
// Modified by Piyush on 03/07/2018
//else if(lsCctrCodeAr == null || lsCctrCodeAr.length() == 0){
else
{
lsCctrCodeAr = "";
}
......@@ -1827,7 +1931,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,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;
}
......@@ -1860,7 +1967,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,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;
}
......@@ -1901,7 +2011,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,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;
}
......@@ -1935,7 +2048,10 @@ AssetSalesConfLocal,AssetSalesConfRemote
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,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;
}
......@@ -1976,11 +2092,16 @@ AssetSalesConfLocal,AssetSalesConfRemote
glTrace.put("ref_id",lsTranId);
lsErrcode = finCommon.glTraceUpdate(glTrace,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;
}
//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();
glReceivables = new HashMap();
......@@ -2098,8 +2219,8 @@ 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]
if(lcDeprAmtRevl2 != 0){
//Get Depr. reserv revalue account code
lsCctrCodeDrrev = finCommon.getAcctDetrTtype(lsItemCode,lsItemSer,"DRREV",lsGrpCode,conn);
......@@ -2197,7 +2318,9 @@ AssetSalesConfLocal,AssetSalesConfRemote
/* if(gbf_post_online() == "Y"){
lsErrcode = finComman.checkGlTranDrCr(asTranser, lsTranId, conn);
}*/
lsErrcode = finCommon.checkGlTranDrCr(asTranser, lsTranId, conn);
//Modified by Anjali R. on [04/07/2018][All records will post after header level posting is done][Start]
//lsErrcode = finCommon.checkGlTranDrCr(asTranser, lsTranId, conn);
//Modified by Anjali R. on [04/07/2018][All records will post after header level posting is done][End]
//}while(true);
}catch(Exception e){
......@@ -2259,7 +2382,449 @@ 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)
{
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;
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
{
......
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