407: l_high_watermark_date ar_trx_summary.op_bal_high_watermark_date%type;
408: l_high_watermark ar_trx_summary.op_bal_high_watermark%type;
409: l_final_high_watermark ar_trx_summary.op_bal_high_watermark%type;
410: l_final_high_watermark_date ar_trx_summary.as_of_date%type;
411: l_last_payment_amount ar_trx_bal_summary.last_payment_amount%type;
412: l_last_payment_date ar_trx_bal_summary.last_payment_date%type;
413: l_last_payment_number ar_trx_bal_summary.last_payment_number%type;
414: l_last_payment_currency ar_trx_bal_summary.currency%type;
415: l_last_payment_amount_conv ar_trx_bal_summary.last_payment_amount%type;
408: l_high_watermark ar_trx_summary.op_bal_high_watermark%type;
409: l_final_high_watermark ar_trx_summary.op_bal_high_watermark%type;
410: l_final_high_watermark_date ar_trx_summary.as_of_date%type;
411: l_last_payment_amount ar_trx_bal_summary.last_payment_amount%type;
412: l_last_payment_date ar_trx_bal_summary.last_payment_date%type;
413: l_last_payment_number ar_trx_bal_summary.last_payment_number%type;
414: l_last_payment_currency ar_trx_bal_summary.currency%type;
415: l_last_payment_amount_conv ar_trx_bal_summary.last_payment_amount%type;
416:
409: l_final_high_watermark ar_trx_summary.op_bal_high_watermark%type;
410: l_final_high_watermark_date ar_trx_summary.as_of_date%type;
411: l_last_payment_amount ar_trx_bal_summary.last_payment_amount%type;
412: l_last_payment_date ar_trx_bal_summary.last_payment_date%type;
413: l_last_payment_number ar_trx_bal_summary.last_payment_number%type;
414: l_last_payment_currency ar_trx_bal_summary.currency%type;
415: l_last_payment_amount_conv ar_trx_bal_summary.last_payment_amount%type;
416:
417: l_result VARCHAR2(150); -- 6513911
410: l_final_high_watermark_date ar_trx_summary.as_of_date%type;
411: l_last_payment_amount ar_trx_bal_summary.last_payment_amount%type;
412: l_last_payment_date ar_trx_bal_summary.last_payment_date%type;
413: l_last_payment_number ar_trx_bal_summary.last_payment_number%type;
414: l_last_payment_currency ar_trx_bal_summary.currency%type;
415: l_last_payment_amount_conv ar_trx_bal_summary.last_payment_amount%type;
416:
417: l_result VARCHAR2(150); -- 6513911
418:
411: l_last_payment_amount ar_trx_bal_summary.last_payment_amount%type;
412: l_last_payment_date ar_trx_bal_summary.last_payment_date%type;
413: l_last_payment_number ar_trx_bal_summary.last_payment_number%type;
414: l_last_payment_currency ar_trx_bal_summary.currency%type;
415: l_last_payment_amount_conv ar_trx_bal_summary.last_payment_amount%type;
416:
417: l_result VARCHAR2(150); -- 6513911
418:
419: l_party_sql VARCHAR2(4000) :='select LARGEST_INV_DATE,
821: SELECT last_payment_amount, last_payment_date,
822: last_payment_number, currency
823: INTO l_last_payment_amount, l_last_payment_date,
824: l_last_payment_number, l_last_payment_currency
825: FROM AR_TRX_BAL_SUMMARY
826: WHERE cust_account_id in (select cust_account_id
827: FROM hz_cust_accounts
828: WHERE party_id in
829: ( SELECT child_id
853: = p_credit_request_id)
854: and last_payment_number IS NOT NULL
855: and last_payment_date IS NOT NULL
856: and last_payment_date = ( select max(last_payment_date) from
857: ar_trx_bal_summary
858: where cust_account_id in
859: (select cust_account_id
860: FROM hz_cust_accounts
861: WHERE party_id in
892: SELECT last_payment_amount, last_payment_date,
893: last_payment_number, currency
894: INTO l_last_payment_amount, l_last_payment_date,
895: l_last_payment_number, l_last_payment_currency
896: FROM AR_TRX_BAL_SUMMARY
897: where cust_account_id = p_cust_account_id
898: and last_payment_date IS NOT NULL
899: and last_payment_number IS NOT NULL
900: and org_id = decode(p_global_exposure_flag,'Y', org_id, 'N',
903: and currency in ( SELECT CURRENCY FROM
904: ar_cmgt_curr_usage_gt
905: WHERE nvl(credit_request_id,p_credit_request_id) = p_credit_request_id)
906: and last_payment_date = ( select max(last_payment_date) from
907: ar_trx_bal_summary
908: where cust_account_id = p_cust_account_id
909: and last_payment_date IS NOT NULL
910: and last_payment_number IS NOT NULL
911: and currency in ( SELECT CURRENCY FROM
918: SELECT last_payment_amount, last_payment_date,
919: last_payment_number, currency
920: INTO l_last_payment_amount, l_last_payment_date,
921: l_last_payment_number, l_last_payment_currency
922: FROM AR_TRX_BAL_SUMMARY
923: where cust_account_id = p_cust_account_id
924: and site_use_id = p_site_use_id
925: and last_payment_date IS NOT NULL
926: and last_payment_number IS NOT NULL
927: and currency in ( SELECT CURRENCY FROM
928: ar_cmgt_curr_usage_gt
929: WHERE nvl(credit_request_id,p_credit_request_id) = p_credit_request_id)
930: and last_payment_date = ( select max(last_payment_date) from
931: ar_trx_bal_summary
932: where cust_account_id = p_cust_account_id
933: and site_use_id = p_site_use_id
934: and last_payment_date IS NOT NULL
935: and last_payment_number IS NOT NULL
5186: l_limit_currency,sysdate,
5187: l_exchange_rate_type,
5188: SUM(nvl(op_invoices_value,0) - nvl(past_due_inv_value,0))) current_invoice_value,
5189: SUM(nvl(op_invoices_count,0) - nvl(past_due_inv_inst_count,0)) current_invoice_count
5190: FROM AR_TRX_BAL_SUMMARY
5191: WHERE cust_account_id in (select cust_account_id
5192: FROM hz_cust_accounts
5193: WHERE party_id in
5194: ( SELECT child_id
5308: l_limit_currency,sysdate,
5309: l_exchange_rate_type,
5310: SUM(nvl(op_invoices_value,0) - nvl(past_due_inv_value,0))) current_invoice_value,
5311: SUM(nvl(op_invoices_count,0) - nvl(past_due_inv_inst_count,0)) current_invoice_count
5312: FROM AR_TRX_BAL_SUMMARY
5313: WHERE org_id = decode(l_global_exposure_flag,'Y', org_id, 'N',
5314: decode(p_org_id,null, org_id, p_org_id), null,
5315: decode(p_org_id,null, org_id, p_org_id))
5316: and cust_account_id = p_cust_account_id
5412: l_limit_currency,sysdate,
5413: l_exchange_rate_type,
5414: SUM(nvl(op_invoices_value,0) - nvl(past_due_inv_value,0))) current_invoice_value,
5415: SUM(nvl(op_invoices_count,0) - nvl(past_due_inv_inst_count,0)) current_invoice_count
5416: FROM AR_TRX_BAL_SUMMARY
5417: WHERE cust_account_id = p_cust_account_id
5418: and CURRENCY IN ( SELECT CURRENCY FROM
5419: ar_cmgt_curr_usage_gt
5420: WHERE nvl(credit_request_id,p_credit_request_id) = p_credit_request_id)
5440: (SUM(nvl(OP_INVOICES_VALUE,0) + nvl(OP_DEBIT_MEMOS_VALUE,0) +
5441: nvl(OP_DEPOSITS_VALUE,0) + nvl(OP_BILLS_RECEIVABLES_VALUE,0) +
5442: nvl(OP_CHARGEBACK_VALUE,0) + nvl(OP_CREDIT_MEMOS_VALUE,0)
5443: - nvl(BEST_CURRENT_RECEIVABLES,0))*l_certified_dso_days)) delinquent_dso
5444: FROM ar_trx_bal_summary
5445: WHERE cust_account_id in (select cust_account_id
5446: FROM hz_cust_accounts
5447: WHERE party_id in
5448: ( SELECT child_id
5488: (SUM(nvl(OP_INVOICES_VALUE,0) + nvl(OP_DEBIT_MEMOS_VALUE,0) +
5489: nvl(OP_DEPOSITS_VALUE,0) + nvl(OP_BILLS_RECEIVABLES_VALUE,0) +
5490: nvl(OP_CHARGEBACK_VALUE,0) + nvl(OP_CREDIT_MEMOS_VALUE,0)
5491: - nvl(BEST_CURRENT_RECEIVABLES,0))*l_certified_dso_days)) delinquent_dso
5492: FROM ar_trx_bal_summary
5493: WHERE cust_account_id = p_cust_account_id
5494: and org_id = decode(l_global_exposure_flag,'Y', org_id, 'N',
5495: decode(p_org_id,null, org_id, p_org_id), null,
5496: decode(p_org_id,null, org_id, p_org_id))
5516: (SUM(nvl(OP_INVOICES_VALUE,0) + nvl(OP_DEBIT_MEMOS_VALUE,0) +
5517: nvl(OP_DEPOSITS_VALUE,0) + nvl(OP_BILLS_RECEIVABLES_VALUE,0) +
5518: nvl(OP_CHARGEBACK_VALUE,0) + nvl(OP_CREDIT_MEMOS_VALUE,0)
5519: - nvl(BEST_CURRENT_RECEIVABLES,0))*l_certified_dso_days)) delinquent_dso
5520: FROM ar_trx_bal_summary
5521: WHERE cust_account_id = p_cust_account_id
5522: and site_use_id = p_cust_acct_site_id
5523: and CURRENCY IN ( SELECT CURRENCY FROM
5524: ar_cmgt_curr_usage_gt
5788: ELSE
5789: -- populate temp table with all currency. may not be a good soulution
5790: -- to take this approach. Would be better to have another cursor.
5791: INSERT INTO ar_cmgt_curr_usage_gt(currency)
5792: ( select distinct currency from ar_trx_bal_summary);
5793: IF pg_wf_debug = 'Y'
5794: THEN
5795: ar_cmgt_util.wf_debug(l_tag,
5796: ' ALL currencies from ar_trx_bal_summary');
5792: ( select distinct currency from ar_trx_bal_summary);
5793: IF pg_wf_debug = 'Y'
5794: THEN
5795: ar_cmgt_util.wf_debug(l_tag,
5796: ' ALL currencies from ar_trx_bal_summary');
5797: END IF;
5798: END IF;
5799:
5800: p_limit_currency := l_limit_currency;
6101: END LOOP;
6102: END IF;
6103: EXCEPTION
6104: WHEN OTHERS THEN
6105: p_error_msg := 'Error While Getting Data from AR_TRX_BAL_SUMMARY, Probably exchange rate '
6106: ||'is not set correctly '||'Sql Error:'||sqlerrm;
6107: p_resultout := 1;
6108: ar_cmgt_util.wf_debug(p_case_folder_id, p_error_msg || '2');
6109: return;