Commit ab2a2c35 authored by kdabholkar's avatar kdabholkar

Added new queries in GSTR2 for Expense Payable to Customer

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192278 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 60289e93
...@@ -52,7 +52,8 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -52,7 +52,8 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
GST_IMPGDSEZ_TAXCLASS="",GST_IMPGDSEZ_TAXENV="",GST_PURSEZWP_TAXENV="",GST_PURSEZWP_TAXCLASS="",GST_PURSEZWOP_TAXENV="",GST_PURSEZWOP_TAXCLASS="", 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_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="",GST_TRANSFER_TOSHOW_INNILRATED="",GST_EXCLUDE_NILL_CDNR = "",GST_ISD_OP_IGSTAC="",GST_ISD_OP_CGSTAC="",GST_ISD_OP_SGSTAC="",GST_ISD_OP_CESSAC="", GST_BANKCHANGES_ACC_CODES="",GST_TRANSFER_TOSHOW_INNILRATED="",GST_EXCLUDE_NILL_CDNR = "",GST_ISD_OP_IGSTAC="",GST_ISD_OP_CGSTAC="",GST_ISD_OP_SGSTAC="",GST_ISD_OP_CESSAC="",
GST_ISD_IN_IGSTAC="",GST_ISD_IN_CGSTAC="",GST_ISD_IN_SGSTAC="",GST_ISD_IN_CESSAC="", nulldata ="NULLFOUND", GST_SALES_ACC_CODES ="",GST_PURCHASE_ACC_CODES ="", GST_CUST_PAY_CDN = ""; GST_ISD_IN_IGSTAC="",GST_ISD_IN_CGSTAC="",GST_ISD_IN_SGSTAC="",GST_ISD_IN_CESSAC="", nulldata ="NULLFOUND", GST_SALES_ACC_CODES ="",GST_PURCHASE_ACC_CODES ="", GST_CUST_PAY_CDN = "",
GST_EXP_PAY_BYCUST="";
...@@ -364,6 +365,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -364,6 +365,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
//New Disparm Created By Kaustubh on 12 sep 2018 to handle customer payable Credit Notes start //New Disparm Created By Kaustubh on 12 sep 2018 to handle customer payable Credit Notes start
GST_CUST_PAY_CDN = distCommon.getDisparams("999999", "GST_CUST_PAY_CDN", connGST); GST_CUST_PAY_CDN = distCommon.getDisparams("999999", "GST_CUST_PAY_CDN", connGST);
//New Disparm Created By Kaustubh on 12 sep 2018 to handle customer payable Credit Notes end //New Disparm Created By Kaustubh on 12 sep 2018 to handle customer payable Credit Notes end
//New Disparm Created By Kaustubh on 23 oct 2018 to handle customer payable Credit Notes start
GST_EXP_PAY_BYCUST = distCommon.getDisparams("999999", "GST_EXP_PAY_BYCUST", connGST);
//New Disparm Created By Kaustubh on 23 oct 2018 to handle customer payable Credit Notes end
TAX_CHAP_STR=TAX_CHAP_STR.replace(",", "','"); TAX_CHAP_STR=TAX_CHAP_STR.replace(",", "','");
TAX_CHAP_STR="'"+TAX_CHAP_STR+"'"; TAX_CHAP_STR="'"+TAX_CHAP_STR+"'";
...@@ -379,6 +384,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -379,6 +384,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
GST_CUST_PAY_CDN= GST_CUST_PAY_CDN.replace(",", "','"); GST_CUST_PAY_CDN= GST_CUST_PAY_CDN.replace(",", "','");
GST_CUST_PAY_CDN="'"+GST_CUST_PAY_CDN+"'"; GST_CUST_PAY_CDN="'"+GST_CUST_PAY_CDN+"'";
GST_EXP_PAY_BYCUST= GST_EXP_PAY_BYCUST.replace(",", "','");
GST_EXP_PAY_BYCUST="'"+GST_EXP_PAY_BYCUST+"'";
RCM_DATA_VOUCH = distCommon.getDisparams("999999", "RCM_DATA_VOUCH", connGST); RCM_DATA_VOUCH = distCommon.getDisparams("999999", "RCM_DATA_VOUCH", connGST);
...@@ -4930,9 +4940,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -4930,9 +4940,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
// +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP // +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP
+" and st_c.GST_CODE = '00' "; +" and st_c.GST_CODE = '00' ";
//+" and trim(i.tran_type) != 'PR' " //+" and trim(i.tran_type) != 'PR' "
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code " +"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code "
...@@ -5299,11 +5309,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -5299,11 +5309,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and i.sundry_code in (select cust_code from customer where trim(tax_reg_2) = 'UNREGISTER') " +" and i.sundry_code in (select cust_code from customer where trim(tax_reg_2) = 'UNREGISTER') "
+" and st_c.GST_CODE <> '00' "; +" and st_c.GST_CODE <> '00' ";
// +" and trim(i.tran_type) != 'PR' " // +" and trim(i.tran_type) != 'PR' "
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code " +"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code "
+ " and ti.tran_code = 'MDRCRC'" + " and ti.tran_code = 'MDRCRC'"
+ " and i.TRAN_ID =ti.TRAN_ID" + " and i.TRAN_ID =ti.TRAN_ID"
...@@ -5496,11 +5506,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -5496,11 +5506,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+"AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' " +"AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' "
+" and i.sundry_code in (select cust_code from customer where trim(tax_reg_2) = 'UNREGISTER') " +" and i.sundry_code in (select cust_code from customer where trim(tax_reg_2) = 'UNREGISTER') "
+" and st_c.GST_CODE <> '00' "; +" and st_c.GST_CODE <> '00' ";
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
//+ " and trim(i.tran_type) != 'PR'" //+ " and trim(i.tran_type) != 'PR'"
// +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP // +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP
+"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code " +"AND (SELECT COUNT(1) FROM taxtran ti,tax tm WHERE tm.tax_code = ti.tax_code "
...@@ -7829,10 +7839,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -7829,10 +7839,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and s.state_code = c.state_code " +" and s.state_code = c.state_code "
+" and trim(c.tax_reg_2) <> 'UNREGISTER' " +" and trim(c.tax_reg_2) <> 'UNREGISTER' "
+" and state.GST_CODE <> '00'"; +" and state.GST_CODE <> '00'";
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id " +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 "; +" and ti.tax_perc = 0 ";
...@@ -7992,10 +8002,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -7992,10 +8002,10 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and s.state_code = c.state_code " +" and s.state_code = c.state_code "
+" and trim(c.tax_reg_2) = 'UNREGISTER' " +" and trim(c.tax_reg_2) = 'UNREGISTER' "
+" and state.GST_CODE <> '00' "; +" and state.GST_CODE <> '00' ";
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id " +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 "; +" and ti.tax_perc = 0 ";
...@@ -8154,11 +8164,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -8154,11 +8164,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and s.state_code <> c.state_code " +" and s.state_code <> c.state_code "
+" and trim(c.tax_reg_2) = 'UNREGISTER' " +" and trim(c.tax_reg_2) = 'UNREGISTER' "
+" and state.GST_CODE <> '00' "; +" and state.GST_CODE <> '00' ";
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id " +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 "; +" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0) if(GST_NIL_TAXCLASS.length() > 0)
...@@ -8317,11 +8327,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -8317,11 +8327,11 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and s.state_code <> c.state_code " +" and s.state_code <> c.state_code "
+" and trim(c.tax_reg_2) <> 'UNREGISTER' " +" and trim(c.tax_reg_2) <> 'UNREGISTER' "
+" and state.GST_CODE <> '00' "; +" and state.GST_CODE <> '00' ";
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id " +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' and ti.tran_id = i.tran_id "
+" and ti.tax_perc = 0 "; +" and ti.tax_perc = 0 ";
if(GST_NIL_TAXCLASS.length() > 0) if(GST_NIL_TAXCLASS.length() > 0)
...@@ -10040,9 +10050,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -10040,9 +10050,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and d.line_no = (select min(line_no) from misc_drcr_rdet where tran_id=i.tran_id) " +" and d.line_no = (select min(line_no) from misc_drcr_rdet where tran_id=i.tran_id) "
+" AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' "; +" AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' ";
//+" and trim(i.tran_type) != 'PR' " //+" and trim(i.tran_type) != 'PR' "
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP +" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP
...@@ -10406,9 +10416,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc ...@@ -10406,9 +10416,9 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
+" and trim(c.tax_reg_2) = 'UNREGISTER' " +" and trim(c.tax_reg_2) = 'UNREGISTER' "
+" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' "; +" and case when i.confirmed is null then 'N' else i.confirmed end = 'Y' ";
//+" and trim(i.tran_type) != 'PR' " //+" and trim(i.tran_type) != 'PR' "
if(GST_CUST_PAY_CDN.length() > 0) if(GST_CUST_PAY_CDN.length() > 0 && GST_EXP_PAY_BYCUST.length() > 0 )
{ {
hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+") "; hdrSql = hdrSql +" and i.tran_type NOT IN ("+GST_CUST_PAY_CDN+","+GST_EXP_PAY_BYCUST+") ";
} }
hdrSql = hdrSql hdrSql = hdrSql
+" and i.tran_date between ? and ? " +" and i.tran_date between ? and ? "
...@@ -24494,7 +24504,343 @@ dtlSql = " select '' as TRAN_ID, " ...@@ -24494,7 +24504,343 @@ dtlSql = " select '' as TRAN_ID, "
try{ try{
/**Added New Queries By Kaustubh on 12 Sep for Approach to Handle Customer Payable Start **/ /** Added New Queries By Kaustubh on 23 Oct 2018 for Approach to Handle Expense payable raised by
* the customer in Receivables Misc. Credit Note. Start
* */
{
{
hdrSql = "select "
+"TRAN_ID,TRAN_ID__REF,SITE_CODE ,PRD_CODE ,REC_TYPE,GST_TYPE,TRAN_TYPE,CUST_CODE,CUST_NAME,GST_CODE,SUBMISSION_TYPE, "
+"DOC_CHECKSUM,DOC_TYPE,DOC_NO,DOC_DATE,AMOUNT,REVERSE_CHRG,LR_NO,REAS_CODE,REF_ID__INV,REF_DATE__INV,PROV_ASSMNT, "
+"ORDER_NO,REMARKS,REF_ID,SUBMIT_STATUS,ADD_USER,ADD_TERM,CHG_USER,CHG_DATE,CHG_TERM,TAX_REG_NO, RECO_STATUS,ECOM_REG_NO,REF_SER "
+"from "
+"(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 ,"
+"'2' AS REC_TYPE,"
+"'C' AS GST_TYPE,"
+"'1' AS TRAN_TYPE,"
+"i.sundry_code AS CUST_CODE,"
+"c.cust_name AS CUST_NAME,"
+"case when length(trim(state.GST_CODE)) is NULL then '00' else state.gst_code end as 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,"
+" d.invoice_ref AS REF_ID__INV, "
+" d.INV_REF_DATE AS REF_DATE__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,"
+" i.TRAN_DATE as CHG_DATE, "
+"' 'CHG_TERM,"
+" case when trim(c.tax_reg_2) is null then 'UNREGISTR' else trim(c.tax_reg_2) end AS TAX_REG_NO, "
+"' ' AS RECO_STATUS,"
+"' ' as ECOM_REG_NO,"
+"'MDRCRC' as REF_SER "
+"FROM misc_drcr_rcp i,misc_drcr_rdet d,customer c,site s,state "
+"WHERE c.cust_code = i.sundry_code "
+"AND s.site_code = i.site_code "
+"AND state.state_code = c.STATE_CODE "
+"AND i.drcr_flag ='C' "
+"AND i.tran_id = d.tran_id "
+" and d.line_no = (select min(line_no) from misc_drcr_rdet where tran_id=i.tran_id) "
+" AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' ";
if(GST_EXP_PAY_BYCUST.length() > 0)
{
hdrSql = hdrSql +" and i.tran_type in ("+GST_EXP_PAY_BYCUST+") ";
}
hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 " //modified by kaustubh on 26 july 2017 add DRNCRP
+" and trim(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 = 'MDRCRC' and ref_id = i.tran_id ) = 0 )"
+" group by "
+" TRAN_ID,TRAN_ID__REF,SITE_CODE ,PRD_CODE ,REC_TYPE,GST_TYPE,TRAN_TYPE,CUST_CODE,CUST_NAME,GST_CODE,SUBMISSION_TYPE, "
+" DOC_CHECKSUM,DOC_TYPE,DOC_NO,DOC_DATE,AMOUNT,REVERSE_CHRG,LR_NO,REAS_CODE,REF_ID__INV,REF_DATE__INV,PROV_ASSMNT,ORDER_NO, "
+" REMARKS,REF_ID,SUBMIT_STATUS,ADD_USER,ADD_TERM,CHG_USER,CHG_DATE,CHG_TERM,TAX_REG_NO,RECO_STATUS,ECOM_REG_NO,REF_SER";
/**
* Detail CDNR Credit Note registered 9C(1) (MDRCRC)*
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" CASE WHEN it.item_code IS NULL THEN 'S' ELSE 'G' END AS LINE_TYPE,"
+" (select CASE "
+" WHEN (NVL(it.item_code,'X')<>'X') "
+" THEN (fn_get_hsn_no(i.site_code,it.item_code)) "
+" WHEN (NVL(it.item_code,'X')='X' AND NVL(GD.anal_code,'X')<>'X') "
+" THEN (select SH_DESCR from ANALYSIS where ANALYSIS.ANAL_CODE=GD.anal_code) "
+" WHEN (NVL(it.item_code,'X')='X' AND NVL(GD.anal_code,'X')='X') "
+" THEN fn_get_hsn_sac(GH.site_code,'',GD.acct_code) END "
+" from MISC_DRCR_RCP GH,MISC_DRCR_RDET GD where GH.tran_id=GD.tran_id and GH.tran_id=i.tran_id "
+" and it.line_no=GD.line_no ) AS GS_CODE, ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql
+" fn_gst_rate_amt(CAST('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+" (select CASE "
+" WHEN (NVL(it.item_code,'X')='X') "
+" THEN 'OTH' "
+" WHEN (NVL(it.item_code,'X')<>'X') "
+" THEN (SELECT CASE WHEN udf_str2 IS NULL THEN descr ELSE udf_str2 END AS Unit FROM uom "
+" WHERE unit=(select item.unit from item where item.item_code=it.item_code) ) END "
+" from dual ) AS UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('MDRCRC' 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('MDRCRC' 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('MDRCRC',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('MDRCRC',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('MDRCRC',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('MDRCRC',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from MISC_DRCR_RCP i,MISC_DRCR_RDET it"
+" where i.tran_id = it.tran_id "
+"and (select count(1) from taxtran ti, tax tx where tx.tax_code = ti.tax_code "
+"and ti.tran_code = 'MDRCRC' "
+"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,"EXP_PAY(MISC-CRN-REG)");
}
/**Receivable UNREG queries for misc_drcr_rcp start*/
{
hdrSql = "select "
+"TRAN_ID,TRAN_ID__REF,SITE_CODE ,PRD_CODE ,REC_TYPE,GST_TYPE,TRAN_TYPE,CUST_CODE,CUST_NAME,GST_CODE,SUBMISSION_TYPE, "
+"DOC_CHECKSUM,DOC_TYPE,DOC_NO,DOC_DATE,AMOUNT,REVERSE_CHRG,LR_NO,REAS_CODE,REF_ID__INV,REF_DATE__INV,PROV_ASSMNT, "
+"ORDER_NO,REMARKS,REF_ID,SUBMIT_STATUS,ADD_USER,ADD_TERM,CHG_USER,CHG_DATE,CHG_TERM,TAX_REG_NO, RECO_STATUS,ECOM_REG_NO,REF_SER "
+"from "
+"(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 ,"
+"'2' AS REC_TYPE,"
+"'C' AS GST_TYPE,"
+"'6' AS TRAN_TYPE,"
+"i.sundry_code AS CUST_CODE,"
+"c.cust_name AS CUST_NAME,"
+"case when length(trim(state.GST_CODE)) is NULL then '00' else state.gst_code end as 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,"
+" d.invoice_ref AS REF_ID__INV, "
+" d.INV_REF_DATE AS REF_DATE__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,"
+" i.TRAN_DATE as CHG_DATE, "
+"' 'CHG_TERM,"
+" case when trim(c.tax_reg_2) is null then 'UNREGISTR' else trim(c.tax_reg_2) end AS TAX_REG_NO, "
+"' ' AS RECO_STATUS,"
+"' ' as ECOM_REG_NO,"
+"'MDRCRC' as REF_SER "
+"FROM misc_drcr_rcp i,misc_drcr_rdet d,customer c,site s,state "
+"WHERE c.cust_code = i.sundry_code "
+"AND s.site_code = i.site_code "
+"AND state.state_code = c.STATE_CODE "
+"AND i.drcr_flag ='C' "
+"AND i.tran_id = d.tran_id "
+" and d.line_no = (select min(line_no) from misc_drcr_rdet where tran_id=i.tran_id) "
+" AND CASE WHEN i.confirmed IS NULL THEN 'N' ELSE i.confirmed END = 'Y' ";
if(GST_EXP_PAY_BYCUST.length() > 0)
{
hdrSql = hdrSql +" and i.tran_type in ("+GST_EXP_PAY_BYCUST+") ";
}
hdrSql = hdrSql
+" and (select count(1) from taxtran ti where ti.tran_code = 'MDRCRC' ) > 0 "
+" and trim(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 = 'MDRCRC' and ref_id = i.tran_id ) = 0 )"
+" group by "
+" TRAN_ID,TRAN_ID__REF,SITE_CODE ,PRD_CODE ,REC_TYPE,GST_TYPE,TRAN_TYPE,CUST_CODE,CUST_NAME,GST_CODE,SUBMISSION_TYPE, "
+" DOC_CHECKSUM,DOC_TYPE,DOC_NO,DOC_DATE,AMOUNT,REVERSE_CHRG,LR_NO,REAS_CODE,REF_ID__INV,REF_DATE__INV,PROV_ASSMNT,ORDER_NO, "
+" REMARKS,REF_ID,SUBMIT_STATUS,ADD_USER,ADD_TERM,CHG_USER,CHG_DATE,CHG_TERM,TAX_REG_NO,RECO_STATUS,ECOM_REG_NO,REF_SER";
/**
* Detail CDNR Credit Note registered 9C(1) (MDRCRC)*
*/
dtlSql = " select '' as TRAN_ID, "
+" it.line_no as LINE_NO, "
+" 'A' as STATUS, "
+" 0 as SR_NO__OLD, "
+" CASE WHEN it.item_code IS NULL THEN 'S' ELSE 'G' END AS LINE_TYPE,"
+" (select CASE "
+" WHEN (NVL(it.item_code,'X')<>'X') "
+" THEN (fn_get_hsn_no(i.site_code,it.item_code)) "
+" WHEN (NVL(it.item_code,'X')='X' AND NVL(GD.anal_code,'X')<>'X') "
+" THEN (select SH_DESCR from ANALYSIS where ANALYSIS.ANAL_CODE=GD.anal_code) "
+" WHEN (NVL(it.item_code,'X')='X' AND NVL(GD.anal_code,'X')='X') "
+" THEN fn_get_hsn_sac(GH.site_code,'',GD.acct_code) END "
+" from MISC_DRCR_RCP GH,MISC_DRCR_RDET GD where GH.tran_id=GD.tran_id and GH.tran_id=i.tran_id "
+" and it.line_no=GD.line_no ) AS GS_CODE, ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql
+" fn_gst_rate_amt(CAST('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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('MDRCRC' 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_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, ' ', 'T') * i.EXCH_RATE as TAXABLE_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+ "fn_gst_rate_amt('MDRCRC',i.tran_id, it.line_no, 'G', 'A') as SGST_AMT,";
}
dtlSql = dtlSql
+" ' ' as GS_DESCR, "
+" (select CASE "
+" WHEN (NVL(it.item_code,'X')='X') "
+" THEN 'OTH' "
+" WHEN (NVL(it.item_code,'X')<>'X') "
+" THEN (SELECT CASE WHEN udf_str2 IS NULL THEN descr ELSE udf_str2 END AS Unit FROM uom "
+" WHERE unit=(select item.unit from item where item.item_code=it.item_code) ) END "
+" from dual ) AS UNIT, "
+" (it.quantity) as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('MDRCRC' 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('MDRCRC' 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('MDRCRC',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('MDRCRC',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('MDRCRC',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +" fn_get_gst_rate('MDRCRC',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+" from MISC_DRCR_RCP i,MISC_DRCR_RDET it"
+" where i.tran_id = it.tran_id "
+"and (select count(1) from taxtran ti, tax tx where tx.tax_code = ti.tax_code "
+"and ti.tran_code = 'MDRCRC' "
+"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,"EXP_PAY(MISC-CRN-UNREG)");
}
/**Customer Payable UNREG queries for misc_drcr_rcp End */
}
/** Added New Queries By Kaustubh on 23 Oct 2018 for Approach to Handle Expense payable raised by
* the customer in Receivables Misc. Credit Note. End
* */
/**Added New Queries By Kaustubh on 12 Sep 2018 for Approach to Handle Customer Payable Start **/
{ {
{ {
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