Commit e0748726 authored by agaikwad's avatar agaikwad

Request-Id-F17DSUN003


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106526 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0f0bd7a6
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpAdvTaxCalulationProIC extends ValidatorEJB implements RcpAdvTaxCalulationProICLocal,RcpAdvTaxCalulationProICRemote // SessionBean
{
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String resultString = "";
Document dom = null,dom1 = null,dom2 = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try{
if(xmlString != null){
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null){
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null){
dom2 = genericUtility.parseString(xmlString2);
}
resultString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(ITMException e)
{
System.out.println("ITMException "+e);
e.printStackTrace();
throw e;
}
catch(Exception e)
{
System.out.println("Exception in itemchange "+e);
e.printStackTrace();
throw new ITMException(e);
}
return resultString;
}
public String itemChanged(Document dom,Document dom1,Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql="";
ConnDriver connDriver = new ConnDriver();
java.util.Date currDate = new java.util.Date(System.currentTimeMillis());
String dateStr = "";
String descr = "",currcode = "",currdescr="";
double stdexrt=0,taxAmt=0;
StringBuffer valueXmlString = new StringBuffer();
String loginSite = "",confirmed="N";
String taxClass="",taxChap="",taxEnv="",taxEnvigst="",finEntity="",currCode="";
E12GenericUtility genericUtility = new E12GenericUtility();
try{
conn = getConnection();
connDriver = null;
FinCommon finCommon = new FinCommon();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
dateStr = sdf.format(currDate);
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSite");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail1>");
if(currentColumn.equalsIgnoreCase("itm_default"))
{
valueXmlString.append("<site_code><![CDATA[" + loginSite+ "]]></site_code>");
valueXmlString.append("<tran_date__fr><![CDATA[" + dateStr+ "]]></tran_date__fr>");
valueXmlString.append("<tran_date__to><![CDATA[" + dateStr+ "]]></tran_date__to>");
taxClass = finCommon.getFinparams("999999","RCPTAXCALC_TAX_CLASS",conn);
valueXmlString.append("<tax_class><![CDATA[" + taxClass+ "]]></tax_class>");
taxChap = finCommon.getFinparams("999999","RCPTAXCALC_TAX_CHAP",conn);
valueXmlString.append("<tax_chap><![CDATA[" + taxChap+ "]]></tax_chap>");
taxEnv = finCommon.getFinparams("999999","RCPTAXCALC_TAX_ENV",conn);
valueXmlString.append("<tax_env><![CDATA[" + taxEnv+ "]]></tax_env>");
taxEnvigst = finCommon.getFinparams("999999","RCPTAX_TAXENVIGST",conn);
valueXmlString.append("<tax_env_igst><![CDATA[" + taxEnvigst+ "]]></tax_env_igst>");
valueXmlString.append("<confirmed><![CDATA[" + confirmed+ "]]></confirmed>");
valueXmlString.append("<tax_amt protect = \"1\"><![CDATA[" + taxAmt+ "]]></tax_amt>");
sql = "select fin_entity from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
finEntity = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("finEntity["+finEntity+"]");
sql = "select curr_code from finent where fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,finEntity);
rs = pstmt.executeQuery();
if(rs.next())
{
currCode = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("currCode["+currCode+"]");
valueXmlString.append("<curr_code><![CDATA[" + currCode + "]]></curr_code>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
}
catch(ITMException e)
{
throw e;
}
catch(Exception e)
{
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}catch(Exception e){}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpAdvTaxCalulationProICLocal extends ValidatorLocal////,EJBObject
{
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, 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;
}
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import javax.ejb.Remote; // added for ejb3
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote // added for ejb3
public interface RcpAdvTaxCalulationProICRemote extends ValidatorRemote
{
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, 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;
}
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.fin.InvAcct;
import ibase.webitm.ejb.fin.adv.CalculateCommission;
import ibase.webitm.ejb.fin.adv.RcvIbcaConf;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@Stateless
public class RcpAdvTaxcalcConf extends ActionHandlerEJB implements RcpAdvTaxcalcConfLocal, RcpAdvTaxcalcConfRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
ITMDBAccessEJB itmDBAccessEJB = null;
@Override
public String confirm(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException
{
String errString = "";
Connection conn = null;
try {
System.out
.println("@@@@@@@@@@@ RcpAdvTaxcalcConfTest confirm() @@@@@@@@@@@@@@@ ");
errString = confirm(tranId, xtraParams, forcedFlag, conn);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Exception in confirm() ==>" + e.getMessage());
errString = genericUtility.createErrorString(e);
System.out.println("errString in cofirm() ==>" + errString);
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag,
Connection conn) throws RemoteException, ITMException {
// Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
ConnDriver connDriver = null;
String confirm = "", siteCode = "";
String errString = "";
boolean isLocal=false;
FinCommon finCommon = null;
ITMDBAccessEJB itmDBAccessEJB = null;
try {
System.out
.println("@@@@@@@@@@@ RcpAdvTaxcalcConfTest @@@@@@@@@@@@@@@ ");
finCommon = new FinCommon();
itmDBAccessEJB = new ITMDBAccessEJB();
if (conn == null)
{
connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
System.out.println("Connection[" + conn + "]");
connDriver = null;
conn.setAutoCommit(false);
isLocal=true;
}
sql = " select confirmed from adv_rcp_tax where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next()) {
confirm = rs.getString("confirmed");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (confirm != null && "Y".equalsIgnoreCase(confirm)) {
System.out
.println("The Selected transaction is already confirmed");
errString = itmDBAccessEJB.getErrorString("", "VTMCONF1", "",
"", conn);
return errString;
} else {
errString = this.rcpAdvtaxCalcProcess(tranId, xtraParams, conn);
if (errString != null && errString.trim().length() > 0) {
if(errString.indexOf("CONFSUCCES") > -1)
{
if(isLocal)
{
conn.commit();
}
System.out.println("Committing..............");
}
else
{
if(isLocal)
{
conn.rollback();
}
System.out.println("Rollbacking..............");
}
}
}
} // end of try
catch (Exception e) {
System.out.println("Exception ::" + e.getMessage());
errString = genericUtility.createErrorString(e);
e.printStackTrace();
try {
conn.rollback();
} catch (Exception e1) {
System.out.println("Exception while rollbackin.......");
}
throw new ITMException(e);
} finally
{
try
{
if(conn!=null && isLocal)
{
System.out.println(" finally Rollbacking..............");
conn.close();
conn=null;
}
//conn = 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();
throw new ITMException(e);
}
}
return errString;
}
public String rcpAdvtaxCalcProcess(String tranId, String xtraParams,
Connection conn) throws ITMException {
ArrayList rcpAdvList = new ArrayList();
ArrayList DetailList = new ArrayList();
ArrayList invoiceDetList = new ArrayList();
HashMap detMapMain = null;
String analysisStr[] = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String lineNoTemp = "", prevSordNo = "";
String errString = "";
HashMap RcpAcctMap = null;
ArrayList RcpAcctList = new ArrayList();
ArrayList RcpAcctScreenList = new ArrayList();
HashMap detRcpadvList = new HashMap();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
double totRecoAmt = 0;
try {
// invoiceDeapList=getDetail(tranId,conn);
itmDBAccessEJB = new ITMDBAccessEJB();
DetailList = getDetail(tranId, conn);
if (DetailList.size() > 0) {
int getLineNo = 0;
String getsiteCode = "", finEntity = "", getCurrCode = "", getRefType = "";
double exchRate = 0, getamount = 0;
String remarks = "", sgstcr = "", sgstcracct = "", sgstcrcctr = "", sgstdr = "", sgstdracct = "", sgstdrcctr = "";
String cgstcr = "", cgstcracct = "", cgstcrcctr = "";
String cgstdr = "", cgstdracct = "", cgstdrcctr = "";
String igstcr = "", igstcracct = "", igstcrcctr="";
String igstdr = "", igstdracct = "", igstdrcctr="";
String acctCodesgstadj = "", cctrCodesgstadj = "";
double taxAmtSgst = 0, taxAmttemp = 0, taxAmtcgsttemp = 0;
double taxAmtCgst = 0;
Timestamp gettranDate = null;
sgstdr = finCommon.getFinparams("999999", "SGST_RADV_ACCT_DR",conn);
if (sgstdr != "NULLFOUND")
{
String[] arry = sgstdr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0) {
sgstdracct = arry[0];
System.out.println("sgstdracct[" + sgstcracct + "]");
} else {
sgstdracct = "";
}
if (arry.length > 1) {
sgstdrcctr = arry[1];
System.out.println("sgstdrcctr[" + sgstdrcctr + "]");
} else {
sgstdrcctr = "";
}
}
sgstcr = finCommon.getFinparams("999999", "SGST_RADV_ACCT_CR",conn);
if (sgstcr != "NULLFOUND") {
String[] arry = sgstcr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0) {
sgstcracct = arry[0];
System.out.println("sgstcracct[" + sgstcracct + "]");
} else {
sgstcracct = "";
}
if (arry.length > 1) {
sgstcrcctr = arry[1];
System.out.println("sgstcrcctr[" + sgstcrcctr + "]");
} else {
sgstcrcctr = "";
}
}
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////CGST//////////////////////////////////////////////////
cgstdr = finCommon.getFinparams("999999", "CGST_RADV_ACCT_DR",
conn);
if (cgstdr != "NULLFOUND") {
String[] arry = cgstdr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0) {
cgstdracct = arry[0];
System.out.println("cgstdracct[" + cgstdracct + "]");
} else {
cgstdracct = "";
}
if (arry.length > 1) {
cgstdrcctr = arry[1];
System.out.println("cgstdrcctr[" + cgstdrcctr + "]");
} else {
cgstdrcctr = "";
}
}
cgstcr = finCommon.getFinparams("999999", "CGST_RADV_ACCT_CR",
conn);
if (cgstcr != "NULLFOUND") {
String[] arry = cgstcr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0) {
cgstcracct = arry[0];
System.out.println("cgstcracct[" + cgstcracct + "]");
} else {
cgstcracct = "";
}
if (arry.length > 1) {
cgstcrcctr = arry[1];
System.out.println("cgstcrcctr[" + cgstcrcctr + "]");
} else {
cgstcrcctr = "";
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////IGST
/* igstcr = finCommon.getFinparams("999999", "IGST_RADV_ACCT_CR",conn);
if (igstcr != "NULLFOUND")
{
String[] arry = igstcr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0)
{
igstcracct = arry[0];
System.out.println("igstcracct[" + igstcracct + "]");
}
else
{
igstcracct = "";
}
if (arry.length > 1)
{
igstcrcctr = arry[1];
System.out.println("igstcrcctr[" + igstcrcctr + "]");
} else
{
igstcrcctr = "";
}
}
igstdr = finCommon.getFinparams("999999", "IGST_RADV_ACCT_DR",conn);
if (igstdr != "NULLFOUND")
{
String[] arry = igstdr.split((","));
System.out.println("@@@@@ arry[" + arry.length + "]");
if (arry.length > 0)
{
igstdracct = arry[0];
System.out.println("igstdracct[" + igstdracct + "]");
}
else
{
igstdracct = "";
}
if (arry.length > 1)
{
igstdrcctr = arry[1];
System.out.println("igstdrcctr[" + igstdrcctr + "]");
} else
{
igstdrcctr = "";
}
}*/
// ///////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////
String sgstdradj = "", sgstdracctadj = "", sgstdrcctradj = "";
String sgstcradj = "", sgstcracctadj = "", sgstcrcctradj = "";
String cgstdradj = "", cgstdracctadj = "", cgstdrcctradj = "";
String cgstcradj = "", cgstcracctadj = "", cgstcrcctradj = "";
String igstdradj = "", igstdracctadj = "", igstdrcctradj = "";
String igstcradj = "", igstcracctadj = "", igstcrcctradj = "";
sgstdradj = finCommon.getFinparams("999999","SGST_RADJ_ACCT_DR", conn);
if (sgstdradj != "NULLFOUND")
{
String[] arry1 = sgstdradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0)
{
sgstdracctadj = arry1[0];
System.out.println("sgstdracctadj[" + sgstdracctadj
+ "]");
}
else
{
sgstdracctadj = "";
}
if (arry1.length > 1)
{
sgstdrcctradj = arry1[1];
System.out.println("sgstdrcctradj[" + sgstdrcctradj
+ "]");
}
else
{
sgstdrcctradj = "";
}
}
sgstcradj = finCommon.getFinparams("999999","SGST_RADJ_ACCT_CR", conn);
if (sgstcradj != "NULLFOUND") {
String[] arry1 = sgstcradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0) {
sgstcracctadj = arry1[0];
System.out.println("sgstcracct[" + sgstcracctadj + "]");
} else {
sgstcracctadj = "";
}
if (arry1.length > 1) {
sgstcrcctradj = arry1[1];
System.out.println("sgstcrcctradj[" + sgstcrcctradj
+ "]");
} else {
sgstcrcctradj = "";
}
}
// sgstAcct.put("cctr_code",sgstdrcctr);
cgstdradj = finCommon.getFinparams("999999",
"CGST_RADJ_ACCT_DR", conn);
if (cgstdradj != "NULLFOUND")
{
String[] arry1 = cgstdradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0) {
cgstdracctadj = arry1[0];
System.out.println("cgstdracctadj[" + cgstdracctadj
+ "]");
} else {
cgstdracctadj = "";
}
if (arry1.length > 1) {
cgstdrcctradj = arry1[1];
System.out.println("cgstdrcctr[" + cgstdrcctradj + "]");
} else {
cgstdrcctradj = "";
}
}
cgstcradj = finCommon.getFinparams("999999","CGST_RADJ_ACCT_CR", conn);
if (cgstcradj != "NULLFOUND")
{
String[] arry1 = cgstcradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0)
{
cgstcracctadj = arry1[0];
System.out.println("cgstcracctadj[" + cgstcracctadj+ "]");
}
else
{
cgstcracctadj = "";
}
if (arry1.length > 1)
{
cgstcrcctradj = arry1[1];
System.out.println("cgstcrcctradj[" + cgstcrcctradj+ "]");
}
else
{
cgstcrcctradj = "";
}
}
igstcradj = finCommon.getFinparams("999999", "IGST_RADJ_ACCT_CR",conn);
if (igstcradj != "NULLFOUND")
{
String[] arry1 = igstcradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0)
{
igstcracctadj = arry1[0];
System.out.println("igstcracctadj[" + igstcracctadj+ "]");
}
else
{
igstcracctadj = "";
}
if (arry1.length > 1)
{
igstcrcctradj = arry1[1];
System.out.println("igstcrcctradj[" + igstcrcctradj+ "]");
}
else
{
igstcrcctradj = "";
}
}
igstdradj = finCommon.getFinparams("999999", "IGST_RADJ_ACCT_DR",conn);
if (igstdradj != "NULLFOUND")
{
String[] arry1 = igstdradj.split((","));
System.out.println("@@@@@ arry[" + arry1.length + "]");
if (arry1.length > 0)
{
igstdracctadj = arry1[0];
System.out.println("igstdracctadj[" + igstdracctadj
+ "]");
}
else
{
igstdracctadj = "";
}
if (arry1.length > 1)
{
igstdrcctradj = arry1[1];
System.out.println("igstdrcctradj[" + igstdrcctradj+ "]");
}
else
{
igstcrcctradj = "";
}
}
for (int itr = 0; itr < DetailList.size(); itr++) {
double taxAmt = 0;
detMapMain = (HashMap) DetailList.get(itr);
System.out.println(" detMapMain ctr [" + itr + "] ["+ detMapMain + "]");
getRefType = checkNull((String) detMapMain.get("ref_type"));
getLineNo = (Integer) detMapMain.get("line_no");
if ("1".equalsIgnoreCase(getRefType))
{
System.out.println("Refrence Type is :["+getRefType+"]");
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='G' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next()) {
taxAmttemp = rs.getDouble(1);
System.out.println(" taxAmttemp [" + taxAmttemp
+ "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code", sgstdracct);
RcpAcctMap.put("cctr_code", sgstdrcctr);
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, sgstdracct, sgstdrcctr, taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 1["+ RcpAcctList + "]");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code", sgstcracct);
RcpAcctMap.put("cctr_code", sgstcrcctr);
System.out.println("Sgst Credit before taxAmt[" + taxAmt + "]");
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, sgstcracct, sgstcrcctr, taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 2["+ RcpAcctList + "]");
/*Added code-*/
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='H' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next()) {
taxAmtcgsttemp = rs.getDouble(1);
System.out.println(" taxAmtcgsttemp ["+ taxAmtcgsttemp + "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code", cgstdracct);
RcpAcctMap.put("cctr_code", cgstdrcctr);
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 3["+ RcpAcctList + "]");
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, cgstdracct, cgstdrcctr,taxAmt);
System.out.println("After Modify[" + taxAmttemp + "");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", cgstcracct);
RcpAcctMap.put("cctr_code", cgstcrcctr);
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, cgstcracct, cgstcrcctr,taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 4["+ RcpAcctList + "]");
//IGST
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='I' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next()) {
taxAmtcgsttemp = rs.getDouble(1);
System.out.println(" taxAmtcgsttemp ["+ taxAmtcgsttemp + "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code", igstdracct);
RcpAcctMap.put("cctr_code", igstdrcctr);
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 5["+ RcpAcctList + "]");
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, igstdracct, igstdrcctr,taxAmt);
System.out.println("After Modify[" + taxAmttemp + "");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", igstcracct);
RcpAcctMap.put("cctr_code", igstcrcctr);
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, igstcracct, igstcrcctr,taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 6["+ RcpAcctList + "]");
}
if ("2".equalsIgnoreCase(getRefType))
{
System.out.println("Refrence Type is 2:["+getRefType+"]");
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='G' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next())
{
taxAmttemp = rs.getDouble(1);
System.out.println(" taxAmttemp ADJ [" + taxAmttemp+ "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", sgstdracctadj);
RcpAcctMap.put("cctr_code", sgstdrcctradj);
System.out.println("Adj sgst dr taxAmttemp["+taxAmttemp+"]");
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmtADJ[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, sgstdracctadj, sgstdrcctradj,taxAmt);
System.out.println("Sgst cr amount after " + taxAmttemp);
System.out.println("RcpAcctListADJ@@@@@@@@@@ 1["+ RcpAcctList + "]");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code", sgstcracctadj);
RcpAcctMap.put("cctr_code", sgstcrcctradj);
System.out.println("Adj sgst cr taxAmttemp["+taxAmttemp+"]");
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmtAdj[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, sgstcracctadj, sgstcrcctradj, taxAmt);
System.out.println("RcpAcctListAdj@@@@@@@@@@ 2["+ RcpAcctList + "]");
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='H' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next())
{
taxAmtcgsttemp = rs.getDouble(1);
System.out.println(" taxAmtcgsttempAdj ["+ taxAmtcgsttemp + "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", cgstdracctadj);
RcpAcctMap.put("cctr_code", cgstdrcctradj);
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmtadj[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 3["+ RcpAcctList + "]");
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, cgstdracctadj, cgstdrcctradj,taxAmt);
System.out.println("After Modify[" + taxAmttemp + "");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", cgstcracctadj);
RcpAcctMap.put("cctr_code", cgstcrcctradj);
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmtAdj[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, cgstcracctadj, cgstcrcctradj,taxAmt);
System.out.println("RcpAcctListADJ@@@@@@@@@@ 4["+ RcpAcctList + "]");
sql = "select sum(ti.tax_amt) from taxtran ti, tax tm,adv_rcp_tax a "
+ "where tm.tax_code = ti.tax_code and ti.tran_code = 'A-TAX' and ti.tran_id =a.tran_id and tm.tax_type ='I' and ti.tran_id = ? and ti.line_no= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
pstmt.setInt(2, getLineNo);
rs = pstmt.executeQuery();
if (rs.next()) {
taxAmtcgsttemp = rs.getDouble(1);
System.out.println(" taxAmtcgsttemp ["+ taxAmtcgsttemp + "] ");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
// invAcctMap.put("line_no",detLineNo);
RcpAcctMap.put("acct_code",igstcracctadj);
RcpAcctMap.put("cctr_code", igstcrcctradj);
taxAmt = getCreditAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 5["+ RcpAcctList + "]");
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, igstcracctadj, igstcrcctradj,taxAmt);
System.out.println("After Modify[" + taxAmttemp + "");
RcpAcctMap = new HashMap();
RcpAcctMap.put("tran_id", tranId);
RcpAcctMap.put("acct_code", igstdracctadj);
RcpAcctMap.put("cctr_code", igstdrcctradj);
taxAmt = getDebitAmt(taxAmttemp);
System.out.println("taxAmt[" + taxAmt + "]");
RcpAcctMap.put("amount", "" + taxAmt);
RcpAcctList = modifyRcpAcctList(RcpAcctList,RcpAcctMap, igstdracctadj, igstdrcctradj,taxAmt);
System.out.println("RcpAcctList@@@@@@@@@@ 6["+ RcpAcctList + "]");
}
}
errString = insertRcpAcctList(RcpAcctList, conn);
if (errString == null || errString.trim().length() == 0) {
RcpAcctScreenList = getRcpAcctDet(tranId, conn);
System.out.println("RcpAcctScreenList.size()["+ RcpAcctScreenList + "]");
detRcpadvList = getRcpDetailScreen(tranId, conn);
System.out.println("detRcpadvList()[" + detRcpadvList + "]");
errString = gbfPostRcpAdvDet(RcpAcctScreenList,detRcpadvList, conn);
}
if (errString == null || errString.trim().length() == 0) {
errString = finCommon.checkGlTranDrCr("A-TAX", tranId, conn);
}
if (errString == null || errString.trim().length() == 0) {
sql = " update adv_rcp_tax set confirmed = 'Y' , conf_date = ? where tran_id = ? ";
System.out.println("SQL : " + sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, new Timestamp(System
.currentTimeMillis()));
pstmt.setString(2, tranId);
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
conn.commit();
}
System.out.println("errString"+errString);
if(errString !=null && errString.trim().length() > 0)
{
return errString;
}
if(errString == null || errString.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("", "CONFSUCCES", "");
System.out.println("Misc Drcr Confirmed .." + errString);
}
System.out.println("Errstring End.." + errString);
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
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);
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
private String insertRcpAcctList(ArrayList RcpAcctList, Connection conn)
throws ITMException {
int detLineNo = 1;
String sql = "", errCode = "";
PreparedStatement pstmt = null;
try {
System.out.println(" RcpAcctList [" + RcpAcctList + "]");
System.out.println(" RcpAcctList [" + RcpAcctList.size() + "]");
sql = "insert into adv_rcp_tax_acct (tran_id,line_no,acct_code,cctr_code,amount)"
+ " values (?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
for (int i = 0; i < RcpAcctList.size(); i++) {
HashMap tempMap = new HashMap();
tempMap = (HashMap) RcpAcctList.get(i);
if (tempMap != null) {
System.out.println("detLineNo" + detLineNo);
String amt = "";
double amount = 0;
amt = (String) tempMap.get("amount");
amount = Double.parseDouble(amt);
pstmt.setString(1, (String) tempMap.get("tran_id"));
pstmt.setInt(2, detLineNo);
pstmt.setString(3, (String) tempMap.get("acct_code"));
pstmt.setString(4, (String) tempMap.get("cctr_code"));
pstmt.setDouble(5, amount);
pstmt.addBatch();
pstmt.clearParameters();
detLineNo++;
}
}
pstmt.executeBatch();
pstmt.clearBatch();
pstmt.close();
pstmt = null;
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return errCode;
}
private ArrayList modifyRcpAcctList(ArrayList RcpAcctList,
HashMap RcpAcctMap, String lsAcctCodeSal, String lsCctrCodeSal,
double detAmount) {
boolean findFlag = false;
HashMap<String, String> tempMap = null;
String acctTemp = "";
String cctrTemp = "";
String tempAmt = "";
double amt = 0;
for (int i = 0; i < RcpAcctList.size(); i++) {
tempMap = (HashMap) RcpAcctList.get(i);
System.out.println("lsAcctCodeSal[" + lsAcctCodeSal + "]");
System.out.println("lsCctrCodeSal[" + lsCctrCodeSal + "]");
acctTemp = tempMap.get("acct_code").trim();
System.out.println("acctTemp[" + acctTemp + "]");
cctrTemp = tempMap.get("cctr_code").trim();
System.out.println("cctrTemp[" + cctrTemp + "]");
if (lsAcctCodeSal.trim().equals(tempMap.get("acct_code").trim())&& lsCctrCodeSal.trim().equals(tempMap.get("cctr_code").trim())) {
System.out.println("Inside equal");
detAmount = detAmount+ Double.parseDouble(tempMap.get("amount"));
System.out.println("detAmount is["+detAmount+"]");
tempMap.put("amount", "" + detAmount);
findFlag = true;
RcpAcctList.set(i, tempMap);
System.out.println("RcpAcctList.set(i,tempMap)@@{"
+ RcpAcctList + "]");
break;
}
}
if (!findFlag) {
RcpAcctList.add(RcpAcctMap);
System.out.println("!findFlag RcpAcctList[" + RcpAcctList + "]");
}
return RcpAcctList;
}
private ArrayList getRcpAcctDet(String tranId, Connection conn)
throws ITMException {
// TODO Auto-generated method stub
ArrayList<Object> DetList = new ArrayList<Object>();
HashMap DetailMap = null;
String sql = "", chgDtStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String acctCode = "", tranid = "", cctrCode = "";
int lineNo = 0;
double amount = 0;
Timestamp refDate = null, tranDate = null;
sql = "select tran_id,line_no,acct_code,cctr_code,amount from adv_rcp_tax_acct where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next()) {
DetailMap = new HashMap();
tranid = rs.getString(1);
lineNo = rs.getInt(2);
acctCode = rs.getString(3);
cctrCode = rs.getString(4);
amount = rs.getDouble(5);
System.out.println("tranid[" + tranid + "] lineNo [" + lineNo
+ "] acctCode [" + acctCode + "] cctrCode[" + cctrCode
+ "]");
System.out.println("amount[" + amount + "]");
DetailMap.put("tran_id", tranid);
DetailMap.put("line_no", lineNo);
DetailMap.put("acct_code", acctCode);
DetailMap.put("cctr_code", cctrCode);
DetailMap.put("amount", amount);
DetList.add(DetailMap);
System.out.println("DetList::[" + DetList + "]");
System.out.println("DetList Size::[" + DetList.size() + "]");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return DetList;
}
private String gbfPostRcpAdvDet(ArrayList rcpAdvTaxCalcList,
HashMap detRcpadvHashMap, Connection conn) throws Exception {
// TODO Auto-generated method stub
String retString = "", lsPostdate = "", ldPostdate = "", sql = "", lsProjCode = "", partyDocRef = "";
PreparedStatement pstmt = null;
String refType = "";
ResultSet rs = null;
HashMap glTraceMap = null;
HashMap detMap = null;
Timestamp ldPostdate2 = null;
double getamount = 0;
try {
System.out.println("rcpAdvTaxCalcList[" + rcpAdvTaxCalcList + "]");
System.out.println("rcpAdvTaxCalcList[" + rcpAdvTaxCalcList.size()
+ "]");
for (int itr = 0; itr < rcpAdvTaxCalcList.size(); itr++) {
detMap = new HashMap();
detMap = (HashMap) rcpAdvTaxCalcList.get(itr);
getamount = (Double) detMap.get("amount");
System.out.println(" detMapDrsgst [" + detMap + "]");
glTraceMap = new HashMap();
glTraceMap.put("tran_date", (Timestamp) detRcpadvHashMap
.get("tran_date"));
glTraceMap.put("eff_date", (Timestamp) detRcpadvHashMap
.get("eff_date"));
glTraceMap.put("fin_entity", (String) detRcpadvHashMap
.get("fin_entity"));
glTraceMap.put("site_code", (String) detRcpadvHashMap
.get("site_code"));
glTraceMap.put("sundry_type", "O");
glTraceMap.put("sundry_code", " ");
glTraceMap.put("acct_code", (String) detMap.get("acct_code"));
glTraceMap.put("cctr_code", (String) detMap.get("cctr_code"));
glTraceMap.put("emp_code", (String) detRcpadvHashMap
.get("emp_code"));
glTraceMap.put("anal_code", (String) detRcpadvHashMap
.get("anal_code"));
glTraceMap.put("curr_code", (String) detRcpadvHashMap
.get("curr_code"));
glTraceMap.put("exch_rate", (Double) detRcpadvHashMap
.get("exch_rate"));
if ((Double) detMap.get("amount") > 0)
{
glTraceMap.put("dr_amt", (Double) (detMap.get("amount")));
glTraceMap.put("cr_amt", Double.parseDouble("0"));
}
else
{
glTraceMap.put("cr_amt", (0 - (Double) (detMap.get("amount"))));
glTraceMap.put("dr_amt", Double.parseDouble("0"));
}
glTraceMap.put("ref_type", "F");
glTraceMap.put("ref_id", (String) detRcpadvHashMap
.get("ref_id"));// Doubt
glTraceMap.put("ref_ser", "A-TAX");
String remarks = "These transaction is Advance Receipt and amount is "
+ getamount + "";
glTraceMap.put("remarks", remarks);
retString = finCommon.glTraceUpdate((HashMap) glTraceMap, conn);
System.out.println("After glTraceUpdate SGST debit---->["+ retString + "]");
if (retString != null && retString.trim().length() > 0) {
return retString;
}
}
} catch (ITMException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return retString;
}
private ArrayList getDetail(String tranId, Connection conn)
throws ITMException {
ArrayList advPostList = new ArrayList();
double ln_amount_dis = 0.00, ln_amount_sal = 0.00;
String rateStd = "", qtyStd = "", discount = "", ls_cctr_code__sal = "", mfgDtStr = "", expDtStr = "", excDtStr = "";
// TODO Auto-generated method stub
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
HashMap advPostMap = null;
try {
String custCode = "", refType = "", refSer = "", refId = "", refidadv = "", taxClass = "", taxChap = "", taxEnv = "", siteCode = "", currCode = "";
int lineNo = 0;
double amount = 0, taxAmt = 0;
Timestamp refDate = null, tranDate = null;
sql = "select d.line_no,d.cust_code,d.ref_type,d.ref_ser,d.ref_id,d.ref_date,d.amount, d.ref_id__adv,d.tax_class,d.tax_chap,d.tax_env, d.tax_amt ,"
+ " h.tran_date,h.site_code, h.curr_code from adv_rcp_tax_det d,adv_rcp_tax h where d.tran_id=h.tran_id and d.tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next()) {
lineNo = rs.getInt(1);
custCode = rs.getString(2);
refType = rs.getString(3);
refSer = rs.getString(4);
refId = rs.getString(5);
refDate = rs.getTimestamp(6);
amount = rs.getDouble(7);
refidadv = rs.getString(8);
taxClass = rs.getString(9);
taxChap = rs.getString(10);
taxEnv = rs.getString(11);
taxAmt = rs.getDouble(12);
tranDate = rs.getTimestamp(13);
siteCode = rs.getString(14);
currCode = rs.getString(15);
System.out.println("lineNo[" + lineNo + "] custCode ["
+ custCode + "] refType [" + refType + "] refSer["
+ refSer + "]");
System.out.println("ref_id[" + refId + "] ref_date [" + refDate
+ "] amount [" + amount + "] refidadv[" + refidadv
+ "]");
System.out.println("taxClass[" + taxClass + "] taxChap ["
+ taxChap + "] taxEnv [" + taxEnv + "] taxAmt["
+ taxAmt + "]");
System.out.println("tranDate[" + tranDate + "] siteCode ["
+ siteCode + "]");
advPostMap = new HashMap();
advPostMap.put("line_no", lineNo);
advPostMap.put("cust_code", custCode);
advPostMap.put("ref_type", refType);
advPostMap.put("ref_ser", refSer);
advPostMap.put("ref_id", refId);
advPostMap.put("ref_date", refDate);
advPostMap.put("amount", amount);
advPostMap.put("ref_id__adv", refidadv);
advPostMap.put("tax_class", taxClass);
advPostMap.put("tax_chap", taxChap);
advPostMap.put("tax_env", taxEnv);
advPostMap.put("tax_amt", taxAmt);
advPostMap.put("tran_date", tranDate);
advPostMap.put("site_code", siteCode);
advPostList.add(advPostMap);
System.out.println("advPostList::[" + advPostList + "]");
System.out.println("advPostList Size::[" + advPostList.size()
+ "]");
amount = 0;
taxAmt = 0;
custCode = "";
refType = "";
refSer = "";
refId = "";
refidadv = "";
taxClass = "";
taxChap = "";
taxEnv = "";
refDate = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return advPostList;
}
private String checkNull(String inputStr) {
// TODO Auto-generated method stub
if (inputStr == null) {
inputStr = "";
}
return inputStr;
}
private String checkNullSpace(String inputStr) {
// TODO Auto-generated method stub
if (inputStr == null || inputStr.trim().length() == 0) {
inputStr = " ";
}
return inputStr;
}
private HashMap getRcpDetailScreen(String tranId, Connection conn)
throws ITMException {
// TODO Auto-generated method stub
ArrayList DetailList = new ArrayList();
HashMap advRcpDetMap = null;
String sql = "", sql1 = "", chgDtStr = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
try {
String custCode = "", refType = "", refSer = "", refId = "", refidadv = "", taxClass = "", taxChap = "", taxEnv = "", siteCode = "", currCode = "", finEntity = "";
int lineNo = 0;
double amount = 0, taxAmt = 0, exchRate = 0;
Timestamp refDate = null, tranDate = null;
sql = "select d.line_no,d.cust_code,d.ref_type,d.ref_ser,d.ref_id,d.ref_date,d.amount, d.ref_id__adv,d.tax_class,d.tax_chap,d.tax_env, d.tax_amt ,"
+ " h.tran_date,h.site_code, h.curr_code from adv_rcp_tax_det d,adv_rcp_tax h where d.tran_id=h.tran_id and d.tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next()) {
lineNo = rs.getInt(1);
custCode = rs.getString(2);
refType = rs.getString(3);
refSer = rs.getString(4);
refId = rs.getString(5);
refDate = rs.getTimestamp(6);
amount = rs.getDouble(7);
refidadv = rs.getString(8);
taxClass = rs.getString(9);
taxChap = rs.getString(10);
taxEnv = rs.getString(11);
taxAmt = rs.getDouble(12);
tranDate = rs.getTimestamp(13);
siteCode = rs.getString(14);
currCode = rs.getString(15);
System.out.println("lineNo[" + lineNo + "] custCode ["
+ custCode + "] refType [" + refType + "] refSer["
+ refSer + "]");
System.out.println("ref_id[" + refId + "] ref_date [" + refDate
+ "] amount [" + amount + "] refidadv[" + refidadv
+ "]");
System.out.println("taxClass[" + taxClass + "] taxChap ["
+ taxChap + "] taxEnv [" + taxEnv + "] taxAmt["
+ taxAmt + "]");
System.out.println("tranDate[" + tranDate + "] siteCode ["
+ siteCode + "]");
advRcpDetMap = new HashMap();
advRcpDetMap.put("line_no", lineNo);
advRcpDetMap.put("cust_code", custCode);
advRcpDetMap.put("ref_type", refType);
advRcpDetMap.put("ref_ser", refSer);
advRcpDetMap.put("ref_id", tranId);
advRcpDetMap.put("ref_date", refDate);
advRcpDetMap.put("amount", amount);
advRcpDetMap.put("ref_id__adv", refidadv);
advRcpDetMap.put("tax_class", taxClass);
advRcpDetMap.put("tax_chap", taxChap);
advRcpDetMap.put("tax_env", taxEnv);
advRcpDetMap.put("tax_amt", taxAmt);
advRcpDetMap.put("tran_date", tranDate);
advRcpDetMap.put("site_code", siteCode);
advRcpDetMap.put("curr_code", currCode);
// DetailList.add(advPostMap);
sql1 = "select fin_entity from site where site_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
finEntity = rs1.getString(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sql1 = "select std_exrt from currency where curr_code = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, currCode);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
exchRate = rs1.getDouble(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
advRcpDetMap.put("fin_entity", finEntity);
advRcpDetMap.put("exch_rate", exchRate);
advRcpDetMap.put("eff_date", tranDate);
System.out.println("advRcpDetMap::[" + advRcpDetMap + "]");
System.out.println("advPostList Size::[" + advRcpDetMap.size()
+ "]");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return advRcpDetMap;
}
private double getCreditAmt(Double input) {
double inputTemp = 0;
if (input < 0) {
inputTemp = input;
} else {
inputTemp = (-1) * input;
}
System.out.println("inputTemp[" + inputTemp + "]");
return inputTemp;
}
private double getDebitAmt(Double input) {
double inputTemp = 0;
if (input < 0) {
inputTemp = (-1) * input;
} else {
inputTemp = input;
}
System.out.println("inputTemp[" + inputTemp + "]");
return inputTemp;
}
}
package ibase.webitm.ejb.gstclient;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Local; // added for ejb3
@Local
public interface RcpAdvTaxcalcConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm(String tranID, String xtraParams, String forcedFlag,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.gstclient;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpAdvTaxcalcConfRemote extends ActionHandlerRemote
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm(String tranID, String xtraParams, String forcedFlag,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.gstclient;
//package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
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.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
@Stateless
public class RcpAdvTaxcalcIC extends ValidatorEJB
{
E12GenericUtility genericUtility= new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
ValidatorEJB validator = null;
@Override
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
System.out.println("Validation Start..........");
System.out.println("Validation Start.....xmlString[" + xmlString+ "]]]]]xmlString1[[[[[" + xmlString1 + "]]]]]][[[[[[["+ 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("retString:::"+retString);
}
catch(Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage());
e.getMessage();
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2,String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String userId = "";
String tranId = "";
String tranDate = "";
String errCode= "";
String errString = "";
String siteCode = "";
String custCode = "";
String acctcode = "";
String taxClass ="";
String taxChap ="";
String taxEnv ="";
String cctrcode = "";
String lineNo="";
int ctr = 0;
String errorType = "";
String sql="";
int currentFormNo = 0;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null;
E12GenericUtility genericUtility = new E12GenericUtility();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo["+currentFormNo+"]");
}
switch(currentFormNo)
{
case 1:
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
int childNodeListLength = childNodeList.getLength();
tranId=checkNull(genericUtility.getColumnValue("tran_id", dom));
System.out.println("tran id from boqdet --4-->>>>["+tranId+"]");
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("CURRENT COLUMN IN VALIDATION ["+childNodeName+"]");
//tran_date
if (childNodeName.equalsIgnoreCase("tran_date"))
{
tranDate=genericUtility.getColumnValue("tran_date", dom);
System.out.println("TranDate"+tranDate);
if (tranDate == null || tranDate.equals("DD/MM/YY"))
{
errCode = "VMTRANDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//site_code
else if (childNodeName.equalsIgnoreCase("site_code"))
{
int cnt =0;
siteCode = genericUtility.getColumnValue("site_code", dom);
System.out.println("Site Code"+siteCode);
if (siteCode == null || siteCode.trim().length() == 0)
{
errCode = "NULLSITECO";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " SELECT COUNT(1) FROM site WHERE site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VTINSFINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
String refSer="";
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("cust_code"))
{
int cnt=0;
custCode = genericUtility.getColumnValue("cust_code", dom);
if (custCode == null || custCode.trim().length() == 0)
{
errCode = "NULLCUSTCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " SELECT COUNT(1) FROM customer WHERE cust_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errCode = "VTINVCUST1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if (childNodeName.equalsIgnoreCase("ref_ser"))
{
int cntRefser=0;
refSer = genericUtility.getColumnValue("ref_ser", dom);
System.out.println("Ref Ser is:"+refSer);
if (refSer == null || refSer.trim().length() == 0)
{
errCode = "VMBRNUL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " SELECT COUNT(1) FROM refser WHERE ref_ser = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer);
rs = pstmt.executeQuery();
if (rs.next())
{
cntRefser = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Count is:"+cntRefser);
if (cntRefser == 0)
{
errCode = "VMREFSER ";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if (childNodeName.equalsIgnoreCase("tax_class"))
{
int cnttaxClass=0;
taxClass = checkNull(genericUtility.getColumnValue("tax_class", dom));
System.out.println("taxClass: " + taxClass);
if(taxClass != null && taxClass.trim().length() > 0 )
{
sql="select count(*) from taxclass where tax_class=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxClass);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxClass=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxClass" +cnttaxClass);
System.out.println("site_code" + siteCode);
if(cnttaxClass==0)
{
errCode = "VTTCLASS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Tax class not define in tax class master.");
}
}
}
else if (childNodeName.equalsIgnoreCase("tax_chap"))
{
int cnttaxChap=0;
taxChap = checkNull(genericUtility.getColumnValue("tax_chap", dom));
System.out.println("taxChap: " + taxChap);
if(taxChap != null && taxChap.trim().length() > 0 )
{
sql="select count(*) from taxchap where tax_chap=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxChap);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxChap=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxChap" +cnttaxChap);
if(cnttaxChap==0)
{
errCode = "VTTCHAP1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Tax chapter not define in tax chapter master");
}
}
}
else if (childNodeName.equalsIgnoreCase("tax_env"))
{
int cnttaxEnv=0;
taxEnv = checkNull(genericUtility.getColumnValue("tax_env", dom));
if(taxEnv != null && taxEnv.trim().length() > 0 )
{
sql="select count(*) from taxenv where tax_env=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxEnv);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxEnv=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxEnv" +cnttaxEnv);
if(cnttaxEnv==0)
{
errCode = "VTTENV1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("TAX ENVIRONMENT NOT DEFINED");
}
}
}
}
break;
case 3:
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
//acct_code
if (childNodeName.equalsIgnoreCase("acct_code"))
{
int cnt=0;
acctcode = genericUtility.getColumnValue("acct_code", dom);
System.out.println("Acct Code is"+acctcode);
if (acctcode == null || acctcode.trim().length() == 0)
{
errCode = "VTACCTBD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(1) from accounts where acct_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctcode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("Acct Code cnt"+cnt);
if (cnt == 0)
{
errCode = "VMACTCDMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
if (childNodeName.equalsIgnoreCase("cctr_code"))
{
int cnt =0;
cctrcode = genericUtility.getColumnValue("cctr_code", dom);
System.out.println("CCTR Code is"+cctrcode);
if (cctrcode == null || cctrcode.trim().length() == 0)
{
errCode = "VMCCTRNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(1) from costctr where cctr_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cctrcode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("CCTR Code cnt"+cnt);
if (cnt == 0)
{
errCode = "VMINVC";
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 = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>"+errString);
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");
}
else
{
errStringXml = new StringBuffer("");
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
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 d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
return errString;
}
private String gfCheckTaxenvStatus(String taxEnv,Connection conn)
{
String errorCode="",sql="",lsStatus="";
PreparedStatement pstmt=null;
ResultSet rs=null;
try
{
sql="select (case when status is null then 'A' else status end) as ls_status from taxenv where tax_env= ? and status_date <=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, taxEnv);
rs=pstmt.executeQuery();
if(rs.next())
{
lsStatus=rs.getString("ls_status");
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if("C".equalsIgnoreCase(lsStatus))
{
errorCode="VTTAXENVCL";
}
}
catch (SQLException e)
{
e.printStackTrace();
}
return errorCode;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
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();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
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);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :RcpAdvTaxCalcIC:itemChanged(String,String,String,String,String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println("returning from WsfaGradeTest itemChanged");
return (valueXmlString);
}
@Override
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
System.out.println("@@@@@@@ RcpAdvTaxcalcIC itemChanged called");
String custCode = "";
String cctrCode = "";
String acctCode = "";
String descr = "";
String loginSite = "";
String childNodeName = null;
String sql = "";
String taxClass ="";
String taxChap ="";
String taxEnv ="",taxEnvigst="";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
E12GenericUtility genericUtility = new E12GenericUtility();
//Added
System.out.println("Dom"+dom);
System.out.println( "dom1"+dom1);
System.out.println( "objcontext"+objContext);
try
{
conn = getConnection();
this.finCommon = new FinCommon();
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1 :
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '"+ currentColumn + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("loginSite["+loginSite+"]");
sql = "select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Description is["+descr+"]");
valueXmlString.append("<site_descr>").append("<![CDATA["+descr+"]]>").append("</site_descr>");
valueXmlString.append("<site_code>").append("<![CDATA["+loginSite+"]]>").append("</site_code>");
String currAppdate ="";
java.sql.Timestamp currDate = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate);
System.out.println("");
valueXmlString.append("<tran_date>").append("<![CDATA["+currAppdate+"]]>").append("</tran_date>");
}
else if(currentColumn.trim().equalsIgnoreCase("site_code"))
{
String siteCode="";
siteCode = checkNull(this.genericUtility.getColumnValue("site_code",dom));
System.out.println("siteCode["+siteCode+"]");
sql = "select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Description is["+descr+"]");
valueXmlString.append("<site_descr>").append("<![CDATA["+descr+"]]>").append("</site_descr>");
}
valueXmlString.append("</Detail1>");
break;
case 2 :
valueXmlString.append("<Detail2>");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '"+ currentColumn + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
taxClass = finCommon.getFinparams("999999","RCPTAXCALC_TAX_CLASS",conn);
System.out.println("taxClass"+taxClass);
valueXmlString.append("<tax_class protect = \"0\"><![CDATA[" + taxClass+ "]]></tax_class>");
taxChap = finCommon.getFinparams("999999","RCPTAXCALC_TAX_CHAP",conn);
System.out.println("taxChap"+taxChap);
valueXmlString.append("<tax_chap protect = \"0\"><![CDATA[" + taxChap+ "]]></tax_chap>");
taxEnv = finCommon.getFinparams("999999","RCPTAXCALC_TAX_ENV",conn);
System.out.println("taxEnv"+taxEnv);
valueXmlString.append("<tax_env protect = \"0\"><![CDATA[" + taxEnv+ "]]></tax_env>");
taxEnvigst = finCommon.getFinparams("999999","RCPTAX_TAXENVIGST",conn);
System.out.println("taxEnvigst"+taxEnvigst);
valueXmlString.append("<tax_env_igst protect = \"0\"><![CDATA[" + taxEnvigst+ "]]></tax_env_igst>");
}
if (currentColumn.trim().equalsIgnoreCase("cust_code"))
{
custCode = checkNull(this.genericUtility.getColumnValue("cust_code",dom));
sql = "select cust_name from customer where cust_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<cust_code>").append("<![CDATA["+custCode+"]]>").append("</cust_code>");
valueXmlString.append("<cust_name>").append("<![CDATA["+descr+"]]>").append("</cust_name>");
}
valueXmlString.append("</Detail2>");
break;
case 3 :
valueXmlString.append("<Detail3>");
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '"+ currentColumn + "'");
if (currentColumn.trim().equalsIgnoreCase("acct_code"))
{
acctCode = checkNull(genericUtility.getColumnValue("acct_code",dom));
sql = "select descr from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acctCode);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<acct_code>").append("<![CDATA["+acctCode+"]]>").append("</acct_code>");
valueXmlString.append("<descr>").append("<![CDATA["+descr+"]]>").append("</descr>");
}
valueXmlString.append("</Detail3>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
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 d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface RcpAdvTaxcalcLocal 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(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, 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;
}
/*
Button Name : Process
*/
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
//import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import javax.ejb.Stateless; // added for ejb3
import javax.naming.InitialContext;
@Stateless // added for ejb3
public class RcpAdvTaxcalcPrc extends ProcessEJB implements AcctCctrPrcLocal,AcctCctrPrcRemote //SessionBean
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("#### RcpAdvTaxcalcPrc @@");
Document dom = null,dom1 = null;
String retString = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(xmlString);
}
retString = process(dom,dom1,windowName,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :RcpAdvTaxcalcPrc :Process (String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("Returning from Process :: "+retString);
return retString;
}
public String process(Document dom,Document dom1,String windowName,String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
ResultSet rs = null,rs1 = null,rs2=null;
String sql = "",sql1="",sql2="";
String userId="",refNorecv="",dateStr="";
String siteCode = "",taxEnv = "";
String confirmed = "",retString = "";
String taxChap = "";
String frDate="", toDate="";
String taxClass="",taxEnvigst="";
double totAmt=0,totAmtrevAdj=0,totAmtrevAdjcnt=0,repadvAdjamt=0;
Timestamp dateFrom = null,dateTo = null;
int cntsiteCode = 0,cnttaxClass=0,cnttaxChap = 0,cnttaxEnv = 0,cntcurrCode=0;
ConnDriver connDriver = new ConnDriver();
SimpleDateFormat sdf = null;
StringBuffer xmlBuff = null;
RcpAdvTaxcalcConf Conf = null;
Timestamp refDate=null;
String custCode="";
String refSer="";
E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList receivableslList = new ArrayList();
java.util.Date currDate1 = new java.util.Date(System.currentTimeMillis());
String xmlString="",currCode="";
String siteCodeXml="",tranIdPe="";
String forcedFlag = "";
String finEntity="";
try
{ Conf = new RcpAdvTaxcalcConf();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
dateStr = sdf.format(currDate1);
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
String loginUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String empCodeAprv = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
System.out.println("Login User"+loginUser);
System.out.println(" empCodeAprv"+empCodeAprv);
String termID = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
siteCode = genericUtility.getColumnValue("site_code",dom);
confirmed = genericUtility.getColumnValue("confirmed",dom);
taxClass = genericUtility.getColumnValue("tax_class",dom);
taxChap = genericUtility.getColumnValue("tax_chap",dom);
taxEnv = genericUtility.getColumnValue("tax_env",dom);
taxEnvigst = genericUtility.getColumnValue("tax_env_igst",dom);
// currCode = genericUtility.getColumnValue("curr_code",dom);
System.out.println("RcpAdvTaxcalcPrc :siteCode:"+siteCode+":");
System.out.println("RcpAdvTaxcalcPrc :currCode:"+currCode+":");
System.out.println("RcpAdvTaxcalcPrc :confirmed:"+confirmed+":");
System.out.println("RcpAdvTaxcalcPrc :taxClass:"+taxClass+":");
System.out.println("RcpAdvTaxcalcPrc :taxChap:"+taxChap+":");
System.out.println("RcpAdvTaxcalcPrc :taxEnv: "+taxEnv+":");
frDate = genericUtility.getColumnValue("tran_date__fr",dom);
toDate = genericUtility.getColumnValue("tran_date__to",dom);
System.out.println("RcpAdvTaxcalcPrc :frDate: "+frDate+":");
System.out.println("RcpAdvTaxcalcPrc :toDate: "+toDate+":");
refSer="R-ADV";
if(siteCode == null || siteCode.trim().length() == 0 )
{
retString = itmDBAccess.getErrorString("site_code","CNFDITSITE",userId);
return retString;
}
else
{
sql="select count(*) from site where site_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cntsiteCode=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cntsiteCode" +cntsiteCode);
System.out.println("site_code" + siteCode);
if(cntsiteCode==0)
{
retString = itmDBAccess.getErrorString("site_code","VMSITE",userId);
return retString;
}
}
//
/* if(currCode == null || currCode.trim().length() == 0 )
{
retString = itmDBAccess.getErrorString("curr_code","VMCURRCD1",userId);
return retString;
}
else
{
sql="select count(*) from currency where curr_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cntcurrCode=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cntcurrCode" +cntcurrCode);
System.out.println("curr_code" + currCode);
if(cntcurrCode==0)
{
retString = itmDBAccess.getErrorString("curr_code","INVCURRCD",userId);
return retString;
}
}*/
if(taxClass != null && taxClass.trim().length() > 0 )
{
sql="select count(*) from taxclass where tax_class=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxClass);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxClass=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxClass" +cnttaxClass);
System.out.println("site_code" + siteCode);
if(cnttaxClass==0)
{
retString = itmDBAccess.getErrorString("tax_class","VMTAXCLND",userId);
return retString;
}
}
if(taxChap != null && taxChap.trim().length() > 0 )
{
sql="select count(*) from taxchap where tax_chap=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxChap);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxChap=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxChap" +cnttaxChap);
if(cnttaxChap==0)
{
retString = itmDBAccess.getErrorString("tax_chap","VMTAXCPND",userId);
return retString;
}
}
//tax env
if(taxEnv != null && taxEnv.trim().length() > 0 )
{
sql="select count(*) from taxenv where tax_env=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxEnv);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxEnv=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxChap" +cnttaxChap);
if(cnttaxEnv==0)
{
retString = itmDBAccess.getErrorString("tax_env","VMTAXENVNF",userId);
return retString;
}
}
//tax envigst
if(taxEnvigst != null && taxEnvigst.trim().length() > 0 )
{
sql="select count(*) from taxenv where tax_env=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, taxEnvigst);
rs = pstmt.executeQuery();
if(rs.next())
{
cnttaxEnv=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnttaxChap" +cnttaxChap);
if(cnttaxEnv==0)
{
retString = itmDBAccess.getErrorString("tax_env_igst","VMTAXENVNF",userId);
return retString;
}
}
if(frDate == null || toDate == null)
{
retString = itmDBAccess.getErrorString("","VEDATE",userId);
return retString;
}
else
{
java.util.Date fromUtilDate = null, toUtilDate = null;
if(frDate!= null && frDate.indexOf("-") != -1){
frDate = frDate.replace('-','/');
}
if(toDate!= null && toDate.indexOf("-") != -1){
toDate = toDate.replace('-','/');
}
fromUtilDate = sdf.parse(frDate.substring(0,8));
toUtilDate = sdf.parse(toDate.substring(0,8));
if (fromUtilDate.after(toUtilDate))
{
retString = itmDBAccess.getErrorString("","VFRTODATE",userId);
return retString;
}
}
sql = "select fin_entity from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
finEntity = rs.getString(1);
}
else
{
retString = itmDBAccess.getErrorString("","VTFINENT",userId);
return retString;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// Checking Currency Code
sql = "select curr_code from finent where fin_entity = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,finEntity);
rs = pstmt.executeQuery();
if(rs.next())
{
currCode = rs.getString(1);
}
else
{
retString = itmDBAccess.getErrorString("","VTCURFIN",userId);
return retString;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
String stateCodeCust="",stateCodeSite="";
Object date = null;
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
date = sdf.parse(frDate);
sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
dateFrom = java.sql.Timestamp.valueOf(sdf1.format(date).toString() + " 00:00:00.0");
date = sdf.parse(toDate);
dateTo = java.sql.Timestamp.valueOf(sdf1.format(date).toString() + " 00:00:00.0");
int cnt=0;
sql=" select count(1) from ADV_RCP_TAX where confirmed='N' and tran_date between ? and ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, dateFrom);
pstmt.setTimestamp(2, dateTo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("cnt" +cnt);
if(cnt > 0)
{
retString = itmDBAccess.getErrorString("","VMEMPBND15",userId);
return retString;
}
else
{
sql="select tot_amt,ref_no,cust_code,ref_date from receivables where ref_date > = ? and ref_date <= ? and site_code=? and tran_ser=? " +
"and ref_no NOT IN( select ADV_RCP_TAX_DET.ref_id " +
"from ADV_RCP_TAX_DET ,ADV_RCP_TAX where ADV_RCP_TAX_DET.tran_id = ADV_RCP_TAX.tran_id " +
"and ADV_RCP_TAX.confirmed = 'Y' and (ADV_RCP_TAX.tran_date between ? and ?) and ADV_RCP_TAX_DET.ref_type = '1' )";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, dateFrom);
pstmt.setTimestamp(2, dateTo);
pstmt.setString(3, siteCode);
pstmt.setString(4,refSer);
pstmt.setTimestamp(5, dateFrom);
pstmt.setTimestamp(6, dateTo);
rs = pstmt.executeQuery();
System.out.println("rs["+rs+"]");
while(rs.next())
{
totAmt=rs.getDouble(1);
refNorecv=rs.getString(2);
custCode=rs.getString(3);
refDate=rs.getTimestamp(4);
HashMap receivablesMap = new HashMap();
receivablesMap.put("cust_code",custCode);
receivablesMap.put("ref_type","1");
receivablesMap.put("ref_ser","R-ADV");
receivablesMap.put("ref_id",refNorecv);
receivablesMap.put("ref_date",refDate);
receivablesMap.put("amount",totAmt);
receivablesMap.put("ref_id__adv","");
//receivablesMap.put("date_adv","");
receivablesMap.put("tax_class",taxClass);
receivablesMap.put("tax_chap",taxChap);
sql1="select stan_code from customer where cust_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,custCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeCust=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
sql1="select stan_code from site where site_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeSite=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
System.out.println("stateCodeCust["+stateCodeCust+"] stateCodeSite["+stateCodeSite+"]");
System.out.println("! stateCodeCust.equalsIgnoreCase(stateCodeSite)"+! stateCodeCust.equalsIgnoreCase(stateCodeSite));
if(! stateCodeCust.equalsIgnoreCase(stateCodeSite))
{
receivablesMap.put("tax_env",taxEnvigst);
}
else
{
receivablesMap.put("tax_env",taxEnv);
}
receivableslList.add(receivablesMap);
System.out.println("@@@@@@@@@@@@@@@@ List1["+receivableslList+"]");
System.out.println("@@@@@@@@@@@@@@@@ Size[List1]["+receivableslList.size()+"]");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
String refSerAdj="",custCodei="",refNo="",refNoAdj="";
double netAmt=0;
String refseries="R-ADV";
String refseriesAdj="S-INV";
Timestamp tranDatei= null;
sql1="select r.ref_ser_adj ,r.ref_no_adj,r.adj_amt,i.cust_code,i.tran_date ,r.ref_no from receivables_adj r ,invoice i where r.ref_no_adj=i.invoice_id " +
"and r.ref_ser= ? and r.ref_ser_adj= ? and i.tran_date > =? and i.tran_date < =? and i.confirmed= 'Y' " +
"and r.ref_no_adj NOT IN( select ADV_RCP_TAX_DET.ref_id " +
"from ADV_RCP_TAX_DET ,ADV_RCP_TAX where ADV_RCP_TAX_DET.tran_id = ADV_RCP_TAX.tran_id " +
"and ADV_RCP_TAX.confirmed = 'Y' and (ADV_RCP_TAX.tran_date between ? and ?) and ADV_RCP_TAX_DET.ref_type = '2' )";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,refseries);
pstmt1.setString(2,refseriesAdj);
pstmt1.setTimestamp(3,dateFrom);
pstmt1.setTimestamp(4,dateTo);
pstmt1.setTimestamp(5,dateFrom);
pstmt1.setTimestamp(6,dateTo);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
refSerAdj=rs1.getString(1);
refNoAdj=rs1.getString(2);
netAmt=rs1.getDouble(3);
custCodei=rs1.getString(4);
tranDatei=rs1.getTimestamp(5);
refNo=rs1.getString(6);
System.out.println("refSerAdj["+refSerAdj+"] refNoAdj ["+refNoAdj+"] netAmt ["+netAmt+"] custCodei["+custCodei+"] tranDatei ["+tranDatei+"]");
System.out.println("refNo["+refNo+"]");
HashMap receivableadj = new HashMap();
receivableadj.put("cust_code",custCodei); //invoice cust code
receivableadj.put("ref_type","2");
receivableadj.put("ref_ser",refSerAdj);
receivableadj.put("ref_id",refNoAdj); //invoice number
receivableadj.put("ref_date",tranDatei); //inv tran date
receivableadj.put("amount",netAmt); // net amt
receivableadj.put("ref_id__adv",refNo);//receivables ref_no
//receivableadj.put("date_adv","");
receivableadj.put("tax_class",taxClass);
receivableadj.put("tax_chap",taxChap);
sql2="select stan_code from customer where cust_code= ?";
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1,custCodei);
rs2 = pstmt2.executeQuery();
if(rs2.next())
{
stateCodeCust=rs2.getString(1);
}
rs2.close();
rs2=null;
pstmt2.close();
pstmt2=null;
sql2="select stan_code from site where site_code= ?";
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1,siteCode);
rs2 = pstmt2.executeQuery();
if(rs2.next())
{
stateCodeSite=rs2.getString(1);
}
rs2.close();
rs2=null;
pstmt2.close();
pstmt2=null;
if(! stateCodeCust.equalsIgnoreCase(stateCodeSite))
{
receivableadj.put("tax_env",taxEnvigst);
}
else
{
receivableadj.put("tax_env",taxEnv);
}
System.out.println("@@@@@@@@@@@@@@@@receivableadj["+receivableadj+"]");
receivableslList.add(receivableadj);
refSerAdj="";
refNoAdj="";
netAmt= 0;
custCodei="";
tranDatei=null;
refNo="";
totAmtrevAdj=0;
custCode="";
refNorecv="";
refDate=null;
totAmt=0;
System.out.println("@@@@@@@@@@@@@@@@receivableslList[receivableadj]["+receivableslList+"]");
System.out.println("@@@@@@@@@@@@@@@@receivableslList Size[receivablesMap]["+receivableslList.size()+"]");
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
System.out.println("2 List["+receivableslList+"]");
System.out.println("2 List Size["+receivableslList.size()+"]");
double repadvTotamt=0;
String reciptTranId="",rcpAdvCustCOde="",rcpAdvrefType="2",rcpadvRefno="";
Timestamp rcpAdvrefDate=null;
sql="select rcpadv.adj_amt,receipt.cust_code,receipt.tran_date,receipt.tran_id,rcpadv.ref_no from rcpadv ,receipt " +
"where receipt.tran_id=rcpadv.tran_id and receipt.tran_date >= ? and receipt.tran_date <= ? and rcpadv.ref_ser=? and " +
" receipt.tran_id NOT IN( select ADV_RCP_TAX_DET.ref_id " +
"from ADV_RCP_TAX_DET ,ADV_RCP_TAX where ADV_RCP_TAX_DET.tran_id = ADV_RCP_TAX.tran_id " +
"and ADV_RCP_TAX.confirmed = 'Y' and (ADV_RCP_TAX.tran_date between ? and ?) and ADV_RCP_TAX_DET.ref_type = '2' )";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, dateFrom);
pstmt.setTimestamp(2, dateTo);
pstmt.setString(3, refSer);
pstmt.setTimestamp(4, dateFrom);
pstmt.setTimestamp(5, dateTo);
rs = pstmt.executeQuery();
while(rs.next())
{
repadvAdjamt=rs.getDouble(1);
rcpAdvCustCOde=rs.getString(2);
rcpAdvrefDate=rs.getTimestamp(3);
reciptTranId=rs.getString(4);
rcpadvRefno=rs.getString(5);
System.out.println("repadvTotamt["+repadvTotamt+"] reciptTranId ["+reciptTranId+"] repadvAdjamt ["+repadvAdjamt+"] rcpAdvCustCOde["+rcpAdvCustCOde+"] rcpAdvrefDate ["+rcpAdvrefDate+"]");
HashMap rcpAdv = new HashMap();
rcpAdv.put("cust_code",rcpAdvCustCOde);
rcpAdv.put("ref_type","2");
rcpAdv.put("ref_ser","RCP");
rcpAdv.put("ref_id",reciptTranId); //receipt Number
rcpAdv.put("ref_date",rcpAdvrefDate);
rcpAdv.put("amount",repadvAdjamt);
rcpAdv.put("ref_id__adv",rcpadvRefno); //rcpadv
//rcpAdv.put("date_adv","");
rcpAdv.put("tax_class",taxClass);
rcpAdv.put("tax_chap",taxChap);
sql1="select stan_code from customer where cust_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,rcpAdvCustCOde);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeCust=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
sql1="select stan_code from site where site_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeSite=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
if(! stateCodeCust.equalsIgnoreCase(stateCodeSite))
{
rcpAdv.put("tax_env",taxEnvigst);
}
else
{
rcpAdv.put("tax_env",taxEnv);
}
receivableslList.add(rcpAdv);
System.out.println("@@@@@@@@@@@@@@@@ List3["+receivableslList+"]");
System.out.println("@@@@@@@@@@@@@@@@ List3 Size["+receivableslList.size()+"]");
repadvAdjamt=0;
rcpAdvCustCOde="";
rcpAdvrefDate=null;
reciptTranId="";
rcpadvRefno="";
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//rcpdet
String rcpDetrefNo="",rcpDetCustCOde="",rcpAdvrefNo="",rcpTranId="";
double rcpDetrcpAmt=0;
String confTemp="N";
Timestamp rcpDetrefDate=null;
sql="select rcpdet.ref_no,rcpdet.rcp_amt,receipt.cust_code,receipt.tran_date,receipt.tran_id from rcpdet,receipt where receipt.tran_id=rcpdet.tran_id and receipt.tran_date >= ? and receipt.tran_date <= ? and rcpdet.ref_ser= ? and " +
" receipt.tran_id NOT IN( select ADV_RCP_TAX_DET.ref_id " +
"from ADV_RCP_TAX_DET ,ADV_RCP_TAX where ADV_RCP_TAX_DET.tran_id = ADV_RCP_TAX.tran_id " +
"and ADV_RCP_TAX.confirmed = 'Y' and (ADV_RCP_TAX.tran_date between ? and ?) and ADV_RCP_TAX_DET.ref_type = '2' )";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, dateFrom);
pstmt.setTimestamp(2, dateTo);
pstmt.setString(3, refSer);
pstmt.setTimestamp(4, dateFrom);
pstmt.setTimestamp(5, dateTo);
rs = pstmt.executeQuery();
while(rs.next())
{
rcpDetrefNo=rs.getString(1);
rcpDetrcpAmt=rs.getDouble(2);
rcpDetCustCOde=rs.getString(3);
rcpDetrefDate=rs.getTimestamp(4);
rcpTranId=rs.getString(5);
System.out.println("rcpDetrcpAmt["+rcpDetrcpAmt+"] rcpDetrefNo ["+rcpDetrefNo+"] rcpDetCustCOde["+rcpDetCustCOde+"] rcpDetrefDate ["+rcpDetrefDate+"]");
HashMap rcpDet = new HashMap();
rcpDet.put("cust_code",rcpDetCustCOde);
rcpDet.put("ref_type","2");
rcpDet.put("ref_ser","RCP");
rcpDet.put("ref_id",rcpTranId);
rcpDet.put("ref_date",rcpDetrefDate);
rcpDet.put("amount",rcpDetrcpAmt);
rcpDet.put("ref_id__adv",rcpDetrefNo);
rcpDet.put("tax_class",taxClass);
rcpDet.put("tax_chap",taxChap);
sql1="select stan_code from customer where cust_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,rcpDetCustCOde);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeCust=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
sql1="select stan_code from site where site_code= ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,siteCode);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
stateCodeSite=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
if(! stateCodeCust.equalsIgnoreCase(stateCodeSite))
{
rcpDet.put("tax_env",taxEnvigst);
}
else
{
rcpDet.put("tax_env",taxEnv);
}
receivableslList.add(rcpDet);
rcpAdvCustCOde="";
rcpAdvrefNo="";
rcpAdvrefDate=null;
repadvTotamt=0;
System.out.println("@@@@@@@@@@@@@@@@ List4["+receivableslList+"]");
System.out.println("@@@@@@@@@@@@@@@@ List4["+receivableslList.size()+"]");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
xmlBuff = new StringBuffer();
System.out.println("--XML CREATION --");
System.out.println("--Records Details--"+receivableslList);
System.out.println("--Records --"+receivableslList.size());
if(receivableslList.size() > 0)
{
System.out.println("tran_date-->dateStr@@["+dateStr+"]");
System.out.println("confTemp-->["+dateStr+"]");
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("rcpadv_taxcalc").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"rcpadv_taxcalc\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
//xmlBuff.append("<tran_id><![CDATA[" + tranIdPe + "]]></tran_id>");
xmlBuff.append("<tran_id><![CDATA[]]></tran_id>");
xmlBuff.append("<tran_date><![CDATA[" + dateStr + "]]></tran_date>");
xmlBuff.append("<curr_code><![CDATA[" + currCode + "]]></curr_code>");
//xmlBuff.append("<tax_date><![CDATA[" + sdf.format(new java.util.Date()).toString() + "]]></tax_date>");
xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>");
xmlBuff.append("<confirmed><![CDATA[" + confTemp + "]]></confirmed>");
xmlBuff.append("<add_date><![CDATA[" + dateStr + "]]></add_date>");
xmlBuff.append("<add_user><![CDATA[" + loginUser + "]]></add_user>");
xmlBuff.append("<add_term><![CDATA[" + termID + "]]></add_term>");
xmlBuff.append("<chg_date><![CDATA[" + dateStr + "]]></chg_date>");
xmlBuff.append("<chg_user><![CDATA[" + loginUser + "]]></chg_user>");
xmlBuff.append("<chg_term><![CDATA[" + termID + "]]></chg_term>");
xmlBuff.append("</Detail1>");
int lilineno1=1;
for(int n = 0;n < receivableslList.size();n++)
{
String custcodeDet="",refTypeDet="",refSerDet="",refIdDet="",refIdAdvDet="",taxClassDet="",taxChapDet="",taxEnvDet="";
double amount=0,lctaxdet=0;
Timestamp refDadteDet=null;
SimpleDateFormat sdftemp = null;
HashMap payDetTranMap = (HashMap)receivableslList.get(n);
System.out.println("lilineno1["+lilineno1+"]");
custcodeDet =(String)payDetTranMap.get("cust_code");
refTypeDet = (String)payDetTranMap.get("ref_type");
refSerDet = (String)payDetTranMap.get("ref_ser");
refIdDet= (String)payDetTranMap.get("ref_id");
refDadteDet =(Timestamp)(payDetTranMap.get("ref_date"));
amount = ((Double)payDetTranMap.get("amount")).doubleValue();
taxClassDet = (String)payDetTranMap.get("tax_class");
System.out.println("taxClassDet is [In Loop]"+taxClassDet);
taxChapDet = (String)payDetTranMap.get("tax_chap");
System.out.println("taxChapDet is [In Loop]"+taxChapDet);
taxEnvDet = (String)payDetTranMap.get("tax_env");
System.out.println("taxEnvDet is [In Loop]"+taxEnvDet);
refIdAdvDet=(String)payDetTranMap.get("ref_id__adv");
sdftemp=new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("Amount is [In Loop]"+amount);
if(amount !=0)
{
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"rcpadv_taxcalc\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id><![CDATA[]]></tran_id>");
xmlBuff.append("<line_no><![CDATA["+lilineno1+"]]></line_no>");
xmlBuff.append("<cust_code><![CDATA["+custcodeDet+"]]></cust_code>");
xmlBuff.append("<ref_type><![CDATA["+refTypeDet+"]]></ref_type>");
System.out.println("refTypeDet"+refTypeDet);
xmlBuff.append("<ref_ser><![CDATA["+refSerDet+"]]></ref_ser>");
if(refIdDet !=null && refIdDet.trim().length() > 0)
{
xmlBuff.append("<ref_id><![CDATA["+refIdDet.trim()+"]]></ref_id>");
}
if(refIdAdvDet !=null && refIdAdvDet.trim().length() > 0)
{
System.out.println("refDadteDet:::"+refDadteDet);
dateStr = sdftemp.format(refDadteDet);
System.out.println("dateStr:::"+dateStr);
xmlBuff.append("<ref_date><![CDATA["+dateStr+"]]></ref_date>");
}
else
{
System.out.println("Ref Date in Else");
xmlBuff.append("<ref_date><![CDATA[]]></ref_date>");
}
if("1".equalsIgnoreCase(refTypeDet))
{
double amt=0;
amt=getAdvance(amount);
System.out.println("amt["+amt+"]");
xmlBuff.append("<amount><![CDATA["+amt+"]]></amount>");
}
else
{
System.out.println("Else refType is:"+refTypeDet);
double amttemp=0;
amttemp=getAdjust(amount);
System.out.println("amttemp["+amttemp+"]");
xmlBuff.append("<amount><![CDATA["+amttemp+"]]></amount>");
}
if(refIdAdvDet!=null && refIdAdvDet.trim().length() > 0)
{
xmlBuff.append("<ref_id__adv><![CDATA["+refIdAdvDet.trim()+"]]></ref_id__adv>");
}
xmlBuff.append("<tax_class><![CDATA["+taxClassDet+"]]></tax_class>");
xmlBuff.append("<tax_chap><![CDATA["+taxChapDet+"]]></tax_chap>");
xmlBuff.append("<tax_env><![CDATA["+taxEnvDet+"]]></tax_env>");
xmlBuff.append("<tax_amt><![CDATA["+ lctaxdet +"]]></tax_amt>");
xmlBuff.append("</Detail2>");
System.out.println("XML@@@@@@@@@@@@@Deatil2"+xmlBuff);
lilineno1++;
}
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("@@@@@2: xmlString:"+xmlBuff.toString());
System.out.println("...............just before savdata()");
siteCodeXml = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("== siteCodeXml =="+siteCodeXml);
retString = saveData(siteCodeXml,xmlString,conn);
System.out.println("@@@@@2: retString :"+retString);
System.out.println("--retString finished--");
}
else
{
retString = itmDBAccessEJB.getErrorString("","NORECFND","","",conn);
}
if (retString.indexOf("Success") > -1)
{
System.out.println(" Generated retString [" + retString + "]");
String[] arrayForTranId1 = retString.split("<TranID>");
System.out.println("Tran ID :::::in conf:::::::"+arrayForTranId1);
System.out.println("Tran ID :::::in conf:::::::"+arrayForTranId1[1]);
int endIndex1 = arrayForTranId1[1].indexOf("</TranID>");
System.out.println("endIndex1:::::::"+endIndex1);
tranIdPe = arrayForTranId1[1].substring(0, endIndex1);
System.out.println("tranIdPe=====["+tranIdPe+"]");
}
else
{
conn.rollback();
return retString;
}
confirmed = genericUtility.getColumnValue("confirmed",dom);
System.out.println("confirmed()"+confirmed);
if( "Y".equalsIgnoreCase(confirmed))
{
System.out.println("confirmed"+ confirmed);
retString = Conf.confirm(tranIdPe, xtraParams, forcedFlag,conn); //nvo_miscvouch.gbf_retrieve_misc_vou(lstr_pur_exp_reco.voucher_no, lstr_pur_exp_reco.voucher_no,2,ls_errcode,ls_site_code)
}
Conf = null;
System.out.println("@@@@@@retString is" + retString);
if(retString.indexOf("CONFSUCCES") > -1 || retString.indexOf("Success") > -1 )
{
retString = itmDBAccessEJB.getErrorString("","VPSUCC1","","",conn);
}
else
{
conn.rollback();
System.out.println("#####Error String is" + retString);
return retString;
}
tranIdPe="";
if("N".equalsIgnoreCase(confirmed))
{
System.out.println("N.equalsIgnoreCase(confirmed)"+confirmed );
}
}
}
catch(SQLException e)
{
System.out.println("Exception : RcpAdvTaxCalcPrc : Process()" +e.getMessage());
throw new ITMException(e);
}
catch(Exception e)
{
System.out.println("Exception :RcpAdvTaxCalcPrc :Process():"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Database Connection......");
conn.close();
conn = null;
}catch(Exception se){}
}
return retString;
}
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);
System.out.println("--retString - -"+retString);
}
catch(ITMException itme)
{
System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme;
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e);
}
return retString;
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
private double getAdvance(Double input)
{
double inputTemp =0;
if (input < 0)
{
inputTemp=input;
}
else
{
inputTemp=(-1) * input;
}
System.out.println("inputTemp["+inputTemp+"]");
return inputTemp;
}
private double getAdjust(Double input)
{
double inputTemp =0;
if (input < 0)
{
inputTemp=(-1) * input;
}
else
{
inputTemp=input;
}
System.out.println("inputTemp["+inputTemp+"]");
return inputTemp;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpAdvTaxcalcPrcLocal extends ProcessLocal
{
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpAdvTaxcalcPrcRemote extends ProcessRemote
{
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface RcpAdvTaxcalcRemote 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(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, 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;
}
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