Commit 6bd59d3b authored by vvengurlekar's avatar vvengurlekar

AssetInstallConf.java

AssetInstallConfLocal.java
AssetInstallConfRemote.java
FixedAssetCommon.java -  asset install confirmation migration done in java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194308 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 17af2db3
/********************************************************
Title : AssetInstallConf []
Date : 13/Nov/18
Developer: Varsha Vengurlekar.
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Arrays;
import javax.ejb.Stateless;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
@Stateless
public class AssetInstallConf extends ActionHandlerEJB implements BankGauranteeAmdConfLocal,BankGauranteeAmdConfRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{
FixedAssetCommon fixedAssetCom = new FixedAssetCommon();
String sql = "";
String confirmed = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String errString = "", errorCode = "";
FinCommon Fcommon = new FinCommon();
try
{
System.out.println("In AssetInstallConf Confirmation Process >>>>>>>>>>>>>> ");
conn = getConnection();
System.out.println("Getting Tran_ID=============="+tranId);
sql = "select confirmed from asset_install where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
confirmed = checkNull(rs.getString("confirmed"));
}
else
{
System.out.println("transaction does not exist");
errString = itmDBAccessEJB.getErrorString("","VTMCONF20","","",conn);
return errString;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ("Y".equalsIgnoreCase(confirmed))
{
System.out.println("transaction already confirmed");
errString = itmDBAccessEJB.getErrorString("","VTASST1","");
return errString;
}
errString = fixedAssetCom.assetInstallPost(tranId, xtraParams, conn);
System.out.println("errorCode from FixedAssetCommon:::: ["+errorCode+"]");
if(errString == null || errString.trim().length() == 0)
{
System.out.println("Commit called..........");
errString = itmDBAccessEJB.getErrorString("","VTEDCCONF4","");
conn.commit();
}
else
{
System.out.println("Rollback called..........");
conn.rollback();
return errString;
}
}
catch( Exception e )
{
System.out.println("AssetInstallConf..."+e.getMessage());
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("AssetInstallConf..."+e1.getMessage());
e1.printStackTrace();
throw new ITMException(e1);
}
throw new ITMException(e);
}
finally
{
try
{
if( conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception : "+e);
e.printStackTrace();
}
}
System.out.println("In AssetInstallConf errString is : "+errString);
return errString ;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
}
\ No newline at end of file
/********************************************************
Title : BankGauranteeAmdConfLocal [F15DSUN031]
Date : 10/AUG/15
Developer: Priyanka Shinde.
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface AssetInstallConfLocal extends ActionHandlerLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/********************************************************
Title : BankGauranteeAmdConfRemote [F15DSUN031]
Date : 10/AUG/15
Developer: Priyanka Shinde.
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface AssetInstallConfRemote extends ActionHandlerRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin.adv;
import java.sql.Connection;
//import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import ibase.planner.utility.ITMException;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
public class FixedAssetCommon
{
@SuppressWarnings("unchecked")
public String assetInstallPost(String tranId, String xtraParams, Connection conn) throws ITMException
{
String errString = "", sql = "";
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
DistCommon disCommon = new DistCommon();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
SimpleDateFormat sdf = null;
String currentDate = "", tranSeries = "", assetCode = "", tranType = "", invOnline = "";
int count = 0;
Timestamp currentTm = null;
PreparedStatement pstmt = null, pstmtCopy = null, pstmtIn = null;
ResultSet rs = null, rsCopy = null, rsIn = null;
UtilMethods utilsMethod = new UtilMethods();
String siteCode = "", alocCode = "", assetType = "", descr = "", remark = "", empCode = "", currCode = "", itemCode = "", currCodeInst = "",
cctrCode = "", acctCodeInst = "", cctrCodeInst = "", assetCodePar = "", excTaxCode = "", assetInstallTax = "",
groupCode = "", assetSaleType = "", acctCodeEmp = "", cctrCodeEmp = "", usefulLife = "", residualVal = "", octroiChgs = "",
commChgs = "", assetClass = "", finEntity = "", itemSeries = "", octroiVarValue = "", commVarValue = "",
cctrAcctFin = "", method1 = "", acctCodeFin = "", cctrCodeFin = "", commVarValue1 = "", assetSource = "";
String[] acctCctrPl;
int updCnt = 0;
double exchRate = 0.0, exchRateInst = 0.0, excrecoAmt = 0.0, installChgs = 0.0, originalValue = 0.0, totTotalValue = 0;
//Date tranDate = null;
Timestamp tranDate = null;
Timestamp useDate = null;
String billNo = "", suppCode = "", suppName = "", tranIdRcp = "", lineNoRcp = "", lotNo = "", keyString = "",
lineNo = "", assetCodeDet = "", userid = "", termid = "", assetCodeFr = "";
double quantity = 0.0, rate = 0.0, taxAmt = 0.0, taxRecoAmt = 0.0, exciseAmt = 0.0, excrecoAmtDet = 0.0,
quantityPoRcp = 0.0, totalQty = 0.0, registerQuantity = 0.0, originalValueDet = 0.0, totalValue = 0.0;
Timestamp rcpDate = null, billDate = null, instDate = null;
HashMap glTrace = null;
UtilMethods utilMethods = new UtilMethods();
try
{
userid = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termid = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currentDate = sdf.format(new java.util.Date());
currentTm = Timestamp.valueOf(genericUtility.getValidDateString(currentDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
tranSeries = "P-RCP";
sql = "select asset_code, tran_type from asset_install where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
assetCode = checkNull(rs.getString("asset_code"));
tranType = checkNull(rs.getString("tran_type"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(tranType == null || tranType.trim().length() == 0)
{
tranType = " ";
}
count = 0;
sql = "select count(1) as registerCount from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, assetCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("registerCount");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count > 0)
{
if(!(tranType.equalsIgnoreCase("W")))
{
errString = itmDBAccessEJB.getErrorString("","VTASST1","","",conn);
return errString;
}
}
invOnline = checkNull(finCommon.getFinparams("999999", "INV_ACCT_FAINST", conn));
if(invOnline.equalsIgnoreCase("NULLFOUND"))
{
errString = itmDBAccessEJB.getErrorString("","VTFINPARM","","",conn);
return errString;
}
invOnline = utilsMethod.left(invOnline, 1); System.out.println("INVONLINE ["+invOnline+"]");
//if("Y_N".indexOf(invOnline) == -1)
if (!"Y".equals(invOnline) && !"N".equals(invOnline))
{
errString = itmDBAccessEJB.getErrorString("","VTFINPARM1","","",conn);
return errString;
}
sql = "select site_code, aloc_code, asset_type, descr, remarks, emp_code, curr_code, item_code, curr_code__inst, " +
"exch_rate, exch_rate__inst, original_value, install_chgs, tran_date, use_date, cctr_code, acct_code__inst, cctr_code__inst, " +
"asset_code__par, excreco_amt, grp_code, inst_date, asset_sale_type, acct_code__emp, " +
"cctr_code__emp, useful_life, residual_val, octroi_chgs, comm_chgs, asset_class from asset_install where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
siteCode = checkNull(rs.getString("site_code"));
alocCode = checkNull(rs.getString("aloc_code"));
assetType = checkNull(rs.getString("asset_type"));
descr = checkNull(rs.getString("descr"));
remark = checkNull(rs.getString("remarks"));
empCode = checkNull(rs.getString("emp_code"));
currCode = checkNull(rs.getString("curr_code"));
itemCode = checkNull(rs.getString("item_code"));
currCodeInst = checkNull(rs.getString("curr_code__inst"));
exchRate = rs.getDouble("exch_rate");
exchRateInst = rs.getDouble("exch_rate__inst");
originalValue= rs.getDouble("original_value");
installChgs = rs.getDouble("install_chgs");
//tranDate = rs.getDate("tran_date");
tranDate = rs.getTimestamp("tran_date");
useDate = rs.getTimestamp("use_date");
cctrCode = checkNull(rs.getString("cctr_code"));
acctCodeInst = checkNull(rs.getString("acct_code__inst"));
cctrCodeInst = checkNull(rs.getString("cctr_code__inst"));
assetCodePar = checkNull(rs.getString("asset_code__par"));
excrecoAmt = rs.getDouble("excreco_amt");
groupCode = checkNull(rs.getString("grp_code"));
instDate = rs.getTimestamp("inst_date");
assetSaleType= checkNull(rs.getString("asset_sale_type"));
acctCodeEmp = checkNull(rs.getString("acct_code__emp"));
cctrCodeEmp = checkNull(rs.getString("cctr_code__emp"));
usefulLife = checkNull(rs.getString("useful_life"));
residualVal = checkNull(rs.getString("residual_val"));
octroiChgs = checkNull(rs.getString("octroi_chgs"));
commChgs = checkNull(rs.getString("comm_chgs"));
assetClass = checkNull(rs.getString("asset_class"));
}
else
{
errString = itmDBAccessEJB.getErrorString("","DS000100","","",conn);
return errString;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(assetClass == null || assetClass.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTASTCLSNL","","",conn);
return errString;
}
sql = "select fin_entity from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
finEntity = checkNull(rs.getString("fin_entity"));
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTFINENT1","","",conn);
return errString;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(!(tranType.equalsIgnoreCase("W")))
{
String errorCode = assetStockUpd(tranId, siteCode, "AI", xtraParams, conn);
if(errorCode != null && errorCode.trim().length() > 0)
{
errString = itmDBAccessEJB.getErrorString("",errorCode,"","",conn);
return errString;
}
}
sql = "select item_ser from item where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemSeries = checkNull(rs.getString("item_ser"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
totTotalValue = 0.0;
octroiVarValue = "";
octroiVarValue = checkNull(finCommon.getFinparams("999999", "ASSET_REGISTER_OCTROI_TAXCODE", conn));
if(octroiVarValue.trim().length() > 0 && octroiVarValue.equalsIgnoreCase("NULLFOUND"))
{
octroiVarValue = gfgetSqlInString(octroiVarValue, conn);
System.out.println("ASSET_REGISTER_OCTROI_TAXCODE :: ["+octroiVarValue+"]");
}
/*if(octroiVarValue.trim().length() > 0 && octroiVarValue.equalsIgnoreCase("NULLFOUND"))
{
String[] octroiArray = octroiVarValue.split(",");
String octoroiTemp = "";
octroiVarValue = "";
for (int ctr = 0; ctr < octroiArray.length; ctr++)
{
octoroiTemp = octroiArray[ctr];
octroiVarValue = octroiVarValue + "'".concat(octoroiTemp).concat("',");
}
}
else
{
octroiVarValue = "";
}*/
commVarValue = checkNull(finCommon.getFinparams("999999", "ASSET_REGISTER_COMM_TAXCODE", conn));
if(commVarValue.trim().length() > 0 && commVarValue.equalsIgnoreCase("NULLFOUND"))
{
commVarValue = gfgetSqlInString(commVarValue, conn);
System.out.println("ASSET_REGISTER_COMM_TAXCODE :: ["+commVarValue+"]");
}
/*if(commVarValue.trim().length() > 0 && commVarValue.equalsIgnoreCase("NULLFOUND"))
{
String[] taxArray = commVarValue.split(",");
String taxTemp = "";
commVarValue = "";
for (int ctr = 0; ctr < taxArray.length; ctr++)
{
taxTemp = taxArray[ctr];
commVarValue = commVarValue + "'".concat(taxTemp).concat("',");
}
}
else
{
commVarValue = "";
}*/
billNo = ""; suppCode = ""; suppName = ""; tranIdRcp = ""; lineNoRcp = ""; lotNo = "";
originalValueDet = 0.0; lineNo = ""; assetCodeDet = "";
quantity = 0.0; rate = 0.0; taxAmt = 0.0; taxRecoAmt = 0.0; exciseAmt = 0.0; excrecoAmtDet = 0.0;
rcpDate = null; billDate = null;
count = 0;
sql = "Select bill_no, rcp_date, supp_code, supp_name, tran_id__rcp, line_no__rcp, lot_no, rate, quantity, " +
" tax_amt, tax_reco_amt, excise_amt, original_value, line_no, asset_code, bill_date, excreco_amt " +
" from asset_installdet where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
count++;
billNo = checkNull(rs.getString("bill_no"));
rcpDate = rs.getTimestamp("rcp_date");
suppCode = checkNull(rs.getString("supp_code"));
suppName = checkNull(rs.getString("supp_name"));
tranIdRcp = checkNull(rs.getString("tran_id__rcp"));
lineNoRcp = checkNull(rs.getString("line_no__rcp"));
rate = rs.getDouble("rate");
quantity = rs.getDouble("quantity");
taxAmt = rs.getDouble("tax_amt");
taxRecoAmt = rs.getDouble("tax_reco_amt");
exciseAmt = rs.getDouble("excise_amt");
originalValueDet= rs.getDouble("original_value");
lineNo = checkNull(rs.getString("line_no"));
lotNo = checkNull(rs.getString("lot_no"));
assetCodeDet = checkNull(rs.getString("asset_code"));
billDate = rs.getTimestamp("bill_date");
excrecoAmtDet = rs.getDouble("excreco_amt");
if(assetCodeDet == null || assetCodeDet.trim().length() == 0)
{
sql = "Select key_string from transetup where upper(tran_window) = 'W_ASSET_REGISTER'";
pstmtCopy = conn.prepareStatement(sql);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
keyString = checkNull(rsCopy.getString("key_string"));
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTSEQ","","",conn);
break;
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
String xmlValues = "";
xmlValues = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<asset_code></asset_code>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<item_ser>" + itemSeries + "</item_ser>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :[" + xmlValues + "]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
assetCode = tg.generateTranSeqID("ASSREG", "asset_code", keyString, conn);
System.out.println("Generated Asset Code::["+assetCode+"]");
if(assetCode == null || assetCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTASSETCD","","",conn);
break;
}
else
{
sql = "update asset_install set asset_code = ? where tran_id = ? ";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, assetCode);
pstmtCopy.setString(2, tranId);
updCnt = pstmtCopy.executeUpdate();
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(updCnt > 0)
{
sql = "update asset_installdet set "
+ "asset_code = ? "
+ "where tran_id = ? "
+ "and line_no = ?";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, assetCode);
pstmtCopy.setString(2, tranId);
pstmtCopy.setString(3, lineNo);
updCnt = pstmtCopy.executeUpdate();
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
}
}
if(!(tranType.equalsIgnoreCase("W")) && (tranIdRcp != null && tranIdRcp.trim().length() > 0))
{
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3);
System.out.println(" lineNoRcp ["+lineNoRcp+"]");
quantityPoRcp = 0.0;
sql = "select sum(quantity) as porcp_qty "
+ "from porcpdet "
+ "where tran_id = ? "
+ "and line_no = ?";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, tranIdRcp);
pstmtCopy.setString(2, lineNoRcp);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
quantityPoRcp = rsCopy.getDouble("porcp_qty");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
System.out.println("ItemCode is["+itemCode+"]\t ItemSeries is["+itemSeries+"]\t GroupCode is["+groupCode+"]");
cctrAcctFin = finCommon.getAcctDetrTtype(itemCode, itemSeries, "FA", groupCode, conn);
System.out.println("cctrAcctFin>>>>>>> ["+cctrAcctFin+"]");
if(cctrAcctFin.equals(" , ") || cctrAcctFin.equals(","))
{
acctCodeFin = "";
}
else
{
acctCctrPl = cctrAcctFin.split(",");
acctCodeFin = acctCctrPl[0];
System.out.println(">>>>123112"+acctCctrPl[0] + "\t ["+acctCodeFin+"]");
}
if(acctCodeFin == null || acctCodeFin.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTACCTCD1","","",conn);
break;
}
if(cctrCode == null || cctrCode.trim().length() == 0)
{
cctrCodeFin = " ";
}
else
{
cctrCodeFin = cctrCode;
}
totalQty = 0.0;
if(!(tranType.equalsIgnoreCase("W")) && (tranIdRcp != null && tranIdRcp.trim().length() > 0))
{
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3); System.out.println("lineNoRcp ["+lineNoRcp+"]");
sql = "select b.quantity as reg_quantity from asset_install a, asset_installdet b, asset_register c " +
" where a.tran_id = b.tran_id and c.asset_code = a.asset_code " +
" and b.tran_id__rcp = ? and b.line_no__rcp = ?";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, tranIdRcp);
pstmtCopy.setString(2, lineNoRcp);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
registerQuantity = rsCopy.getDouble("reg_quantity");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
System.out.println("121 totalQty["+totalQty+"]\t registerQuantity["+registerQuantity+"]\t quantity["+quantity+"]");
totalQty = registerQuantity + quantity;
if(totalQty > quantityPoRcp)
{
errString = itmDBAccessEJB.getErrorString("","VTPORCPQTY","","",conn);
break;
}
}
taxRecoAmt = taxRecoAmt * exchRate;
excrecoAmtDet = excrecoAmtDet * exchRate;
totalValue = (originalValueDet * exchRate) + (installChgs * exchRateInst);
originalValue = (quantity * rate) * exchRate;
taxAmt = taxAmt * exchRate;
totTotalValue = totTotalValue + (originalValueDet + installChgs);
System.out.println("taxRecoAmt ["+taxRecoAmt+"] \n excrecoAmtDet ["+excrecoAmtDet+"] \n "
+ "totalValue ["+totalValue+"] \n originalValue ["+originalValue+"] \n"
+ "taxAmt ["+taxAmt+"] \n totTotalValue ["+totTotalValue+"]");
method1 = checkNull(finCommon.getFinparams("999999", "FA_METHOD_IT", conn));
if(method1.equalsIgnoreCase("NULLFOUND"))
{
errString = itmDBAccessEJB.getErrorString("","VTDEPRMTD1","","",conn);
break;
}
int deprPerc1 = 0;
sql = "select depr_perc as depr_perc_1 from depr_itemgrp " +
" where item_grp = ? and depr_method = ? " +
" and purpose = 'I' and ? between eff_from and valid_upto " +
" and depr_type = 'N'";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, groupCode);
pstmtCopy.setString(2, method1);
pstmtCopy.setTimestamp(3, useDate);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
deprPerc1 = rsCopy.getInt("depr_perc_1");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(deprPerc1 <= 0)
{
deprPerc1 = 0;
sql = "select depr_perc as depr_perc_1 from depr_itemser " +
" where item_ser = ? and depr_method = ? " +
"and purpose = 'I' and ? between eff_from and valid_upto";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, itemSeries);
pstmtCopy.setString(2, method1);
pstmtCopy.setTimestamp(3, useDate);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
deprPerc1 = rsCopy.getInt("depr_perc_1");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
commVarValue1 = checkNull(finCommon.getFinparams("999999", "FA_METHOD_CA", conn));
if(commVarValue1.equalsIgnoreCase("NULLFOUND"))
{
errString = itmDBAccessEJB.getErrorString("","VTDEPRMTD2","","",conn);
break;
}
int deprPerc2 = 0;
sql = "select depr_perc as depr_perc_2 from depr_itemgrp " +
" where item_grp = ? and depr_method = ? " +
" and purpose = 'C' and ? between eff_from and valid_upto " +
" and depr_type = 'N'";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, groupCode);
pstmtCopy.setString(2, commVarValue1);
pstmtCopy.setTimestamp(3, useDate);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
deprPerc2 = rsCopy.getInt("depr_perc_2");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(deprPerc2 <= 0)
{
deprPerc2 = 0;
sql = "select depr_perc as depr_perc_2 from depr_itemser " +
" where item_ser = ? and depr_method = ? " +
"and purpose = 'C' and ? between eff_from and valid_upto";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, itemSeries);
pstmtCopy.setString(2, commVarValue1);
pstmtCopy.setTimestamp(3, useDate);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
deprPerc2 = rsCopy.getInt("depr_perc_2");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
sql = "insert into asset_register "
+ "( asset_code , item_ser , item_code , site_code , aloc_code , asset_type , descr , rcp_date , "
+ "bill_no , inst_date , supp_code , curr_code , exch_rate , orginal_value , other_chgs , "
+ "tax_amt , tax_reco_amt , diff_amt__exch , revalue_amt , total_value , depr_type , depr_perc_1 , "
+ "depr_method_1 , depr_amt_1 , wdv_amt_1 , depr_perc_2 , depr_method_2 , depr_amt_2 , wdv_amt_2 ,"
+ " remarks , status , chg_date , chg_user , chg_term , grp_code , rem_value , use_date ,"
+ " excise_amt , comm_chgs , install_chgs , octroi_chgs , insur_chgs , profit_loss , supp_name , "
+ "tot_value__bc , tran_id__create , tran_ser__create , cctr_code , asset_code__par ,"
+ " asset_sale_type , acct_code__emp, cctr_code__emp, emp_code , proc_date_1 , proc_date_2 , "
+ "asset_no , useful_life , residual_val , tran_id__assetinst, bill_date , excreco_amt , asset_class "
+ ") VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , 0 , ? , ? , "
+ "0 , 0 , ? , 'N' , ? , ? , 0 , ? , ? , ? , 0 , ? , ? , 'A' , ? , "
+ "? , ? , ? , 0 , ? , ?, ? , ?, ?, 0 , 0 , ? , ? , ? , ? , ? , ?, ? , "
+ "?, ?, ? , ? , ?, ? , ? , ?, ?, ? , ? , ? ) ";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, assetCode);
pstmtCopy.setString(2, itemSeries);
pstmtCopy.setString(3, itemCode);
pstmtCopy.setString(4, siteCode);
pstmtCopy.setString(5, alocCode);
pstmtCopy.setString(6, assetType);
pstmtCopy.setString(7, descr);
pstmtCopy.setTimestamp(8, rcpDate);
pstmtCopy.setString(9, billNo);
pstmtCopy.setTimestamp(10, instDate);
pstmtCopy.setString(11, suppCode);
pstmtCopy.setString(12, currCode);
pstmtCopy.setDouble(13, exchRate);
pstmtCopy.setDouble(14, originalValue);
pstmtCopy.setDouble(15, taxAmt);
pstmtCopy.setDouble(16, taxRecoAmt);
pstmtCopy.setDouble(17, totalValue);
pstmtCopy.setInt(18, deprPerc1);
pstmtCopy.setString(19, method1);
pstmtCopy.setDouble(20, totalValue);
pstmtCopy.setInt(21, deprPerc2);
pstmtCopy.setString(22, commVarValue1);
pstmtCopy.setDouble(23, totalValue);
pstmtCopy.setString(24, remark);
pstmtCopy.setTimestamp(25, currentTm);
pstmtCopy.setString(26, userid);
pstmtCopy.setString(27, termid);
pstmtCopy.setString(28, groupCode);
pstmtCopy.setTimestamp(29, useDate);
pstmtCopy.setDouble(30, exciseAmt);
pstmtCopy.setString(31, commChgs);
pstmtCopy.setDouble(32, installChgs);
pstmtCopy.setString(33, octroiChgs);
pstmtCopy.setString(34, suppName);
pstmtCopy.setDouble(35, totalValue);
pstmtCopy.setString(36, tranIdRcp);
pstmtCopy.setString(37, tranSeries);
pstmtCopy.setString(38, cctrCodeFin);
pstmtCopy.setString(39, assetCodePar);
pstmtCopy.setString(40, assetSaleType);
pstmtCopy.setString(41, acctCodeEmp);
pstmtCopy.setString(42, cctrCodeEmp);
pstmtCopy.setString(43, empCode);
pstmtCopy.setTimestamp(44, useDate);
pstmtCopy.setTimestamp(45, useDate);
pstmtCopy.setString(46, lotNo);
pstmtCopy.setString(47, usefulLife);
pstmtCopy.setString(48, residualVal);
pstmtCopy.setString(49, tranId);
pstmtCopy.setTimestamp(50, billDate);
pstmtCopy.setDouble(51, excrecoAmt);
pstmtCopy.setString(52, assetClass);
updCnt = pstmtCopy.executeUpdate();
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(!(tranType.equalsIgnoreCase("W")) && (tranIdRcp != null && tranIdRcp.trim().length() > 0))
{
excTaxCode = disCommon.getDisparams("999999", "EXC_TAX_CODE", conn);
if((excTaxCode != null && excTaxCode.trim().length() > 0) && !(excTaxCode.equalsIgnoreCase("NULLFOUND")))
{
excTaxCode = gfgetSqlInString(excTaxCode, conn);
System.out.println("EXC_TAX_CODE :: ["+excTaxCode+"]");
}
/*if((excTaxCode != null && excTaxCode.trim().length() > 0) && !(excTaxCode.equalsIgnoreCase("NULLFOUND")))
{
String[] excTaxArray = excTaxCode.split(",");
String taxTemp = "";
excTaxCode = "";
for (int ctr = 0; ctr < excTaxArray.length; ctr++)
{
taxTemp = excTaxArray[ctr];
excTaxCode = excTaxCode + "'".concat(taxTemp).concat("',");
}
}
else
{
excTaxCode = "";
}*/
assetInstallTax = disCommon.getDisparams("999999", "ASSET_REGISTER_INSTALL_TAXCODE", conn);
if((assetInstallTax != null && assetInstallTax.trim().length() > 0) && !(assetInstallTax.equalsIgnoreCase("NULLFOUND")))
{
assetInstallTax = gfgetSqlInString(assetInstallTax, conn);
System.out.println("ASSET_REGISTER_INSTALL_TAXCODE :: ["+assetInstallTax+"]");
}
/*if((assetInstallTax != null && assetInstallTax.trim().length() > 0) && !(assetInstallTax.equalsIgnoreCase("NULLFOUND")))
{
String[] installTaxArray = assetInstallTax.split(",");
String taxTemp = "";
assetInstallTax = "";
for (int ctr = 0; ctr < installTaxArray.length; ctr++)
{
taxTemp = installTaxArray[ctr];
assetInstallTax = assetInstallTax + "'".concat(taxTemp).concat("',");
}
}
else
{
assetInstallTax = "";
}*/
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3); System.out.println("lineNoRcp ["+lineNoRcp+"]");
sql = "select tax_code, (case when tax_amt is null then 0 else tax_amt end) - (case when reco_amount is null then 0 else reco_amount end) ";
sql = sql + "as tax_amt from taxtran where tran_code = 'P-RCP' " ;
sql = sql + " and tran_id = ? " ;
sql = sql + " and line_no = ? " ;
sql = sql + "and (case when tax_amt is null then 0 else tax_amt end) <> 0 ";
if(excTaxCode != null && excTaxCode.trim().length() > 0)
{
sql = sql + " and tax_code not in (" + excTaxCode + ") ";
}
if(assetInstallTax != null && assetInstallTax.trim().length() > 0)
{
sql = sql + " and tax_code not in (" + assetInstallTax + ") ";
}
if(octroiVarValue != null && octroiVarValue.trim().length() > 0)
{
sql = sql + " and tax_code not in (" + octroiVarValue + ") " ;
}
if(commVarValue != null && commVarValue.trim().length() > 0)
{
sql = sql + " and tax_code not in (" + commVarValue + ") " ;
}
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, tranIdRcp);
pstmtCopy.setString(2, lineNoRcp);
rsCopy = pstmtCopy.executeQuery();
while(rsCopy.next())
{
String taxCodeTran = "";
double taxAmtTran = 0.0;
taxCodeTran = checkNull(rsCopy.getString("tax_code"));
taxAmtTran = rsCopy.getDouble("tax_amt");
taxAmtTran = ((taxAmtTran / quantityPoRcp) * quantity) * exchRate;
sql = "insert into asset_tax (asset_code,tax_code,tax_amt) values (?,?,?)";
pstmtIn = conn.prepareStatement(sql);
pstmtIn.setString(1, assetCode);
pstmtIn.setString(2, taxCodeTran);
pstmtIn.setDouble(3, taxAmtTran);
updCnt = pstmtIn.executeUpdate();
if(pstmtIn != null)
{
pstmtIn.close();
pstmtIn = null;
}
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTOPENCUR","","",conn);
return errString;
}
if(errString.trim().length() > 0)
{
return errString;
}
sql = "update asset_install set confirmed = 'Y' where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCnt = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(updCnt == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTFINENT1","","",conn);
return errString;
}
if(invOnline.equalsIgnoreCase("N"))
{
//exit
}
glTrace = new HashMap();
glTrace.put("tran_date", tranDate);
glTrace.put("eff_date", tranDate);
glTrace.put("fin_entity", finEntity);
glTrace.put("site_code", siteCode);
glTrace.put("sundry_type", "O");
glTrace.put("sundry_code", "");
glTrace.put("acct_code", acctCodeFin);
glTrace.put("cctr_code", cctrCodeFin);
glTrace.put("emp_code", "");
glTrace.put("anal_code", "");
glTrace.put("curr_code", currCode);
glTrace.put("exch_rate", exchRate);
if(totTotalValue > 0)
{
glTrace.put("dr_amt",totTotalValue);
glTrace.put("cr_amt",0);
}
else
{
glTrace.put("dr_amt", 0);
glTrace.put("cr_amt",0 - totTotalValue);
}
glTrace.put("ref_type","F");
glTrace.put("ref_ser", "FAINST");
glTrace.put("ref_id", tranId);
glTrace.put("remarks",remark);
System.out.println("848 glTraceUpdate Called glTrace[" + glTrace.toString() + "]");
errString = finCommon.glTraceUpdate(glTrace,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
sql = "select asset_source from asset_install where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
assetSource = checkNull(rs.getString("asset_source"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select tran_id__rcp from asset_installdet where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
tranIdRcp = checkNull(rs.getString("tran_id__rcp"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
sql = "select asset_code__from from asset_transfer_det where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
assetCodeFr = checkNull(rs.getString("asset_code__from"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(assetSource.equalsIgnoreCase("T"))
{
Double wdvAmount = 0.0;
String siteCodeRG = "";
sql = "select wdv_amt_2 ,site_code from asset_register where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, assetCodeFr);
rs = pstmt.executeQuery();
if(rs.next())
{
wdvAmount = rs.getDouble("wdv_amt_2");
siteCodeRG = checkNull(rs.getString("site_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
String cctrAcctWdv = "", acctCodeWdv = "",cctrCodeWdv = "";
cctrAcctWdv = finCommon.getAcctDetrDistTtype(siteCodeRG, siteCode, itemSeries, groupCode, itemCode, "FAXFRR", tranType, conn);
System.out.println("acctCodeWdv1111 :: ["+acctCodeWdv+"] \t cctrCodeWdv :: ["+cctrCodeWdv+"]");
if(cctrAcctWdv.equals(" , ") || cctrAcctWdv.equals(","))
{
acctCodeWdv = "";
}
else
{
acctCctrPl = cctrAcctWdv.split(",");
System.out.println(">>>>"+acctCctrPl[0]);
acctCodeWdv = acctCctrPl[0];
if(acctCctrPl.length > 1)
cctrCodeWdv = acctCctrPl[1];
}
System.out.println("acctCodeWdv :: ["+acctCodeWdv+"] \t cctrCodeWdv :: ["+cctrCodeWdv+"]");
if(acctCodeWdv == null || acctCodeWdv.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTACCTCD1","","",conn);
return errString;
}
glTrace = new HashMap();
glTrace.put("tran_date", tranDate);
glTrace.put("eff_date", tranDate);
glTrace.put("fin_entity", finEntity);
glTrace.put("site_code", siteCode);
glTrace.put("sundry_type", "O");
glTrace.put("sundry_code", "");
glTrace.put("acct_code", acctCodeWdv);
glTrace.put("cctr_code", cctrCodeWdv);
glTrace.put("emp_code", "");
glTrace.put("anal_code", "");
glTrace.put("curr_code", currCode);
glTrace.put("exch_rate", exchRate);
if(wdvAmount > 0)
{
glTrace.put("dr_amt",0);
glTrace.put("cr_amt",wdvAmount);
}
else
{
glTrace.put("dr_amt", 0 - wdvAmount);
glTrace.put("cr_amt",0);
}
glTrace.put("ref_type","F");
glTrace.put("ref_ser", "FAINST");
glTrace.put("ref_id", tranId);
glTrace.put("remarks",remark);
System.out.println("849 glTraceUpdate Called glTrace[" + glTrace.toString() + "]");
errString = finCommon.glTraceUpdate(glTrace,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
Double deprAmount = originalValue - wdvAmount;
glTrace = new HashMap();
glTrace.put("tran_date", tranDate);
glTrace.put("eff_date", tranDate);
glTrace.put("fin_entity", finEntity);
glTrace.put("site_code", siteCode);
glTrace.put("sundry_type", "O");
glTrace.put("sundry_code", "");
glTrace.put("acct_code", acctCodeFin);
glTrace.put("cctr_code", cctrCodeFin);
glTrace.put("emp_code", "");
glTrace.put("anal_code", "");
glTrace.put("curr_code", currCode);
glTrace.put("exch_rate", exchRate);
if(deprAmount > 0)
{
glTrace.put("dr_amt",0);
glTrace.put("cr_amt",deprAmount);
}
else
{
glTrace.put("dr_amt", 0 - deprAmount);
glTrace.put("cr_amt",0);
}
glTrace.put("ref_type","F");
glTrace.put("ref_ser", "FAINST");
glTrace.put("ref_id", tranId);
glTrace.put("remarks",remark);
System.out.println("850 glTraceUpdate Called glTrace[" + glTrace.toString() + "]");
errString = finCommon.glTraceUpdate(glTrace,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
sql = "update asset_register set depr_amt_op_co = ? where asset_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, deprAmount);
pstmt.setString(2, assetCode);
updCnt = pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
String prcpId = "", acctCode = "";
Double detQty = 0.0, detRate = 0.0, detTax = 0.0, detExcise = 0.0, discount = 0.0, discountAmt = 0.0;
sql = "select tran_id__rcp, line_no__rcp , quantity, rate, tax_amt, excise_amt " +
" from asset_installdet where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
prcpId = checkNull(rs.getString("tran_id__rcp"));
lineNoRcp = checkNull(rs.getString("line_no__rcp"));
detQty = rs.getDouble("quantity");
detRate = rs.getDouble("rate");
detTax = rs.getDouble("tax_amt");
detExcise = rs.getDouble("excise_amt");
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3); System.out.println("lineNoRcp ["+lineNoRcp+"]");
if(prcpId != null && prcpId.trim().length() > 0)
{
sql = "select acct_code__dr, cctr_code__dr, discount " +
" from porcpdet where tran_id = ? and line_no = ?";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, prcpId);
pstmtCopy.setString(2, lineNoRcp);
rsCopy = pstmtCopy.executeQuery();
if(rsCopy.next())
{
acctCode = checkNull(rsCopy.getString("acct_code__dr"));
cctrCode = checkNull(rsCopy.getString("cctr_code__dr"));
discount = rsCopy.getDouble("discount");
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
}
discountAmt = ((detRate * detQty) * discount) / 100;
glTrace = new HashMap();
glTrace.put("tran_date", tranDate);
glTrace.put("eff_date", tranDate);
glTrace.put("fin_entity", finEntity);
glTrace.put("site_code", siteCode);
glTrace.put("sundry_type", "O");
glTrace.put("sundry_code", "");
glTrace.put("acct_code", acctCode);
glTrace.put("cctr_code", cctrCode);
glTrace.put("emp_code", "");
glTrace.put("anal_code", "");
glTrace.put("curr_code", currCode);
glTrace.put("exch_rate", exchRate);
double detAmount = (detQty * detRate) + detTax + detExcise;
if(detAmount > 0)
{
glTrace.put("dr_amt",0);
glTrace.put("cr_amt",detAmount - discountAmt);
}
else
{
glTrace.put("dr_amt", 0 - (detAmount - discountAmt));
glTrace.put("cr_amt",0);
}
glTrace.put("ref_type","F");
glTrace.put("ref_ser", "FAINST");
glTrace.put("ref_id", tranId);
glTrace.put("remarks",remark);
System.out.println("851 glTraceUpdate Called glTrace[" + glTrace.toString() + "]");
errString = finCommon.glTraceUpdate(glTrace,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
if(installChgs != 0)
{
glTrace = new HashMap();
glTrace.put("tran_date", tranDate);
glTrace.put("eff_date", tranDate);
glTrace.put("fin_entity", finEntity);
glTrace.put("site_code", siteCode);
glTrace.put("sundry_type", "O");
glTrace.put("sundry_code", "");
glTrace.put("acct_code", acctCodeInst);
if(cctrCodeInst == null || cctrCodeInst.trim().length() == 0)
{
glTrace.put("cctr_code", cctrCode);
}
else
{
glTrace.put("cctr_code", cctrCodeInst);
}
glTrace.put("emp_code", "");
glTrace.put("anal_code", "");
glTrace.put("curr_code", currCode);
glTrace.put("exch_rate", exchRateInst);
if(installChgs > 0)
{
glTrace.put("dr_amt",0);
glTrace.put("cr_amt",installChgs);
}
else
{
glTrace.put("dr_amt", 0 - installChgs);
glTrace.put("cr_amt",0);
}
glTrace.put("ref_type","F");
glTrace.put("ref_ser", "FAINST");
glTrace.put("ref_id", tranId);
glTrace.put("remarks",remark);
System.out.println("852 glTraceUpdate Called glTrace[" + glTrace.toString() + "]");
errString = finCommon.glTraceUpdate(glTrace,conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
}
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
String postOnLine = finCommon.getFinparams("999999", "POST_ON_LINE",conn);
if(postOnLine == null || postOnLine.equalsIgnoreCase("")){
errString = itmDBAccessEJB.getErrorString("","VTENVAR1","","",conn);
return errString;
}
postOnLine = postOnLine.substring(0,1);
if("Y_N".indexOf(postOnLine) == -1){
errString = itmDBAccessEJB.getErrorString("","VTENVAR1","","",conn);
return errString;
}
if(postOnLine.equalsIgnoreCase("Y"))
{
errString = finCommon.checkGlTranDrCr("FAINST", tranId, conn);
if(errString != null && errString.trim().length() > 0)
{
return errString;
}
}
}
catch( Exception e )
{
System.out.println("AssetInstallConf [assetInstallPost]..."+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rsIn != null)
{
rsIn.close();
rsIn = null;
}
if(pstmtIn != null)
{
pstmtIn.close();
pstmtIn = null;
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception : "+e);
e.printStackTrace();
}
}
System.out.println("errString in assetInstallPost::: "+errString);
return errString;
}
@SuppressWarnings("unchecked")
public String assetStockUpd(String tranId, String siteCode, String tranType, String xtraParams, Connection conn) throws ITMException
{
String errorCode = "", sql = "", todayDate = "";
PreparedStatement pstmt = null, pstmtCopy = null;
ResultSet rs = null, rsCopy = null;
//Date tranDate = null;
Timestamp tranDate = null;
String itemCode = "", locCode = "", lotNo = "", lotSl = "", lineNo = "", itemSer = "", invStat = "";
int stockOpt = 0;
double quantity = 0.0, stockQuantity = 0.0;
String localTranId = tranId, localSiteCode = siteCode;
String siteCodeMfg = "", potencyPerc = "", packCode = "", grossWeight = "",tareWeight = "", netWeight = "", packInstr = "",
dimension = "", acctCodeInv = "", cctrCodeInv = "", acctCodeOH = "", suppCodeMfg = "", grade = "",
cctrCodeOH = "", convQtyStduom = "", batchNo = "", unit = "", unitAlt = "", noArt = "";
//Date retestDate = null, mfgDateStock = null, expDateStock = null;
Timestamp retestDate = null, mfgDateStock = null, expDateStock = null;
double rate =0.0, rateOH = 0.0, grossRate =0.0;
StockUpdate updateStock = new StockUpdate();
HashMap updStockMap = new HashMap();
Timestamp todayTm = null;
GenericUtility genericUtility = new GenericUtility();
SimpleDateFormat sdf = null;
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
todayDate = sdf.format(new java.util.Date());
todayTm = Timestamp.valueOf(genericUtility.getValidDateString(todayDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(tranType.equalsIgnoreCase("AI"))
{
sql = "select tran_date from asset_install where tran_id = ? ";
}
else
{
sql = "select tran_date from asset_revalue where tran_id = ? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
//tranDate = rs.getDate("tran_date");
tranDate = rs.getTimestamp("tran_date");
}
else
{
errorCode = "DS000100";
return errorCode;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(tranType.equalsIgnoreCase("AI"))
{
sql = "select item_code, loc_code, lot_no, lot_sl, quantity, line_no from asset_installdet where tran_id = ? ";
}
else
{
sql = "select item_code, loc_code, lot_no, lot_sl, quantity, line_no from asset_revaluedet where tran_id = ? ";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode = checkNull(rs.getString("item_code"));
locCode = checkNull(rs.getString("loc_code"));
lotNo = checkNull(rs.getString("lot_no"));
lotSl = checkNull(rs.getString("lot_sl"));
quantity = rs.getDouble("quantity");
lineNo = checkNull(rs.getString("line_no"));
sql = "SELECT stk_opt, item_ser FROM item WHERE item_code = ? ";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, itemCode);
rsCopy= pstmtCopy.executeQuery();
if(rsCopy.next())
{
stockOpt = rsCopy.getInt("stk_opt");
itemSer = checkNull(rsCopy.getString("item_ser"));
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
sql = "select inv_stat from location where loc_code = ? ";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, locCode);
rsCopy= pstmtCopy.executeQuery();
if(rsCopy.next())
{
invStat = checkNull(rsCopy.getString("inv_stat"));
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(stockOpt != 0)
{
sql = "SELECT quantity, rate, site_code__mfg, mfg_date, potency_perc, exp_date, pack_code, " +
" gross_weight, tare_weight, net_weight, pack_instr, dimension, acct_code__inv, " +
" cctr_code__inv, rate__oh, acct_code__oh, cctr_code__oh, retest_date, supp_code__mfg, " +
" grade, gross_rate, conv__qty_stduom,batch_no, unit, unit__alt, no_art " +
" FROM stock " +
" WHERE site_code = ? " +
" and item_code = ? " +
" and loc_code = ? " +
" and lot_no = ? " +
" and lot_sl = ?";
pstmtCopy = conn.prepareStatement(sql);
pstmtCopy.setString(1, localSiteCode);
pstmtCopy.setString(2, itemCode);
pstmtCopy.setString(3, locCode);
pstmtCopy.setString(4, lotNo);
pstmtCopy.setString(5, lotSl);
rsCopy= pstmtCopy.executeQuery();
if(rsCopy.next())
{
stockQuantity = rsCopy.getDouble("quantity");
rate = rsCopy.getDouble("rate");
siteCodeMfg = checkNull(rsCopy.getString("site_code__mfg"));
//mfgDateStock = rsCopy.getDate("mfg_date");
mfgDateStock = rsCopy.getTimestamp("mfg_date");
potencyPerc = checkNull(rsCopy.getString("potency_perc"));
//expDateStock = rsCopy.getDate("exp_date");
expDateStock = rsCopy.getTimestamp("exp_date");
packCode = checkNull(rsCopy.getString("pack_code"));
grossWeight = checkNull(rsCopy.getString("gross_weight"));
tareWeight = checkNull(rsCopy.getString("tare_weight"));
netWeight = checkNull(rsCopy.getString("net_weight"));
packInstr = checkNull(rsCopy.getString("pack_instr"));
dimension = checkNull(rsCopy.getString("dimension"));
acctCodeInv = checkNull(rsCopy.getString("acct_code__inv"));
cctrCodeInv = checkNull(rsCopy.getString("cctr_code__inv"));
rateOH = rsCopy.getDouble("rate__oh");
acctCodeOH = checkNull(rsCopy.getString("acct_code__oh"));
cctrCodeOH = checkNull(rsCopy.getString("cctr_code__oh"));
//retestDate = rsCopy.getDate("retest_date");
retestDate = rsCopy.getTimestamp("retest_date");
suppCodeMfg = checkNull(rsCopy.getString("supp_code__mfg"));
grade = checkNull(rsCopy.getString("grade"));
grossRate = rsCopy.getDouble("gross_rate");
convQtyStduom = checkNull(rsCopy.getString("conv__qty_stduom"));
batchNo = checkNull(rsCopy.getString("batch_no"));
unit = checkNull(rsCopy.getString("unit"));
unitAlt = checkNull(rsCopy.getString("unit__alt"));
noArt = checkNull(rsCopy.getString("no_art"));
}
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(stockQuantity >= quantity )
{
updStockMap.put("item_code", itemCode);
updStockMap.put("site_code", localSiteCode);
updStockMap.put("loc_code", locCode);
updStockMap.put("lot_no", lotNo);
updStockMap.put("lot_sl", lotSl);
updStockMap.put("unit", unit);
updStockMap.put("tran_type", "I");
updStockMap.put("tran_date", tranDate);
updStockMap.put("tran_ser", "FAINST");
updStockMap.put("tran_id", localTranId);
updStockMap.put("line_no", lineNo);
updStockMap.put("rate", rate);
updStockMap.put("supp_code__mfg",suppCodeMfg);
updStockMap.put("mfg_date", mfgDateStock);
updStockMap.put("potency_perc", potencyPerc);
updStockMap.put("exp_date", expDateStock);
updStockMap.put("pack_code", packCode);
updStockMap.put("quantity", quantity);
updStockMap.put("qty_stduom", quantity);
updStockMap.put("item_ser", itemSer);
updStockMap.put("inv_stat", invStat);
updStockMap.put("gross_weight", grossWeight);
updStockMap.put("tare_weight", tareWeight);
updStockMap.put("net_weight", netWeight);
updStockMap.put("pack_instr", packInstr);
updStockMap.put("dimension", dimension);
updStockMap.put("acct_code_inv", acctCodeInv);
updStockMap.put("cctr_code_inv", cctrCodeInv);
updStockMap.put("rate_oh", rateOH);
updStockMap.put("acct_code_OH", acctCodeOH);
updStockMap.put("cctr_code_OH", cctrCodeOH);
updStockMap.put("retest_date", retestDate);
updStockMap.put("supp_code__mfg", suppCodeMfg);
updStockMap.put("grade", grade);
updStockMap.put("gross_rate", grossRate);
updStockMap.put("conv__qty_stduom", convQtyStduom);
updStockMap.put("batch_no", batchNo);
updStockMap.put("unit__alt", unitAlt);
updStockMap.put("no_art", noArt);
updStockMap.put("last_phyc_date", todayTm);
errorCode = updateStock.updateStock(updStockMap,xtraParams, conn);
if(errorCode !=null && errorCode.trim().length() >0)
{
return errorCode;
}
}
else
{
errorCode = "VTSTK";
return errorCode;
}
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch( Exception e )
{
System.out.println("AssetInstallConf [assetStockUpd]..."+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rsCopy != null)
{
rsCopy.close();
rsCopy = null;
}
if(pstmtCopy != null)
{
pstmtCopy.close();
pstmtCopy = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception : "+e);
e.printStackTrace();
}
}
return errorCode;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
private String gfgetSqlInString(String lsAssetInstallTax,Connection conn)throws ITMException
{
String lsInstallTax="";
if((lsAssetInstallTax != null) && (lsAssetInstallTax.length() >0))
{
String tempArray[]=lsAssetInstallTax.split(",");
System.out.println("tempArray[].length :-["+tempArray.length+"]");
for(int itrArr=0; itrArr < tempArray.length;itrArr++)
{
lsInstallTax=lsInstallTax+"'"+tempArray[itrArr]+"',";
}
System.out.println("line1 before sql in method gfgetSqlInString:- ["+lsInstallTax+"]");
lsInstallTax=lsInstallTax.substring(0, lsInstallTax.length()-1);
System.out.println("line1 After sql: in method gfgetSqlInString:-- ["+lsInstallTax+"]");
}
if(lsInstallTax == null ||lsInstallTax.trim().length() == 0)
{
lsInstallTax= "''";
}
return lsInstallTax;
}
}
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