Commit 31c8d5ba authored by kdabholkar's avatar kdabholkar

Adding new code for custom mismatch sheet .

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189030 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5f7d76c4
......@@ -14,6 +14,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -5129,10 +5130,22 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
XSSFSheet nilDataSheet = retDataWorkbook.getSheet("exemp");
sql = " SELECT TRAN_TYPE,SUM(AMOUNT) AS AMOUNT FROM GST_DATA_HDR "
/***Updated By kaustubh on 19 july 2018 change in tax calculation query start *****/
/*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";
+ " GROUP BY TRAN_TYPE";*/
sql = "SELECT GDH.tran_type,SUM(GDD.TAXABLE_AMT) AS AMOUNT FROM GST_DATA_HDR GDH, GST_DATA_DET GDD " +
" WHERE GDH.TRAN_ID = GDD.TRAN_ID " +
" AND GDH.REC_TYPE ='2' " +
" AND GDH.TRAN_TYPE in (?,?,?,?) " +
" AND GDH.SITE_CODE = ? " +
" AND GDH.PRD_CODE = ? " +
" GROUP BY GDH.tran_type ";
/***Updated By kaustubh on 19 july 2018 change in tax calculation query end *****/
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "18");
pstmt.setString(2, "19");
......@@ -5173,10 +5186,23 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
compDlrAmount = 0.0; nilAmount = 0.0; exemtAmount = 0.0; nonGSTAmount = 0.0;
sql = " SELECT TRAN_TYPE,SUM(AMOUNT) AS AMOUNT FROM GST_DATA_HDR "
/***Updated By kaustubh on 19 july 2018 change in tax calculation query start *****/
/* 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";
+ " GROUP BY TRAN_TYPE";*/
sql = "SELECT GDH.tran_type,SUM(GDD.TAXABLE_AMT) AS AMOUNT FROM GST_DATA_HDR GDH, GST_DATA_DET GDD " +
" WHERE GDH.TRAN_ID = GDD.TRAN_ID " +
" AND GDH.REC_TYPE ='2' " +
" AND GDH.TRAN_TYPE in (?,?,?,?) " +
" AND GDH.SITE_CODE = ? " +
" AND GDH.PRD_CODE = ? " +
" GROUP BY GDH.tran_type ";
/***Updated By kaustubh on 19 july 2018 change in tax calculation query end *****/
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "22");
pstmt.setString(2, "23");
......@@ -5222,7 +5248,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
+ " 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')"
// + " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.TRAN_TYPE NOT IN ('10','11','18','19','20','21','22','23','24','25')"
+ " AND GDH.SITE_CODE = ? AND GDH.PRD_CODE = ? AND GDH.TRAN_TYPE NOT IN ('10','11')"
+ " 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,"
......@@ -6253,7 +6280,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
String tranId = "", ctin = "", posStateCode = "", docNo = "", docDateStr = "",chgDateStr="",errorCode = "", dataErrMsg = "", refInvId = "",
refInvDtStr = "", preGST = "", portCode = "", gstDateFormat = "", customerName = "", regUreg = "UNREGISTERED",
siteGSTStCode = "", isRCM = "", tranTypeStr = "", interIntraExp = "", suppGSTStCode = "", crdrType = "", refId="",hsnNo="",
transType = "",gstCode ="",lineNo ="";
transType = "",gstCode ="",lineNo ="", transType1 ="";
boolean noDataFound = false;
double amount =0.0, gstRate = 0.0, taxableAmt = 0.0, cessAmt = 0.0;
......@@ -6828,6 +6855,31 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
** By Kaustubh on 12 july 2018 start **/
hdrSql = "select d.GS_CODE,h.ref_id, d.LINE_NO,h.CHG_DATE,h.CUST_NAME,h.TAX_REG_NO,h.GST_CODE,s.descr,d.TAXABLE_AMT,d.GST_RATE, " +
"case when (h.tran_type in ('01','02','03','04','05') and h.rec_type='2') then 'B2B' " +
" when (h.tran_type in ('06') and h.rec_type='2') then 'B2BUR' " +
" when (h.tran_type in ('07') and h.rec_type='2') then 'IMP_S' " +
" when (h.tran_type in ('08','09') and h.rec_type='2') then 'IMP_G' " +
" when (h.tran_type in ('10','11') and h.rec_type='2') then 'Debit Note' " +
" when (h.tran_type in ('12','13') and h.rec_type='2') then 'Credit Note' " +
" when (h.tran_type in ('14','15') and h.rec_type='2') then 'TXPI' " +
" when (h.tran_type in ('16','17') and h.rec_type='2') then 'TXPD' " +
" when (h.tran_type in ('16','17') and h.rec_type='2') then 'TXPD' " +
" when (h.tran_type between'18' and '25' and h.rec_type='2') then 'NIL_SUPPLIES' " +
" when (h.tran_type between'26' and '32' and h.rec_type='2') then 'ITC_RVSL' " +
" when (h.tran_type in ('01','02','03') and h.rec_type='1') then 'B2B' " +
" when (h.tran_type in ('04','05') and h.rec_type='1') then 'B2CL' " +
" when (h.tran_type in ('06','07','08','09','10') and h.rec_type='1') then 'EXP' " +
" when (h.tran_type in ('11','12','13','14') and h.rec_type='1') then 'B2CS' " +
" when (h.tran_type between'15' and '26' and h.rec_type='1') then 'NIL_SUPPLIES' " +
" when (h.tran_type in ('27','28') and h.rec_type='1') then 'EXPA' " +
" when (h.tran_type in ('29','31','33','35') and h.rec_type='1') then 'Credit Note' " +
" when (h.tran_type in ('30','32','34','36') and h.rec_type='1') then 'Debit Note' " +
" when (h.tran_type in ('37','38','39','40') and h.rec_type='1') then 'B2CSA' " +
" when (h.tran_type in ('41','42') and h.rec_type='1') then 'AT' " +
" when (h.tran_type in ('43','44') and h.rec_type='1') then 'TXP' " +
" when (h.tran_type in ('45','46') and h.rec_type='1') then 'ATA' " +
" when (h.tran_type in ('47','48') and h.rec_type='1') then 'TXPA' " +
" else ' - ' end as tran_type, " +
"d.IGST_AMT,d.CGST_AMT ,d.SGST_AMT,d.CESS_AMT,h.AMOUNT," +
" case when h.rec_type ='1' then 'Sales' else 'Purchase' end as trans_type" +
" from gst_data_hdr h, gst_data_det d, state s " +
......@@ -6835,6 +6887,8 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
"and s.gst_code =h.gst_code "+
"and h.PRD_CODE = ? " +
"and h.SITE_CODE = ? and SUBMIT_STATUS = ?";
hdrPstmt = conn.prepareStatement(hdrSql);
hdrPstmt.setString(1, periodCode);
......@@ -6863,6 +6917,7 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
cessAmt = Double.parseDouble(String.format("%.2f",hdrRs.getDouble("CESS_AMT")));
amount = Double.parseDouble(String.format("%.2f",hdrRs.getDouble("AMOUNT")));
transType =hdrRs.getString("trans_type");
transType1 =hdrRs.getString("tran_type");
double totTaxAmt = igstAmt + cgstAmt + sgstAmt + cessAmt;
totTaxAmt = Double.parseDouble(String.format("%.2f",totTaxAmt));
......@@ -6887,11 +6942,12 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
dataRow.createCell(4).setCellValue(customerName);
dataRow.createCell(5).setCellValue(transType);
dataRow.createCell(6).setCellValue(transType1);
// dataRow.createCell(4).setCellValue(interIntraExp);
//dataRow.createCell(5).setCellValue(isRCM);
// dataRow.createCell(6).setCellValue(tranTypeStr);
dataRow.createCell(6).setCellValue(ctin);
dataRow.createCell(7).setCellValue(posStateCode+"-"+gstCode);
dataRow.createCell(7).setCellValue(ctin);
dataRow.createCell(8).setCellValue(posStateCode+"-"+gstCode);
/*dataRow.createCell(9).setCellValue(docNo);
......@@ -6902,14 +6958,14 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
docDateCell.setCellStyle(dateCellStyle);
}*/
dataRow.createCell(8).setCellValue(amount);
dataRow.createCell(9).setCellValue(taxableAmt);
dataRow.createCell(10).setCellValue(gstRate);
dataRow.createCell(11).setCellValue(igstAmt);
dataRow.createCell(12).setCellValue(cgstAmt);
dataRow.createCell(13).setCellValue(sgstAmt);
dataRow.createCell(14).setCellValue(cessAmt);
dataRow.createCell(15).setCellValue(totTaxAmt);
dataRow.createCell(9).setCellValue(amount);
dataRow.createCell(10).setCellValue(taxableAmt);
dataRow.createCell(11).setCellValue(gstRate);
dataRow.createCell(12).setCellValue(igstAmt);
dataRow.createCell(13).setCellValue(cgstAmt);
dataRow.createCell(14).setCellValue(sgstAmt);
dataRow.createCell(15).setCellValue(cessAmt);
dataRow.createCell(16).setCellValue(totTaxAmt);
// dataRow.createCell(19).setCellValue(portCode);
//closeResources(detRs, detPstmt);
......@@ -6977,6 +7033,189 @@ public class GSTDataSubmitWizEJB extends ValidatorEJB implements GSTDataSubmitWi
}
}
/***Added new mismatch custom data sheet queries By Kaustubh on 2nd August 2018 start *****/
public Object generateMismatchOfflineFile(String periodCode, String siteCode) throws ITMException
{
System.out.println("Inside mismatch file ejb");
XSSFWorkbook retDataWorkbook = null;
String gstrWorkBookPath = "";
String sep = File.separator;
String tranId = "",tranCode ="", gstDateFormat = "",toDateStr="",fromDateStr="",tranDateStr="",type="",recType="",errorCode="",dataErrMsg="";
Date tranDate = null;
int outWrdSuppdataRow = 2;
Timestamp fromDate = null, toDate = null ;
boolean noDataFound =false;
Connection conn = null;
String sql = "", hdrSql = "", detSql = "";
PreparedStatement pstmt = null, hdrPstmt = null, detPstmt = null;
ResultSet rs = null, hdrRs = null, detRs = null;
FinCommon finCommon = new FinCommon();
try
{
conn = getConnection();
sql = "SELECT COUNT(1) AS CNT FROM GST_DATA_HDR WHERE SUBMIT_STATUS = 'P' AND PRD_CODE = ? AND SITE_CODE = ? AND REC_TYPE IN ('1','2')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, periodCode);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getInt("CNT") == 0)
{
noDataFound = true;
errorCode = "VTNOSYDATA";
}
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(noDataFound)
{
sql = "SELECT MSG_DESCR FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if(rs.next())
{
dataErrMsg = rs.getString("MSG_DESCR");
}
closeResources(rs, pstmt);
return "<root><message><![CDATA[Message : "+dataErrMsg+"]]></message></root>";
}
else
{
gstrWorkBookPath = CommonConstants.JBOSSHOME + sep + "DOWNLOAD" + sep + "template" + sep + "GSTR_Mismatch_Format.xlsx";
File gstrExcleFile = new File(gstrWorkBookPath);
if(gstrExcleFile.exists())
{
retDataWorkbook = new XSSFWorkbook(new FileInputStream(gstrExcleFile));
}
CellStyle dateCellStyle = retDataWorkbook.createCellStyle();
CreationHelper createHelper = retDataWorkbook.getCreationHelper();
dateCellStyle.setDataFormat( createHelper.createDataFormat().getFormat(gstDateFormat));
gstDateFormat = finCommon.getFinparams("999999", "GST_EXCL_DATE_FORMAT", conn);
SimpleDateFormat gstDateFormatSdf = new SimpleDateFormat(gstDateFormat);
hdrSql = "select REF_ID,CHG_DATE,REF_SER, " +
"case when REC_TYPE= '1' then 'Sales' else 'Purchase' end as rec_type " +
"from GST_DATA_HDR where TRAN_TYPE = ? and SITE_CODE = ? and PRD_CODE = ? " ;
hdrPstmt = conn.prepareStatement(hdrSql);
hdrPstmt.setString(1, "50");
hdrPstmt.setString(2, siteCode);
hdrPstmt.setString(3, periodCode);
hdrRs = hdrPstmt.executeQuery();
XSSFSheet outWrdSuppdataSheet = retDataWorkbook.getSheet("mismatch_Sales_purchase_Data");
while (hdrRs.next())
{
tranId = hdrRs.getString("REF_ID");
tranDate = hdrRs.getDate("CHG_DATE");
type = hdrRs.getString("REF_SER");
recType = hdrRs.getString("rec_type");
if(tranDate != null)
{
tranDateStr = gstDateFormatSdf.format(tranDate);
}
XSSFRow dataRow = outWrdSuppdataSheet.createRow(outWrdSuppdataRow++);
dataRow.createCell(0).setCellValue(tranId);
if(tranDateStr !=null && tranDateStr.trim().length() > 0)
{
dataRow.createCell(1).setCellValue(tranDateStr);
}
dataRow.createCell(2).setCellValue(type);
dataRow.createCell(3).setCellValue(recType);
}
closeResources(hdrRs, hdrPstmt);
return retDataWorkbook;
}
}
catch(Exception e)
{
System.out.println("GSTDataSubmitWizEJB.generateMismatchOfflineFile()["+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(hdrPstmt!=null)
{
hdrPstmt.close();
hdrPstmt = null;
}
if(hdrRs!=null)
{
hdrRs.close();
hdrRs=null;
}
if(detPstmt!=null)
{
detPstmt.close();
detPstmt = null;
}
if(detRs!=null)
{
detRs.close();
detRs=null;
}
if(conn!=null && !conn.isClosed())
{
conn.close();
conn=null;
}
}
catch(SQLException se)
{
System.out.println("GSTDataSubmitWizEJB.generateOfflineFile()["+se.getMessage()+"]");
se.printStackTrace();
}
}
}
/***Added new mismatch custom data sheet queries By Kaustubh on 2ND August 2018 End *****/
private String checkNull(String input)
{
if (input==null)
......
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