Commit cabf3ffa 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@106532 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 13ae6d63
...@@ -23,11 +23,6 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -23,11 +23,6 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
E12GenericUtility e12GenericUtility = new E12GenericUtility(); E12GenericUtility e12GenericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); 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 public String wfValData(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{ {
Document currDom = null; Document currDom = null;
...@@ -37,7 +32,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -37,7 +32,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
try try
{ {
System.out.println("Inside GstDataIC wfValData"); System.out.println("Inside GenerateGSTR3BIC wfValData");
if(currXmlDataStr != null && currXmlDataStr.trim().length()!=0) if(currXmlDataStr != null && currXmlDataStr.trim().length()!=0)
{ {
currDom = e12GenericUtility.parseString(currXmlDataStr); currDom = e12GenericUtility.parseString(currXmlDataStr);
...@@ -52,16 +47,16 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -52,16 +47,16 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
} }
errString = wfValData( currDom, hdrDom, allDom, objContext, editFlag, xtraParams ); errString = wfValData( currDom, hdrDom, allDom, objContext, editFlag, xtraParams );
}//end of try }
catch(Exception e) catch(Exception e)
{ {
errString = e12GenericUtility.createErrorString(e); errString = e12GenericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
}//end of catch }
return errString ; 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 public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{ {
...@@ -83,7 +78,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -83,7 +78,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
{ {
conn = getConnection(); conn = getConnection();
String userID = e12GenericUtility.getValueFromXTRA_PARAMS( xtraParams, "LoginCode" ); String userID = e12GenericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
if ( objContext != null && objContext.trim().length() > 0 ) if ( objContext != null && objContext.trim().length() > 0 )
{ {
...@@ -120,36 +115,13 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -120,36 +115,13 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
errString = getErrorString("prd_code","NOTANUMBR1",userID); errString = getErrorString("prd_code","NOTANUMBR1",userID);
break; 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 ) if ("gstin".equalsIgnoreCase( childNodeName ) )
{
pstmt.close();pstmt = null;
}*/
/*if(count == 0)
{
errString = itmDBAccessEJB.getErrorString("","VMPRDNTDF","","",connObject);
break;
}*/
}
}
if ("gst_type".equalsIgnoreCase( childNodeName ) )
{ {
if (childNode.getFirstChild()==null) if (childNode.getFirstChild()==null)
{ {
errString = getErrorString("gst_type","VTBLNKTYPE",userID); errString = getErrorString("gstin","VTBLNKTYPE",userID);
break; break;
} }
} }
...@@ -157,7 +129,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -157,7 +129,7 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception in GstDataIC wfValData == >"+e.getMessage()); System.out.println("GenerateGSTR3BIC.wfValData()["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -184,12 +156,12 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -184,12 +156,12 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
}//end of catch }
} //end of finally }
return (errString); return (errString);
} }
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{ {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
...@@ -328,15 +300,18 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe ...@@ -328,15 +300,18 @@ public class GenerateGSTR3BIC extends ValidatorEJB implements GenerateGSTR3BICRe
{ {
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close();pstmt = null; pstmt.close();
pstmt = null;
} }
if(rs != null) if(rs != null)
{ {
rs.close();rs = null; rs.close();
rs = null;
} }
if(conn != null) if(conn != null)
{ {
conn.close();conn = null; conn.close();
conn = null;
} }
} }
catch(Exception d) catch(Exception d)
......
...@@ -8,10 +8,8 @@ import org.w3c.dom.*; ...@@ -8,10 +8,8 @@ import org.w3c.dom.*;
@javax.ejb.Local @javax.ejb.Local
public interface GenerateGSTR3BICLocal extends ValidatorLocal 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(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 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(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; 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
...@@ -8,10 +8,8 @@ import org.w3c.dom.*; ...@@ -8,10 +8,8 @@ import org.w3c.dom.*;
@javax.ejb.Remote @javax.ejb.Remote
public interface GenerateGSTR3BICRemote extends ValidatorRemote 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(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 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(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; 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; package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB; import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon; import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.util.gst.GSTCommonUtil;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@javax.ejb.Stateless @javax.ejb.Stateless
public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLocal,GenerateGSTR3BPrcRemote public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLocal,GenerateGSTR3BPrcRemote
{ {
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility e12GenericUtility = new E12GenericUtility(); E12GenericUtility e12GenericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon(); GSTCommonUtil gstCommonUtil = new GSTCommonUtil();
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(); FinCommon finCommon = new FinCommon();
public String process() throws RemoteException, ITMException
{
return "";
}
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException public String process(String xmlString, String xmlString2, String objContext, String xtraParams) throws ITMException
{ {
String retStr = ""; String retStr = "";
Document detailDom = null; Document detailDom = null;
...@@ -56,7 +37,7 @@ public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLo ...@@ -56,7 +37,7 @@ public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLo
{ {
System.out.println("xmlString [" + xmlString + "]"); System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString2 [" + xmlString2 + "]"); System.out.println("xmlString2 [" + xmlString2 + "]");
System.out.println("windowName [" + windowName + "]"); System.out.println("objContext [" + objContext + "]");
System.out.println("xtraParams [" + xtraParams + "]"); System.out.println("xtraParams [" + xtraParams + "]");
if (xmlString != null && xmlString.trim().length() != 0) if (xmlString != null && xmlString.trim().length() != 0)
...@@ -68,248 +49,1156 @@ public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLo ...@@ -68,248 +49,1156 @@ public class GenerateGSTR3BPrc extends ProcessEJB implements GenerateGSTR3BPrcLo
detailDom = e12GenericUtility.parseString(xmlString2); detailDom = e12GenericUtility.parseString(xmlString2);
} }
retStr = process(headerDom, detailDom, windowName, xtraParams); retStr = process(headerDom, detailDom, objContext, xtraParams);
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception GstDataPrc :process()"+ e.getMessage() + ":"); System.out.println("GenerateGSTR3BPrc.process()["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return retStr; return retStr;
} }
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException public String process(Document headerDom, Document detailDom, String objContext, String xtraParams) throws ITMException
{ {
String errString = "";
String prdCode = "", gstin = "", loginSiteCode= "", gstCode = "";
boolean isDataFound01 = false, isDataFound03 = false, isDataFound04 = false, isDataFound05 = false, isDataFound06 = false, isDataFound09 = false,
isDataFound10 = false, isDataFound11 = false, isDataFound14 = false, isDataFound21 = false, isDataFound28 = false, isDataFound29 = false,
isDataFound30 = false, isDataFound31 = false;
//Connection connGST = null,connLocal = null; double taxableAmtTemp1 = 0.0, igstAmtTemp1 = 0.0, cgstAmtTemp1 = 0.0, sgstAmtTemp1 = 0.0, cessAmtTemp1 = 0.0;
ConnDriver connDriverGST = null,connDriverLocal = null; double taxableAmtTemp2 = 0.0, igstAmtTemp2 = 0.0, cgstAmtTemp2 = 0.0, sgstAmtTemp2 = 0.0, cessAmtTemp2 = 0.0;
double taxableAmt = 0.0, igstAmt = 0.0, cgstAmt = 0.0, sgstAmt = 0.0, cessAmt = 0.0;
PreparedStatement pstmt = null,pstmtInsHdr = null,pstmtInsDet = null, pstmtSelHdr = null,pstmtSelDet = null; HashMap<String,Object> headerDataHMap = new HashMap<String,Object>();
ResultSet rs = null, rsSelHdr= null, rsSelDet = null; HashMap<String,Object> detailDataHMap = new HashMap<String,Object>();
List<HashMap<String,Object>> detailDataList = new ArrayList<HashMap<String,Object>>();
String period = "", type = "", sql = "",retString = "",prdcode = ""; String sql = "";
//java.sql.Timestamp currDate = null; PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
boolean isError = false; boolean isError = false;
try
{
conn = getConnection();
prdCode = gstCommonUtil.checkNull(e12GenericUtility.getColumnValue("prd_code", headerDom));
gstin = gstCommonUtil.checkNull(e12GenericUtility.getColumnValue("gstin", headerDom));
System.out.println("prdCode["+prdCode+"] gstin["+gstin+"]");
if(prdCode.trim().length() == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTBLNKPRD","","",conn);
return errString;
}
else if(prdCode.trim().length() > 0)
{
sql = "SELECT COUNT(*) AS CNT FROM PERIOD WHERE TO_CHAR(TO_DATE(CODE,'yyyymm'),'mmyyyy') = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getInt("CNT") == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTMONATD10","","",conn);
return errString;
}
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
}
String hdrSql = "",dtlSql = "",gstDataSink = ""; loginSiteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
int cnt = 0; System.out.println("Outward taxable supplies (other than zero) START");
String monthStr = "",yearStr = ""; sql = " SELECT SUM(GDD.TAXABLE_AMT) AS TAXABLE_AMT ,SUM(GDD.IGST_AMT) AS IGST_AMT,SUM(GDD.CGST_AMT) AS CGST_AMT, "
int month = 0, year = 0; + " SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
boolean isNumeric = false; + " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('01','03','08','09','10','06','07','11','12','30','41','42') ";
try pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
if(rs.next())
{
isDataFound01 = true;
taxableAmtTemp1 = rs.getDouble("TAXABLE_AMT");
igstAmtTemp1 = rs.getDouble("IGST_AMT");
cgstAmtTemp1 = rs.getDouble("CGST_AMT");
sgstAmtTemp1 = rs.getDouble("SGST_AMT");
cessAmtTemp1 = rs.getDouble("CESS_AMT");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{ {
pstmt.close();
pstmt=null;
}
sql = " SELECT SUM(GDD.TAXABLE_AMT) AS TAXABLE_AMT ,SUM(GDD.IGST_AMT) AS IGST_AMT,SUM(GDD.CGST_AMT) AS CGST_AMT, "
+ " SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('29','43','44') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
if(rs.next())
{
isDataFound01 = true;
taxableAmtTemp2 = rs.getDouble("TAXABLE_AMT");
igstAmtTemp2 = rs.getDouble("IGST_AMT");
cgstAmtTemp2 = rs.getDouble("CGST_AMT");
sgstAmtTemp2 = rs.getDouble("SGST_AMT");
cessAmtTemp2 = rs.getDouble("CESS_AMT");
} }
catch (Exception e) if(rs!=null)
{ {
System.out.println("Exception inside GstDataPrc==>"+e.getMessage()); rs.close();
isError = true; rs=null;
e.printStackTrace();
//throw new ITMException(e);
errorMessage.append("\n["+e.getMessage()+"]");
} }
finally if(pstmt!=null)
{ {
System.out.println("Inside finally isError["+isError+"] connStatus[]"); pstmt.close();
try pstmt=null;
}
if(isDataFound01)
{ {
if(rs != null) taxableAmt = taxableAmtTemp1 - taxableAmtTemp2;
igstAmt = igstAmtTemp1 - igstAmtTemp2;
cgstAmt = cgstAmtTemp1 - cgstAmtTemp2;
sgstAmt = sgstAmtTemp1 - sgstAmtTemp2;
cessAmt = cessAmtTemp1 - cessAmtTemp2;
System.out.println("taxableAmt["+taxableAmt+"]");
System.out.println("igstAmt["+igstAmt+"]");
System.out.println("cgstAmt["+cgstAmt+"]");
System.out.println("sgstAmt["+sgstAmt+"]");
System.out.println("cessAmt["+cessAmt+"]");
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "01");
headerDataHMap.put("gst_type", "O");
detailDataHMap.clear();
detailDataHMap.put("taxable_amt", taxableAmt);
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
taxableAmtTemp1 = 0.0; igstAmtTemp1 = 0.0; cgstAmtTemp1 = 0.0; sgstAmtTemp1 = 0.0; cessAmtTemp1 = 0.0;
taxableAmtTemp2 = 0.0; igstAmtTemp2 = 0.0; cgstAmtTemp2 = 0.0; sgstAmtTemp2 = 0.0; cessAmtTemp2 = 0.0;
}
else
{ {
rs.close();rs = null; System.out.println("No data found for GSTR3B trantype [01]");
} }
if(pstmt != null)
System.out.println("Outward taxable supplies (other than zero) END");
System.out.println("Outward taxable supplies (zero rated ) START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("Outward taxable supplies (zero rated ) END");
System.out.println("Other outward supplies (Nil rated, exempted) START");
sql = " SELECT SUM(GDH.AMOUNT) AS AMOUNT "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('15','16','18','19','21','22','24','25') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
if(rs.next())
{ {
pstmt.close();pstmt = null; isDataFound03 = true;
taxableAmt = rs.getDouble("AMOUNT");
} }
if(pstmtSelHdr != null) if(rs!=null)
{ {
pstmtSelHdr.close();pstmtSelHdr = null; rs.close();
rs=null;
} }
if(pstmtSelDet != null) if(pstmt!=null)
{ {
pstmtSelDet.close();pstmtSelDet = null; pstmt.close();
pstmt=null;
} }
if(pstmtInsHdr != null)
if(isDataFound03)
{ {
pstmtInsHdr.close();pstmtInsHdr = null; headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "03");
headerDataHMap.put("gst_type", "O");
headerDataHMap.put("amount", taxableAmt);
insertGSTHdrDetData(headerDataHMap, null, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
} }
if(pstmtInsDet != null) else
{ {
pstmtInsDet.close();pstmtInsDet = null; System.out.println("No data found for GSTR3B trantype [03]");
} }
if(rsSelHdr != null)
System.out.println("Other outward supplies (Nil rated, exempted) END");
System.out.println("Inward supplies (liable to reverse charge) START");
sql = " SELECT SUM(GDD.TAXABLE_AMT) AS TAXABLE_AMT ,SUM(GDD.IGST_AMT) AS IGST_AMT,SUM(GDD.CGST_AMT) AS CGST_AMT, "
+ " SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('02') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
if(rs.next())
{ {
rsSelHdr.close();rsSelHdr = null; isDataFound04 = true;
taxableAmt = rs.getDouble("TAXABLE_AMT");
igstAmt = rs.getDouble("IGST_AMT");
cgstAmt = rs.getDouble("CGST_AMT");
sgstAmt = rs.getDouble("SGST_AMT");
cessAmt = rs.getDouble("CESS_AMT");
} }
if(rsSelDet != null) if(rs!=null)
{ {
rsSelDet.close();rsSelDet = null; rs.close();
rs=null;
} }
if(isError) if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(isDataFound04)
{
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "04");
headerDataHMap.put("gst_type", "O");
detailDataHMap.clear();
detailDataHMap.put("taxable_amt", taxableAmt);
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
}
else
{
System.out.println("No data found for GSTR3B trantype [04]");
}
System.out.println("Inward supplies (liable to reverse charge) END");
System.out.println("Non-GST outward supplies START");
sql = " SELECT SUM(GDH.AMOUNT) AS AMOUNT "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('17','20','23','26') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
if(rs.next())
{ {
System.out.println("GstDataPrc connection RollBack....."); isDataFound05 = true;
//connLocal.rollback(); taxableAmt = rs.getDouble("AMOUNT");
connGST.rollback();
//retString = itmDBAccessEJB.getErrorString("","VTPRCESERR","","",connLocal);
//retString = itmDBAccessEJB.getErrorString("","VTPRCESERR","","",connGST);
retString = getError(errorMessage.toString(),"PRCSUCCESS",connGST);
} }
if(!isError) if(rs!=null)
{ {
System.out.println("GstDataPrc connection Commit....."); rs.close();
//connLocal.commit();//Temporary commented rs=null;
//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() ) if(pstmt!=null)
{ {
connLocal.close();connLocal = null; pstmt.close();
pstmt=null;
}
if(isDataFound05)
{
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "05");
headerDataHMap.put("gst_type", "O");
headerDataHMap.put("amount", taxableAmt);
insertGSTHdrDetData(headerDataHMap, null, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
} }
if( connGST != null && !connGST.isClosed() ) else
{ {
connGST.close();connGST = null; System.out.println("No data found for GSTR3B trantype [05]");
} }
errorMessage.delete(0, errorMessage.length()); System.out.println("Non-GST outward supplies END");
System.out.println("Supplies to unregistered persons START");
sql = " SELECT GDH.GST_CODE, SUM(GDD.TAXABLE_AMT) AS TAXABLE_AMT ,SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('04','05','13','14') GROUP BY GST_CODE ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "1");
rs = pstmt.executeQuery();
while(rs.next())
{
isDataFound06 = true;
gstCode = rs.getString("GST_CODE");
taxableAmt = rs.getDouble("TAXABLE_AMT");
igstAmt = rs.getDouble("IGST_AMT");
cessAmt = rs.getDouble("CESS_AMT");
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "06");
headerDataHMap.put("gst_type", "D");
headerDataHMap.put("gst_code", gstCode);
headerDataHMap.put("doc_type", "U");
detailDataHMap.clear();
detailDataHMap.put("taxable_amt", taxableAmt);
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
} }
catch (Exception ex) if(rs!=null)
{ {
ex.printStackTrace(); rs.close();
throw new ITMException(ex); rs=null;
} }
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
} }
System.out.println("Return String from Post Save ["+retString+"]");
return retString; if(!isDataFound06)
{
System.out.println("No data found for GSTR3B trantype [06]");
} }
public String getError(String message,String Code, Connection conn) throws ITMException, Exception System.out.println("Supplies to unregistered persons END");
System.out.println("Supplies to composite persons START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("Supplies to composite persons END");
System.out.println("Supplies to UIN holders START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("Supplies to UIN holders END");
System.out.println("IMPG ITC avilable START");
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('08','09') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "2");
rs = pstmt.executeQuery();
if(rs.next())
{ {
String mainStr =""; isDataFound09 = true;
igstAmt = rs.getDouble("IGST_AMT");
cgstAmt = rs.getDouble("CGST_AMT");
sgstAmt = rs.getDouble("SGST_AMT");
cessAmt = rs.getDouble("CESS_AMT");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
try if(isDataFound09)
{ {
String errString = ""; headerDataHMap.clear();
errString = itmDBAccessEJB.getErrorString("",Code,"","",conn); headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "09");
headerDataHMap.put("gst_type", "E");
String begPart = errString.substring(0,errString.indexOf("</description>")); detailDataHMap.clear();
String endDesc = errString.substring(errString.indexOf("</description>"),errString.length()); detailDataHMap.put("itc_type", "IG");
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
mainStr = begPart + message + endDesc; detailDataList.clear();
begPart = null; detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
} }
catch(Exception e) else
{ {
e.printStackTrace(); System.out.println("No data found for GSTR3B trantype [09]");
throw new ITMException(e);
} }
return mainStr;
System.out.println("IMPG ITC avilable END");
System.out.println("IMPS ITC avilable START");
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('07') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "2");
rs = pstmt.executeQuery();
if(rs.next())
{
isDataFound10 = true;
igstAmt = rs.getDouble("IGST_AMT");
cgstAmt = rs.getDouble("CGST_AMT");
sgstAmt = rs.getDouble("SGST_AMT");
cessAmt = rs.getDouble("CESS_AMT");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
} }
private String generateTranId(String windowName, String siteCode,String tranDateStr, Connection conn) throws ITMException, Exception if(isDataFound10)
{ {
PreparedStatement pstmt = null; headerDataHMap.clear();
ResultSet rs = null; headerDataHMap.put("prd_code", prdCode);
String selSql = ""; headerDataHMap.put("tran_type", "10");
String tranId = ""; headerDataHMap.put("gst_type", "E");
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
try detailDataHMap.clear();
detailDataHMap.put("itc_type", "IS");
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
}
else
{
System.out.println("No data found for GSTR3B trantype [10]");
}
System.out.println("IMPS ITC avilable END");
System.out.println("ISRC ITC avilable START");
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('05') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "2");
rs = pstmt.executeQuery();
if(rs.next())
{ {
String monthStr = ""; isDataFound11 = true;
java.util.Date date= new Date(); igstAmt = rs.getDouble("IGST_AMT");
Calendar cal = Calendar.getInstance(); cgstAmt = rs.getDouble("CGST_AMT");
cal.setTime(date); sgstAmt = rs.getDouble("SGST_AMT");
int month = cal.get(Calendar.MONTH); cessAmt = rs.getDouble("CESS_AMT");
month = month - 1; }
if(month < 10) if(rs!=null)
{ {
monthStr = "0"+month; rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(isDataFound11)
{
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "11");
headerDataHMap.put("gst_type", "E");
detailDataHMap.clear();
detailDataHMap.put("itc_type", "IC");
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
} }
else else
{ {
monthStr = ""+month; System.out.println("No data found for GSTR3B trantype [11]");
} }
System.out.println("Current Month is=["+monthStr+"]");
System.out.println("ISRC ITC avilable END");
System.out.println("ISD ITC avilable START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("ISD ITC avilable END");
System.out.println("RUL ITC avilable START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("RUL ITC avilable END");
System.out.println("OTH ITC avilable START");
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT,SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('01','02','03','04','06','10','11','16','17') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "2");
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(); rs = pstmt.executeQuery();
if (rs.next())
if(rs.next())
{ {
keyString = rs.getString("KEY_STRING"); isDataFound14 = true;
keyCol = rs.getString("TRAN_ID_COL"); igstAmtTemp1 = rs.getDouble("IGST_AMT");
tranSer = rs.getString("REF_SER"); cgstAmtTemp1 = rs.getDouble("CGST_AMT");
sgstAmtTemp1 = rs.getDouble("SGST_AMT");
cessAmtTemp1 = rs.getDouble("CESS_AMT");
} }
if(rs!=null)
{
rs.close(); rs.close();
rs = null; rs=null;
}
if(pstmt!=null)
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt=null;
System.out.println("keyString :" + keyString); }
System.out.println("keyCol :" + keyCol);
System.out.println("tranSer :" + tranSer); sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT,SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
xmlValues = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>"; + " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
xmlValues = xmlValues + "<Header></Header>"; + " AND GDH.TRAN_TYPE IN ('12','13','14','15') ";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>"; pstmt = conn.prepareStatement(sql);
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>"; pstmt.setString(1, loginSiteCode);
xmlValues = xmlValues + "<month>" + monthStr + "</month>"; pstmt.setString(2, prdCode);
xmlValues = xmlValues + "<tran_date>" + tranDateStr +"</tran_date>"; pstmt.setString(3, "2");
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :[" + xmlValues + "]"); rs = pstmt.executeQuery();
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE",CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn); if(rs.next())
System.out.println("tranId :" + tranId); {
isDataFound14 = true;
} igstAmtTemp2 = rs.getDouble("IGST_AMT");
catch (SQLException ex) cgstAmtTemp2 = rs.getDouble("CGST_AMT");
{ sgstAmtTemp2 = rs.getDouble("SGST_AMT");
System.out.println("Exception ::" + selSql + ex.getMessage() + ":"); cessAmtTemp2 = rs.getDouble("CESS_AMT");
ex.printStackTrace(); }
throw new ITMException(ex); if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(isDataFound14)
{
igstAmt = igstAmtTemp1 - igstAmtTemp2;
cgstAmt = cgstAmtTemp1 - cgstAmtTemp2;
sgstAmt = sgstAmtTemp1 - sgstAmtTemp2;
cessAmt = cessAmtTemp1 - cessAmtTemp2;
System.out.println("igstAmt["+igstAmt+"]");
System.out.println("cgstAmt["+cgstAmt+"]");
System.out.println("sgstAmt["+sgstAmt+"]");
System.out.println("cessAmt["+cessAmt+"]");
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "14");
headerDataHMap.put("gst_type", "E");
detailDataHMap.clear();
detailDataHMap.put("itc_type", "OT");
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
taxableAmtTemp1 = 0.0; igstAmtTemp1 = 0.0; cgstAmtTemp1 = 0.0; sgstAmtTemp1 = 0.0; cessAmtTemp1 = 0.0;
taxableAmtTemp2 = 0.0; igstAmtTemp2 = 0.0; cgstAmtTemp2 = 0.0; sgstAmtTemp2 = 0.0; cessAmtTemp2 = 0.0;
}
else
{
System.out.println("No data found for GSTR3B trantype [14]");
}
System.out.println("OTH ITC avilable END");
System.out.println("IMPG ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("IMPG ITC reversed END");
System.out.println("IMPS ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("IMPS ITC reversed END");
System.out.println("ISRC ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("ISRC ITC reversed END");
System.out.println("ISD ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("ISD ITC reversed END");
System.out.println("RUL ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("RUL ITC reversed END");
System.out.println("OTH ITC reversed START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("OTH ITC reversed END");
System.out.println("NET ITC Available START");
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('09','10','11','12','13','14') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "6");
rs = pstmt.executeQuery();
if(rs.next())
{
isDataFound21 = true;
igstAmtTemp1 = rs.getDouble("IGST_AMT");
cgstAmtTemp1 = rs.getDouble("CGST_AMT");
sgstAmtTemp1 = rs.getDouble("SGST_AMT");
cessAmtTemp1 = rs.getDouble("CESS_AMT");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
sql = " SELECT SUM(GDD.IGST_AMT) AS IGST_AMT, SUM(GDD.CGST_AMT) AS CGST_AMT, SUM(GDD.SGST_AMT) AS SGST_AMT, SUM(GDD.CESS_AMT) AS CESS_AMT "
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD "
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.REC_TYPE = ? "
+ " AND GDH.TRAN_TYPE IN ('15','16','17','18','19','20') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSiteCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, "6");
rs = pstmt.executeQuery();
if(rs.next())
{
isDataFound21 = true;
igstAmtTemp2 = rs.getDouble("IGST_AMT");
cgstAmtTemp2 = rs.getDouble("CGST_AMT");
sgstAmtTemp2 = rs.getDouble("SGST_AMT");
cessAmtTemp2 = rs.getDouble("CESS_AMT");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(isDataFound21)
{
igstAmt = igstAmtTemp1 - igstAmtTemp2;
cgstAmt = cgstAmtTemp1 - cgstAmtTemp2;
sgstAmt = sgstAmtTemp1 - sgstAmtTemp2;
cessAmt = cessAmtTemp1 - cessAmtTemp2;
System.out.println("igstAmt["+igstAmt+"]");
System.out.println("cgstAmt["+cgstAmt+"]");
System.out.println("sgstAmt["+sgstAmt+"]");
System.out.println("cessAmt["+cessAmt+"]");
headerDataHMap.clear();
headerDataHMap.put("prd_code", prdCode);
headerDataHMap.put("tran_type", "21");
headerDataHMap.put("gst_type", "E");
detailDataHMap.clear();
detailDataHMap.put("igst_amt", igstAmt);
detailDataHMap.put("cgst_amt", cgstAmt);
detailDataHMap.put("sgst_amt", sgstAmt);
detailDataHMap.put("cess_amt", cessAmt);
detailDataList.clear();
detailDataList.add(detailDataHMap);
insertGSTHdrDetData(headerDataHMap, detailDataList, xtraParams, conn);
taxableAmt = 0.0; igstAmt = 0.0; cgstAmt = 0.0; sgstAmt = 0.0; cessAmt = 0.0;
taxableAmtTemp1 = 0.0; igstAmtTemp1 = 0.0; cgstAmtTemp1 = 0.0; sgstAmtTemp1 = 0.0; cessAmtTemp1 = 0.0;
taxableAmtTemp2 = 0.0; igstAmtTemp2 = 0.0; cgstAmtTemp2 = 0.0; sgstAmtTemp2 = 0.0; cessAmtTemp2 = 0.0;
}
else
{
System.out.println("No data found for GSTR3B trantype [21]");
}
System.out.println("NET ITC Available END");
System.out.println("IMPG ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("IMPG ITC ineligible END");
System.out.println("IMPS ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("IMPS ITC ineligible END");
System.out.println("ISRC ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("ISRC ITC reversed END");
System.out.println("ISD ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("ISD ITC ineligible END");
System.out.println("RUL ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("RUL ITC ineligible END");
System.out.println("OTH ITC ineligible START");
System.out.println("!!!!!!!!!!!!!!No inforamtion to identify data!!!!!!!!!!!!!!");
System.out.println("OTH ITC ineligible END");
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception ::" + e.getMessage() + ":"); System.out.println("GenerateGSTR3BPrc.process()["+e.getMessage()+"]");
isError = true;
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e);
} }
finally finally
{ {
if (rs != null) System.out.println("Inside finally isError["+isError+"]");
try
{
if(isError)
{
conn.rollback();
if(rs!=null)
{ {
rs.close(); rs.close();
rs = null; rs=null;
} }
if (pstmt != null) if(pstmt!=null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt=null;
}
}
if((errString == null || errString.trim().length() == 0) && !isError)
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","PRCSUCCESS","","",conn);
}
if(conn != null && !conn.isClosed())
{
conn.close();
conn=null;
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
}
System.out.println("Return String from process ["+errString+"]");
return errString;
}
private void insertGSTHdrDetData(HashMap<String,Object> headerDataHMap, List<HashMap<String,Object>> detailDataList, String xtraParams, Connection conn) throws ITMException
{
String tranId = "", siteCode = "", periodCode = "", tranType = "", docType = "", gstCode = "", gstType = "",
loginCode = "", chgTerm = "", supplyType = "", itcType = "";
double amount = 0.0, taxableAmt = 0.0, igstAmt = 0.0, cgstAmt = 0.0, sgstAmt = 0.0, cessAmt = 0.0;
int lineNo = 0;
int hdrInsCnt = 0;
int[] detInsCnt = null;
String hdrInsSql = "", detInsSql = "";
PreparedStatement hdrInsPstmt = null, detInsPstmt = null;
boolean isError = false;
try
{
siteCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginCode = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
periodCode = (String)headerDataHMap.get("prd_code");
tranType = (String)headerDataHMap.get("tran_type");
docType = (String)headerDataHMap.get("doc_type");
gstCode = (String)headerDataHMap.get("gst_code");
gstType = (String)headerDataHMap.get("gst_type");
amount = (double)headerDataHMap.get("amount");
hdrInsSql = " INSERT INTO GST_DATA_HDR (TRAN_ID, TRAN_DATE, TRAN_ID__REF, SITE_CODE, PRD_CODE, REC_TYPE, TRAN_TYPE, CUST_CODE, CUST_NAME,"
+ " SUBMISSION_TYPE, DOC_CHECKSUM, DOC_TYPE, DOC_NO, DOC_DATE, AMOUNT, REVERSE_CHRG, LR_NO, LR_DATE, REAS_CODE, REF_ID__INV,"
+ " REF_DATE__INV, PROV_ASSMNT, ORDER_NO, ORDER_DATE, REMARKS, SUBMIT_STATUS, SUBMIT_DATE, ADD_USER, ADD_DATE, ADD_TERM, CHG_USER,"
+ " CHG_DATE, CHG_TERM, TAX_REG_NO, RECO_STATUS, ECOM_REG_NO, REF_SER, GST_CODE, GST_TYPE, REF_ID)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
hdrInsPstmt = conn.prepareStatement(hdrInsSql);
tranId = gstCommonUtil.generateTranId("w_gstr3b", siteCode, conn);
hdrInsPstmt.setString(1, tranId);
hdrInsPstmt.setTimestamp(2, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(new Date(), e12GenericUtility.getDBDateTimeFormat())));
hdrInsPstmt.setString(3, null);
hdrInsPstmt.setString(4, siteCode);
hdrInsPstmt.setString(5, periodCode);
hdrInsPstmt.setString(6, "6");
hdrInsPstmt.setString(7, tranType);
hdrInsPstmt.setString(8, null);
hdrInsPstmt.setString(9, null);
hdrInsPstmt.setString(10, null);
hdrInsPstmt.setString(11, null);
hdrInsPstmt.setString(12, docType);
hdrInsPstmt.setString(13, null);
hdrInsPstmt.setTimestamp(14, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(new Date(), e12GenericUtility.getDBDateTimeFormat())));
hdrInsPstmt.setDouble(15, amount);
hdrInsPstmt.setString(16, null);
hdrInsPstmt.setString(17, null);
hdrInsPstmt.setTimestamp(18, null);
hdrInsPstmt.setString(19, null);
hdrInsPstmt.setString(20, null);
hdrInsPstmt.setTimestamp(21, null);
hdrInsPstmt.setString(22, null);
hdrInsPstmt.setString(23, null);
hdrInsPstmt.setTimestamp(24, null);
hdrInsPstmt.setString(25, null);
hdrInsPstmt.setString(26, "P");
hdrInsPstmt.setTimestamp(27, null);
hdrInsPstmt.setString(28, loginCode);
hdrInsPstmt.setTimestamp(29, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(new Date(), e12GenericUtility.getDBDateTimeFormat())));
hdrInsPstmt.setString(30, chgTerm);
hdrInsPstmt.setString(31, loginCode);
hdrInsPstmt.setTimestamp(32, java.sql.Timestamp.valueOf(e12GenericUtility.getValidDateString(new Date(), e12GenericUtility.getDBDateTimeFormat())));
hdrInsPstmt.setString(33, chgTerm);
hdrInsPstmt.setString(34, null);
hdrInsPstmt.setString(35, null);
hdrInsPstmt.setString(36, null);
hdrInsPstmt.setString(37, null);
hdrInsPstmt.setString(38, gstCode);
hdrInsPstmt.setString(39, gstType);
hdrInsPstmt.setString(40, null);
hdrInsCnt = hdrInsPstmt.executeUpdate();
System.out.println("data inserted into header ["+hdrInsCnt+"]");
if(hdrInsPstmt != null)
{
hdrInsPstmt.close();
hdrInsPstmt = null;
}
if(detailDataList != null && detailDataList.size() > 0)
{
detInsSql = " INSERT INTO GST_DATA_DET (TRAN_ID, LINE_NO, STATUS, SR_NO__OLD, LINE_TYPE, GS_CODE, TAXABLE_AMT, IGST_PERC,"
+ " IGST_AMT, CGST_PERC, CGST_AMT, SGST_PERC, SGST_AMT, GS_DESCR, UNIT, QUANTITY, SUPPLY_TYPE, CESS_PERC, CESS_AMT,"
+ " REMARKS, ITC_TYPE, ITC_IGST, ITC_CGST, ITC_SGST, ITC_CESS, GST_RATE)"
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
detInsPstmt = conn.prepareStatement(detInsSql);
for(HashMap<String,Object> eachDataHMap : detailDataList)
{
taxableAmt = (double)eachDataHMap.get("taxable_amt");
igstAmt = (double)eachDataHMap.get("igst_amt");
cgstAmt = (double)eachDataHMap.get("cgst_amt");
sgstAmt = (double)eachDataHMap.get("sgst_amt");
cessAmt = (double)eachDataHMap.get("cess_amt");
supplyType = (String)eachDataHMap.get("supply_type");
itcType = (String)eachDataHMap.get("itc_type");
detInsPstmt.setString(1, tranId);
detInsPstmt.setInt(2, ++lineNo);
detInsPstmt.setString(3, null);
detInsPstmt.setInt(4, 0);
detInsPstmt.setString(5, null);
detInsPstmt.setString(6, null);
detInsPstmt.setDouble(7, taxableAmt);
detInsPstmt.setDouble(8, 0.0);
detInsPstmt.setDouble(9, igstAmt);
detInsPstmt.setDouble(10, 0.0);
detInsPstmt.setDouble(11, cgstAmt);
detInsPstmt.setDouble(12, 0.0);
detInsPstmt.setDouble(13, sgstAmt);
detInsPstmt.setString(14, null);
detInsPstmt.setString(15, null);
detInsPstmt.setInt(16, 0);
detInsPstmt.setString(17, supplyType);
detInsPstmt.setDouble(18, 0.0);
detInsPstmt.setDouble(19, cessAmt);
detInsPstmt.setString(20, null);
detInsPstmt.setString(21, itcType);
detInsPstmt.setDouble(22, 0.0);
detInsPstmt.setDouble(23, 0.0);
detInsPstmt.setDouble(24, 0.0);
detInsPstmt.setDouble(25, 0.0);
detInsPstmt.setDouble(26, 0.0);
detInsPstmt.addBatch();
detInsPstmt.clearParameters();
}
detInsCnt = detInsPstmt.executeBatch();
if(detInsPstmt != null)
{
detInsPstmt.close();
detInsPstmt = null;
}
if(detInsCnt!=null)
{
for(int eachRowCnt : detInsCnt)
{
System.out.println("data inserted into detail ["+eachRowCnt+"]");
} }
} }
return tranId;
} }
}
catch(Exception e)
{
isError = true;
System.out.println("GenerateGSTR3BPrc.insertGSTHdrDetData()");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("inside GenerateGSTR3BPrc.insertGSTHdrDetData() isError["+isError+"]");
private String checkNull(String input) if(isError)
{
if(hdrInsPstmt != null)
{ {
if (input == null) hdrInsPstmt.close();
hdrInsPstmt = null;
}
if(detInsPstmt != null)
{ {
input = ""; detInsPstmt.close();
detInsPstmt = null;
}
}
} }
return input; catch(SQLException se)
{
System.out.println("GenerateGSTR3BPrc.insertGSTHdrDetData()["+se.getMessage()+"]");
se.printStackTrace();
}
}
}
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;
} }
} }
\ No newline at end of file
package ibase.webitm.ejb.gst; package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import ibase.webitm.ejb.ProcessLocal; import ibase.webitm.ejb.ProcessLocal;
...@@ -10,7 +8,6 @@ import ibase.webitm.utility.ITMException; ...@@ -10,7 +8,6 @@ import ibase.webitm.utility.ITMException;
@javax.ejb.Local @javax.ejb.Local
public interface GenerateGSTR3BPrcLocal extends ProcessLocal public interface GenerateGSTR3BPrcLocal extends ProcessLocal
{ {
public String process() throws RemoteException,ITMException; public String process(String xmlString, String xmlString2, String objContext, String xtraParams) throws ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException; public String process(Document headerDom, Document detailDom, String objContext, String xtraParams) throws 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; package ibase.webitm.ejb.gst;
import java.rmi.RemoteException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import ibase.webitm.ejb.ProcessRemote; import ibase.webitm.ejb.ProcessRemote;
...@@ -10,8 +8,7 @@ import ibase.webitm.utility.ITMException; ...@@ -10,8 +8,7 @@ import ibase.webitm.utility.ITMException;
@javax.ejb.Remote @javax.ejb.Remote
public interface GenerateGSTR3BPrcRemote extends ProcessRemote public interface GenerateGSTR3BPrcRemote extends ProcessRemote
{ {
public String process() throws RemoteException,ITMException; public String process(String xmlString, String xmlString2, String objContext, String xtraParams) throws ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException; public String process(Document headerDom, Document detailDom, String objContext, String xtraParams) throws 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