Commit 23c0c30c authored by kdabholkar's avatar kdabholkar

Adding new queries reagrding Debt Note (P-RET).

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@179716 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 760f1f5b
......@@ -13786,6 +13786,300 @@ public class GstDataPrc extends ProcessEJB implements GstDataPrcLocal,GstDataPrc
{
/******* 6 started debit note from porcp (P-RET)********/
/** debit Note Date - 6/02/2018 **/
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,"
+" '2' as REC_TYPE,"// -- GSTR1,GSTR2,etc.
+" 'D' as GST_TYPE," //need to ask
+" '10' as TRAN_TYPE,"// -- b2b,b2c
+" i.supp_code as CUST_CODE,"
+" c.supp_name as CUST_NAME,"
+" state.GST_CODE,"// -- 2 digit code
+" ' ' as SUBMISSION_TYPE,"// -- M-Modify, D-Delete, A-Accept, R-Reject
+" ' ' as DOC_CHECKSUM,"
+" ' ' as DOC_TYPE,"// -- R- Regular B2B Invoices, DE – Deemed Exports, SEWP – SEZ Exports with payment,SEWOP – SEZ exports without payment
+" i.tran_id as DOC_NO,"
+" i.invoice_date as DOC_DATE,"
+" i.amount as AMOUNT,"
+" 'Y' as REVERSE_CHRG,"
+" ' ' as LR_NO,"
+" ' ' as REAS_CODE,"
+" i.invoice_no as REF_ID__INV,"
+" 'N' as PROV_ASSMNT,"// -- not required
+" '' as ORDER_NO,"// -- not required
+" c.site_code as REMARKS, " // added on 9 aug
+" i.invoice_no 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,"
+" 'P-RET' as ref_ser "
+"from porcp i,supplier c, site s, state state"
+" where c.supp_code = i.supp_code "
+" and s.site_code = i.site_code "
+" and state.state_code = c.STATE_CODE "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code "
+" and ti.tran_code = 'P-RET' and ti.tran_id = i.tran_id "
+" and tm.TAX_GROUP IN ('ITC','NITC') "
+" and tm.tax_type in ('G','H','I','J')";
if(taxClassAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class not in ("+taxClassAllStrOfPurchase+") ";
}
if(taxEnvAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_env not in ("+taxEnvAllStrOfPurchase+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'P-RET' and ref_id = i.tran_id ) = 0 ";
/**
* debit note *
*/
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, ";
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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+"fn_gst_rate_amt('P-RET',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 as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and cast(ti.line_no as integer) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
else
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and to_number(trim(ti.line_no)) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
dtlSql = dtlSql
+" 'ig' as ITC_TYPE , ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+"from porcp i,porcpdet 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 = 'P-RET' "
+" and tx.TAX_GROUP IN ('ITC','NITC') "
+" 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-P-RET");
/** debit Note Un-register Date - 6/02/2018 **/
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,"
+" '2' as REC_TYPE,"// -- GSTR1,GSTR2,etc.
+" 'D' as GST_TYPE," //need to ask
+" '10' as TRAN_TYPE,"// -- b2b,b2c
+" i.supp_code as CUST_CODE,"
+" c.supp_name as CUST_NAME,"
+" state.GST_CODE,"// -- 2 digit code
+" ' ' as SUBMISSION_TYPE,"// -- M-Modify, D-Delete, A-Accept, R-Reject
+" ' ' as DOC_CHECKSUM,"
+" ' ' as DOC_TYPE,"// -- R- Regular B2B Invoices, DE – Deemed Exports, SEWP – SEZ Exports with payment,SEWOP – SEZ exports without payment
+" i.tran_id as DOC_NO,"
+" i.invoice_date as DOC_DATE,"
+" i.amount as AMOUNT,"
+" 'Y' as REVERSE_CHRG,"
+" ' ' as LR_NO,"
+" ' ' as REAS_CODE,"
+" i.invoice_no as REF_ID__INV,"
+" 'N' as PROV_ASSMNT,"// -- not required
+" '' as ORDER_NO,"// -- not required
+" c.site_code as REMARKS, " // added on 9 aug
+" i.invoice_no 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,"
+" 'P-RET' as ref_ser "
+"from porcp i,supplier c, site s, state state"
+" where c.supp_code = i.supp_code "
+" and s.site_code = i.site_code "
+" and state.state_code = c.STATE_CODE "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code "
+" and ti.tran_code = 'P-RET' and ti.tran_id = i.tran_id "
+" and tm.TAX_GROUP IN ('ITC','NITC') "
+" and tm.tax_type in ('G','H','I','J')";
if(taxClassAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class not in ("+taxClassAllStrOfPurchase+") ";
}
if(taxEnvAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_env not in ("+taxEnvAllStrOfPurchase+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'P-RET' and ref_id = i.tran_id ) = 0 ";
/**
* debit note *
*/
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, ";
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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+"fn_gst_rate_amt('P-RET',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 as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and cast(ti.line_no as integer) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
else
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and to_number(trim(ti.line_no)) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
dtlSql = dtlSql
+" 'ig' as ITC_TYPE , ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+"from porcp i,porcpdet 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 = 'P-RET' "
+" and tx.TAX_GROUP IN ('ITC','NITC') "
+" 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,"CDNUR-P-RET");
/**
* (A) D-RCP Header distribution receipt *
*/
......@@ -23965,9 +24259,302 @@ dtlSql = " select '' as TRAN_ID, "
/******* 6 started ********/
/******* 6 started debit note from porcp (P-RET)********/
/** debit Note Date - 6/02/2018 **/
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,"
+" '2' as REC_TYPE,"// -- GSTR1,GSTR2,etc.
+" 'D' as GST_TYPE," //need to ask
+" '10' as TRAN_TYPE,"// -- b2b,b2c
+" i.supp_code as CUST_CODE,"
+" c.supp_name as CUST_NAME,"
+" state.GST_CODE,"// -- 2 digit code
+" ' ' as SUBMISSION_TYPE,"// -- M-Modify, D-Delete, A-Accept, R-Reject
+" ' ' as DOC_CHECKSUM,"
+" ' ' as DOC_TYPE,"// -- R- Regular B2B Invoices, DE – Deemed Exports, SEWP – SEZ Exports with payment,SEWOP – SEZ exports without payment
+" i.tran_id as DOC_NO,"
+" i.invoice_date as DOC_DATE,"
+" i.amount as AMOUNT,"
+" 'Y' as REVERSE_CHRG,"
+" ' ' as LR_NO,"
+" ' ' as REAS_CODE,"
+" i.invoice_no as REF_ID__INV,"
+" 'N' as PROV_ASSMNT,"// -- not required
+" '' as ORDER_NO,"// -- not required
+" c.site_code as REMARKS, " // added on 9 aug
+" i.invoice_no 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,"
+" 'P-RET' as ref_ser "
+"from porcp i,supplier c, site s, state state"
+" where c.supp_code = i.supp_code "
+" and s.site_code = i.site_code "
+" and state.state_code = c.STATE_CODE "
+" and c.tax_reg_2 <> 'UNREGISTER' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code "
+" and ti.tran_code = 'P-RET' and ti.tran_id = i.tran_id "
+" and tm.TAX_GROUP IN ('ITC','NITC') "
+" and tm.tax_type in ('G','H','I','J')";
if(taxClassAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class not in ("+taxClassAllStrOfPurchase+") ";
}
if(taxEnvAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_env not in ("+taxEnvAllStrOfPurchase+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'P-RET' and ref_id = i.tran_id ) = 0 ";
/**
* debit note *
*/
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, ";
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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+"fn_gst_rate_amt('P-RET',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 as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and cast(ti.line_no as integer) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
else
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and to_number(trim(ti.line_no)) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
dtlSql = dtlSql
+" 'ig' as ITC_TYPE , ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+"from porcp i,porcpdet 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 = 'P-RET' "
+" and tx.TAX_GROUP IN ('ITC','NITC') "
+" 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-P-RET");
/** debit Note Un-register Date - 6/02/2018 **/
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,"
+" '2' as REC_TYPE,"// -- GSTR1,GSTR2,etc.
+" 'D' as GST_TYPE," //need to ask
+" '10' as TRAN_TYPE,"// -- b2b,b2c
+" i.supp_code as CUST_CODE,"
+" c.supp_name as CUST_NAME,"
+" state.GST_CODE,"// -- 2 digit code
+" ' ' as SUBMISSION_TYPE,"// -- M-Modify, D-Delete, A-Accept, R-Reject
+" ' ' as DOC_CHECKSUM,"
+" ' ' as DOC_TYPE,"// -- R- Regular B2B Invoices, DE – Deemed Exports, SEWP – SEZ Exports with payment,SEWOP – SEZ exports without payment
+" i.tran_id as DOC_NO,"
+" i.invoice_date as DOC_DATE,"
+" i.amount as AMOUNT,"
+" 'Y' as REVERSE_CHRG,"
+" ' ' as LR_NO,"
+" ' ' as REAS_CODE,"
+" i.invoice_no as REF_ID__INV,"
+" 'N' as PROV_ASSMNT,"// -- not required
+" '' as ORDER_NO,"// -- not required
+" c.site_code as REMARKS, " // added on 9 aug
+" i.invoice_no 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,"
+" 'P-RET' as ref_ser "
+"from porcp i,supplier c, site s, state state"
+" where c.supp_code = i.supp_code "
+" and s.site_code = i.site_code "
+" and state.state_code = c.STATE_CODE "
+" and c.tax_reg_2 = 'UNREGISTER' "
+" and (select count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code "
+" and ti.tran_code = 'P-RET' and ti.tran_id = i.tran_id "
+" and tm.TAX_GROUP IN ('ITC','NITC') "
+" and tm.tax_type in ('G','H','I','J')";
if(taxClassAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_class not in ("+taxClassAllStrOfPurchase+") ";
}
if(taxEnvAllStrOfPurchase.length() > 0)
{
hdrSql = hdrSql +" and ti.tax_env not in ("+taxEnvAllStrOfPurchase+") ";
}
hdrSql = hdrSql +" ) > 0 "
+" and i.tran_date between ? and ? "
+" and (select count(1) from gst_data_hdr where ref_ser = 'P-RET' and ref_id = i.tran_id ) = 0 ";
/**
* debit note *
*/
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, ";
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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, ' ', 'T') as TAXABLE_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'R') as IGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'I', 'A') as IGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'R') as CGST_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'H', 'A') as CGST_AMT,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'G', 'R') as SGST_PERC,"
+"fn_gst_rate_amt('P-RET',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 as QUANTITY,"
+" 'OE' as SUPPLY_TYPE," ;
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql + "fn_gst_rate_amt(CAST('P-RET' 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('P-RET' 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('P-RET',i.tran_id, it.line_no, 'J', 'R') as CESS_PERC,"
+"fn_gst_rate_amt('P-RET',i.tran_id, it.line_no, 'J', 'A') as CESS_AMT,";
}
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and cast(ti.line_no as integer) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
else
{
dtlSql = dtlSql +"(SELECT count(1) from taxtran ti, tax tm where tm.tax_code = ti.tax_code and ti.tran_id = i.tran_id and to_number(trim(ti.line_no)) = it.line_no and tm.tax_group='ITC' ) as REMARKS, ";
}
dtlSql = dtlSql
+" 'ig' as ITC_TYPE , ";
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ))
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id,CAST(it.line_no as char(3))) as gst_rate ";
}
else
{
dtlSql = dtlSql +"fn_get_gst_rate('P-RET',i.tran_id, it.line_no) as gst_rate ";
}
dtlSql = dtlSql
+"from porcp i,porcpdet 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 = 'P-RET' "
+" and tx.TAX_GROUP IN ('ITC','NITC') "
+" 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,"CDNUR-P-RET");
/*** 6C(1) (CDNR Debit Note registered) Header DRNPAY Debit Note (Register User) *****/
{
......@@ -24137,7 +24724,7 @@ dtlSql = " select '' as TRAN_ID, "
/*** 6C(2) (CDNUR Debit Note to unregistered) Header DRNPAY Debit Note (Register User) *****/
{
{
hdrSql = " select '' as TRAN_ID, "
/* +" to_date(i.GP_DATE) as TRAN_DATE, "*/
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