Commit ef0942f1 authored by vvengurlekar's avatar vvengurlekar

AssetInstallIC.java

AssetInstallLocal.java
AssetInstallRemote.java - asset install validation and item change component added


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@193697 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9bf8b97e
package ibase.webitm.ejb.fin;
/**
* AUTHOR : ANJALI R.
* COMPONENT : VALIDATION AND ITEMCHANGE OF ASSET INSTALL OBJECT
**/
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
@Stateless
public class AssetInstallIC extends ValidatorEJB implements AssetInstallLocal,AssetInstallRemote
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
String retString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
System.out.println("xmlString............." + xmlString);
System.out.println("xmlString1............" + xmlString1);
System.out.println("xmlString2............" + xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = wfValData(dom, dom1, dom2, objContext, editFlag,xtraParams);
System.out.println("ErrString :" + retString);
}
catch(Exception e)
{
System.out.println("Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
NodeList parentList = null;
Node parentNode = null;
NodeList childList = null;
Node childNode = null;
String childNodeName = "";
String userId = "";
Connection conn = null;
int currentFormNo = 0;
int ctr = 0;
int cnt = 0;
java.util.Date tranDate = null;
String tranDateStr = null;
String siteCode = "" , modName = "";
String cctrCode = "";
String alocCode = "";
String empCode = "";
String itemCode = "";
String currCode = "";
String currCodeInst = "";
String acct = "";
String cctr = "";
String projectCode = "";
String assetClass = "";
String lotSl = "";
String locCode= "";
String suppcode="";
String currCodeDet = "";
String lotNo = "";
String lineNoRcp = "";
String tranIdRcp = "";
SimpleDateFormat dateFormat = null;
UtilMethods utilMethods = new UtilMethods();
DistCommon disCommon = new DistCommon();
FinCommon finCommon = new FinCommon();
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String errCode = "" , errString = "" , errorType = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
System.out.println("Inside wfValdata ***********");
conn = getConnection();
dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo)
{
case 1:
{
parentList = dom.getElementsByTagName("Detail1");
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
for (ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("site_code"))
{
tranDateStr = genericUtility.getColumnValue("tran_date", dom);
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
if(tranDateStr != null && tranDateStr.trim().length() > 0)
{
System.out.println("tranDateStr ["+tranDateStr+"]");
tranDate = dateFormat.parse(genericUtility.getColumnValue("tran_date", dom));
}
errCode = finCommon.isSiteCode(siteCode,"",conn); System.out.println("ReturnString ["+errCode+"]");
if(errCode == null || errCode.trim().length() == 0 )
{
errCode = finCommon.nfCheckPeriod("FIN", tranDate, siteCode,conn);
System.out.println("Error ["+errCode+"]");
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("cctr_code"))
{
cnt = 0;
cctrCode = checkNull(genericUtility.getColumnValue("cctr_code", dom));
if(cctrCode != null && cctrCode.trim().length() > 0)
{
sql = "select count(*) from costctr where cctr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cctrCode);
rs = pstmt.executeQuery();
while(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Count from costctr --["+cnt+"]");
if(cnt == 0)
{
errCode = "VTCCTRCDPL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("aloc_code"))
{
cnt = 0;
alocCode = checkNull(genericUtility.getColumnValue("aloc_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select count(*) from asset_location where aloc_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, alocCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMALOC";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
sql = "select count(*) from asset_location "
+ "where aloc_code = ? "
+ "and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, alocCode);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMASITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("emp_code"))
{
cnt = 0;
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCode != null && empCode.trim().length() >0)
{
sql = "select count(*) from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMEMP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("item_code"))
{
cnt = 0;
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
sql = "select count(*) from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTITEM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("curr_code"))
{
cnt = 0;
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
sql = "select count(1) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if (childNodeName.equalsIgnoreCase("curr_code__inst"))
{
cnt = 0;
currCodeInst = checkNull(genericUtility.getColumnValue("curr_code__inst", dom));
sql = "select count(1) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCodeInst);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("acct_code__inst"))
{
acct = checkNull(genericUtility.getColumnValue("acct_code__inst", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
errCode = finCommon.isAcctCode(siteCode, acct, modName, conn);
System.out.println("[acct_code__inst] is ["+errCode+"]");
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("cctr_code__inst"))
{
acct = checkNull(genericUtility.getColumnValue("acct_code__inst", dom));
cctr = checkNull(genericUtility.getColumnValue("cctr_code__inst", dom));
errCode = finCommon.isCctrCode(acct, cctr, modName, conn);
System.out.println("[cctr_code__inst] is ["+errCode+"]");
if(errCode != null && errCode.trim().length() > 0)
{
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("proj_code"))
{
cnt = 0;
projectCode = checkNull(genericUtility.getColumnValue("proj_code", dom));
if(projectCode != null && projectCode.trim().length() > 0)
{
sql = "select count(*) from project where proj_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, projectCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMPROJCDX";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("asset_class"))
{
cnt = 0;
assetClass = checkNull(genericUtility.getColumnValue("asset_class", dom));
if(assetClass == null || assetClass.trim().length() == 0)
{
errCode = "VTASTCLSNL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) from asset_class where asset_class = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, assetClass);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTASTCSIN";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}//End of Case 1
break;
case 2 :
{
parentList = dom.getElementsByTagName("Detail" + currentFormNo);
parentNode = parentList.item(0);
childList = parentNode.getChildNodes();
for (ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("item_code"))
{
cnt = 0;
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
sql = "select count(*) from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTITEM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("loc_code"))
{
cnt = 0;
locCode = checkNull(genericUtility.getColumnValue("loc_code", dom));
sql = "select count(*) from location where loc_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMLOC1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("supp_code"))
{
cnt = 0;
suppcode = checkNull(genericUtility.getColumnValue("supp_code", dom));
sql = "select count(*) from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppcode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTSUPP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("curr_code"))
{
cnt = 0;
currCodeDet = checkNull(genericUtility.getColumnValue("curr_code", dom));
sql = "select count(1) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCodeDet);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom1));
currCodeInst = checkNull(genericUtility.getColumnValue("curr_code__inst", dom1));
if(!(currCode.equalsIgnoreCase(currCodeDet)) || !(currCodeInst.equalsIgnoreCase(currCodeDet)) || !(currCode.equalsIgnoreCase(currCodeInst)))
{
errCode = "VTATCURRCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("lot_no"))
{
int lineNoRcpInt = 0 ;
cnt = 0;
lotNo = checkNull(genericUtility.getColumnValue("lot_no", dom));
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
try{ lineNoRcpInt = Integer.parseInt(lineNoRcp); } catch(Exception e) {e.printStackTrace(); lineNoRcpInt = 0;}
if(lineNoRcpInt > 0 && tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
lineNoRcp = utilMethods.right(" "+String.valueOf(lineNoRcp), 3);////ls_line_no__rcp = right(space(3) + string(li_line_no_rcp),3) //Need to change
System.out.println("lineNoRcp is ["+lineNoRcp+"]");
sql = "select count(1) "
+ "from porcpdet where "
+ "tran_id = ? "
+ "and line_no = ? "
+ "and lot_no = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
pstmt.setString(3, lotNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTLOTNOPOR";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("lot_sl"))
{
int lineNoRcpInt = 0;
cnt = 0;
lotSl = checkNull(genericUtility.getColumnValue("lot_sl", dom));
lotNo = checkNull(genericUtility.getColumnValue("lot_no", dom));
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
try{ lineNoRcpInt = Integer.parseInt(lineNoRcp); }catch(Exception e) {e.printStackTrace(); lineNoRcpInt = 0;}
if(lineNoRcpInt > 0 && tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
lineNoRcp = utilMethods.right(" "+String.valueOf(lineNoRcp), 3);////ls_line_no__rcp = right(space(3) + string(li_line_no_rcp),3) //Need to change
sql = "select count(1) "
+ "from porcpdet "
+ "where tran_id = ? "
+ "and line_no = ? "
+ "and lot_no = ? "
+ "and lot_sl = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
pstmt.setString(3, lotNo);
pstmt.setString(4, lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
/*errCode = "VTLOTSLPOR";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());*/
}
}
}
else if(childNodeName.equalsIgnoreCase("exch_rate") || childNodeName.equalsIgnoreCase("rate") || childNodeName.equalsIgnoreCase("quantity") ||
childNodeName.equalsIgnoreCase("tax_amt") || childNodeName.equalsIgnoreCase("excise_amt") )
{
double exchRatePorcp = 0.0;
double rate = 0.0;
double quantity = 0.0;
double recoAmt = 0.0;
double rcpRecoAmt = 0.0;
double valRcp = 0.0;
double quantityRcp = 0.0;
double discount = 0.0;
double exch = 0.0;
double tax = 0.0;
double exc = 0.0;
double taxReco = 0.0;
String tranId = "";
String quantityStr = "";
String rateStr = "";
String varValue = "";
String purchaseOrder = "";
String porcptranType = "";
String pordType = "";
String tranType = "" , cwipTranType = "";
double totQty = 0.0 , qcPassed = 0.0;
String lsToken = "" , lsString = "";
rate = checkNullForDouble(genericUtility.getColumnValue("rate", dom));
quantity = checkNullForDouble(genericUtility.getColumnValue("quantity", dom));
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
if(rate == 0)
{
errCode = "VTRTVLD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(quantity == 0)
{
errCode = "VTQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if(tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
lineNoRcp = utilMethods.right(" "+String.valueOf(lineNoRcp), 3);//ls_line_no__rcp = right(space(3) + string(li_line_no_rcp),3) //Need to change
System.out.println("lineNoRcp ["+lineNoRcp+"]");
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "EXC_TAX_CODE", conn));
lsString = gfgetSqlInString(varValue, conn);
System.out.println("EXC_TAX_CODE :: ["+lsString+"]");
/*while(utilMethods.pos(varValue, ",") != 0)
{
lsToken = disCommon.getToken(varValue, ",");
lsString = lsString + "'" + lsToken + "'" + ",";
}
lsString = "(" + lsString + "'" + varValue + "'" + ")";*/
sql = "select sum(case when reco_amount is null then 0 else reco_amount end) as reco_amt "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and tax_code IN ("+lsString+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
recoAmt = rs.getDouble("reco_amt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "EXC_TAX_CODE_ASSET", conn));
lsString = gfgetSqlInString(varValue, conn);
System.out.println("EXC_TAX_CODE_ASSET :: ["+lsString+"]");
/*while(utilMethods.pos(varValue, ",") != 0)
{
lsToken = disCommon.getToken(varValue, ".");
lsString = lsString + "'" + lsString + "'" + ",";
}
lsString = "(" + lsString + "'" + varValue + "'" + ")";*/
sql = "select sum(case when reco_amount is null then 0 else reco_amount end) as rcp_reco_amt "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and tax_code IN ("+lsString+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
recoAmt = rs.getDouble("rcp_reco_amt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select purc_order,"
+ "exch_rate, "
+ "tran_type "
+ "from porcp "
+ "where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
purchaseOrder = checkNull(rs.getString("purc_order"));
exchRatePorcp = rs.getDouble("exch_rate");
porcptranType = checkNull(rs.getString("tran_type"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select PORD_TYPE from porder where purc_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
pordType = checkNull(rs.getString("PORD_TYPE"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select net_amt, "
+ "quantity , "
+ "discount "
+ "from porcpdet "
+ "where tran_id = ? "
+ "and line_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
valRcp = rs.getDouble("net_amt");
quantityRcp = rs.getDouble("quantity");
discount = rs.getDouble("discount");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
rate = checkNullForDouble(genericUtility.getColumnValue("rate", dom));
quantity = checkNullForDouble(genericUtility.getColumnValue("quantity", dom));
exch = checkNullForDouble(genericUtility.getColumnValue("exch_rate", dom));
tax = checkNullForDouble(genericUtility.getColumnValue("tax_amt", dom));
exc = checkNullForDouble(genericUtility.getColumnValue("excise_amt", dom));
taxReco = checkNullForDouble(genericUtility.getColumnValue("tax_reco_amt", dom));
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
if("Q".equalsIgnoreCase(pordType) || "H".equalsIgnoreCase(pordType))
{
tranType = checkNull(getEnvDis("999999", "ASSET_PORCP_TRAN_TYPE", conn));
cwipTranType = checkNull(getEnvDis("999999", "ASSET_PORCP_CWIP_TRAN_TYPE", conn));
System.out.println("tranType ["+tranType+"] \t cwipTranType ["+cwipTranType+"]");
if(("NULLFOUND".equalsIgnoreCase(cwipTranType)) || (cwipTranType == null || cwipTranType.trim().length() == 0))
{
tranType = " ";
}
if(("NULLFOUND".equalsIgnoreCase(tranType)) || (tranType == null || tranType.trim().length() == 0))
{
tranType = " ";
}
if(!porcptranType.equalsIgnoreCase(tranType))
{
if(!(porcptranType.equalsIgnoreCase(cwipTranType)))
{
errCode = "VTRCPTYPE2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
if(quantity > 1)
{
errCode = "VTRCPQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if(tranId == null || tranId.trim().length() > 0){tranId = " ";}
sql = "select sum(quantity) "
+ "from asset_installdet "
+ "where tran_id__rcp = ? "
+ "and line_no__rcp = ? "
+ "and tran_id <> ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
pstmt.setString(3, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
totQty = rs.getDouble(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("totQty ["+totQty+"] \t quantity ["+quantity+"]");
List<String> currentData = new ArrayList<String>();
currentData.add(tranIdRcp); currentData.add(lineNoRcp);
totQty = getSumOfDetail2Quantity(currentData, totQty ,quantity, dom);
totQty = totQty + quantity;
if(totQty > quantityRcp)
{
errCode = "VTPORCPQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
sql = "select count(1) "
+ "from qc_order "
+ "where porcp_no = ? "
+ "and status = 'U'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errCode = "VTQCAMD01";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
sql = "select count(1) "
+ "from qc_order "
+ "where porcp_no = ? "
+ "and item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt != 0)
{
sql = "select sum(qty_passed) "
+ "from qc_order "
+ "where porcp_no = ? "
+ "AND item_code = ? "
+ "AND status = 'C'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
qcPassed = rs.getDouble(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(totQty > qcPassed)
{
errCode = "VTPORCPQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
double discAmt = 0.0;//lc_disc_amt = (( ld_rate * lc_exch * ld_quantity ) * lc_disc) / 100
discAmt = ((rate * exch * quantity) * discount)/100;
double val = 0.0;//lc_val = (( ld_rate * ld_quantity ) + lc_tax + lc_exc + lc_tax_reco -lc_disc_amt) * lc_exch
val = ((rate * quantity) + tax + exc + taxReco - discAmt ) * exch;
valRcp = (valRcp - recoAmt - rcpRecoAmt) * exchRatePorcp;//lc_val_prcp = (lc_val_prcp - ld_reco_amt - lc_rcpreco_amt) * lc_exch_rate
System.out.println("val ["+val+"] \t valRcp ["+valRcp+"] \t quantityRcp ["+quantityRcp+"] \t quantity ["+quantity+"]");
if( (val != valRcp) && (quantityRcp == quantity) )
{
errCode = "VTPORCPVAL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
/*else if(childNodeName.equalsIgnoreCase("rate"))
{
}
else if(childNodeName.equalsIgnoreCase("quantity"))
{
}
else if(childNodeName.equalsIgnoreCase("tax_amt"))
{
}
else if(childNodeName.equalsIgnoreCase("excise_amt"))
{
}*/
else if(childNodeName.equalsIgnoreCase("tran_id__rcp"))
{
cnt = 0;
String mVal = "";
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom1));
if(tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
sql = "SELECT COUNT(1) "
+ "FROM PORCP,PORDER "
+ "WHERE PORCP.PURC_ORDER = PORDER.PURC_ORDER "
+ "AND PORDER.CONFIRMED = 'Y'"
+ "AND PORCP.TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTRCONF2";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
cnt = 0;
sql = "select site_code from porcp where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
mVal = checkNull(rs.getString("site_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(!(siteCode.equalsIgnoreCase(mVal)))
{
errCode = "VTPOSITE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
}
break;
}
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode+"errString>>>>>>>>>"+errString);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}//end of if for errList
else
{
errStringXml = new StringBuffer("");
}
errString = errStringXml.toString();
}
catch(Exception e)
{
System.out.println("Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
public String itemChanged(String xmString, String xmString1, String xmString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("currFrmXmlStr::"+xmString);
System.out.println("hdrFrmXmlStr::"+xmString1);
System.out.println("allFrmXmlStr::"+xmString2);
try
{
if (xmString != null && xmString.trim().length()!=0)
{
dom = genericUtility.parseString(xmString);
}
if (xmString1 != null && xmString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmString1);
}
if (xmString2 != null && xmString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch (Exception e)
{
System.out.println ( "Exception : ItemChanged(String,String):" + e.getMessage() + ":" );
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String itemChanged( Document dom , Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
int cnt =0;
int currentFormNo = 0;
Timestamp todaysDate = null;
SimpleDateFormat sdf =null;
FinCommon finCommon = new FinCommon();
UtilMethods utilMethods = new UtilMethods();
String tranDate = "";
String siteCode = "";
String siteDescr = "";
String cctrCode = "";
String acctCode = "";
String currCode = "";
String assetCode = "";
String alocCode = "";
String locdescr = "";
String asserDesc = "";
String fname = "";
String lname = "";
String name = "";
String empCode = "";
String tranId = "";
double exchRate = 0.0;
double originalValue = 0.0;
double originalValueBC = 0.0;
double exchRateInst = 0.0;
double installChgs = 0.0;
double chgsBC = 0.0;
String itemCode = "",itemDescr = "", grpCode = "", itemSer = "",grpCodeDescr = "",finEntity = "",assetClass = "",projectCode = "" , projectDescr = "";
int liCnt = 0;
double usefulLife = 0.0;
double quantity = 0.0 ,rate = 0.0,taxAmount = 0.0,netAmount = 0.0;
String locCode = "", lotNo = "", lotSl = "", PurcOrder = "";
String lineNo = "" , lineNoRcp = "";
String tranIdRcp = "";
String suppCode = "", dcNo = "", invoiceNo = "",porcptranType = "",suppName = "";
String billNo = "";
Timestamp billDate = null;
DistCommon disCommon = new DistCommon();
String currentDateTime = "";
double lcTaxAmt = 0.0;
double taxRecoAmt = 0.0;
double octroiChg = 0.0;
double commChgs = 0.0;
double exciseAmount = 0.0;
double taxRecoAmount = 0.0;
String detCntStr = "";
int linecnt = 0;
try
{
conn = getConnection();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
todaysDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currentDateTime = sdf.format(todaysDate);
//tranDate = sdf.format(todaysDate.toString());
System.out.println("tranDate ---["+tranDate+"]");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
valueXmlString.append( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch ( currentFormNo )
{
case 1:
{
valueXmlString.append("<Detail1>");
if(currentColumn.equalsIgnoreCase("itm_default"))
{
String lsAssetCode = " ";
valueXmlString.append("<tran_date>").append("<![CDATA["+currentDateTime+"]]>").append("</tran_date>");
valueXmlString.append("<inst_date>").append("<![CDATA["+currentDateTime+"]]>").append("</inst_date>");
valueXmlString.append("<use_date>").append("<![CDATA["+currentDateTime+"]]>").append("</use_date>");
valueXmlString.append("<asset_code>").append("<![CDATA["+lsAssetCode+"]]>").append("</asset_code>");
sql= "select count(1) as count from transetup where upper(tran_window) = 'W_ASSET_REGISTER' and key_flag= 'A' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
valueXmlString.append( "<asset_code protect = '1'>" ).append("<![CDATA["+lsAssetCode+"]]>").append("</asset_code>\r\n");
}
else
{
valueXmlString.append( "<asset_code protect = '0'>" ).append("<![CDATA["+lsAssetCode+"]]>").append("</asset_code>\r\n");
}
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select site.descr as site_descr from site where site.site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = checkNull(rs.getString("site_descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<site_descr>").append("<![CDATA["+ siteDescr +"]]>").append("</site_descr>");
cctrCode = checkNull(finCommon.getFinparams("999999", "ACCT_CWIP", conn)); System.out.println("[CCTRCODE is ["+cctrCode+"]]");
if(cctrCode != null && cctrCode.trim().length() > 0 && !"NULLFOUND".equalsIgnoreCase(cctrCode))
{
//acctCode = disCommon.getToken(cctrCode, ";");
String value[] = getTokens(cctrCode, ";");
acctCode = value[0];
cctrCode = value[1];
System.out.println("[ACCTCODE is ["+acctCode+"]] \t CCTRCODE is ["+cctrCode+"]");
valueXmlString.append("<acct_code__inst>").append("<![CDATA["+ acctCode +"]]>").append("</acct_code__inst>");
valueXmlString.append("<cctr_code__inst>").append("<![CDATA["+ cctrCode +"]]>").append("</cctr_code__inst>");
}
valueXmlString.append("<install_chgs>").append("<![CDATA["+ "0" +"]]>").append("</install_chgs>");
valueXmlString.append("<original_value>").append("<![CDATA["+ "0" +"]]>").append("</original_value>");
}
else if(currentColumn.equalsIgnoreCase("itm_defaultedit"))
{
String mcurrCode = "";
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
assetCode = checkNull(genericUtility.getColumnValue("asset_code", dom));
exchRate = checkNullForDouble(genericUtility.getColumnValue("exch_rate", dom));
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA["+siteCode+"]]>").append("</site_code>");
valueXmlString.append("<curr_code protect = '1'>").append("<![CDATA["+currCode+"]]>").append("</curr_code>");
valueXmlString.append("<exch_rate protect = '1'>").append("<![CDATA["+exchRate+"]]>").append("</exch_rate>");
sql = "select finent.curr_code "
+ "from site, finent "
+ "where ( site.fin_entity = finent.fin_entity ) "
+ "and ( site.site_code = ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mcurrCode = checkNull(rs.getString("curr_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<curr_code protect = '1'>").append("<![CDATA["+currCode+"]]>").append("</curr_code>");
if((mcurrCode != null) && (mcurrCode.equalsIgnoreCase(currCode)))
{
valueXmlString.append("<exch_rate protect = '1'>").append("<![CDATA[]]>").append("</exch_rate>");
}
else
{
valueXmlString.append("<exch_rate protect = '0'>").append("<![CDATA[]]>").append("</exch_rate>");
}
sql= "select count(1) as count "
+ "from transetup where upper(tran_window) = 'W_ASSET_REGISTER' "
+ "and key_flag= 'A' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
valueXmlString.append("<asset_code protect = '1'>").append("<![CDATA["+assetCode+"]]>").append("</asset_code>");
}
else
{
valueXmlString.append("<asset_code protect = '0'>").append("<![CDATA["+assetCode+"]]>").append("</asset_code>");
}
}
else if(currentColumn.equalsIgnoreCase("site_code"))
{
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select currency.std_exrt , site.descr "
+ "from currency, finent, site "
+ "where ( site.fin_entity = finent.fin_entity ) "
+ "and ( finent.curr_code = currency.curr_code ) "
+ "and ( site.site_code = ? )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
exchRate = rs.getDouble("std_exrt");
siteDescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<site_descr>").append("<![CDATA["+ siteDescr +"]]>").append("</site_descr>");
valueXmlString.append("<exch_rate>").append("<![CDATA["+ exchRate +"]]>").append("</exch_rate>");
}
else if(currentColumn.equalsIgnoreCase("aloc_code"))
{
alocCode = checkNull(genericUtility.getColumnValue("aloc_code", dom));
sql = "select asset_location.descr "
+ "from asset_location "
+ "where asset_location.aloc_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, alocCode);
rs = pstmt.executeQuery();
if(rs.next())
{
locdescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<location_descr>").append("<![CDATA["+ locdescr +"]]>").append("</location_descr>");
}
else if(currentColumn.equalsIgnoreCase("asset_code"))
{
assetCode = checkNull(genericUtility.getColumnValue("asset_code", dom));
sql = "select asset_register.descr "
+ "from asset_register "
+ "where asset_register.asset_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, assetCode);
rs = pstmt.executeQuery();
if(rs.next())
{
asserDesc = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<descr>").append("<![CDATA["+ asserDesc +"]]>").append("</descr>");
valueXmlString.append("<asset_code__par>").append("<![CDATA["+ assetCode +"]]>").append("</asset_code__par>");
}
else if(currentColumn.equalsIgnoreCase("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
sql = "select employee.emp_fname, employee.emp_lname "
+ "from employee where employee.emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
fname = checkNull(rs.getString("emp_fname"));
lname = checkNull(rs.getString("emp_lname"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
name = fname + " " + lname + " ";
name = utilMethods.mid(name,1,15); System.out.println("Name of An Employee is ["+name+"]");
valueXmlString.append("<emp_fname>").append("<![CDATA["+ name +"]]>").append("</emp_fname>");
}
else if(currentColumn.equalsIgnoreCase("curr_code"))
{
String mcurrCode = "";
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
System.out.println("Inside curr_code Itemchange Value currCode["+currCode+"] \t tranId["+tranId+"]");
sql = "select std_exrt "
+ "from currency "
+ "where curr_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
exchRate = rs.getDouble("std_exrt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<exch_rate>").append("<![CDATA["+ exchRate +"]]>").append("</exch_rate>");
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select finent.curr_code "
+ "from site, finent "
+ "where ( site.fin_entity = finent.fin_entity ) "
+ "and ( site.site_code = ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mcurrCode = checkNull(rs.getString("curr_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("Currency Code ["+currCode+"] \t MCurrency Code ["+mcurrCode+"]");
if((mcurrCode != null) && (mcurrCode.equalsIgnoreCase(currCode)))
{
valueXmlString.append("<exch_rate protect = '1'>").append("<![CDATA["+ exchRate +"]]>").append("</exch_rate>");
}
else
{
valueXmlString.append("<exch_rate protect = '0'>").append("<![CDATA["+ exchRate +"]]>").append("</exch_rate>");
}
originalValue = checkNullForDouble(genericUtility.getColumnValue("original_value", dom));
originalValueBC = exchRate * originalValue;
System.out.println("originalValue is ["+originalValue+"] AND originalValueBC ["+originalValueBC+"]");
valueXmlString.append("<original_value__bc>").append("<![CDATA["+ originalValueBC +"]]>").append("</original_value__bc>");
}
else if(currentColumn.equalsIgnoreCase("curr_code__inst"))
{
currCode = checkNull(genericUtility.getColumnValue("curr_code__inst", dom));
sql = "select std_exrt "
+ "from currency "
+ "where curr_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
exchRateInst = rs.getDouble("std_exrt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<exch_rate__inst>").append("<![CDATA["+ exchRateInst +"]]>").append("</exch_rate__inst>");
installChgs = checkNullForDouble(genericUtility.getColumnValue("install_chgs", dom));
chgsBC = exchRateInst * installChgs;
System.out.println("[curr_code__inst Itemchange]installChgs ["+installChgs+"] \t chgsBC ["+chgsBC+"]");
valueXmlString.append("<inst_chgs__bc>").append("<![CDATA["+ chgsBC +"]]>").append("</inst_chgs__bc>");
}
else if(currentColumn.equalsIgnoreCase("exch_rate__inst"))
{
exchRateInst = checkNullForDouble(genericUtility.getColumnValue("exch_rate__inst", dom));
installChgs = checkNullForDouble(genericUtility.getColumnValue("install_chgs", dom));
chgsBC = exchRateInst * installChgs;System.out.println("[exch_rate__inst Itemchange]installChgs ["+installChgs+"] \t chgsBC ["+chgsBC+"]");
valueXmlString.append("<inst_chgs__bc>").append("<![CDATA["+ chgsBC +"]]>").append("</inst_chgs__bc>");
}
else if(currentColumn.equalsIgnoreCase("install_chgs"))
{
installChgs = checkNullForDouble(genericUtility.getColumnValue("install_chgs", dom));
exchRateInst = checkNullForDouble(genericUtility.getColumnValue("exch_rate__inst", dom));
chgsBC = exchRateInst * installChgs;System.out.println("[install_chgs Itemchange]installChgs ["+installChgs+"] \t chgsBC ["+chgsBC+"]");
valueXmlString.append("<inst_chgs__bc>").append("<![CDATA["+ chgsBC +"]]>").append("</inst_chgs__bc>");
}
else if(currentColumn.equalsIgnoreCase("exch_rate"))
{
exchRate = checkNullForDouble(genericUtility.getColumnValue("exch_rate", dom));
originalValue = checkNullForDouble(genericUtility.getColumnValue("original_value", dom));
originalValueBC = exchRate * originalValue;System.out.println("[exch_rate Itemchange]installChgs ["+installChgs+"] \t originalValueBC ["+originalValueBC+"]");
valueXmlString.append("<original_value__bc>").append("<![CDATA["+ originalValueBC +"]]>").append("</original_value__bc>");
}
else if(currentColumn.equalsIgnoreCase("item_code"))
{
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
sql = "select descr, "
+ "grp_code, "
+ "item_ser "
+ "from item "
+ "where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemDescr = checkNull(rs.getString("descr"));
grpCode = checkNull(rs.getString("grp_code"));
itemSer = checkNull(rs.getString("item_ser"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<item_descr>").append("<![CDATA["+ itemDescr +"]]>").append("</item_descr>");
valueXmlString.append("<grp_code>").append("<![CDATA["+ grpCode +"]]>").append("</grp_code>");
sql = "select descr from gencodes "
+ "where fld_name = 'GRP_CODE' "
+ "AND fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, grpCode);
rs = pstmt.executeQuery();
if(rs.next())
{
grpCodeDescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<gencodes_descr>").append("<![CDATA["+ grpCodeDescr +"]]>").append("</gencodes_descr>");
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"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
liCnt = 0;
sql = "select count(*) as cnt from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? "
+ "and fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
pstmt.setString(3, finEntity);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(liCnt > 0)
{
sql = "select asset_class ,useful_life from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? "
+ "and fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
pstmt.setString(3, finEntity);
rs = pstmt.executeQuery();
if(rs.next())
{
assetClass = checkNull(rs.getString("asset_class"));
usefulLife = checkNullForDouble(rs.getString("useful_life"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
sql = "select asset_class ,useful_life from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
rs = pstmt.executeQuery();
if(rs.next())
{
assetClass = checkNull(rs.getString("asset_class"));
usefulLife = checkNullForDouble(rs.getString("useful_life"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("<asset_class>").append("<![CDATA["+ assetClass +"]]>").append("</asset_class>");
valueXmlString.append("<useful_life>").append("<![CDATA["+ usefulLife +"]]>").append("</useful_life>");
}
else if(currentColumn.equalsIgnoreCase("grp_code"))
{
grpCode = checkNull(genericUtility.getColumnValue("grp_code", dom));
sql = "select descr from gencodes "
+ "where fld_name = 'GRP_CODE' "
+ "AND fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, grpCode);
rs = pstmt.executeQuery();
if(rs.next())
{
grpCodeDescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<gencodes_descr>").append("<![CDATA["+ grpCodeDescr +"]]>").append("</gencodes_descr>");
}
else if(currentColumn.equalsIgnoreCase("proj_code"))
{
projectCode = checkNull(genericUtility.getColumnValue("proj_code", dom));
sql = "select descr "
+ "from project "
+ "where proj_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, projectCode);
rs = pstmt.executeQuery();
if(rs.next())
{
projectDescr = rs.getString("descr");
valueXmlString.append("<project_descr>").append("<![CDATA["+ projectDescr +"]]>").append("</project_descr>");
}
else
{
valueXmlString.append("<project_descr>").append("<![CDATA["+ "" +"]]>").append("</project_descr>");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else if(currentColumn.equalsIgnoreCase("asset_class"))
{
assetClass = checkNull(genericUtility.getColumnValue("asset_class", dom));
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
grpCode = checkNull(genericUtility.getColumnValue("grp_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
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"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select item_ser "
+ "from item "
+ "where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemSer = checkNull(rs.getString("item_ser"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
liCnt = 0;
sql = "select count(*) as cnt from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? "
+ "and fin_entity = ? "
+ "and asset_class = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
pstmt.setString(3, finEntity);
pstmt.setString(4, assetClass);
rs = pstmt.executeQuery();
if(rs.next())
{
liCnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("liCnt is ["+liCnt+"]");
if(liCnt > 0)
{
sql = "select useful_life from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? "
+ "and fin_entity = ?"
+ "and asset_class = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
pstmt.setString(3, finEntity);
pstmt.setString(4, assetClass);
rs = pstmt.executeQuery();
if(rs.next())
{
usefulLife = checkNullForDouble(rs.getString("useful_life"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
sql = "select useful_life from asset_class "
+ "where item_ser = ? "
+ "and grp_code = ? "
+ "and asset_class = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
pstmt.setString(2, grpCode);
pstmt.setString(3, assetClass);
rs = pstmt.executeQuery();
if(rs.next())
{
usefulLife = checkNullForDouble(rs.getString("useful_life"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("<useful_life>").append("<![CDATA["+ usefulLife +"]]>").append("</useful_life>");
}
valueXmlString.append("</Detail1>");
}
break;
case 2:
{
valueXmlString.append("<Detail2>");
if(currentColumn.equalsIgnoreCase("itm_default"))
{
detCntStr = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"detCnt");
System.out.println("Values of detCntStr ["+detCntStr+"]");
try {linecnt = Integer.valueOf(detCntStr);} catch(Exception e) {linecnt = 0;}
if(linecnt > 0)
{
valueXmlString.append("<line_no >").append(linecnt).append ("</line_no>");
}
valueXmlString.append("<line_no protect = '1'><![CDATA[").append(checkNull(genericUtility.getColumnValue("line_no", dom))).append("]]></line_no>\r\n");
valueXmlString.append("<tran_id ><![CDATA[").append(checkNull(genericUtility.getColumnValue("tran_id", dom))).append ("]]></tran_id>");
valueXmlString.append("<grp_code><![CDATA[").append(checkNull(genericUtility.getColumnValue("grp_code", dom))).append("]]></grp_code>\r\n");
}
else if(currentColumn.equalsIgnoreCase("line_no__rcp"))
{
String dcDateStr = "", invoiceDateStr = "", transactionDateStr = "",billDateStr = "";
Timestamp dcDate = null, invoiceDate = null, transactionDate = null;
lineNo = genericUtility.getColumnValue("line_no", dom);
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
if(tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3); System.out.println("lineNoRcp >>> ["+lineNoRcp+"]");
sql = "select supp_code, curr_code, exch_rate , "
+ "dc_no, dc_date, invoice_no, invoice_date, "
+ "tran_type, tran_date "
+ "from porcp where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
suppCode = checkNull(rs.getString("supp_code"));
currCode = checkNull(rs.getString("curr_code"));
exchRate = rs.getDouble("exch_rate");
dcNo = checkNull(rs.getString("dc_no"));
dcDate = rs.getTimestamp("dc_date");
invoiceNo = checkNull(rs.getString("invoice_no"));
invoiceDate = rs.getTimestamp("invoice_date");
porcptranType = checkNull(rs.getString("tran_type"));
transactionDate = rs.getTimestamp("tran_date");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(dcDate != null )
{
dcDateStr = sdf.format(dcDate).toString();
}
if(invoiceDate != null )
{
invoiceDateStr = sdf.format(invoiceDate).toString();
}
if(transactionDate != null )
{
transactionDateStr = sdf.format(transactionDate).toString();
}
sql = "select supp_name from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppCode);
rs = pstmt.executeQuery();
if(rs.next())
{
suppName = checkNull(rs.getString("supp_name"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<supp_name><![CDATA[" ).append( suppName ).append( "]]></supp_name>\r\n" );
valueXmlString.append( "<rcp_date><![CDATA[" ).append( transactionDateStr ).append( "]]></rcp_date>\r\n" );
if(invoiceNo != null && invoiceNo.trim().length() > 0)
{
billNo = invoiceNo;
//billDate = invoiceDate;
billDateStr = invoiceDateStr;
}
else
{
billNo = dcNo;
//billDate = dcDate;
billDateStr = dcDateStr;
}
valueXmlString.append( "<supp_code><![CDATA[" ).append( suppCode ).append( "]]></supp_code>\r\n" );
valueXmlString.append( "<curr_code><![CDATA[" ).append( currCode ).append( "]]></curr_code>\r\n" );
valueXmlString.append( "<exch_rate><![CDATA[" ).append( exchRate ).append( "]]></exch_rate>\r\n" );
valueXmlString.append( "<bill_no><![CDATA[" ).append( billNo ).append( "]]></bill_no>\r\n" );
valueXmlString.append( "<bill_date><![CDATA[" ).append( billDateStr ).append( "]]></bill_date>\r\n" );
sql = "select item_code, quantity, rate, tax_amt, net_amt, loc_code, "
+ "lot_no, lot_sl, purc_order "
+ "from porcpdet where "
+ "tran_id = ? and line_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
itemCode = checkNull(rs.getString("item_code"));
quantity = rs.getDouble("quantity");
rate = rs.getDouble("rate");
taxAmount = rs.getDouble("tax_amt");
netAmount = rs.getDouble("net_amt");
locCode = checkNull(rs.getString("loc_code"));
lotNo = checkNull(rs.getString("lot_no"));
lotSl = checkNull(rs.getString("lot_sl"));
PurcOrder = checkNull(rs.getString("purc_order"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "select descr "
+ "from item "
+ "where item_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemDescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
String tranType = "";
tranType = checkNull(getEnvDis("999999", "ASSET_PORCP_TRAN_TYPE", conn));
if(("NULLFOUND".equalsIgnoreCase(tranType)) || (tranType == null || tranType.trim().length() == 0 ))
{
tranType = " ";
}
else
{
if(tranType.equalsIgnoreCase(porcptranType))
{
quantity = 1;
}
}
sql = "select descr from location where loc_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if(rs.next())
{
locdescr = rs.getString("descr");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<location_descr><![CDATA[" ).append( locdescr ).append( "]]></location_descr>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode ).append( "]]></item_code>\r\n" );
valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode ).append( "]]></loc_code>\r\n" );
valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo ).append( "]]></lot_no>\r\n" );
valueXmlString.append( "<lot_sl><![CDATA[" ).append( lotSl ).append( "]]></lot_sl>\r\n" );
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n" );
valueXmlString.append( "<rate><![CDATA[" ).append( rate ).append( "]]></rate>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( quantity ).append( "]]></quantity>\r\n" );
}
}
else if(currentColumn.equalsIgnoreCase("item_code"))
{
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
sql = "select descr from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemDescr = checkNull(rs.getString("descr"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n" );
}
else if(currentColumn.equalsIgnoreCase("supp_code"))
{
suppCode = checkNull(genericUtility.getColumnValue("supp_code", dom));
sql = "select supp_name from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, suppCode);
rs = pstmt.executeQuery();
if(rs.next())
{
suppName = checkNull(rs.getString("supp_name"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<supp_name><![CDATA[" ).append( suppName ).append( "]]></supp_name>\r\n" );
}
else if(currentColumn.equalsIgnoreCase("loc_code"))
{
locCode = checkNull(genericUtility.getColumnValue("loc_code", dom));
sql = "select descr from location where loc_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if(rs.next())
{
locdescr = rs.getString("descr");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<location_descr><![CDATA[" ).append( locdescr ).append( "]]></location_descr>\r\n" );
}
else if(currentColumn.equalsIgnoreCase("quantity"))
{
double quantityNew = 0.0 , rcpRecoAmt = 0.0,discount = 0.0 , discAmount = 0.0 , recoAmt = 0.0 , taxAmt = 0.0,exciseAmt = 0.0 ;
String valueAsset = "";
String assetInstallTax = "" ;
double taxInstallChgs = 0.0;
double taxOctroiChgs = 0.0;
double taxCommChgs = 0.0;
String varValue = "" , lsToken = "" , lsString = "";
quantityNew = checkNullForDouble(genericUtility.getColumnValue("quantity", dom));
rate = checkNullForDouble(genericUtility.getColumnValue("rate", dom));
lineNo = checkNull(genericUtility.getColumnValue("line_no", dom));
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
System.out.println("quantityNew ["+quantityNew+"]\t rate["+rate+"]\t lineNo["+lineNo+"]\t lineNoRcp["+lineNoRcp+"]\t tranIdRcp["+tranIdRcp+"]");
if(tranIdRcp != null && tranIdRcp.trim().length() > 0)
{
lineNoRcp = utilMethods.right(" " + lineNoRcp.trim(), 3);System.out.println("lineNoRcp["+lineNoRcp+"]");
sql = "select quantity, tax_amt, discount "
+ "from porcpdet "
+ "where tran_id = ? "
+ "and line_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
quantity = rs.getDouble("quantity");
taxAmount = rs.getDouble("tax_amt");
discount = rs.getDouble("discount");
}
System.out.println("quantity["+quantity+"]\t taxAmount["+taxAmount+"]\t discount["+discount+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
discAmount = (( rate * quantity ) * discount) / 100;
System.out.println("Discount111 ["+discAmount+"]");
if(quantity > 0)
{
discAmount = ((discAmount / quantity) * quantityNew );
System.out.println("Discount222 ["+discAmount+"]");
}
sql = "select "
+ "sum(case when reco_amount is null then 0 else reco_amount end) as rcp_reco_amt , "
+ "sum(case when tax_amt is null then 0 else tax_amt end) as tax_amt "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
recoAmt = rs.getDouble("rcp_reco_amt");
exciseAmt = rs.getDouble("tax_amt");
}
System.out.println("recoAmt["+recoAmt+"]\t exciseAmt["+exciseAmt+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "EXC_TAX_CODE", conn));
lsString = gfgetSqlInString(varValue, conn);
System.out.println("EXC_TAX_CODE :: ["+lsString+"]");
/*while(utilMethods.pos(varValue, ",") != 0)
{
lsToken = disCommon.getToken(varValue, ",");
lsString = lsString + "'" + lsToken + "'" + ",";
}
lsString = "(" + lsString + "'" + varValue + "'" + ")";*/
sql = "select "
+ "sum(case when reco_amount is null then 0 else reco_amount end) as rcp_reco_amt , "
+ "sum(case when tax_amt is null then 0 else tax_amt end) as tax_amt "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and taxtran.tax_code IN ("+lsString+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
recoAmt = rs.getDouble("rcp_reco_amt");
taxAmt = rs.getDouble("tax_amt");
}
System.out.println("EXC_TAX_CODE -- recoAmt["+recoAmt+"]\t taxAmt["+taxAmt+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "EXC_TAX_CODE_ASSET", conn));
System.out.println("EXC_TAX_CODE :: ["+varValue+"]");
if(!("NULLFOUND".equalsIgnoreCase(varValue)) && (varValue != null && varValue.trim().length() > 0))
{
valueAsset = gfgetSqlInString(varValue, conn);
System.out.println("EXC_TAX_CODE_ASSET[valueAsset] ::: ["+varValue+"]");
sql = "select "
+ "sum(case when reco_amount is null then 0 else reco_amount end) as rcp_reco_amt , "
+ "sum(case when tax_amt is null then 0 else tax_amt end) as tax_amt "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and taxtran.tax_code IN ("+valueAsset+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
rcpRecoAmt = rs.getDouble("rcp_reco_amt");
taxAmt = rs.getDouble("tax_amt");
}
System.out.println("EXC_TAX_CODE -- recoAmt["+recoAmt+"]\t taxAmt["+taxAmt+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "ASSET_REGISTER_INSTALL_TAXCODE", conn));
System.out.println("ASSET_REGISTER_INSTALL_TAXCODE[valueAsset] ::: ["+varValue+"]");
if(!("NULLFOUND".equalsIgnoreCase(varValue)) && (varValue != null && varValue.trim().length() > 0))
{
valueAsset = gfgetSqlInString(varValue, conn);
sql = "select "
+ "sum(case when tax_amt is null then 0 else tax_amt end - case when reco_amount is null then 0 else reco_amount end) as tax_install_chgs "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and taxtran.tax_code IN ("+valueAsset+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
taxInstallChgs = rs.getDouble("tax_install_chgs");
}
System.out.println("ASSET_REGISTER_INSTALL_TAXCODE -- taxInstallChgs["+taxInstallChgs+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "ASSET_REGISTER_OCTROI_TAXCODE", conn));
System.out.println("ASSET_REGISTER_OCTROI_TAXCODE[valueAsset] ::: ["+varValue+"]");
if(!("NULLFOUND".equalsIgnoreCase(varValue)) && (varValue != null && varValue.trim().length() > 0))
{
sql = "select "
+ "sum(case when tax_amt is null then 0 else tax_amt end - case when reco_amount is null then 0 else reco_amount end) as tax_octroi_chgs "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and taxtran.tax_code IN ("+varValue+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
taxOctroiChgs = rs.getDouble("tax_octroi_chgs");
}
System.out.println("ASSET_REGISTER_OCTROI_TAXCODE -- taxOctroiChgs["+taxOctroiChgs+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
varValue = "";
varValue = checkNull(disCommon.getDisparams("999999", "ASSET_REGISTER_COMM_TAXCODE", conn));
System.out.println("ASSET_REGISTER_COMM_TAXCODE[valueAsset] ::: ["+varValue+"]");
if(!("NULLFOUND".equalsIgnoreCase(varValue)) && (varValue != null && varValue.trim().length() > 0))
{
sql = "select "
+ "sum(case when tax_amt is null then 0 else tax_amt end - case when reco_amount is null then 0 else reco_amount end) as tax_comm_chgs "
+ "from taxtran "
+ "where taxtran.tran_code = 'P-RCP' "
+ "and taxtran.tran_id = ? "
+ "and taxtran.line_no = ? "
+ "and taxtran.tax_code IN ("+varValue+")";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp);
pstmt.setString(2, lineNoRcp);
rs = pstmt.executeQuery();
while(rs.next())
{
taxCommChgs = rs.getDouble("tax_comm_chgs");
}
System.out.println("ASSET_REGISTER_COMM_TAXCODE -- taxCommChgs["+taxCommChgs+"]");
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
if(quantity > 0 && quantityNew > 0)
{
lcTaxAmt = taxAmt - recoAmt - taxInstallChgs - taxOctroiChgs - taxCommChgs;
taxAmt = ((taxAmt / quantity) * quantityNew);
System.out.println("lcTaxAmt ["+lcTaxAmt+"] \t taxAmt ["+taxAmt+"]");
valueXmlString.append( "<tax_amt><![CDATA[" ).append( lcTaxAmt ).append( "]]></tax_amt>\r\n" );
taxRecoAmt = ((recoAmt - (recoAmt + rcpRecoAmt)) / quantity)* quantityNew;
System.out.println("taxRecoAmt ["+taxRecoAmt+"] ");
valueXmlString.append( "<tax_reco_amt><![CDATA[" ).append( taxRecoAmt ).append( "]]></tax_reco_amt>\r\n" );
octroiChg = checkNullForDouble(genericUtility.getColumnValue("octroi_chgs", dom));
commChgs = checkNullForDouble(genericUtility.getColumnValue("comm_chgs", dom));
valueXmlString.append( "<octroi_chgs><![CDATA[" ).append( octroiChg + taxOctroiChgs ).append( "]]></octroi_chgs>\r\n" );
valueXmlString.append( "<comm_chgs><![CDATA[" ).append( commChgs + taxCommChgs ).append( "]]></comm_chgs>\r\n" );
exciseAmt = (((exciseAmt - recoAmt + taxAmt - rcpRecoAmt) / quantity) * quantityNew);
double excrecoAmt = (((recoAmt + rcpRecoAmt) / quantity) * quantityNew);
System.out.println("exciseAmt ["+exciseAmt+"] \t excrecoAmt["+excrecoAmt+"]");
valueXmlString.append( "<excise_amt><![CDATA[" ).append( exciseAmt ).append( "]]></excise_amt>\r\n" );
valueXmlString.append( "<excreco_amt><![CDATA[" ).append( excrecoAmt ).append( "]]></excreco_amt>\r\n" );
}
else
{
valueXmlString.append( "<tax_amt><![CDATA[" ).append( 0 ).append( "]]></tax_amt>\r\n" );
valueXmlString.append( "<excise_amt><![CDATA[" ).append( 0 ).append( "]]></excise_amt>\r\n" );
valueXmlString.append( "<excreco_amt><![CDATA[" ).append( 0 ).append( "]]></excreco_amt>\r\n" );
}
taxAmt = checkNullForDouble(genericUtility.getColumnValue("tax_amt", dom));
taxRecoAmount = checkNullForDouble(genericUtility.getColumnValue("tax_reco_amt", dom));
exciseAmt = checkNullForDouble(genericUtility.getColumnValue("excise_amt", dom));
originalValue = ( rate * quantityNew ) + taxAmt - discount;
valueXmlString.append( "<original_value><![CDATA[" ).append( originalValue ).append( "]]></original_value>\r\n" );
}
}
else if(currentColumn.equalsIgnoreCase("curr_code"))
{
String mcurrCode = "";
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
currCode = checkNull(genericUtility.getColumnValue("curr_code", dom));
sql = "select std_exrt from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
exchRate = rs.getDouble("std_exrt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append( "<exch_rate><![CDATA[" ).append( exchRate ).append( "]]></exch_rate>\r\n" );
sql = "select finent.curr_code as currency_code from Site site, Finent finent "
+ "where site.fin_entity = finent.fin_entity "
+ "AND site.site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mcurrCode = checkNull(rs.getString("currency_code"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if((mcurrCode != null) && (mcurrCode.equalsIgnoreCase(currCode)))
{
valueXmlString.append( "<exch_rate protect = \"1\"><![CDATA[" ).append( exchRate ).append( "]]></exch_rate>\r\n" );
}
else
{
valueXmlString.append( "<exch_rate protect = \"0\"><![CDATA[" ).append( exchRate ).append( "]]></exch_rate>\r\n" );
}
}
valueXmlString.append("</Detail2>");
}
break;
}
valueXmlString.append("</Root>\r\n");
}
catch(Exception e)
{
System.out.println("Exception from itemchanged method --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception from itemchanged method --["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
public String checkNull(String inputStr) throws ITMException
{
try
{
if(inputStr != null && inputStr.trim().length() > 0)
{
return inputStr.trim();
}
else
{
return "";
}
}
catch(Exception e)
{
System.out.println("Exception in checknull--["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
}
public double checkNullForDouble(String inputStr) throws ITMException
{
double retVal = 0.0;
try
{
if(inputStr == null || inputStr.trim().length() == 0)
{
retVal = 0.0;
}
else
{
retVal = Double.parseDouble(inputStr);
}
}
catch(Exception e)
{
System.out.println("Exception in checknull--["+e.getMessage()+"]");
e.printStackTrace();
retVal = 0.0;
throw new ITMException(e);
}
return retVal;
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}
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;
}
private double getSumOfDetail2Quantity(List<String> currentData, double ldTotQuantity ,double currentQty, Document dom) throws ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
int parentNodeListLength =0;
int childNodeListLength = 0;
String childNodeName = "";
Node parentNode = null;
Node childNode = null;
String tranIdRcp = "" , lineNoRcp = "";
String tranIdRcpCur = "" , lineNoRcpCur = "";
boolean isSelected = false;
try
{
System.out.println("15896"+genericUtility.serializeDom(dom));
tranIdRcpCur = currentData.get(0);
lineNoRcpCur = currentData.get(1); System.out.println("Inside getSumOfDetail2Quantity [tranIdRcp is ["+tranIdRcp+"] \t lineNoRcp is ["+lineNoRcp+"]]");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if((childNode.getFirstChild() != null && childNode.getFirstChild().getNodeValue() != null))
{
if (childNodeName.equals("tran_id__rcp"))
{
tranIdRcp = checkNull(childNode.getFirstChild().getNodeValue());
}
if (childNodeName.equals("line_no__rcp"))
{
lineNoRcp = checkNull(childNode.getFirstChild().getNodeValue());
}
isSelected = true;
}
}
}
System.out.println("1111tranIdRcp["+tranIdRcp+"] \t lineNoRcp["+lineNoRcp+"]\t isSelected["+isSelected+"]");
if((tranIdRcpCur.equalsIgnoreCase(tranIdRcp)) && (lineNoRcpCur.equalsIgnoreCase(lineNoRcp)) && (isSelected == false))
{
ldTotQuantity = ldTotQuantity + currentQty; System.out.println("Current Quantity ["+ldTotQuantity+"]");
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("ldTotQuantity >>>>>>> ["+ldTotQuantity+"]");
return ldTotQuantity;
}
private String[] getTokens( String str, String seperator )
{
String val = null;
ArrayList sArr = new ArrayList();
StringTokenizer st = new StringTokenizer( str, seperator );
while (st.hasMoreTokens())
{
val = st.nextToken();
sArr.add( val );
}
st = null;
int lenArr = sArr.size();
String str1[] = new String[ lenArr ];
for( int cnt = 0; cnt < lenArr ; cnt++ )
{
str1[ cnt ] = ( String ) sArr.get( cnt );
}
return str1;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
public interface AssetInstallLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1, Document dom2,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException;
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException;
public String itemChanged(String dom2, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
public interface AssetInstallRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException;
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException;
public String itemChanged(String dom2, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, 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