Select lpad( substr(acr.GLOBAL_ATTRIBUTE6,1,3),3,'0') DGI_tax_regime_code,
lpad( NVL(replace(substr(cust.JGZZ_FISCAL_CODE,1,10),'-','') || NVL(SUBSTR(cust.GLOBAL_ATTRIBUTE12,1,1),NULL),' ') , 13,' ' ) withholding_agent_cuit,
acr.GLOBAL_ATTRIBUTE5 withholding_date ,
lpad(substr(acr.GLOBAL_ATTRIBUTE4,1,16),16,'0') withholding_cert_num ,
acr.amount withholding_amount,
JL_JLARRWTF_XMLP_PKG.cf_with_taken_recformula(lpad ( substr ( acr.GLOBAL_ATTRIBUTE6 , 1 , 3 ) , 3 , '0' ), lpad ( NVL ( replace ( substr ( cust.JGZZ_FISCAL_CODE , 1 , 10 ) , '-' , '' ) || NVL ( SUBSTR ( cust.GLOBAL_ATTRIBUTE12 , 1 , 1 ) , NULL ) , ' ' ) , 13 , ' ' ), acr.GLOBAL_ATTRIBUTE5, lpad ( substr ( acr.GLOBAL_ATTRIBUTE4 , 1 , 16 ) , 16 , '0' ), acr.amount) CF_WITH_TAKEN_REC
FROM ar_cash_receipts_v acr,
hz_parties cust,
hz_cust_accounts custacct,
fnd_lookups fl
WHERE acr.gl_date between :P_START_DATE and :P_END_DATE
AND custacct.cust_account_id = acr.customer_id
AND custacct.party_id =cust.party_id
and fl.lookup_type = 'JLAR_TAX_AUTHORITY_CATEGORY'
and fl.lookup_code = acr.GLOBAL_ATTRIBUTE6
and fl.meaning between :P_WITH_TAX_REGIME_FROM
and :P_WITH_TAX_REGIME_TO
and acr.GLOBAL_ATTRIBUTE4 is not null
and acr.receipt_status <> 'REV'
order by withholding_date,
withholding_agent_cuit,
withholding_cert_num |