Commit 428bed9b authored by vkadam's avatar vkadam

Change in Auto payment generation process, Purchase voucher create scheduler,...

Change in Auto payment generation process, Purchase voucher create scheduler, Generate tax voucher scheduler.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100349 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 78a35a9a
......@@ -56,9 +56,12 @@ public class AutoPmtGenPrc extends ProcessEJB
Timestamp dateTo = null;
Timestamp dateFr = null;
String startDateStr = null;
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
FinCommon finCommon=new FinCommon();
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams)
throws RemoteException, ITMException
......@@ -155,10 +158,11 @@ public class AutoPmtGenPrc extends ProcessEJB
String resultString = "";
String getSql = null;
String currCode = "";
String checkBarCd="";
String sql = null;
ResultSet rs = null;
ResultSet rs1 = null;
String spiltChq = "";
String spiltChq = "",barCode="";
PreparedStatement pstmt = null; PreparedStatement pstmt1 = null;
double unapprovedPayAmt = 0.0D; double payAmt = 0.0D; double netPayable = 0.0D;
......@@ -173,6 +177,24 @@ public class AutoPmtGenPrc extends ProcessEJB
conn.setAutoCommit(false);
stmtTemp = conn.createStatement();
DatabaseMetaData dbmd = conn.getMetaData();
/**
* [F15KSUN014]
* VALLABH KADAM
* select finparam 'CHECK_BARCD_APMT'
* */
checkBarCd=checkNull(finCommon.getFinparams("999999", "CHECK_BARCD_APMT", conn));
if(checkBarCd==null || checkBarCd.trim().length() == 0 || checkBarCd.trim().equalsIgnoreCase("NULLFOUND"))
{
checkBarCd="N";
}
System.out.println("Check bar code from finparm :- ["+checkBarCd+"]");
/**
* [F15KSUN014]
* VALLABH KADAM
* select finparam 'CHECK_BARCD_APMT'
* END
* */
getSql = "select var_value from finparm where prd_code='999999' and var_name='AUTOPAYGEN_LOG_FLAG'";
pstmt = conn.prepareStatement(getSql);
......@@ -372,6 +394,45 @@ public class AutoPmtGenPrc extends ProcessEJB
payAmt = rs.getDouble("pay_amt");
netPayable = rs.getDouble("net_payable");
dueDate = rs.getString("due_date");
/**
* [F15KSUN014]
* VALLABH KADAM
* Select BARCODE
* using 'DDF_GET_MULTI_BARCODE' function
* 24/FEB/16
* */
if("Y".equalsIgnoreCase(checkBarCd))
{
System.out.println("Check bar code found Y");
tempSql="select DDF_GET_MULTI_BARCODE(?) as barcode from dual";
pstmt1=conn.prepareStatement(tempSql);
pstmt1.setString(1, refNo);
rsTemp = pstmt1.executeQuery();
if (rsTemp.next())
{
barCode=checkNull(rsTemp.getString("barcode"));
}
pstmt1.close();
pstmt1 = null;
rsTemp.close();
rsTemp = null;
if(barCode==null || barCode.trim().length()==0)
{
continue;
}
}
/**
* [F15KSUN014]
* VALLABH KADAM
* Select BARCODE
* using 'DDF_GET_MULTI_BARCODE' function
* 24/FEB/16
* END
* */
tempSql = " select sum(b.net_amt) as unconfirm_amt from misc_payment a,misc_paydet b where a.tran_id=b.tran_id and b.tran_ser=? and b.vouch_no= ? and a.confirmed='N' ";
......@@ -572,7 +633,7 @@ public class AutoPmtGenPrc extends ProcessEJB
String wfStatus = "";
String spiltChq = "";
String stanCode = "";
String checkBarCd="";
String tranDate = "";
double diffAmt = 0.0D;
String retString = "";
......@@ -649,6 +710,9 @@ Timestamp refDateSTr=null;
String maxRefNo = "";
try
{
System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........." + intializingLog("Gen_bank_payment_log"));
StringBuffer retBuf = new StringBuffer();
conn = connDriver.getConnectDB("DriverITM");
......
......@@ -435,7 +435,7 @@ public class AutoPmtPrcSch
System.out.println("Calling getData() Method@@@@@@@@@@@");
retString = aPayPrc.getData(xmlString1, xmlString2, windowName, xtraParams, isSSCUsers);
System.out.println("ResultString....." + retString);
System.out.println("Get DATA Result String :- [" + retString+"]");
System.out.println("Processing DATA *****");
System.out.println("getData Method Finished@@@@@@@@@@@2");
......@@ -543,7 +543,7 @@ public class AutoPmtPrcSch
System.out.println("xmlString4@@@@@@@@@@@@@@@@:" + xmlString4);
System.out.println("Calling process() Method@@@@@@@@@@@@");
retString1 = aPayPrc.process(xmlString1, xmlString4, windowName, xtraParams);
System.out.println("retString1 in Scheduler=====" + retString1);
System.out.println("Process return String :-[" + retString1+"]");
System.out.println("-----Process() called successfully-------");
}
......
......@@ -75,7 +75,9 @@ public class CreatePoRcpVoucher
String remarks = "", siteCode = "", invoiceNo = "", DcNo = "", retOpt = "", postType = "", itemSer = "";
String invOnLine = "", poRcpOnLine = "", postProv = "", crTerm = "", projCode = "", pordType = "";
String analCode = "", bankCodePay = "", acctCodePur = "", cctrCodePur = "", payMode = "", profileId = "",tranIdVoucher="";
String finEntity = "", bankCode = "", keyString = "", ledgPostConf = "",whetherToConvert = "N", userId = "SYSTEM", termId = "SYSTEM";
String finEntity = "", bankCode = "", keyString = "", ledgPostConf = "",whetherToConvert = "N";
// String userId = "SYSTEM", termId = "SYSTEM";
String userId = "", termId = "";
java.text.SimpleDateFormat sdf = null;
String acctCodeCF = "", acctCodeCFAP = "", cctrCodeCF = "", cctrCodeCFAP = "", suppCodePay = "";
String rcpLine = "", purcOrderDet = "", lineNoOrd = "", rcpItemCode = "", rcpUnit = "";
......@@ -95,6 +97,10 @@ public class CreatePoRcpVoucher
InitialContext ctx = new InitialContext(p);
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termId= genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
System.out.println("@@@ User Id from xtraparam :- ["+userId+"]");
System.out.println("@@@ Term Id from xtraparam :- ["+termId+"]");
sql = "SELECT PROFILE_ID FROM USERS WHERE CODE = ? ";
pstmt = conn.prepareStatement(sql);
......@@ -839,9 +845,14 @@ public class CreatePoRcpVoucher
xmlBuff.append("<diff_amt__exch><![CDATA[0]]></diff_amt__exch>");
xmlBuff.append("<supp_bill_amt><![CDATA[" + suppBillAmount + "]]></supp_bill_amt>");
sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateTimeFormat());
xmlBuff.append("<add_date><![CDATA[" + sdf.format(today) + "]]></add_date>");
xmlBuff.append("<add_user><![CDATA[" + (userId==null?"BASE":userId) + "]]></add_user>");
xmlBuff.append("<add_term><![CDATA[" + (termId==null?"BASE":termId) + "]]></add_term>");
xmlBuff.append("<chg_user><![CDATA[" + (userId==null?"BASE":userId) + "]]></chg_user>");
xmlBuff.append("<chg_term><![CDATA[" + (termId==null?"BASE":termId) + "]]></chg_term>");
sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateTimeFormat());
//sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateTimeFormat());
xmlBuff.append("<chg_date><![CDATA[" + sdf.format(today) + "]]></chg_date>");
xmlBuff.append("</Detail1>");
......@@ -1775,7 +1786,9 @@ public class CreatePoRcpVoucher
userInfoBean.setUserCountry(userInfoArray[19]);
//masterStatefulLocal = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
//String retString = masterStatefulLocal.processRequest(userInfoBean, xmlString, true, conn);
String retString =saveData(userInfoBean,siteCode, xmlBuff.toString(), conn);
// String retString =saveData(userInfoBean,siteCode, xmlBuff.toString(), conn);
String retString =saveData(xtraParams,siteCode, xmlBuff.toString(), conn);
/**
* Vishakha Dhoble 02-Nov-15 (F15GSUN009)
* */
......@@ -2170,8 +2183,86 @@ public class CreatePoRcpVoucher
return dueDate;
}
// public double[] getPurcRate(String purcOrder,String itemCode,double poRate,double poDisc, Connection conn) throws ITMException
// {
// PreparedStatement pstmt = null;
// ResultSet rs = null;
// String sql = "";
// String porderNo = "", provNo = "";
// double rateDiscount[] = {0,0};
// try
// {
// sql = " select purc_order, (case when provi_tran_id is null then '' else provi_tran_id end) as provi_tran_id"
// + " from porder where purc_order = ?"; //: ;
//
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1,purcOrder);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// porderNo = rs.getString("purc_order");
// provNo = rs.getString("provi_tran_id");
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
//
// if (porderNo.equals(provNo))
// {
// sql = " select rate, discount "
// + " from porder a, porddet b "
// + " where a.purc_order = b.purc_order "
// + " and a.purc_order <> ? "
// + " and a.provi_tran_id = ? "
// + " and b.item_code = ? "
// + " and a.confirmed = 'Y' ";
//
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1,purcOrder);
// pstmt.setString(2,purcOrder);
// pstmt.setString(3,itemCode);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// poRate = rs.getDouble("rate");
// poDisc = rs.getDouble("discount");
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// }
// else
// {
// poRate = -999;
// poDisc = -999;
// }
// rateDiscount[0] = poRate;
// rateDiscount[1] = poDisc;
// } // try
// catch(Exception e)
// {
// throw new ITMException(e);
// }
// finally
// {
// try
// {
// if(rs != null){rs.close();rs = null;}
// if(pstmt != null){pstmt.close();pstmt = null;}
// }
// catch(Exception e)
// {
// throw new ITMException(e);
// }
// }
// return rateDiscount;
//
// }
public double[] getPurcRate(String purcOrder,String itemCode,double poRate,double poDisc, Connection conn) throws ITMException
{
System.out.println("Change method getPurcRate()");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
......@@ -2179,36 +2270,36 @@ public class CreatePoRcpVoucher
double rateDiscount[] = {0,0};
try
{
sql = " select purc_order, (case when provi_tran_id is null then '' else provi_tran_id end) as provi_tran_id"
+ " from porder where purc_order = ?"; //: ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,purcOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
porderNo = rs.getString("purc_order");
provNo = rs.getString("provi_tran_id");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (porderNo.equals(provNo))
{
// sql = " select purc_order, (case when provi_tran_id is null then '' else provi_tran_id end) as provi_tran_id"
// + " from porder where purc_order = ?"; //: ;
//
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1,purcOrder);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// porderNo = rs.getString("purc_order");
// provNo = rs.getString("provi_tran_id");
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
//
// if (porderNo.equals(provNo))
// {
sql = " select rate, discount "
+ " from porder a, porddet b "
+ " where a.purc_order = b.purc_order "
+ " and a.purc_order <> ? "
+ " and a.provi_tran_id = ? "
+ " and b.item_code = ? "
+ " and a.confirmed = 'Y' ";
+ " from porder a, porddet b "
+ " where a.purc_order = b.purc_order "
+ " and a.purc_order = ? "
//+ " and a.provi_tran_id = ? "
+ " and b.item_code = ? "
+ " and a.confirmed = 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,purcOrder);
pstmt.setString(2,purcOrder);
pstmt.setString(3,itemCode);
// pstmt.setString(2,purcOrder);
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -2219,12 +2310,12 @@ public class CreatePoRcpVoucher
rs = null;
pstmt.close();
pstmt = null;
}
else
{
poRate = -999;
poDisc = -999;
}
// }
// else
// {
// poRate = -999;
// poDisc = -999;
// }
rateDiscount[0] = poRate;
rateDiscount[1] = poDisc;
} // try
......@@ -2244,6 +2335,10 @@ public class CreatePoRcpVoucher
throw new ITMException(e);
}
}
System.out.println("Arry length :- ["+rateDiscount.length+"]");
System.out.println("Arry :- ["+rateDiscount[0]+"]");
System.out.println("Arry :- ["+rateDiscount[1]+"]");
return rateDiscount;
}
......@@ -2387,12 +2482,16 @@ public class CreatePoRcpVoucher
}
return errCode;
}
private String saveData(UserInfoBean userInfoBean,String siteCode, String xmlString, Connection conn) throws ITMException
// private String saveData(UserInfoBean userInfoBean,String siteCode, String xmlString, Connection conn) throws ITMException
private String saveData(String xtraParams,String siteCode, String xmlString, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
ibase.utility.UserInfoBean userInfoBean=new UserInfoBean();
try
{
AppConnectParm appConnect = new AppConnectParm();
......@@ -2403,6 +2502,21 @@ public class CreatePoRcpVoucher
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
// chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgUser");
// chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
// loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
// loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
// loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
userInfoBean.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
userInfoBean.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
userInfoBean.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
userInfoBean.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
userInfoBean.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
// userInfoBean=
// retString=masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
retString=masterStateful.processRequest(userInfoBean,xmlString,true,conn);
//retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
} catch (ITMException itme)
......
/*
* Request Id=F15GSUN010
* developer : mahendra jadhav
* Functinal Impact : Provision to generate scheduler for creation of Tax Voucher for each
* series which mapped with each tax code.
*
*
*/
package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import com.sun.jmx.snmp.Timestamp;
import ibase.webitm.ejb.dis.POrderMilestone;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.utility.CommonConstants;
import javax.naming.InitialContext;
import javax.xml.rpc.ParameterMode;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.system.config.AppConnectParm;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.*;
public class GenTaxVoucherSch extends ValidatorEJB implements Schedule {
E12GenericUtility e12GenericUtility = new E12GenericUtility();
UtilMethods utilmethod = new UtilMethods();
Calendar calendar = Calendar.getInstance();
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
UtilMethods utilMethod = new UtilMethods();
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
FinCommon finCommon = new FinCommon();
String startDateStr = null;
String strToWrite="",strToWriteHead="";
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedule(String scheduleParamXML) throws Exception {
// TODO Auto-generated method stub
String siteCode = "",actualLoginSiteCode="",errString="",logFileInit="";
String xtraParams = "",loginSiteCode="";
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
try
{
System.out.println("Calling GenTaxVoucherSch : ["+scheduleParamXML+"]");
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
System.out.println("loginSiteCode :"+loginSiteCode);
xtraParams = "loginEmpCode="+userInfo.getEmpCode()+"~~loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode;
GenericUtility genericUtility=GenericUtility.getInstance();
Document dom=genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
int childNodeListLength = 0;
String childNodeName = null;
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
/*if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
actualLoginSiteCode=childNode.getFirstChild().getNodeValue();
}
}*/
}
logFileInit=intializingLog("Tax_Vou_sch_log");
System.out.println("intializingLog !!!!"+logFileInit);
errString = genTextVouchSch(xtraParams,conn);
if(errString.trim().length() > 0)
{
System.out.println(">>>After Schedulaer Process completed>> strToWrite:"+strToWrite);
strToWrite= "Schedulaer Process completed!!";
fos1.write(strToWrite.getBytes());
}
else
{
System.out.println(">>>No date Found to complete the process:"+strToWrite);
strToWrite = "<?xml version='1.0'?><Root><errors><message>";
strToWrite = strToWrite + "<![CDATA[Error :Data Not Found To Generate Tax Voucher!!]]></message>";
strToWrite= strToWrite + "</errors></Root>";
fos1.write(strToWrite.getBytes());
}
}
catch(Exception e)
{
throw new Exception(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
System.out.println("errString>>>["+errString+"]");
return errString;
}
/*------------------------------------------------------------------------------------------------------*/
public String genTextVouchSch(String xtraParams,Connection conn)
{
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null,pstmt4 = null;
ResultSet rs = null,rs1=null,rs2=null,rs3=null,rs4=null;
java.sql.Timestamp tranDateFrm=null,tranDateTo=null,prdFrom=null,sysDateTstmp=null,frmDateCurr=null,toDateCurr=null,vouchDateFrm=null,vouchDateTo=null;
Map<String,List<String>> taxSiteMap = new HashMap<String,List<String>>();
Date currentDate = new Date();
String sql="",valuexmlString="",retString="",sysDateStr="",taxCode="",siteCode="",vauchDtVar="";
try
{
System.out.println("called genTextVouchSch !!");
SimpleDateFormat sdf= new SimpleDateFormat((GenericUtility.getInstance()).getApplDateFormat());
String seriesArr [] = new String[8];
/*seriesArr[0] = "M-VOUC"; // Misc.Voucher
seriesArr[1] = "VOUCH"; // Purchase Voucher
seriesArr[2] = "S-INV"; // Sales Invoice
seriesArr[3] = "MDRCRD"; // Misc Debit Note
seriesArr[4] = "MDRCRC"; // Misc.Credit Note
seriesArr[5] = "CRNRCP"; // Credit Note
seriesArr[6] = "DRNRCP"; // Debit Note
seriesArr[7] = "DRNPAY"; // Dr Note Payable
seriesArr[8] = "CRNPAY"; // Cr Note Payable
seriesArr[9] = "CRNINV"; // Comm Credit Note
*/
seriesArr[0] = "M-VOUC"; // Misc.Voucher
seriesArr[1] = "VOUCH"; // Purchase Voucher
seriesArr[2] = "S-INV"; // Sales Invoice
seriesArr[3] = "MDRCRD"; // Misc Debit Note
seriesArr[4] = "MDRCRC"; // Misc.Credit Note
seriesArr[5] = "CRNINV"; // Comm Credit Note
seriesArr[6] = "CRNRCP"; // Credit Note
seriesArr[7] = "DRNRCP"; // Debit Note
//seriesArr[8] = "DRNPAY"; // Dr Note Payable(not use)
//seriesArr[9] = "CRNPAY"; // Cr Note Payable(not use)
/*---------------Calculate previous month of first date and last date-------------------------*/
sysDateStr = sdf.format(currentDate);
sysDateTstmp = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(sysDateStr, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("sysDateTstmp :"+sysDateTstmp);
sql= " select FR_DATE,TO_DATE from period where ? "
+ " between FR_DATE and TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDateTstmp);
rs = pstmt.executeQuery();
if(rs.next())
{
frmDateCurr = rs.getTimestamp("FR_DATE");
toDateCurr = rs.getTimestamp("TO_DATE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("frmDateCurr :"+frmDateCurr);
System.out.println("toDateCurr :"+toDateCurr);
//frmDateCurr: 1st date of current month
prdFrom = getPreviousDate(frmDateCurr,conn);
System.out.println("prdFrom :"+prdFrom);
sql= " select FR_DATE,TO_DATE from period where ? "
+ " between FR_DATE and TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, prdFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
tranDateFrm = rs.getTimestamp("FR_DATE"); //first date of previous month
tranDateTo = rs.getTimestamp("TO_DATE"); // last date of previous month
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("tranDateFrm :"+tranDateFrm);
System.out.println("tranDateTo :"+tranDateTo);
/*----------------------------------------------------------------------------------------*/
startDateStr = sdf.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
System.out.println("seriesArr.length :"+seriesArr.length);
/*String frmdate= "29/06/15";
String todate= "30/06/15";
tranDateFrm = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(frmdate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateFrm :"+tranDateFrm);
tranDateTo = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(todate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateTo :"+tranDateTo);*/
vauchDtVar = checkNull(finCommon.getFinparams("999999", "TAX_VOUCH_DATE", conn));
System.out.println("vauchDtVar="+vauchDtVar);
if(vauchDtVar.equalsIgnoreCase("Y"))
{
vouchDateFrm=tranDateTo;
vouchDateTo=tranDateTo;
}
else
{
vouchDateFrm=sysDateTstmp;
vouchDateTo=sysDateTstmp;
}
for(int serNo = 0 ; serNo < seriesArr.length ; serNo++ )
{
System.out.println("for count :"+serNo);
System.out.println("Series :"+seriesArr[serNo]);
taxSiteMap=getTaxSiteCodeOfSer(seriesArr[serNo],tranDateFrm,tranDateTo,conn);
for (Map.Entry<String, List<String>> entry : taxSiteMap.entrySet())
{
String key = entry.getKey();
List<String> values = entry.getValue();
System.out.println("Key = " + key);
System.out.println("Values = " + values);
for (String code : values)
{
System.out.println(code);
int pos = code.indexOf("@");
System.out.println(pos);
taxCode = code.substring(0,pos);
System.out.println("taxCode :"+taxCode);
siteCode = code.substring(pos+1);
System.out.println("SiteCode :"+siteCode);
strToWrite="";
strToWriteHead="Series :"+seriesArr[serNo]+" Tax Code:"+taxCode+" Site Code:"+siteCode+" Tran Date From:"+tranDateFrm+" Tran Date To:"+tranDateTo+" Voucher Date:"+tranDateFrm+" Voucher Due on:"+tranDateTo+"\n";
strToWrite=strToWrite + strToWriteHead;
strToWrite=strToWrite+startDateStr+",";
StringBuffer TaxVocStrBuff = new StringBuffer();
TaxVocStrBuff.append(taxCode).append("\t"); //tax_code
TaxVocStrBuff.append(siteCode).append("\t"); //site_code__fr
TaxVocStrBuff.append(siteCode).append("\t"); //site_code__to
TaxVocStrBuff.append(seriesArr[serNo]).append("\t"); //as_transfer
TaxVocStrBuff.append(tranDateFrm).append("\t"); //ad_trandate_fr
TaxVocStrBuff.append(tranDateTo).append("\t"); //ad_trandate_to
TaxVocStrBuff.append(vouchDateFrm).append("\t"); //ad_tran_date
TaxVocStrBuff.append(vouchDateTo).append("\t"); //ad_due_date
TaxVocStrBuff.append("X").append("\t"); //sundry_type
TaxVocStrBuff.append("").append("\t"); //tran_type
TaxVocStrBuff.append("0").append("\t"); //vch_amt
TaxVocStrBuff.append("D").append("\t"); //as_opt
TaxVocStrBuff.append("").append("\t"); //as_id
TaxVocStrBuff.append("").append("\t"); //acct_code
TaxVocStrBuff.append("").append("\t"); //cctr_code
valuexmlString=TaxVocStrBuff.toString();
System.out.println("valuexmlString :"+valuexmlString);
StringBuffer TaxVocStrBuffAll = new StringBuffer();
retString = taxVochProcess("taxpost_chap",valuexmlString, xtraParams, conn);
System.out.println("retString :"+retString);
strToWrite = strToWrite + retString+"\r\n\r\n";
//fos1.write(strToWrite.getBytes());
System.out.println(">>>Before Write to fos1 strToWrite:"+strToWrite);
fos1.write(strToWrite.getBytes());
}
}//end of loop for tax and site code map
System.out.println("000000000000");
System.out.println(serNo);
}//end of for loop for series
System.out.println("end of for loop for series!!!!");
}
catch(Exception e)
{
e.printStackTrace();
}
return retString;
}
public String taxVochProcess(String businessObj, String tabXmlData, String xtraParams, Connection conn) throws ITMException
{
String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "",compType="";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("Check In taxVochProcess businessObj:"+businessObj);
methodName = "gbf_process";
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
System.out.println(">>>In recPayProcess serviceCode = "+serviceCode+" compName "+compName);
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
}
System.out.println(">>>In recPayProcess serviceURI = "+serviceURI+" compName = "+compName);
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[5];
System.out.println("compType :"+compType);
System.out.println("compName :"+compName);
System.out.println("tabXmlData :"+tabXmlData);
System.out.println("xtraParams :"+xtraParams);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_type"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compType);
aobj[1] = new String(compName);
aobj[2] = new String(tabXmlData);
aobj[3] = new String("");
aobj[4] = new String(xtraParams);
System.out.println(">>>>>>call.taxVochProcess(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println(">>>>taxVochProcess Complete Return string from NVO is:"+retString);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
/*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
{
System.out.println("Exception in taxVochProcess!!!!");
e.printStackTrace();
try
{
conn.rollback();
}
catch (Exception s)
{
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
}
return retString;
}
/*----------------Calculate TAX Code for Each Series-------------------------------------------------------*/
public Map getTaxSiteCodeOfSer(String series,java.sql.Timestamp tranDateFrm,java.sql.Timestamp tranDateTo,Connection conn)
{
//List<String> taxCodeList = new ArrayList<String>();
//List<String> siteCodeList = new ArrayList<String>();
List<String> taxSiteList = new ArrayList<String>();
Map<String,List<String>> seriesMap = new HashMap<String,List<String>>();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String taxCode="",siteCode="";
try
{
/*String frmdate= "29/06/15";
String todate= "30/06/15";
tranDateFrm = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(frmdate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateFrm :"+tranDateFrm);
tranDateTo = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(todate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateTo :"+tranDateTo);*/
if(series.equalsIgnoreCase("M-VOUC")) //MISC. Voucher
{
sql = " SELECT distinct taxtran.tax_code, misc_voucher.site_code " +
" FROM misc_voucher,taxtran,tax_authority, tax " +
" WHERE ( taxtran.tran_id = misc_voucher.tran_id ) and " +
"( taxtran.tax_code = tax.tax_code ) and" +
" ( tax.tauth_code = tax_authority.tauth_code ) " +
" and ( taxtran.tran_code = 'M-VOUC' ) AND " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END)" +
" = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
// "and ( misc_voucher.tran_date between ? and ? )" +
"and ( misc_voucher.tran_date between ? and ? )" +
" AND ( misc_voucher.confirmed = 'Y' )";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
//taxCodeList.add(taxCode);
//siteCodeList.add(siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("m-vouc@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("VOUCH")) // Purchase Voucher
{
sql="SELECT distinct taxtran.tax_code,voucher.site_code " +
" FROM voucher, taxtran, tax_authority,tax WHERE " +
" ( taxtran.tran_id = voucher.tran_id ) and ( taxtran.tax_code = tax.tax_code )" +
" and ( tax.tauth_code = tax_authority.tauth_code ) and ( taxtran.tran_code = 'VOUCH' )" +
" AND (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' " +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
//" and ( voucher.tran_date between ? and ? )" +
" and ( voucher.tran_date between ? and ?)" +
" AND ( voucher.confirmed = 'Y' ) " ;
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("vouc@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("S-INV")) // Sales Invoice
{
sql= "SELECT distinct taxtran.tax_code, invoice.site_code FROM invoice,TAXTRAN WHERE " +
" ( TAXTRAN.TRAN_ID = invoice.INVOICE_ID ) and ( taxtran.tran_code ='S-INV' ) " +
" AND (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' AND " +
" (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 and " +
" ( invoice.tran_date between ? and ? ) AND ( invoice.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("SINV@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("CRNINV")) //Comm Credit Note
{
sql=" select distinct taxtran.tax_code,drcr_inv.site_code from drcr_inv, " +
" taxtran where ( taxtran.tran_id = drcr_inv.tran_id ) and" +
" ( taxtran.tran_code = 'CRNINV' ) and (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N'" +
" ELSE TAXTRAN.POSTED END) = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE " +
" TAXTRAN.TAX_AMT END) <> 0 and ( drcr_inv.tran_date between ? and ? )" +
" and ( drcr_inv.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("CRNINV@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("MDRCRC")) //Misc. Credit Note
{
sql=" select distinct taxtran.tax_code,misc_drcr_rcp.site_code " +
" from misc_drcr_rcp, taxtran where" +
" ( taxtran.tran_id = misc_drcr_rcp.tran_id ) " +
" and ( taxtran.tran_code = 'MDRCRC' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
" and ( misc_drcr_rcp.tran_date between ? and ? ) and" +
" ( misc_drcr_rcp.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("MDRCRC@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("MDRCRD")) // Misc.debit Note
{
sql=" select distinct taxtran.tax_code,misc_drcr_rcp.site_code " +
" from misc_drcr_rcp, taxtran where" +
" ( taxtran.tran_id = misc_drcr_rcp.tran_id ) " +
" and ( taxtran.tran_code = 'MDRCRD' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
" and ( misc_drcr_rcp.tran_date between ? and ? ) and" +
" ( misc_drcr_rcp.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("MDRCRD@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("DRNRCP")) //Debit Note
{
sql= " select distinct drcr_rcp.site_code,taxtran.tax_code from drcr_rcp," +
" taxtran where ( taxtran.tran_id = drcr_rcp.tran_id ) and " +
" ( taxtran.tran_code = 'DRNRCP' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0" +
" and ( drcr_rcp.tran_date between ? and ? )" +
" and ( drcr_rcp.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("DRNRCP@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("CRNRCP")) // Credit Note
{
sql= " select distinct drcr_rcp.site_code,taxtran.tax_code from drcr_rcp," +
" taxtran where ( taxtran.tran_id = drcr_rcp.tran_id ) and " +
" ( taxtran.tran_code = 'CRNRCP' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0" +
" and ( drcr_rcp.tran_date between ? and ? )" +
" and ( drcr_rcp.confirmed = 'Y' ) ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
System.out.print("siteCode :"+siteCode);
taxSiteList.add(taxCode+"@"+siteCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
seriesMap.put("CRNRCP@Code",taxSiteList);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return seriesMap;
}
/*----------------------------------------------------------------------------------------------------------*/
private String intializingLog(String fileName)
{
String log="";
String strToWrite = "";
String currTime = null;
try
{
System.out.println(">>>In intializingLog() fileName:"+fileName);
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
//strToWrite="\"TRANID\",\"START TIME\",\"END TIME\",\"STATUS\"\r\n";
//fos1.write(strToWrite.getBytes());
log ="IntializingLog_Successesfull";
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Tax Voucher Scheduler Started At: " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
log="IntializingLog_Failed";
e.printStackTrace();
}
return log;
}
public void writeLog(File f,String Msg,boolean flag) throws Exception
{
try
{
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
String currTime = null;
Calendar calendar = Calendar.getInstance();
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
if(! CommonConstants.DEBUG_LEVEL.equals("0"))
{
PrintWriter pw = new PrintWriter((new FileOutputStream(f,flag)),flag);
pw.println("{" + currTime + " " + calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE) + "}\t" + Msg);
pw.close();
}
}
catch(Exception exWm){exWm.printStackTrace();}
}
/*--------------------------------------------------------------------------------------------------*/
private String saveData(String siteCode,String xmlString,String xtraParams, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
ibase.utility.UserInfoBean userInfo;
String chgUser="",chgTerm="",loginEmpCode="";
E12GenericUtility genericUtility=new E12GenericUtility();
try
{ userInfo = new ibase.utility.UserInfoBean();
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 + "]");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgUser");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgTerm");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
userInfo.setEmpCode(loginEmpCode);
userInfo.setLoginCode(chgUser);
userInfo.setRemoteHost(chgTerm);
userInfo.setSiteCode(siteCode);
userInfo.setEntityCode(loginEmpCode);
System.out.println("userInfo>>>>>"+userInfo);
retString = masterStateful.processRequest(userInfo,xmlString,true,conn);
}
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 Timestamp getPreviousDate(java.sql.Timestamp FromDate, Connection conn)
{
String varValueStr="";
int varValue = 0;
java.sql.Timestamp compDate=null,ToDate=null,prdFrom=null;
try
{
varValueStr = dist.getDisparams("999999","SSD_TRANSIT_DAYS",conn);
System.out.println("varValue.." + varValueStr);
if( varValueStr.equalsIgnoreCase("NULLFOUND") )
{
System.out.println("varValue is NULLFOUND" + varValueStr);
}
else
{
varValue = Integer.parseInt(varValueStr);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
System.out.println("varValue = .. " + varValue);
varValue = (-1) * varValue;
System.out.println("changed varValue for to date>>>>>>>>>>>>>>>> = .. " + varValue);
/*compDate = utilMethod.RelativeDate(ToDate,varValue);
System.out.println("compDate >>>>>>"+compDate);*/
varValue = (-1) * 1;
System.out.println("changed varValue>>>>>>>>>>>>>>>> = .. " + varValue);
if(FromDate !=null)
{
prdFrom = utilMethod.RelativeDate(FromDate,varValue);
}
System.out.println("prdFrom :"+prdFrom);
}
catch(Exception e)
{
}
return prdFrom;
}
/*--------------------------------------------------------------------------------------------------*/
/*
public static void main(String arg[])
{
System.out.println("@@@@@@@@@@@@@@@");
String xtraParams="";
String empCode="E17532";
String termId="172.16.9.1";
String loginSiteCode="";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.
getConnection("jdbc:oracle:thin:@172.16.10.24:1521:fintest"
,"SUN","LAXMIMATA1234$");
xtraParams = "loginEmpCode="+empCode+"~~termId="+termId+"~~loginSiteCode="+loginSiteCode;
callProcess(xtraParams,con);
//genTextVouchSch(xtraParams,con);
System.out.println("Created DB Connection....");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}*/
/*public static void callProcess(String xtraParams,Connection conn )
{
genTextVouchSch(xtraParams,conn);
}*/
}
/*
* Request Id=F15GSUN010
* developer : mahendra jadhav
* Functinal Impact : Provision to generate scheduler for creation of Tax Voucher for each
* series which mapped with each tax code.
*
*
*/
package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import com.sun.jmx.snmp.Timestamp;
import ibase.webitm.ejb.dis.POrderMilestone;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.utility.CommonConstants;
import javax.naming.InitialContext;
import javax.xml.rpc.ParameterMode;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.system.config.AppConnectParm;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.*;
public class GenTaxVoucherSch extends ValidatorEJB implements Schedule {
E12GenericUtility e12GenericUtility = new E12GenericUtility();
UtilMethods utilmethod = new UtilMethods();
Calendar calendar = Calendar.getInstance();
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
UtilMethods utilMethod = new UtilMethods();
ibase.webitm.ejb.dis.DistCommon dist = new ibase.webitm.ejb.dis.DistCommon();
FinCommon finCommon = new FinCommon();
String startDateStr = null;
String strToWrite="",strToWriteHead="";
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedule(String scheduleParamXML) throws Exception {
// TODO Auto-generated method stub
String siteCode = "",actualLoginSiteCode="",errString="",logFileInit="";
String xtraParams = "",loginSiteCode="";
ibase.utility.UserInfoBean userInfo = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
try
{
System.out.println("Calling GenTaxVoucherSch : ["+scheduleParamXML+"]");
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
System.out.println("loginSiteCode :"+loginSiteCode);
xtraParams = "loginEmpCode="+userInfo.getEmpCode()+"~~loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode;
GenericUtility genericUtility=GenericUtility.getInstance();
Document dom=genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
int childNodeListLength = 0;
String childNodeName = null;
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
/*if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
actualLoginSiteCode=childNode.getFirstChild().getNodeValue();
}
}*/
}
logFileInit=intializingLog("Tax_Vou_sch_log");
System.out.println("intializingLog !!!!"+logFileInit);
errString = genTextVouchSch(xtraParams,conn);
if(errString.trim().length() > 0)
{
System.out.println(">>>After Schedulaer Process completed>> strToWrite:"+strToWrite);
strToWrite= "Schedulaer Process completed!!";
fos1.write(strToWrite.getBytes());
}
else
{
System.out.println(">>>No date Found to complete the process:"+strToWrite);
strToWrite = "<?xml version='1.0'?><Root><errors><message>";
strToWrite = strToWrite + "<![CDATA[Error :Data Not Found To Generate Tax Voucher!!]]></message>";
strToWrite= strToWrite + "</errors></Root>";
fos1.write(strToWrite.getBytes());
}
}
catch(Exception e)
{
throw new Exception(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
System.out.println("errString>>>["+errString+"]");
return errString;
}
/*------------------------------------------------------------------------------------------------------*/
public String genTextVouchSch(String xtraParams,Connection conn)
{
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null,pstmt4 = null;
ResultSet rs = null,rs1=null,rs2=null,rs3=null,rs4=null;
java.sql.Timestamp tranDateFrm=null,tranDateTo=null,prdFrom=null,sysDateTstmp=null,frmDateCurr=null,toDateCurr=null,vouchDateFrm=null,vouchDateTo=null;
// Map<String,List<String>> taxSiteMap = new HashMap<String,List<String>>();
ArrayList<String> taxCodeList = new ArrayList<String>(); // added by cpatil for tax list for site
Date currentDate = new Date();
String sql="",valuexmlString="",retString="",sysDateStr="";
// ,taxCode="",
String siteCode="",vauchDtVar="";
String series="",prdDateAppl="",sql1=""; //added by cpatil on 05/02/16
try
{
System.out.println("called genTextVouchSch !!");
SimpleDateFormat sdf= new SimpleDateFormat((GenericUtility.getInstance()).getApplDateFormat());
// String seriesArr [] = new String[8]; // comment by cpatil on 05/02/16
/*seriesArr[0] = "M-VOUC"; // Misc.Voucher
seriesArr[1] = "VOUCH"; // Purchase Voucher
seriesArr[2] = "S-INV"; // Sales Invoice
seriesArr[3] = "MDRCRD"; // Misc Debit Note
seriesArr[4] = "MDRCRC"; // Misc.Credit Note
seriesArr[5] = "CRNRCP"; // Credit Note
seriesArr[6] = "DRNRCP"; // Debit Note
seriesArr[7] = "DRNPAY"; // Dr Note Payable
seriesArr[8] = "CRNPAY"; // Cr Note Payable
seriesArr[9] = "CRNINV"; // Comm Credit Note
*/
/* seriesArr[0] = "M-VOUC"; // Misc.Voucher
seriesArr[1] = "VOUCH"; // Purchase Voucher
seriesArr[2] = "S-INV"; // Sales Invoice
seriesArr[3] = "MDRCRD"; // Misc Debit Note
seriesArr[4] = "MDRCRC"; // Misc.Credit Note
seriesArr[5] = "CRNINV"; // Comm Credit Note
seriesArr[6] = "CRNRCP"; // Credit Note
seriesArr[7] = "DRNRCP"; // Debit Note
//seriesArr[8] = "DRNPAY"; // Dr Note Payable(not use)
//seriesArr[9] = "CRNPAY"; // Cr Note Payable(not use)
*/
/*---------------Calculate previous month of first date and last date-------------------------*/
sysDateStr = sdf.format(currentDate);
sysDateTstmp = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(sysDateStr, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("sysDateTstmp :"+sysDateTstmp);
sql= " select FR_DATE,TO_DATE from period where ? "
+ " between FR_DATE and TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDateTstmp);
rs = pstmt.executeQuery();
if(rs.next())
{
frmDateCurr = rs.getTimestamp("FR_DATE");
toDateCurr = rs.getTimestamp("TO_DATE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("frmDateCurr :"+frmDateCurr);
System.out.println("toDateCurr :"+toDateCurr);
//frmDateCurr: 1st date of current month
prdFrom = getPreviousDate(frmDateCurr,conn);
System.out.println("prdFrom :"+prdFrom);
sql= " select FR_DATE,TO_DATE from period where ? "
+ " between FR_DATE and TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, prdFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
tranDateFrm = rs.getTimestamp("FR_DATE"); //first date of previous month
tranDateTo = rs.getTimestamp("TO_DATE"); // last date of previous month
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("tranDateFrm :"+tranDateFrm);
System.out.println("tranDateTo :"+tranDateTo);
//added by cpatil
sql1 = " select descr , sh_descr, udf_str1 from gencodes " +
" where mod_name = 'W_TAX_VOUCH_PARM' and active = 'Y' ";
pstmt1 = conn.prepareStatement(sql1);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
series = checkNull(rs1.getString("descr"));
siteCode = checkNull(rs1.getString("sh_descr"));
prdDateAppl = checkNull(rs1.getString("udf_str1"));
/*
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
*/
System.out.println("@@@@@@@@@@@ series["+series+"]siteCode["+siteCode+"]prdDateAppl["+prdDateAppl+"]");
String seriesArr[]=series.split(",");
/*----------------------------------------------------------------------------------------*/
startDateStr = sdf.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
System.out.println("seriesArr.length :"+seriesArr.length);
/*String frmdate= "29/06/15";
String todate= "30/06/15";
tranDateFrm = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(frmdate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateFrm :"+tranDateFrm);
tranDateTo = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(todate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateTo :"+tranDateTo);*/
//commented by cpatil on 05/02/16
//vauchDtVar = checkNull(finCommon.getFinparams("999999", "TAX_VOUCH_DATE", conn));
//System.out.println("vauchDtVar="+vauchDtVar);
//if(vauchDtVar.equalsIgnoreCase("Y"))
if( prdDateAppl != null && prdDateAppl.equalsIgnoreCase("Y"))
{
vouchDateFrm=tranDateTo;
vouchDateTo=tranDateTo;
}
else
{
vouchDateFrm=sysDateTstmp;
vouchDateTo=sysDateTstmp;
}
for(int serNo = 0 ; serNo < seriesArr.length ; serNo++ )
{
System.out.println("for count :"+serNo);
System.out.println("Series :"+seriesArr[serNo]);
taxCodeList= getTaxCodeOfSer(seriesArr[serNo],tranDateFrm,tranDateTo,siteCode,conn);
System.out.println("@@@@@@@@@ siteCode["+siteCode+"]taxCodeList["+taxCodeList+"]");
// for (Map.Entry<String, List<String>> entry : taxSiteMap.entrySet()) // commented by cpatil
// {
// String key = entry.getKey();
// List<String> values = entry.getValue();
// System.out.println("========>>>Key["+key+"]Values["+values+"]");
// for (String code : values)
for (String taxCode : taxCodeList)
{
System.out.println("tax code:["+taxCode+"]");
//taxCode = code;
/*
int pos = code.indexOf("@");
System.out.println(pos);
taxCode = code.substring(0,pos);
System.out.println("taxCode :"+taxCode);
siteCode = code.substring(pos+1);
System.out.println("SiteCode :"+siteCode);
*/
strToWrite="";
strToWriteHead="Series :"+seriesArr[serNo]+" Tax Code:"+taxCode+" Site Code:"+siteCode+" Tran Date From:"+tranDateFrm+" Tran Date To:"+tranDateTo+" Voucher Date:"+tranDateFrm+" Voucher Due on:"+tranDateTo+"\n";
strToWrite=strToWrite + strToWriteHead;
strToWrite=strToWrite+startDateStr+",";
StringBuffer TaxVocStrBuff = new StringBuffer();
TaxVocStrBuff.append(taxCode).append("\t"); //tax_code
TaxVocStrBuff.append(siteCode).append("\t"); //site_code__fr
TaxVocStrBuff.append(siteCode).append("\t"); //site_code__to
TaxVocStrBuff.append(seriesArr[serNo]).append("\t"); //as_transfer
TaxVocStrBuff.append(tranDateFrm).append("\t"); //ad_trandate_fr
TaxVocStrBuff.append(tranDateTo).append("\t"); //ad_trandate_to
TaxVocStrBuff.append(vouchDateFrm).append("\t"); //ad_tran_date
TaxVocStrBuff.append(vouchDateTo).append("\t"); //ad_due_date
TaxVocStrBuff.append("X").append("\t"); //sundry_type
TaxVocStrBuff.append("").append("\t"); //tran_type
TaxVocStrBuff.append("0").append("\t"); //vch_amt
TaxVocStrBuff.append("D").append("\t"); //as_opt
TaxVocStrBuff.append("").append("\t"); //as_id
TaxVocStrBuff.append("").append("\t"); //acct_code
TaxVocStrBuff.append("").append("\t"); //cctr_code
valuexmlString=TaxVocStrBuff.toString();
System.out.println("=====>>>valuexmlString:["+valuexmlString+"]");
//StringBuffer TaxVocStrBuffAll = new StringBuffer();
retString = taxVochProcess("taxpost_chap",valuexmlString, xtraParams, conn);
System.out.println("retString :"+retString);
strToWrite = strToWrite + retString+"\r\n\r\n";
//fos1.write(strToWrite.getBytes());
System.out.println(">>>Before Write to fos1 strToWrite:"+strToWrite);
fos1.write(strToWrite.getBytes());
} // end of for
// }//end of loop for tax and site code map
System.out.println(serNo);
}//end of for loop for series
////
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
////
System.out.println("end of for loop for series!!!!");
}
catch(Exception e)
{
e.printStackTrace();
}
return retString;
}
public String taxVochProcess(String businessObj, String tabXmlData, String xtraParams, Connection conn) throws ITMException
{
String methodName = "";
String compName = "";
String retString = "";
String serviceCode = "";
String serviceURI = "";
String actionURI = "",compType="";
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("Check In taxVochProcess businessObj:"+businessObj);
methodName = "gbf_process";
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,businessObj);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
System.out.println(">>>In recPayProcess serviceCode = "+serviceCode+" compName "+compName);
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
}
System.out.println(">>>In recPayProcess serviceURI = "+serviceURI+" compName = "+compName);
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[5];
System.out.println("compType :"+compType);
System.out.println("compName :"+compName);
System.out.println("tabXmlData :"+tabXmlData);
System.out.println("xtraParams :"+xtraParams);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_type"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compType);
aobj[1] = new String(compName);
aobj[2] = new String(tabXmlData);
aobj[3] = new String("");
aobj[4] = new String(xtraParams);
System.out.println(">>>>>>call.taxVochProcess(XMLType.XSD_STRING) executed........");
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println(">>>>taxVochProcess Complete Return string from NVO is:"+retString);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
/*if( conn != null ){
conn.close();
conn = null;
}*/
}
catch(Exception e)
{
System.out.println("Exception in taxVochProcess!!!!");
e.printStackTrace();
try
{
conn.rollback();
}
catch (Exception s)
{
System.out.println("Unable to rollback");
s.printStackTrace();
}
throw new ITMException(e);
}
}
return retString;
}
/*----------------Calculate TAX Code for Each Series-------------------------------------------------------*/
public ArrayList<String> getTaxCodeOfSer(String series,java.sql.Timestamp tranDateFrm,java.sql.Timestamp tranDateTo,String siteCode,Connection conn)
{
//List<String> taxCodeList = new ArrayList<String>();
//List<String> siteCodeList = new ArrayList<String>();
ArrayList<String> taxCodeList = new ArrayList<String>();
//Map<String,List<String>> seriesMap = new HashMap<String,List<String>>();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String taxCode=""; //siteCode="";
try
{
/*String frmdate= "29/06/15";
String todate= "30/06/15";
tranDateFrm = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(frmdate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateFrm :"+tranDateFrm);
tranDateTo = java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(todate, e12GenericUtility.getApplDateFormat(),e12GenericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("tranDateTo :"+tranDateTo);*/
if(series.equalsIgnoreCase("M-VOUC")) //MISC. Voucher
{
sql = " SELECT distinct taxtran.tax_code" +
//", misc_voucher.site_code " +
" FROM misc_voucher,taxtran,tax_authority, tax " +
" WHERE ( taxtran.tran_id = misc_voucher.tran_id ) and " +
"( taxtran.tax_code = tax.tax_code ) and" +
" ( tax.tauth_code = tax_authority.tauth_code ) " +
" and ( taxtran.tran_code = 'M-VOUC' ) AND " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END)" +
" = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
// "and ( misc_voucher.tran_date between ? and ? )" +
"and ( misc_voucher.tran_date between ? and ? )" +
" AND ( misc_voucher.confirmed = 'Y' )" +
" And misc_voucher.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxCodeList.add(taxCode);
//siteCodeList.add(siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("m-vouc@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("VOUCH")) // Purchase Voucher
{
sql="SELECT distinct taxtran.tax_code" +
//",voucher.site_code " +
" FROM voucher, taxtran, tax_authority,tax WHERE " +
" ( taxtran.tran_id = voucher.tran_id ) and ( taxtran.tax_code = tax.tax_code )" +
" and ( tax.tauth_code = tax_authority.tauth_code ) and ( taxtran.tran_code = 'VOUCH' )" +
" AND (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' " +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
//" and ( voucher.tran_date between ? and ? )" +
" and ( voucher.tran_date between ? and ?)" +
" AND ( voucher.confirmed = 'Y' ) " +
" AND voucher.site_code = ? " ; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("vouc@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("S-INV")) // Sales Invoice
{
sql= "SELECT distinct taxtran.tax_code" +
//", invoice.site_code " +
" FROM invoice,TAXTRAN WHERE " +
" ( TAXTRAN.TRAN_ID = invoice.INVOICE_ID ) and ( taxtran.tran_code ='S-INV' ) " +
" AND (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' AND " +
" (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 and " +
" ( invoice.tran_date between ? and ? ) AND ( invoice.confirmed = 'Y' )" +
" AND invoice.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("SINV@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("CRNINV")) //Comm Credit Note
{
sql=" select distinct taxtran.tax_code" +
//",drcr_inv.site_code " +
" from drcr_inv, " +
" taxtran where ( taxtran.tran_id = drcr_inv.tran_id ) and" +
" ( taxtran.tran_code = 'CRNINV' ) and (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N'" +
" ELSE TAXTRAN.POSTED END) = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE " +
" TAXTRAN.TAX_AMT END) <> 0 and ( drcr_inv.tran_date between ? and ? )" +
" and ( drcr_inv.confirmed = 'Y' ) " +
" AND drcr_inv.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("CRNINV@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("MDRCRC")) //Misc. Credit Note
{
sql=" select distinct taxtran.tax_code " +
//" ,misc_drcr_rcp.site_code " +
" from misc_drcr_rcp, taxtran where" +
" ( taxtran.tran_id = misc_drcr_rcp.tran_id ) " +
" and ( taxtran.tran_code = 'MDRCRC' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
" and ( misc_drcr_rcp.tran_date between ? and ? ) and" +
" ( misc_drcr_rcp.confirmed = 'Y' ) " +
" AND misc_drcr_rcp.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("MDRCRC@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("MDRCRD")) // Misc.debit Note
{
sql=" select distinct taxtran.tax_code " +
//" ,misc_drcr_rcp.site_code " +
" from misc_drcr_rcp, taxtran where" +
" ( taxtran.tran_id = misc_drcr_rcp.tran_id ) " +
" and ( taxtran.tran_code = 'MDRCRD' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0 " +
" and ( misc_drcr_rcp.tran_date between ? and ? ) and" +
" ( misc_drcr_rcp.confirmed = 'Y' ) " +
" AND misc_drcr_rcp.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("MDRCRD@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("DRNRCP")) //Debit Note
{
sql= " select distinct " +
//" drcr_rcp.site_code," +
" taxtran.tax_code from drcr_rcp," +
" taxtran where ( taxtran.tran_id = drcr_rcp.tran_id ) and " +
" ( taxtran.tran_code = 'DRNRCP' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N'" +
" AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0" +
" and ( drcr_rcp.tran_date between ? and ? )" +
" and ( drcr_rcp.confirmed = 'Y' ) " +
" AND drcr_rcp.site_code = ? "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
pstmt.setString(3,siteCode); // added by cpatil
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("DRNRCP@Code",taxSiteList);
}
else if(series.equalsIgnoreCase("CRNRCP")) // Credit Note
{
sql= " select distinct " +
//" drcr_rcp.site_code," +
" taxtran.tax_code from drcr_rcp," +
" taxtran where ( taxtran.tran_id = drcr_rcp.tran_id ) and " +
" ( taxtran.tran_code = 'CRNRCP' ) and " +
" (CASE WHEN TAXTRAN.POSTED IS NULL THEN 'N' ELSE TAXTRAN.POSTED END) = 'N' AND (CASE WHEN TAXTRAN.TAX_AMT IS NULL THEN 0 ELSE TAXTRAN.TAX_AMT END) <> 0" +
" and ( drcr_rcp.tran_date between ? and ? )" +
" and ( drcr_rcp.confirmed = 'Y' ) "; // added by cpatil
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,tranDateFrm);
pstmt.setTimestamp(2,tranDateTo);
rs = pstmt.executeQuery();
while( rs.next())
{
taxCode = rs.getString("tax_code");
//siteCode = rs.getString("site_code");
System.out.print("taxCode :"+taxCode);
//System.out.print("siteCode :"+siteCode);
//taxSiteList.add(taxCode+"@"+siteCode);
taxCodeList.add(taxCode);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
//seriesMap.put("CRNRCP@Code",taxSiteList);
}
}
catch(Exception e)
{
e.printStackTrace();
}
//return seriesMap;
return taxCodeList;
}
/*----------------------------------------------------------------------------------------------------------*/
private String intializingLog(String fileName)
{
String log="";
String strToWrite = "";
String currTime = null;
try
{
System.out.println(">>>In intializingLog() fileName:"+fileName);
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
//strToWrite="\"TRANID\",\"START TIME\",\"END TIME\",\"STATUS\"\r\n";
//fos1.write(strToWrite.getBytes());
log ="IntializingLog_Successesfull";
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Tax Voucher Scheduler Started At: " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
log="IntializingLog_Failed";
e.printStackTrace();
}
return log;
}
public void writeLog(File f,String Msg,boolean flag) throws Exception
{
try
{
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
String currTime = null;
Calendar calendar = Calendar.getInstance();
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
if(! CommonConstants.DEBUG_LEVEL.equals("0"))
{
PrintWriter pw = new PrintWriter((new FileOutputStream(f,flag)),flag);
pw.println("{" + currTime + " " + calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE) + "}\t" + Msg);
pw.close();
}
}
catch(Exception exWm){exWm.printStackTrace();}
}
/*--------------------------------------------------------------------------------------------------*/
private String saveData(String siteCode,String xmlString,String xtraParams, Connection conn) throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
ibase.utility.UserInfoBean userInfo;
String chgUser="",chgTerm="",loginEmpCode="";
E12GenericUtility genericUtility=new E12GenericUtility();
try
{ userInfo = new ibase.utility.UserInfoBean();
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 + "]");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgUser");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgTerm");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
userInfo.setEmpCode(loginEmpCode);
userInfo.setLoginCode(chgUser);
userInfo.setRemoteHost(chgTerm);
userInfo.setSiteCode(siteCode);
userInfo.setEntityCode(loginEmpCode);
System.out.println("userInfo>>>>>"+userInfo);
retString = masterStateful.processRequest(userInfo,xmlString,true,conn);
}
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 Timestamp getPreviousDate(java.sql.Timestamp FromDate, Connection conn)
{
String varValueStr="";
int varValue = 0;
java.sql.Timestamp compDate=null,ToDate=null,prdFrom=null;
try
{
varValueStr = dist.getDisparams("999999","SSD_TRANSIT_DAYS",conn);
System.out.println("varValue.." + varValueStr);
if( varValueStr.equalsIgnoreCase("NULLFOUND") )
{
System.out.println("varValue is NULLFOUND" + varValueStr);
}
else
{
varValue = Integer.parseInt(varValueStr);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
System.out.println("varValue = .. " + varValue);
varValue = (-1) * varValue;
System.out.println("changed varValue for to date>>>>>>>>>>>>>>>> = .. " + varValue);
/*compDate = utilMethod.RelativeDate(ToDate,varValue);
System.out.println("compDate >>>>>>"+compDate);*/
varValue = (-1) * 1;
System.out.println("changed varValue>>>>>>>>>>>>>>>> = .. " + varValue);
if(FromDate !=null)
{
prdFrom = utilMethod.RelativeDate(FromDate,varValue);
}
System.out.println("prdFrom :"+prdFrom);
}
catch(Exception e)
{
}
return prdFrom;
}
/*--------------------------------------------------------------------------------------------------*/
/*
public static void main(String arg[])
{
System.out.println("@@@@@@@@@@@@@@@");
String xtraParams="";
String empCode="E17532";
String termId="172.16.9.1";
String loginSiteCode="";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.
getConnection("jdbc:oracle:thin:@172.16.10.24:1521:fintest"
,"SUN","LAXMIMATA1234$");
xtraParams = "loginEmpCode="+empCode+"~~termId="+termId+"~~loginSiteCode="+loginSiteCode;
callProcess(xtraParams,con);
//genTextVouchSch(xtraParams,con);
System.out.println("Created DB Connection....");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}*/
/*public static void callProcess(String xtraParams,Connection conn )
{
genTextVouchSch(xtraParams,conn);
}*/
}
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