Commit 9a1f0ac8 authored by steurwadkar's avatar steurwadkar

GSTR3B data generation process screen source code commit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106521 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e79ee794
package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@javax.ejb.Stateless
public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRemote, GenerateGSTR3BICLocal
{
E12GenericUtility e12GenericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String wfValData() throws RemoteException, ITMException
{
return "";
}
public String wfValData(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = null;
try
{
System.out.println("Inside GstDataIC wfValData");
if(currXmlDataStr != null && currXmlDataStr.trim().length()!=0)
{
currDom = e12GenericUtility.parseString(currXmlDataStr);
}
if(hdrXmlDataStr != null && hdrXmlDataStr.trim().length()!=0)
{
hdrDom = e12GenericUtility.parseString(hdrXmlDataStr);
}
if(allXmlDataStr != null && allXmlDataStr.trim().length()!=0)
{
allDom = e12GenericUtility.parseString(allXmlDataStr);
}
errString = wfValData( currDom, hdrDom, allDom, objContext, editFlag, xtraParams );
}//end of try
catch(Exception e)
{
errString = e12GenericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}//end of catch
return errString ;
}//end of wfvalData() of xml string
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
String errString = "",sql = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
NodeList parentList = null;
NodeList childList = null;
int noOfChilds = 0;
String childNodeName = "";
Node childNode =null;
boolean isNumber = true;
String columnValue = "";
int currentFormNo = 0,count = 0;
try
{
conn = getConnection();
String userID = e12GenericUtility.getValueFromXTRA_PARAMS( xtraParams, "LoginCode" );
if ( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
parentList = currDom.getElementsByTagName("Detail" + currentFormNo );
childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item( ctr );
childNodeName = childNode.getNodeName();
System.out.println("childNodeName"+childNodeName);
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
if ( "prd_code".equalsIgnoreCase( childNodeName ) )
{
if (childNode.getFirstChild()==null)
{
errString = getErrorString("prd_code","VTBLNKPRD",userID);
break;
}
else
{
isNumber = checkNumeric( columnValue );
System.out.println("isNumber =["+isNumber+"]");
if ( !isNumber )
{
errString = getErrorString("prd_code","NOTANUMBR1",userID);
break;
}
/*sql = " SELECT COUNT(*) AS CNT FROM PERIOD WHERE TO_CHAR(TO_DATE(code,'yyyymm'),'mmyyyy') = ? ";
pstmt = connObject.prepareStatement(sql);
pstmt.setString(1, columnValue);
rSet = pstmt.executeQuery();
if (rSet.next())
{
count = rSet.getInt(1);
}
if (rSet != null)
{
rSet.close();rSet = null;
}
if (pstmt != null )
{
pstmt.close();pstmt = null;
}*/
/*if(count == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMPRDNTDF","","",connObject);
break;
}*/
}
}
if ("gst_type".equalsIgnoreCase( childNodeName ) )
{
if (childNode.getFirstChild()==null)
{
errString = getErrorString("gst_type","VTBLNKTYPE",userID);
break;
}
}
}
}
catch(Exception e)
{
System.out.println("Exception in GstDataIC wfValData == >"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( conn != null && ! conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}//end of catch
} //end of finally
return (errString);
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
System.out.println("Inside GenerateGSTR3BIC itemChanged");
if (xmlString != null && xmlString.trim().length()!=0)
{
dom = e12GenericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = e12GenericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = e12GenericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
}
catch(Exception e)
{
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
int currentFormNo = 0 ;
String sql = "";
String prdCode = "", gstin = "", siteCode = "", currDateStr = "";
Calendar calendar = null;
try
{
conn = getConnection();
calendar = Calendar.getInstance();
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>");
System.out.println("currentColumn["+currentColumn+"] && currentFormNo["+currentFormNo+"]");
switch(currentFormNo)
{
case 1 :
{
valueXmlString.append("<Detail1>\r\n");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sql = "SELECT REG_NO FROM SITEREGNO SREG, FINENT FI WHERE REF_CODE = 'GSTIN_NO' AND SREG.FIN_ENTITY = FI.FIN_ENTITY AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
gstin = rs.getString("REG_NO");
}
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
currDateStr = sdf.format(calendar.getTime());
System.out.println("currDateStr["+currDateStr+"]");
sql = "SELECT TO_CHAR(TO_DATE(CODE,'yyyymm'),'mmyyyy') AS CODE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, currDateStr);
rs = pstmt.executeQuery();
if(rs.next())
{
prdCode = rs.getString("CODE");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<prd_code><![CDATA["+prdCode+"]]></prd_code>");
valueXmlString.append("<gstin><![CDATA["+gstin+"]]></gstin>");
}
valueXmlString.append("</Detail1>");
}
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
System.out.println("GenerateGSTR3BIC.itemChanged()["+e.getMessage()+"]");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
if(conn != null)
{
conn.close();conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private boolean checkNumeric( String noOfLabel ) throws Exception
{
char[] cArray = noOfLabel.toCharArray();
boolean isNumber = true;
for(int i = 0; i < cArray.length;i++)
{
if( !Character.isDigit(cArray[i]) )
{
isNumber = false;
}
}
return isNumber;
}
}
package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import org.w3c.dom.*;
@javax.ejb.Local
public interface GenerateGSTR3BICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
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() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface GenerateGSTR3BICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
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() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import org.w3c.dom.Document;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@javax.ejb.Stateless
public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLocal,GenerateGSTR3BPrcRemote
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility e12GenericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
Connection connLocal = null,connGST = null;
String taxClassAllStr = "", taxEnvAllStr = "",GST_EXPWP_TAXCLASS = "",GST_EXPWOP_TAXCLASS = "",GST_SEZWP_TAXCLASS = "",
GST_SEZWOP_TAXCLASS = "",GST_DE_TAXCLASS = "",
GST_NIL_TAXCLASS = "",GST_EXE_TAXCLASS = "",GST_EXPWP_TAXENV = "",GST_EXPWOP_TAXENV = "",GST_SEZWP_TAXENV = "",
GST_SEZWOP_TAXENV = "",GST_DE_TAXENV = "",GST_NIL_TAXENV = "",GST_EXE_TAXENV = "",gstB2CLInvValStr = "";
Timestamp fromDate = null, toDate = null;
String chgUser = "",chgTerm = "",loginSiteCode = "",currDateStr = "";
java.sql.Timestamp currDate = null,sysDate = null;
Timestamp currMonthStartDate = null;
double GST_B2CL_INV_VAL = 0.0;
StringBuffer errorMessage = new StringBuffer();
public String process() throws RemoteException, ITMException
{
return "";
}
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
System.out.println("windowName [" + windowName + "]");
System.out.println("xtraParams [" + xtraParams + "]");
if (xmlString != null && xmlString.trim().length() != 0)
{
headerDom = e12GenericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.length() != 0)
{
detailDom = e12GenericUtility.parseString(xmlString2);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception GstDataPrc :process()"+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
//Connection connGST = null,connLocal = null;
ConnDriver connDriverGST = null,connDriverLocal = null;
PreparedStatement pstmt = null,pstmtInsHdr = null,pstmtInsDet = null, pstmtSelHdr = null,pstmtSelDet = null;
ResultSet rs = null, rsSelHdr= null, rsSelDet = null;
String period = "", type = "", sql = "",retString = "",prdcode = "";
//java.sql.Timestamp currDate = null;
boolean isError = false;
String hdrSql = "",dtlSql = "",gstDataSink = "";
int cnt = 0;
String monthStr = "",yearStr = "";
int month = 0, year = 0;
boolean isNumeric = false;
try
{
}
catch (Exception e)
{
System.out.println("Exception inside GstDataPrc==>"+e.getMessage());
isError = true;
e.printStackTrace();
//throw new ITMException(e);
errorMessage.append("\n["+e.getMessage()+"]");
}
finally
{
System.out.println("Inside finally isError["+isError+"] connStatus[]");
try
{
if(rs != null)
{
rs.close();rs = null;
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(pstmtSelHdr != null)
{
pstmtSelHdr.close();pstmtSelHdr = null;
}
if(pstmtSelDet != null)
{
pstmtSelDet.close();pstmtSelDet = null;
}
if(pstmtInsHdr != null)
{
pstmtInsHdr.close();pstmtInsHdr = null;
}
if(pstmtInsDet != null)
{
pstmtInsDet.close();pstmtInsDet = null;
}
if(rsSelHdr != null)
{
rsSelHdr.close();rsSelHdr = null;
}
if(rsSelDet != null)
{
rsSelDet.close();rsSelDet = null;
}
if(isError)
{
System.out.println("GstDataPrc connection RollBack.....");
//connLocal.rollback();
connGST.rollback();
//retString = itmDBAccessEJB.getErrorString("","VTPRCESERR","","",connLocal);
//retString = itmDBAccessEJB.getErrorString("","VTPRCESERR","","",connGST);
retString = getError(errorMessage.toString(),"PRCSUCCESS",connGST);
}
if(!isError)
{
System.out.println("GstDataPrc connection Commit.....");
//connLocal.commit();//Temporary commented
//connLocal.rollback();
connGST.commit();
//retString = itmDBAccessEJB.getErrorString("","PRCSUCCESS","","",connLocal);
//retString = itmDBAccessEJB.getErrorString("","PRCSUCCESS","","",connGST);
retString = getError(errorMessage.toString(),"PRCSUCCESS",connGST);
}
if( connLocal != null && !connLocal.isClosed() )
{
connLocal.close();connLocal = null;
}
if( connGST != null && !connGST.isClosed() )
{
connGST.close();connGST = null;
}
errorMessage.delete(0, errorMessage.length());
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
}
System.out.println("Return String from Post Save ["+retString+"]");
return retString;
}
public String getError(String message,String Code, Connection conn) throws ITMException, Exception
{
String mainStr ="";
try
{
String errString = "";
errString = itmDBAccessEJB.getErrorString("",Code,"","",conn);
String begPart = errString.substring(0,errString.indexOf("</description>"));
String endDesc = errString.substring(errString.indexOf("</description>"),errString.length());
mainStr = begPart + message + endDesc;
begPart = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
private String generateTranId(String windowName, String siteCode,String tranDateStr, Connection conn) throws ITMException, Exception
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
try
{
String monthStr = "";
java.util.Date date= new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int month = cal.get(Calendar.MONTH);
month = month - 1;
if(month < 10)
{
monthStr = "0"+month;
}
else
{
monthStr = ""+month;
}
System.out.println("Current Month is=["+monthStr+"]");
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString(1, windowName);
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("keyString :" + keyString);
System.out.println("keyCol :" + keyCol);
System.out.println("tranSer :" + tranSer);
xmlValues = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<month>" + monthStr + "</month>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr +"</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :[" + xmlValues + "]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE",CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :" + tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" + selSql + ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return tranId;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface GenerateGSTR3BPrcLocal extends ProcessLocal
{
public String process() throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, 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.gst;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface GenerateGSTR3BPrcRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, 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