Commit 7482e324 authored by steurwadkar's avatar steurwadkar

F17ABAS001 GST API integration wizard source code commit

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@172091 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2a4a0a50
......@@ -3434,15 +3434,24 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
public Object generateOfflineFile(String periodCode, String siteCode, String recType) throws ITMException
{
XSSFWorkbook retDataWorkbook = null;
String gstr1WorkBookPath = "";
String gstr1WorkBookPath = "", gstr2WorkBookPath = "";
String sep = File.separator;
String tranType = "", tranId = "", udfStr1 = "", udfStr2 = "", udfStr3 = "", ctin = "", posStateCode = "", docNo = "", docDateStr = "",
reverseCharge = "", etin = "", invoiceType = "", errorCode = "", dataErrMsg = "", stateDscr = "", redInvId = "", refInvDtStr = "",
preGST = "", refTranType = "", customerType = "", portCode = "", shipBillNo = "", shipBillDateStr = "", gstDateFormat = "", supplyType = "";
reverseCharge = "", etin = "", invoiceType = "", errorCode = "", dataErrMsg = "", stateDscr = "", refInvId = "", refInvDtStr = "",
preGST = "", refTranType = "", customerType = "", portCode = "", shipBillNo = "", shipBillDateStr = "", gstDateFormat = "", supplyType = "",
itcType = "", itcTypeDescr = "", supplierName = "", placeOfBusiness = "", documentType = "";
boolean noDataFound = false;
double amount =0.0, gstRate = 0.0, taxableAmt = 0.0, cessAmt = 0.0, nilAmount = 0.0, exemtAmount = 0.0, nonGSTAmount = 0.0;
int b2bRowNum = 4, b2clRowNum = 4, b2csRowNum = 4, cdnrRowNum = 4, cdnurRowNum = 4, expRowNum = 4, atRowNum = 4, atAdjRowNum = 4, hsnRowNum = 4;
double amount =0.0, gstRate = 0.0, taxableAmt = 0.0, cessAmt = 0.0, nilAmount = 0.0, exemtAmount = 0.0, nonGSTAmount = 0.0, compDlrAmount = 0.0;
int b2bRowNum = 4, b2clRowNum = 4, b2csRowNum = 4, cdnrRowNum = 4, cdnurRowNum = 4, expRowNum = 4, atRowNum = 4, atAdjRowNum = 4, hsnRowNum = 4,
b2burRowNum = 4, impsRowNum = 4, impgRowNum = 4;
double igstAmt = 0.0, cgstAmt = 0.0, sgstAmt = 0.0, igstITCAmt = 0.0, cgstITCAmt = 0.0, sgstITCAmt = 0.0, cessITCAmt = 0.0;
HashMap<String,String> itcTypeHMap = new HashMap<String,String>();
itcTypeHMap.put("CP", "Capital goods");
itcTypeHMap.put("IS", "Input services");
itcTypeHMap.put("IP", "Inputs");
itcTypeHMap.put("NO", "Ineligible");
String sql = "", hdrSql = "", detSql = "";
Date docDate = null, refInvDate = null, shipBillDate = null;
......@@ -3505,6 +3514,16 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
retDataWorkbook = new XSSFWorkbook(new FileInputStream(gstr1ExcleFile));
}
}
else if("2".equalsIgnoreCase(recType))
{
gstr2WorkBookPath = CommonConstants.JBOSSHOME + sep + "DOWNLOAD" + sep + "template" + sep + "GSTR2_Offline_Template.xlsx";
File gstr2ExcleFile = new File(gstr2WorkBookPath);
if(gstr2ExcleFile.exists())
{
retDataWorkbook = new XSSFWorkbook(new FileInputStream(gstr2ExcleFile));
}
}
gstDateFormat = finCommon.getFinparams("999999", "GST_EXCL_DATE_FORMAT", conn);
......@@ -3538,7 +3557,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
amount = Double.parseDouble(String.format("%.2f",hdrRs.getDouble("AMOUNT")));
reverseCharge = checkNull(hdrRs.getString("REVERSE_CHRG"));
etin = checkNull(hdrRs.getString("ECOM_REG_NO"));
redInvId = checkNull(hdrRs.getString("REF_ID__INV"));
refInvId = checkNull(hdrRs.getString("REF_ID__INV"));
refInvDate = hdrRs.getDate("REF_DATE__INV");
portCode = checkNull(hdrRs.getString("ORDER_NO"));
shipBillNo = checkNull(hdrRs.getString("LR_NO"));
......@@ -3584,7 +3603,9 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
udfStr3 = checkNull(rs.getString("UDF_STR3"));
}
closeResources(rs, pstmt);
System.out.println("udfStr1["+udfStr1+"] udfStr2["+udfStr2+"] udfStr3["+udfStr3+"]");
if("B2B".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("b2b");
......@@ -3736,7 +3757,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
XSSFRow dataRow = dataSheet.createRow(cdnrRowNum++);
dataRow.createCell(0).setCellValue(ctin);
dataRow.createCell(1).setCellValue(redInvId);
dataRow.createCell(1).setCellValue(refInvId);
XSSFCell refInvDateCell = dataRow.createCell(2);
if(refInvDtStr!=null && refInvDtStr.trim().length()>0)
{
......@@ -3831,7 +3852,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(3).setCellValue(udfStr2);
dataRow.createCell(4).setCellValue(redInvId);
dataRow.createCell(4).setCellValue(refInvId);
XSSFCell refInvDateCell = dataRow.createCell(5);
if(refInvDtStr!=null && refInvDtStr.trim().length()>0)
{
......@@ -4275,7 +4296,716 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
else if("2".equalsIgnoreCase(recType))
{
hdrSql = "SELECT * FROM GST_DATA_HDR WHERE REC_TYPE = ? AND PRD_CODE = ? AND SITE_CODE = ? AND SUBMIT_STATUS = ? ORDER BY DOC_DATE, DOC_NO";
hdrPstmt = conn.prepareStatement(hdrSql);
hdrPstmt.setString(1, recType);
hdrPstmt.setString(2, periodCode);
hdrPstmt.setString(3, siteCode);
hdrPstmt.setString(4, "P");
hdrRs = hdrPstmt.executeQuery();
while(hdrRs.next())
{
stateDscr = "";
tranId = hdrRs.getString("TRAN_ID");
tranType = hdrRs.getString("TRAN_TYPE");
ctin = checkNull(hdrRs.getString("TAX_REG_NO"));
posStateCode = checkNull(hdrRs.getString("GST_CODE"));
docNo = checkNull(hdrRs.getString("DOC_NO"));
docDate = hdrRs.getDate("DOC_DATE");
amount = Double.parseDouble(String.format("%.2f",hdrRs.getDouble("AMOUNT")));
reverseCharge = checkNull(hdrRs.getString("REVERSE_CHRG"));
etin = checkNull(hdrRs.getString("ECOM_REG_NO"));
refInvId = checkNull(hdrRs.getString("REF_ID__INV"));
refInvDate = hdrRs.getDate("REF_DATE__INV");
portCode = checkNull(hdrRs.getString("ORDER_NO"));
shipBillNo = checkNull(hdrRs.getString("LR_NO"));
shipBillDate = hdrRs.getDate("LR_DATE");
supplierName = checkNull(hdrRs.getString("CUST_NAME"));
sql = "SELECT DESCR FROM STATE WHERE GST_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, posStateCode);
rs = pstmt.executeQuery();
if(rs.next())
{
stateDscr = checkNull(rs.getString("DESCR"));
}
closeResources(rs, pstmt);
if(docDate!=null)
{
docDateStr = gstDateFormatSdf.format(docDate);
}
if(refInvDate!=null)
{
refInvDtStr = gstDateFormatSdf.format(refInvDate);
}
if(shipBillDate!=null)
{
shipBillDateStr = gstDateFormatSdf.format(shipBillDate);
}
System.out.println("docDateStr["+docDateStr+"]");
sql = "SELECT UDF_STR1, UDF_STR2, UDF_STR3 FROM GENCODES WHERE MOD_NAME='W_GSTR_PURC' AND FLD_NAME='TRAN_TYPE' AND FLD_VALUE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranType);
rs = pstmt.executeQuery();
if(rs.next())
{
udfStr1 = checkNull(rs.getString("UDF_STR1"));
udfStr2 = checkNull(rs.getString("UDF_STR2"));
udfStr3 = checkNull(rs.getString("UDF_STR3"));
}
closeResources(rs, pstmt);
sql = "SELECT SUBSTR(REG_NO,0,2) AS STATE_CD FROM SITEREGNO WHERE SITE_CODE = ? AND REF_CODE ='GSTIN_NO'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
placeOfBusiness = rs.getString("STATE_CD");
}
closeResources(rs, pstmt);
System.out.println("udfStr1["+udfStr1+"] udfStr2["+udfStr2+"] udfStr3["+udfStr3+"]");
if("B2B".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("b2b");
if("R".equalsIgnoreCase(udfStr2))
{
invoiceType = "Regular";
}
else if("SEWP".equalsIgnoreCase(udfStr2))
{
invoiceType = "SEZ supplies with payment";
}
else if("SEWOP".equalsIgnoreCase(udfStr2))
{
invoiceType = "SEZ supplies without payment";
}
else if("DE".equalsIgnoreCase(udfStr2))
{
invoiceType = "Deemed Exp";
}
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CGST_AMT")));
sgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("SGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CGST")));
sgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_SGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
XSSFRow dataRow = dataSheet.createRow(b2bRowNum++);
dataRow.createCell(0).setCellValue(ctin);
dataRow.createCell(1).setCellValue(docNo);
XSSFCell docDateCell = dataRow.createCell(2);
if(docDateStr!=null && docDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(docDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(3).setCellValue(amount);
dataRow.createCell(4).setCellValue(posStateCode+"-"+stateDscr);
dataRow.createCell(5).setCellValue(reverseCharge);
dataRow.createCell(6).setCellValue(invoiceType);
dataRow.createCell(7).setCellValue(gstRate);
dataRow.createCell(8).setCellValue(taxableAmt);
dataRow.createCell(9).setCellValue(igstAmt);
dataRow.createCell(10).setCellValue(cgstAmt);
dataRow.createCell(11).setCellValue(sgstAmt);
dataRow.createCell(12).setCellValue(cessAmt);
dataRow.createCell(13).setCellValue(itcTypeDescr);
dataRow.createCell(14).setCellValue(igstITCAmt);
dataRow.createCell(15).setCellValue(cgstITCAmt);
dataRow.createCell(16).setCellValue(sgstITCAmt);
dataRow.createCell(17).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("B2BUR".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("b2bur");
if(placeOfBusiness.trim().equalsIgnoreCase(posStateCode.trim()))
{
supplyType = "Intra State";
}
else
{
supplyType = "Inter State";
}
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CGST_AMT")));
sgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("SGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CGST")));
sgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_SGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
XSSFRow dataRow = dataSheet.createRow(b2burRowNum++);
dataRow.createCell(0).setCellValue(supplierName);
dataRow.createCell(1).setCellValue(docNo);
XSSFCell docDateCell = dataRow.createCell(2);
if(docDateStr!=null && docDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(docDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(3).setCellValue(amount);
dataRow.createCell(4).setCellValue(posStateCode+"-"+stateDscr);
dataRow.createCell(5).setCellValue(supplyType);
dataRow.createCell(6).setCellValue(gstRate);
dataRow.createCell(7).setCellValue(taxableAmt);
dataRow.createCell(8).setCellValue(igstAmt);
dataRow.createCell(9).setCellValue(cgstAmt);
dataRow.createCell(10).setCellValue(sgstAmt);
dataRow.createCell(11).setCellValue(cessAmt);
dataRow.createCell(12).setCellValue(itcTypeDescr);
dataRow.createCell(13).setCellValue(igstITCAmt);
dataRow.createCell(14).setCellValue(cgstITCAmt);
dataRow.createCell(15).setCellValue(sgstITCAmt);
dataRow.createCell(16).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("IMP_S".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("imps");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
XSSFRow dataRow = dataSheet.createRow(impsRowNum++);
dataRow.createCell(0).setCellValue(docNo);
XSSFCell docDateCell = dataRow.createCell(1);
if(docDateStr!=null && docDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(docDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(2).setCellValue(amount);
dataRow.createCell(3).setCellValue(posStateCode+"-"+stateDscr);
dataRow.createCell(4).setCellValue(gstRate);
dataRow.createCell(5).setCellValue(taxableAmt);
dataRow.createCell(6).setCellValue(igstAmt);
dataRow.createCell(7).setCellValue(cessAmt);
dataRow.createCell(8).setCellValue(itcTypeDescr);
dataRow.createCell(9).setCellValue(igstITCAmt);
dataRow.createCell(10).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("IMP_G".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("impg");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
if(ctin.trim().length() > 0)
{
documentType = "Received from SEZ";
}
else
{
documentType = "Imports";
}
XSSFRow dataRow = dataSheet.createRow(impgRowNum++);
dataRow.createCell(0).setCellValue(portCode);
dataRow.createCell(1).setCellValue(shipBillNo);
XSSFCell docDateCell = dataRow.createCell(2);
if(shipBillDateStr!=null && shipBillDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(shipBillDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(3).setCellValue(amount);
dataRow.createCell(4).setCellValue(documentType);
dataRow.createCell(5).setCellValue(ctin);
dataRow.createCell(6).setCellValue(gstRate);
dataRow.createCell(7).setCellValue(taxableAmt);
dataRow.createCell(8).setCellValue(igstAmt);
dataRow.createCell(9).setCellValue(cessAmt);
dataRow.createCell(10).setCellValue(itcTypeDescr);
dataRow.createCell(11).setCellValue(igstITCAmt);
dataRow.createCell(12).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("CDN".equalsIgnoreCase(udfStr1))
{
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 06, 01);
Date gstStartDate = calendar.getTime();
if(refInvDate!=null)
{
preGST = refInvDate.before(gstStartDate) ? "Y" : "N";
}
else
{
preGST = "";
}
XSSFSheet dataSheet = retDataWorkbook.getSheet("cdnr");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CGST_AMT")));
sgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("SGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CGST")));
sgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_SGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
if(placeOfBusiness.trim().equalsIgnoreCase(posStateCode.trim()))
{
supplyType = "Intra State";
}
else
{
supplyType = "Inter State";
}
XSSFRow dataRow = dataSheet.createRow(cdnrRowNum++);
dataRow.createCell(0).setCellValue(ctin);
dataRow.createCell(1).setCellValue(docNo);
XSSFCell docDateCell = dataRow.createCell(2);
if(docDateStr!=null && docDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(docDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(3).setCellValue(refInvId);
XSSFCell refInvDateCell = dataRow.createCell(4);
if(refInvDtStr!=null && refInvDtStr.trim().length()>0)
{
refInvDateCell.setCellValue(gstDateFormatSdf.parse(refInvDtStr));
refInvDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(5).setCellValue(preGST);
dataRow.createCell(6).setCellValue(udfStr2);
dataRow.createCell(7).setCellValue("07-Others");
dataRow.createCell(8).setCellValue(supplyType);
dataRow.createCell(9).setCellValue(amount);
dataRow.createCell(10).setCellValue(gstRate);
dataRow.createCell(11).setCellValue(taxableAmt);
dataRow.createCell(12).setCellValue(igstAmt);
dataRow.createCell(13).setCellValue(cgstAmt);
dataRow.createCell(14).setCellValue(sgstAmt);
dataRow.createCell(15).setCellValue(cessAmt);
dataRow.createCell(16).setCellValue(itcTypeDescr);
dataRow.createCell(17).setCellValue(igstITCAmt);
dataRow.createCell(18).setCellValue(cgstITCAmt);
dataRow.createCell(19).setCellValue(sgstITCAmt);
dataRow.createCell(20).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("CDNUR".equalsIgnoreCase(udfStr1))
{
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 06, 01);
Date gstStartDate = calendar.getTime();
if(refInvDate!=null)
{
preGST = refInvDate.before(gstStartDate) ? "Y" : "N";
}
else
{
preGST = "";
}
XSSFSheet dataSheet = retDataWorkbook.getSheet("cdnr");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(IGST_AMT) AS IGST_AMT, SUM(CGST_AMT) AS CGST_AMT, SUM(SGST_AMT) AS SGST_AMT, SUM(CESS_AMT) AS CESS_AMT,"
+ " ITC_TYPE,SUM(ITC_IGST) AS ITC_IGST, SUM(ITC_CGST) AS ITC_CGST, SUM(ITC_SGST) AS ITC_SGST, SUM(ITC_CESS) AS ITC_CESS"
+ " FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE, ITC_TYPE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
igstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("IGST_AMT")));
cgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CGST_AMT")));
sgstAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("SGST_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
itcType = checkNull(detRs.getString("ITC_TYPE"));
igstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_IGST")));
cgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CGST")));
sgstITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_SGST")));
cessITCAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("ITC_CESS")));
if(itcTypeHMap.containsKey(itcType.toUpperCase()))
{
itcTypeDescr = itcTypeHMap.get(itcType.toUpperCase());
}
else
{
itcTypeDescr = "";
}
if(placeOfBusiness.trim().equalsIgnoreCase(posStateCode.trim()))
{
supplyType = "Intra State";
}
else
{
supplyType = "Inter State";
}
XSSFRow dataRow = dataSheet.createRow(cdnrRowNum++);
dataRow.createCell(0).setCellValue(docNo);
XSSFCell docDateCell = dataRow.createCell(1);
if(docDateStr!=null && docDateStr.trim().length()>0)
{
docDateCell.setCellValue(gstDateFormatSdf.parse(docDateStr));
docDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(2).setCellValue(refInvId);
XSSFCell refInvDateCell = dataRow.createCell(3);
if(refInvDtStr!=null && refInvDtStr.trim().length()>0)
{
refInvDateCell.setCellValue(gstDateFormatSdf.parse(refInvDtStr));
refInvDateCell.setCellStyle(dateCellStyle);
}
dataRow.createCell(4).setCellValue(preGST);
dataRow.createCell(5).setCellValue(udfStr2);
dataRow.createCell(6).setCellValue("07-Others");
dataRow.createCell(7).setCellValue(supplyType);
dataRow.createCell(8).setCellValue(amount);
dataRow.createCell(9).setCellValue(gstRate);
dataRow.createCell(10).setCellValue(taxableAmt);
dataRow.createCell(11).setCellValue(igstAmt);
dataRow.createCell(12).setCellValue(cgstAmt);
dataRow.createCell(13).setCellValue(sgstAmt);
dataRow.createCell(14).setCellValue(cessAmt);
dataRow.createCell(15).setCellValue(itcTypeDescr);
dataRow.createCell(16).setCellValue(igstITCAmt);
dataRow.createCell(17).setCellValue(cgstITCAmt);
dataRow.createCell(18).setCellValue(sgstITCAmt);
dataRow.createCell(19).setCellValue(cessITCAmt);
}
closeResources(detRs, detPstmt);
}
if("TXPI".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("at");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(CESS_AMT) AS CESS_AMT FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
XSSFRow dataRow = dataSheet.createRow(atRowNum++);
dataRow.createCell(0).setCellValue(posStateCode+"-"+stateDscr);
dataRow.createCell(1).setCellValue(gstRate);
dataRow.createCell(2).setCellValue(taxableAmt);
dataRow.createCell(3).setCellValue(cessAmt);
}
closeResources(detRs, detPstmt);
}
if("TXPD".equalsIgnoreCase(udfStr1))
{
XSSFSheet dataSheet = retDataWorkbook.getSheet("atadj");
detSql = " SELECT GST_RATE, SUM(TAXABLE_AMT) AS TAXABLE_AMT, SUM(CESS_AMT) AS CESS_AMT FROM GST_DATA_DET WHERE TRAN_ID = ? GROUP BY GST_RATE";
detPstmt = conn.prepareStatement(detSql);
detPstmt.setString(1, tranId);
detRs = detPstmt.executeQuery();
while(detRs.next())
{
gstRate = Double.parseDouble(String.format("%.2f",detRs.getDouble("GST_RATE")));
taxableAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("TAXABLE_AMT")));
cessAmt = Double.parseDouble(String.format("%.2f",detRs.getDouble("CESS_AMT")));
XSSFRow dataRow = dataSheet.createRow(atAdjRowNum++);
dataRow.createCell(0).setCellValue(posStateCode+"-"+stateDscr);
dataRow.createCell(1).setCellValue(gstRate);
dataRow.createCell(2).setCellValue(taxableAmt);
dataRow.createCell(3).setCellValue(cessAmt);
}
closeResources(detRs, detPstmt);
}
}
closeResources(hdrRs, hdrPstmt);
XSSFSheet nilDataSheet = retDataWorkbook.getSheet("exemp");
sql = " SELECT TRAN_TYPE,SUM(AMOUNT) AS AMOUNT FROM GST_DATA_HDR "
+ " WHERE REC_TYPE = '2' AND TRAN_TYPE in (?,?,?,?) AND SITE_CODE = ? AND PRD_CODE = ?"
+ " GROUP BY TRAN_TYPE";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "18");
pstmt.setString(2, "19");
pstmt.setString(3, "20");
pstmt.setString(4, "21");
pstmt.setString(5, siteCode);
pstmt.setString(6, periodCode);
rs = pstmt.executeQuery();
while(rs.next())
{
if("18".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
compDlrAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("19".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
exemtAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("20".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
nonGSTAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("21".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
nilAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
}
closeResources(rs, pstmt);
XSSFRow nilInterDataRow = nilDataSheet.getRow(4);
nilInterDataRow.createCell(1).setCellValue(compDlrAmount);
nilInterDataRow.createCell(2).setCellValue(nilAmount);
nilInterDataRow.createCell(3).setCellValue(exemtAmount);
nilInterDataRow.createCell(4).setCellValue(nonGSTAmount);
compDlrAmount = 0.0; nilAmount = 0.0; exemtAmount = 0.0; nonGSTAmount = 0.0;
sql = " SELECT TRAN_TYPE,SUM(AMOUNT) AS AMOUNT FROM GST_DATA_HDR "
+ " WHERE REC_TYPE = '2' AND TRAN_TYPE in (?,?,?,?) AND SITE_CODE = ? AND PRD_CODE = ?"
+ " GROUP BY TRAN_TYPE";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "22");
pstmt.setString(2, "23");
pstmt.setString(3, "24");
pstmt.setString(4, "25");
pstmt.setString(5, siteCode);
pstmt.setString(6, periodCode);
rs = pstmt.executeQuery();
while(rs.next())
{
if("22".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
compDlrAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("23".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
exemtAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("24".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
nonGSTAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
if("25".equalsIgnoreCase(rs.getString("TRAN_TYPE")))
{
nilAmount = Double.parseDouble(String.format("%.2f",rs.getDouble("AMOUNT")));
}
}
closeResources(rs, pstmt);
XSSFRow nilIntraDataRow = nilDataSheet.getRow(5);
nilIntraDataRow.createCell(1).setCellValue(compDlrAmount);
nilIntraDataRow.createCell(2).setCellValue(nilAmount);
nilIntraDataRow.createCell(3).setCellValue(exemtAmount);
nilIntraDataRow.createCell(4).setCellValue(nonGSTAmount);
XSSFSheet hsnDataSheet = retDataWorkbook.getSheet("hsnsum");
sql = " SELECT GS_CODE, UNIT, DESCR, SUM(TOT_QTY) AS TOT_QTY, SUM(TOT_TAXVAL) AS TOT_TAXVAL, SUM(TOT_IAMT) AS TOT_IAMT, SUM(TOT_CAMT) AS TOT_CAMT, SUM(TOT_SAMT) AS TOT_SAMT, SUM(TOT_CSAMT) AS TOT_CSAMT FROM"
+ " (SELECT GDD.GS_CODE, GDD.UNIT, U.DESCR, SUM(GDD.QUANTITY) AS TOT_QTY, SUM(GDD.TAXABLE_AMT) AS TOT_TAXVAL,"
+ " SUM(GDD.IGST_AMT) AS TOT_IAMT, SUM(CGST_AMT) AS TOT_CAMT, SUM(SGST_AMT) AS TOT_SAMT, SUM(CESS_AMT) AS TOT_CSAMT"
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD, UOM U"
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDD.GS_CODE IS NOT NULL AND GDH.REC_TYPE='2' AND GDD.UNIT=U.UNIT"
+ " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.TRAN_TYPE NOT IN ('10','11','18','19','20','21','22','23','24','25')"
+ " GROUP BY GDD.GS_CODE, GDD.UNIT, U.DESCR"
+ " UNION ALL"
+ " SELECT GDD.GS_CODE, GDD.UNIT, U.DESCR, -1*SUM(GDD.QUANTITY) AS TOT_QTY, -1*SUM(GDD.TAXABLE_AMT) AS TOT_TAXVAL,"
+ " -1*SUM(GDD.IGST_AMT) AS TOT_IAMT, -1*SUM(CGST_AMT) AS TOT_CAMT, -1*SUM(SGST_AMT) AS TOT_SAMT, -1*SUM(CESS_AMT) AS TOT_CSAMT"
+ " FROM GST_DATA_HDR GDH, GST_DATA_DET GDD, UOM U"
+ " WHERE GDH.TRAN_ID = GDD.TRAN_ID AND GDD.GS_CODE IS NOT NULL AND GDH.REC_TYPE='2' AND GDD.UNIT=U.UNIT"
+ " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.TRAN_TYPE IN ('10','11')"
+ " GROUP BY GDD.GS_CODE, GDD.UNIT, U.DESCR) GROUP BY GS_CODE, UNIT, DESCR";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, periodCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, periodCode);
rs = pstmt.executeQuery();
while (rs.next())
{
XSSFRow dataRow = hsnDataSheet.createRow(hsnRowNum++);
dataRow.createCell(0).setCellValue(checkNull(rs.getString("GS_CODE")));
String unitDescr = checkNull(rs.getString("UNIT")) + "-" + checkNull(rs.getString("DESCR"));
dataRow.createCell(2).setCellValue(unitDescr);
dataRow.createCell(3).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_QTY"))));
double totalValue = rs.getDouble("TOT_TAXVAL") + rs.getDouble("TOT_IAMT") + rs.getDouble("TOT_CAMT") + rs.getDouble("TOT_SAMT") + rs.getDouble("TOT_CSAMT");
dataRow.createCell(4).setCellValue(Double.parseDouble(String.format("%.2f",totalValue)));
dataRow.createCell(5).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_TAXVAL"))));
dataRow.createCell(6).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_IAMT"))));
dataRow.createCell(7).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_CAMT"))));
dataRow.createCell(8).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_SAMT"))));
dataRow.createCell(9).setCellValue(Double.parseDouble(String.format("%.2f",rs.getDouble("TOT_CSAMT"))));
}
closeResources(rs, pstmt);
}
return retDataWorkbook;
......
......@@ -83,19 +83,19 @@ public class GSTDataSubmitWizServlet extends HttpServlet
}
else if("GET_OFFLINE_FILE".equalsIgnoreCase(action))
{
String fileName = "";
Workbook retDataWorkbook = null;
String prdCode = request.getParameter("prd_code");
String recType = request.getParameter("rec_type");
String siteCode = request.getParameter("site_code");
String random = request.getParameter("random");
System.out.println("siteCode ["+siteCode+"]");
System.out.println("prdCode ["+prdCode+"]");
System.out.println("recType ["+recType+"]");
System.out.println("random ["+random+"]");
fileName = "GSTR"+recType+"_"+prdCode+"_Offline_Data.xlsx";
GSTDataSubmitWizEJB gstDataSubmitWizEJB = new GSTDataSubmitWizEJB();
......@@ -106,6 +106,7 @@ public class GSTDataSubmitWizServlet extends HttpServlet
{
boolean isWorkbook = retObj instanceof Workbook;
System.out.println("isWorkbook : "+ isWorkbook);
request.getServletContext().setAttribute("GSTR_OFFLINE_FILE:"+siteCode+":"+prdCode+":"+recType+":"+random,"DONE");
if(retObj instanceof String)
{
......@@ -159,6 +160,37 @@ public class GSTDataSubmitWizServlet extends HttpServlet
}
}
}
else if("CHECK_HIDE_IMAGE".equalsIgnoreCase(action))
{
String status = "";
String key = request.getParameter("key");
do
{
status = (String) (request.getServletContext().getAttribute(key) == null ? "" : request.getServletContext().getAttribute(key));
}
while(!"DONE".equalsIgnoreCase(status));
request.getServletContext().removeAttribute(key);
response.setContentType("text/plain");
if(CommonConstants.CONTENT_ENCODING != null && CommonConstants.CONTENT_ENCODING.equalsIgnoreCase("gzip"))
{
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gzOutStream = new GZIPOutputStream(response.getOutputStream());
gzOutStream.write(status.getBytes());
gzOutStream.flush();
gzOutStream.close();
}
else
{
response.setHeader("Content-Encoding", CommonConstants.CONTENT_ENCODING);
OutputStream outStream = response.getOutputStream();
outStream.write(status.getBytes());
outStream.flush();
outStream.close();
}
}
else
{
HashMap<String,String> requestParamMap = new HashMap<String,String>();
......
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