Commit ce2253d7 authored by kdabholkar's avatar kdabholkar

commited to add new changes of GSTR1 and GSTR2 data queries.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106652 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ffc708f0
......@@ -55,7 +55,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
GST_PUREXE_TAXCLASS="",GST_PUREXE_TAXENV="",GST_PURNIL_TAXCLASS="",GST_PURNIL_TAXENV="",GST_PURNON_TAXCLASS="",
GST_PURNON_TAXENV="",GST_IMPSER_TAXCLASS="",GST_IMPSER_TAXENV="",GST_IMPGD_TAXCLASS="",GST_IMPGD_TAXENV="",
GST_IMPGDSEZ_TAXCLASS="",GST_IMPGDSEZ_TAXENV="",GST_PURSEZWP_TAXENV="",GST_PURSEZWP_TAXCLASS="",GST_PURSEZWOP_TAXENV="",GST_PURSEZWOP_TAXCLASS="",
GST_PURDE_TAXENV="",GST_PURDE_TAXCLASS="",GST_RCM_TAXCLASS="",GST_RCM_TAXENV="";
GST_PURDE_TAXENV="",GST_PURDE_TAXCLASS="",GST_RCM_TAXCLASS="",GST_RCM_TAXENV="",SALES_DATA_MISC="";
Timestamp fromDate = null, toDate = null , fromdateOracle = null, todateOracle=null;
......@@ -148,7 +148,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
DatabaseMetaData dbmd = connGST.getMetaData();
System.out.println("________________________________________");
System.out.println(" Driver Information 11 aug ");
System.out.println(" Driver Information ");
System.out.println("________________________________________");
System.out.println("DriverName["+dbmd.getDriverName() + "]");
System.out.println("DriverURI["+dbmd.getURL() + "]");
......@@ -267,6 +267,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
GST_DE_TAXENV = distCommon.getDisparams("999999", "GST_DE_TAXENV", connGST);
GST_NIL_TAXENV = distCommon.getDisparams("999999", "GST_NIL_TAXENV", connGST);
GST_EXE_TAXENV = distCommon.getDisparams("999999", "GST_EXE_TAXENV", connGST);
SALES_DATA_MISC = distCommon.getDisparams("999999", "SALES_DATA_MISC", connGST);
//modified by kaustubh on 18-07-2017 to resolve missing expression issue end
......@@ -332,6 +333,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
GST_EXE_TAXENV="'"+GST_EXE_TAXENV+"'";
taxClassAllStr = GST_EXPWP_TAXCLASS +","+ GST_EXPWOP_TAXCLASS +","+ GST_SEZWP_TAXCLASS +","+ GST_SEZWOP_TAXCLASS +","+ GST_DE_TAXCLASS +","+
GST_NIL_TAXCLASS +","+ GST_EXE_TAXCLASS;
......@@ -349,10 +351,302 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
//modified by kaustubh on 18-07-2017 to resolve missing expression issue end
System.out.println("After ["+taxClassAllStr+"] TaxEnvAllStr ["+taxEnvAllStr+"]");
/******** 3(A) FOR fortune Client sales invoice through misc debit note and invoice *****************/
if ("Y".equalsIgnoreCase(SALES_DATA_MISC))
{
hdrSql = " select '' as TRAN_ID, "
/* +" to_date(i.GP_DATE) as TRAN_DATE, "*/
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPRTNG_SITE') AS SITE_CODE ,"
+" i.tran_date as PRD_CODE ,"
+" '1' as REC_TYPE, "
+" ' ' as GST_TYPE,"
+" ' ' as TRAN_TYPE,"
+" i.cust_code__dlv as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" i.drcr_flag as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
// +"case when i.conf_date is null then i.tran_date else i.conf_date end as DOC_DATE,"
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
// +" null as LR_DATE,"
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
// +"case when inv.gp_date is null then inv.tran_date else inv.gp_date end as REF_DATE__INV, "
+" '' as REF_DATE_INV,"
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
// +" null as ORDER_DATE, "
+" s.site_code as REMARKS, "
+" i.tran_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
// +" null SUBMIT_DATE, "
+" '' ADD_USER, "
// +" sysdate as ADD_DATE, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
// +" sysdate CHG_DATE, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'MDRCRD' as ref_ser "
+" from misc_drcr_rcp i,customer c, site s, state"
// +" from misc_drcr_rcp i,customer c, site s, state, invoice inv "
+" where c.cust_code = i.cust_code__dlv "
+" and s.site_code = i.site_code "
+" and state.state_code = c.STATE_CODE "
// +" and inv.invoice_id = i.invoice_id "
+" and i.drcr_flag ='D'"
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRD' and ti.tran_id = i.tran_id ";
if(GST_DE_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class in ("+taxClassAllStr+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and c.tax_reg_2 <> 'UNREGISTER' "
// +" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'MDRCRD' and ref_id = i.tran_id ) = 0 ";
/**
* Detail FOR fortune Client sales invoice through misc debit note and invoice 3(A) FOR ) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,"
+" accounts.sac_no as GS_CODE,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
// dtlSql = dtlSql +"fn_get_hsn_no(i.site_code,it.item_code) AS GS_CODE,"
// dtlSql = dtlSql +"fn_get_hsn_sac(i.site_code,it.item_code,it.acct_code) AS GS_CODE,"
dtlSql = dtlSql +" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('G' AS CHAR(1)), CAST('A' AS CHAR(1))) AS SGST_AMT,";
}
else
{
// dtlSql = dtlSql + "fn_get_hsn_no(i.site_code,it.item_code) as GS_CODE,"
//dtlSql = dtlSql +"fn_get_hsn_sac(i.site_code,it.item_code,it.acct_code) AS GS_CODE,"
dtlSql = dtlSql + "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
//+" accounts.sac_no as GS_DESCR,"
+" accounts.sac_no as GS_DESCR, "
+" 'NA' as UNIT,"
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('MDRCRD' AS VARCHAR(6)),i.tran_id, it.line_no, CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('MDRCRD',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT," ;
}
dtlSql = dtlSql
+" '' as REMARKS ,"
+" fn_get_gst_rate('MDRCRD',i.tran_id, it.line_no) as gst_rate "
/*+" from drcr_rcp i,drcr_rdet it,taxtran tx, siteitem si, tax t, item,uom u "*/
// +" from misc_drcr_rcp i,misc_drcr_rdet it, item "
+" from misc_drcr_rcp i,misc_drcr_rdet it, accounts "
+" where i.tran_id = it.tran_id "
// +" and item.item_code = it.item_code "
+" and accounts.acct_code=it.acct_code "
+"and (select count(1) from taxtran ti, tax tx where tx.tax_code = ti.tax_code "
+"and ti.tran_code = 'MDRCRD' "
+"and ti.tran_id = i.tran_id "
+"and tx.tax_type in ('G','H','I','J')" ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
//dtlSql = dtlSql +" and cast(tx.line_no as integer) = it.line_no ";
dtlSql =dtlSql +" and cast(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
//dtlSql = dtlSql +" and to_number(trim(tx.line_no)) = it.line_no ";
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"3(A) FOR");
}
else
{
hdrSql = " select '' as TRAN_ID, "
/* +" to_date(i.GP_DATE) as TRAN_DATE, "*/
+" '' as TRAN_ID__REF, "
// +" case when s.SITE_CODE__EXC is null then s.site_code else s.SITE_CODE__EXC end as SITE_CODE, "
+" ddf_get_siteregno(s.site_code,'OPRTNG_SITE') AS SITE_CODE ,"
+ "case when i.GP_DATE is null then i.tran_date else i.GP_DATE end as PRD_CODE,"
+" '1' as REC_TYPE, " // GSTR1,GSTR2,etc.
+" 'I' as GST_TYPE,"
+" '01' as TRAN_TYPE," // b2b,b2c
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, " // 2 digit code
+" '' as SUBMISSION_TYPE," // M-Modify, D-Delete, A-Accept, R-Reject
+" '' as DOC_CHECKSUM,"
+" 'R' as DOC_TYPE, " // R- Regular B2B Invoices, DE – Deemed Exports, SEWP – SEZ Exports with payment,SEWOP – SEZ exports without payment
+" case when i.GP_NO is null then i.invoice_id else i.GP_NO end as DOC_NO, "
+"case when i.gp_date is null then i.tran_date else i.gp_date end as DOC_DATE,"
+" i.net_amt as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
// +" null as LR_DATE,"
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
// +" null REF_DATE__INV, "
+" 'N' as PROV_ASSMNT, " // not required
+" '' as ORDER_NO," //not required
// +" null as ORDER_DATE, "// not required
//+" i.invoice_id as REMARKS, "
+" s.site_code as REMARKS, "
+" i.invoice_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
// +" null SUBMIT_DATE, "
+" '' ADD_USER, "
// +" sysdate as ADD_DATE, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
// +" sysdate CHG_DATE, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'S-INV' as ref_ser "
+" from invoice i,customer c, site s, state state"
+" where c.cust_code = i.cust_code "
+" and s.site_code = i.site_code "
+" and state.state_code = c.state_code "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_code = 'S-INV'"
+" and ti.tran_id = i.invoice_id and tm.tax_type in ('G','H','I','J') ";
if(taxClassAllStr.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class not in ("+taxClassAllStr+") ";
}
if(taxEnvAllStr.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_env not in ("+taxEnvAllStr+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'S-INV' and ref_id = i.invoice_id ) = 0 ";
/**
* Detail Sales Invoice Detail 3(A) S-INV*
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, " //-- M – Modification, A – Accept D – Delete
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,"; // -- G – Goods, S – Serice
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_hsn_no(i.site_code,it.item_code) AS GS_CODE,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('G' AS CHAR(1)), CAST('A' AS CHAR(1))) AS SGST_AMT,";
}
else
{
dtlSql = dtlSql + "fn_get_hsn_no(i.site_code,it.item_code) as GS_CODE,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" item.descr as GS_DESCR,"
+"item.UNIT as UNIT,"
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;// -- E/OE (Ecom/Other than Ecom)
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('S-INV' AS VARCHAR(6)),i.invoice_id, it.line_no, CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('S-INV',i.invoice_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,"
+"fn_get_gst_rate('S-INV',i.invoice_id, it.line_no) as gst_rate "
+" from invoice i,invoice_trace it, item"
+" where i.invoice_id = it.invoice_id "
+" and item.item_code = it.item_code "
+"and (select count(1) from taxtran ti, tax tx where tx.tax_code = ti.tax_code "
+"and ti.tran_code = 'S-INV' "
+"and ti.tran_id = i.invoice_id "
+"and tx.tax_type in ('G','H','I','J')" ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql =dtlSql +" and cast(ti.line_no as integer) = it.line_no ) > 0";
//dtlSql = dtlSql +" and cast(tx.line_no as integer) = it.line_no ";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
//dtlSql = dtlSql +" and to_number(trim(tx.line_no)) = it.line_no ";
}
dtlSql = dtlSql
+" and i.invoice_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"3(A) S-INV");
}
/******* 4A started ********/
/**
* 4(A) S-INV Header Sales Invoice *
......@@ -7720,7 +8014,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
dtlSql = dtlSql +" 'A' as STATUS," // -- M – Modification, A – Accept D – Delete
+" 0 as SR_NO__OLD,"
// +" 'G' as LINE_TYPE," ;// -- G – Goods, S – Serice
+"when case it.item_code is null then 'S' else 'G' end as LINE_TYPE, ";
+" case when it.item_code is null then 'S' else 'G' end as LINE_TYPE, ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
......@@ -10495,7 +10789,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" '' as REMARKS ,"
+" 'ig' as ITC_TYPE , "
+" fn_get_gst_rate('CRNPAY',i.invoice_id, it.line_no) as gst_rate "
+" fn_get_gst_rate('CRNPAY',i.tran_id, it.line_no) as gst_rate "
+"from drcr_pay i,drcr_pdet it, item"
+" where i.tran_id = it.tran_id "
+" and item.item_code = it.item_code "
......@@ -13053,7 +13347,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
public String executeSqlAndPopulateData (String hdrSql, String dtlSql, String tranSer) throws Exception
{
System.out.println("TODAY");
System.out.println("TODAY n");
String retString = "";
PreparedStatement pstmt = null,pstmtInsHdr = null,pstmtInsDet = null, pstmtSelHdr = null,pstmtSelDet = 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