Commit fdf1ff95 authored by kdabholkar's avatar kdabholkar

added new queries for CDNR NIll Rated and CDNR direct Adjust in B2CS

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@185932 ce508802-f39f-4f6c-b175-0d175dae99d5
parent caf842b5
......@@ -51,7 +51,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
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="",SALES_DATA_MISC="",PURCHASE_DATA_PORCP="",MISC_VOUC_TYPE="",INV_ACCT_PORCP="",IMPL_MIN_RATE_HISTORY="",
GST_BANKCHANGES_ACC_CODES="",TRANSFER_TOSHOW_INNILRATED="";
GST_BANKCHANGES_ACC_CODES="",GST_TRANSFER_TOSHOW_INNILRATED="",GST_EXCLUDE_NILL_CDNR = "";
Timestamp fromDate = null, toDate = null , fromdateOracle = null, todateOracle=null;
......@@ -344,7 +344,8 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
if("P".equalsIgnoreCase(prcType))
{
TRANSFER_TOSHOW_INNILRATED = distCommon.getDisparams("999999", "TRANSFER_TOSHOW_INNILRATED", connGST);
GST_TRANSFER_TOSHOW_INNILRATED = distCommon.getDisparams("999999", "GST_TRANSFER_TOSHOW_INNILRATED", connGST);
GST_EXCLUDE_NILL_CDNR = distCommon.getDisparams("999999", "GST_EXCLUDE_NILL_CDNR", connGST);
TAX_CHAP_STR = distCommon.getDisparams("999999", "TAX_CHAP_STR", connGST);
TAX_CHAP_STR=TAX_CHAP_STR.replace(",", "','");
......@@ -4549,8 +4550,6 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
}
dtlSql = dtlSql
+" '' as REMARKS ,";
/*changed by kaustubh on 19-07-2017*/
//+" fn_get_gst_rate('S-INV',i.invoice_id, it.line_no) as gst_rate "
......@@ -5042,7 +5041,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
if("Y".equalsIgnoreCase(TRANSFER_TOSHOW_INNILRATED))
if("Y".equalsIgnoreCase(GST_TRANSFER_TOSHOW_INNILRATED))
{
/************* 8B DIS Nill rated ditribution issue (intra-state register suppliers) *****************************/
......@@ -7448,8 +7447,1639 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"9A(1)");
}
/**
* New Queries Added on 4 JUNE 2018 for CDNR to adjust Directly in B2CS for Client Pitambari Only ---- Start
*/
if("Y".equalsIgnoreCase(GST_EXCLUDE_NILL_CDNR))
{
System.out.println("Inside CDNR Exclude Nill Rated and nill rated Queries");
/** Header CDNR (Credit Note intra-state)B2CS */
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '11' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" st_c.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" i.drcr_flag as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" (i.amount * i.EXCH_RATE) as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" inv.invoice_id as REF_ID__INV,"
+" inv.tran_date as REF_DATE__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" '' as REMARKS, "
+" i.tran_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" FROM drcr_rcp i, customer c, site s, state st_c, state st_own, invoice inv "
+" WHERE c.cust_code = i.cust_code "
+" AND s.site_code = i.site_code "
+" AND st_c.state_code = c.state_code "
+" AND inv.invoice_id = i.invoice_id "
+" and i.drcr_flag ='C'"
+" AND s.state_code = st_own.state_code "
+" AND st_own.gst_code = st_c.gst_code "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_code = 'CRNRCP' "
+" and ti.tran_id = i.invoice_id and tm.tax_type in ('G','H','I','J') "
+" and ti.tax_perc <> 0 ";
if(taxClassAllStr.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class not in ("+taxClassAllStr+") or ti.tax_chap not in ("+TAX_CHAP_STR+")) ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
* Detail CDNR (Credit Note intra-state)B2CS *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) * i.EXCH_RATE AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=item.unit) as UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it, item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(Intra-State)-B2CS");
}
/** Header CDNR (Credit Note Inter-state)B2CS */
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '13' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" st_c.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" i.drcr_flag as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" (i.amount * i.EXCH_RATE) as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" inv.invoice_id as REF_ID__INV,"
+" inv.tran_date as REF_DATE__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" '' as REMARKS, "
+" i.tran_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" FROM drcr_rcp i, customer c, site s, state st_c, state st_own, invoice inv "
+" WHERE c.cust_code = i.cust_code "
+" AND s.site_code = i.site_code "
+" AND st_c.state_code = c.state_code "
+" AND inv.invoice_id = i.invoice_id "
+" and i.drcr_flag ='C'"
+" AND s.state_code = st_own.state_code "
+" AND st_own.gst_code <> st_c.gst_code "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_code = 'CRNRCP' "
+" and ti.tran_id = i.invoice_id and tm.tax_type in ('G','H','I','J') "
+" and ti.tax_perc <> 0 ";
if(taxClassAllStr.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class not in ("+taxClassAllStr+") or ti.tax_chap not in ("+TAX_CHAP_STR+")) ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
* Detail CDNR (Credit Note Inter-state)B2CS *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) * i.EXCH_RATE AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=item.unit) as UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it, item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(Inter-State)-B2CS");
}
/** Header (Debit Note Inter-state)B2CS */
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '13' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" st_c.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" i.drcr_flag as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" (i.amount * i.EXCH_RATE) as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" inv.invoice_id as REF_ID__INV,"
+" inv.tran_date as REF_DATE__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" '' as REMARKS, "
+" i.tran_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" FROM drcr_rcp i, customer c, site s, state st_c, state st_own, invoice inv "
+" WHERE c.cust_code = i.cust_code "
+" AND s.site_code = i.site_code "
+" AND st_c.state_code = c.state_code "
+" AND inv.invoice_id = i.invoice_id "
+" and i.drcr_flag ='D'"
+" AND s.state_code = st_own.state_code "
+" AND st_own.gst_code <> st_c.gst_code "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_code = 'DRNRCP' "
+" and ti.tran_id = i.invoice_id and tm.tax_type in ('G','H','I','J') "
+" and ti.tax_perc <> 0 ";
if(taxClassAllStr.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class not in ("+taxClassAllStr+") or ti.tax_chap not in ("+TAX_CHAP_STR+")) ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
* Detail DN (Debit Note Inter-state)B2CS *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) * i.EXCH_RATE AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=item.unit) as UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it, item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(Inter-State)-B2CS");
}
/** Header (Debit Note Intra-state)B2CS */
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '11' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" st_c.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" i.drcr_flag as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" (i.amount * i.EXCH_RATE) as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" inv.invoice_id as REF_ID__INV,"
+" inv.tran_date as REF_DATE__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" '' as REMARKS, "
+" i.tran_id as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" FROM drcr_rcp i, customer c, site s, state st_c, state st_own, invoice inv "
+" WHERE c.cust_code = i.cust_code "
+" AND s.site_code = i.site_code "
+" AND st_c.state_code = c.state_code "
+" AND inv.invoice_id = i.invoice_id "
+" and i.drcr_flag ='D'"
+" AND s.state_code = st_own.state_code "
+" AND st_own.gst_code = st_c.gst_code "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_code = 'DRNRCP' "
+" and ti.tran_id = i.invoice_id and tm.tax_type in ('G','H','I','J') "
+" and ti.tax_perc <> 0 ";
if(taxClassAllStr.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class not in ("+taxClassAllStr+") or ti.tax_chap not in ("+TAX_CHAP_STR+")) ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
* Detail CDNR (Credit Note Inter-state)B2CS *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) * i.EXCH_RATE AS TAXABLE_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=item.unit) as UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+"fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +"fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it, item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(Intra-state)-B2CS");
}
/**Nill Rated Queries of Credit and Debit Note*/
{
{
/**CDNR Nill Rated Query CDNR(Intra-state Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '18' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code = c.state_code "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'CRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail CDNR Query nill Rated CDNR(Intra-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(NILL)-Intra-REG");
}
/**CDNR Nill Rated Query CDNR(Intra-state UN-Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '24' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code = c.state_code "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'CRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail CDNR Query nill Rated CDNR(Intra-state UN-Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(NILL)-Intra-UNREG");
}
/**CDNR Nill Rated Query CDNR(Inter-state UN-Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '21' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code <> c.state_code "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'CRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail CDNR Query nill Rated CDNR(Intra-state UN-Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(NILL)-Inter-UNREG");
}
/**CDNR Nill Rated Query CDNR(Inter-state Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'C' as GST_TYPE,"
+" '15' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'CRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code <> c.state_code "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'CRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail CDNR Query nill Rated CDNR(Inter-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('CRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('CRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('CRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('CRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'CRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"CDNR(NILL)-Inter-REG");
}
} //End of CNDR Nill Rated queries
/**Nill Rated Debit note Queries*/
{
/**DN Nill Rated Query (Inter-state Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '15' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code <> c.state_code "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'DRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail DN Query nill Rated (Inter-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(NILL)-Inter-REG");
}
/**DN Nill Rated Query (Inter-state UN-Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '21' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code <> c.state_code "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'DRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail DN Query nill Rated (Inter-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(NILL)-Inter-UNREG");
}
/**DN Nill Rated Query (intra-state UN-Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '24' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code = c.state_code "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'DRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail DN Query nill Rated (Intra-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(NILL)-Intra-UNREG");
}
/**DN Nill Rated Query (intra-state Register)*/
{
hdrSql = " select '' as TRAN_ID, "
+" '' as TRAN_ID__REF, "
+" ddf_get_siteregno(s.site_code,'OPTNG_SITE') AS SITE_CODE ,"
+ " i.tran_date as PRD_CODE,"
+" '1' as REC_TYPE, "
+" 'D' as GST_TYPE,"
+" '18' as TRAN_TYPE,"
+" i.cust_code as CUST_CODE, "
+" c.cust_name as CUST_NAME, "
+" state.GST_CODE, "
+" '' as SUBMISSION_TYPE,"
+" '' as DOC_CHECKSUM,"
+" 'NRATD' as DOC_TYPE, "
+" i.tran_id as DOC_NO, "
+" i.tran_date as DOC_DATE,"
+" i.amount as AMOUNT, "
+" 'N' as REVERSE_CHRG, "
+" ' ' as LR_NO, "
+" ' ' as REAS_CODE, "
+" ' ' as REF_ID__INV, "
+" 'N' as PROV_ASSMNT, "
+" ' ' as ORDER_NO,"
+" s.site_code as REMARKS, "
+" i.TRAN_ID as REF_ID, "
+" ' ' as SUBMIT_STATUS, "
+" '' ADD_USER, "
+" '' ADD_TERM, "
+" ' ' CHG_USER, "
+" ' 'CHG_TERM, "
+" c.tax_reg_2 as TAX_REG_NO, "
+" ' ' as RECO_STATUS, "
+" ' ' as ECOM_REG_NO, "
+" 'DRNRCP' as ref_ser "
+" from drcr_rcp 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 s.state_code = c.state_code "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti where ti.tran_code = 'DRNRCP' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0)
{
hdrSql = hdrSql +" and (ti.tax_class in ("+GST_NIL_TAXCLASS+") OR ti.tax_chap in ("+TAX_CHAP_STR+") ) ";
}
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 = 'DRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
*Detail DN Query nill Rated (Intra-state Register) *
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" 'G' as LINE_TYPE,";
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('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST(' ' AS CHAR(1)), CAST('T' AS CHAR(1))) AS TAXABLE_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('R' AS CHAR(1))) AS IGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('I' AS CHAR(1)), CAST('A' AS CHAR(1))) AS IGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('H' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CGST_AMT,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('G' AS CHAR(1)), CAST('R' AS CHAR(1))) AS SGST_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), 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('DRNRCP',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ " - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+"(select case when udf_str2 is null then descr else udf_str2 end as Unit from uom where unit=it.unit) as UNIT, "
+" (it.quantity__stduom) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + " - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('R' AS CHAR(1))) AS CESS_PERC,"
+" - fn_gst_rate_amt(CAST('DRNRCP' AS VARCHAR(6)),i.tran_id,CAST(it.line_no as char(3)), CAST('J' AS CHAR(1)), CAST('A' AS CHAR(1))) AS CESS_AMT,";
}
else
{
dtlSql = dtlSql +" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+" - fn_gst_rate_amt('DRNRCP',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
dtlSql = dtlSql
+" '' as REMARKS ,";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('DRNRCP',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from drcr_rcp i,drcr_rdet it,item "
+" where i.tran_id = it.tran_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 = 'DRNRCP' "
+"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(ti.line_no as integer) = it.line_no ) > 0";
}
else
{
dtlSql =dtlSql +" and to_number(trim(ti.line_no)) = it.line_no ) > 0";
}
dtlSql = dtlSql
+" and i.tran_id = ? ";
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"DN(NILL)-Intra-REG");
}
}//End of Debit Note Nill Rated Queries
}//End of Nill Rated Queries
}//End of IF
/**
* New Queries Added on 4 JUNE 2018 for CDNR to adjust Directly in B2CS for Client Pitambari Only ---- END
*/
else
{
/******* 9B started ********/
/**
* 9B(1) Header CDNR Credit Note registered (CRNRCP)*
......@@ -7555,7 +9185,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
// +" and i.conf_date between ? and ? " commented by kaustubh on 27 july 2017
+" and i.tran_date between ? and ? "
/*changed by kaustubh*/
//+" and (select count(1) from gst_data_hdr where ref_ser = 'S-INV' and ref_id = i.invoice_id ) = 0 ";
//+" and (select count(1) from gst_data_hdr where ref_ser = 'CRNRCP' and ref_id = i.invoice_id ) = 0 ";
+" and (select count(1) from gst_data_hdr where ref_ser = 'CRNRCP' and ref_id = i.tran_id ) = 0 ";
/**
......@@ -8488,7 +10118,7 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
retString = executeSqlAndPopulateData(hdrSql,dtlSql,"9B2(DRN-UNREG)");
}
}//End of Else Loop of Disparm GST_EXCLUDE_NILL_CDNR
if ("Y".equalsIgnoreCase(IMPL_MIN_RATE_HISTORY))
{
......@@ -19884,7 +21514,7 @@ hdrSql = " select '' as TRAN_ID,"
if("Y".equalsIgnoreCase(TRANSFER_TOSHOW_INNILRATED))
if("Y".equalsIgnoreCase(GST_TRANSFER_TOSHOW_INNILRATED))
{
/*********** 7 Started supplies received from composition taxable person and other than exempt/nil rated/non GST supplies received. *************/
......@@ -33925,7 +35555,7 @@ dtlSql = " select '' as TRAN_ID, "
/*********** 7 Started supplies received from composition taxable person and other than exempt/nil rated/non GST supplies received. *************/
if("Y".equalsIgnoreCase(TRANSFER_TOSHOW_INNILRATED))
if("Y".equalsIgnoreCase(GST_TRANSFER_TOSHOW_INNILRATED))
{
/** distribution receipt ( nill rated ) **/
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