0% found this document useful (0 votes)
73 views3 pages

Receipt Auto Application - in Process

This procedure automatically applies receipts to invoices in an accounts receivable system. It begins by initializing variables and checking for any incomplete invoices. Then it identifies all unapplied receipts for the operating unit using two cursors, one for unapplied receipts and one for unapplied invoices/credits. Finally, it applies the receipts to invoices in FIFO (first in, first out) order and logs any receipts still unapplied.

Uploaded by

mohammad zubair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views3 pages

Receipt Auto Application - in Process

This procedure automatically applies receipts to invoices in an accounts receivable system. It begins by initializing variables and checking for any incomplete invoices. Then it identifies all unapplied receipts for the operating unit using two cursors, one for unapplied receipts and one for unapplied invoices/credits. Finally, it applies the receipts to invoices in FIFO (first in, first out) order and logs any receipts still unapplied.

Uploaded by

mohammad zubair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

CREATE OR REPLACE PROCEDURE APPS.

MCN_AR_AUTO_APPLY_API
(
p_org_id NUMBER,
p_cust_id VARCHAR2,
p_period VARCHAR2,
p_resp_id NUMBER,
p_cust_type varchar2
)
AS
--/*-------------------------------------
-- Variables --
-----------------------------------------
-- Local
v_line_tax_amt NUMBER(15, 2);
v_exhange_rate NUMBER(15, 2);
v_currency_code VARCHAR2(25);
v_total_line_amt NUMBER(15, 2);
v_amt_applied NUMBER(15, 2);
v_amt_chk NUMBER(15, 2);
v_amt_chk2 NUMBER(15, 4);
v_rec_avl_amt NUMBER(15, 2);
v_apply_date DATE;
v_period_end_date date ;--VARCHAR2(25);
v_customer_no VARCHAR2(30);
-- API Parameters
l_return_status VARCHAR2(1);
l_msg_count NUMBER(15);
l_msg_data VARCHAR2(240);
l_count NUMBER(15);
l_msg_data_out VARCHAR2(240);
l_mesg VARCHAR2(240);
p_count NUMBER(15);

CURSOR unapp_receipts is
/*-----------------------------------------------------
-- Cursor for UnApplied Receipts --
-----------------------------------------------------*/
SELECT cash_receipt_id,
customer_id,
org_id,
receipt_date,
receipt_number,
sum(amount) amount
from (
/*** This portion picks all unapplied AR Receipts ***/
SELECT acra.cash_receipt_id cash_receipt_id,
acra.pay_from_customer customer_id,
acra.org_id org_id,
acra.receipt_date receipt_date,
acra.receipt_number receipt_number,
acra.amount amount
FROM ar_cash_receipts_all acra,
ar_cash_receipt_history_all acrha
WHERE 1=1
AND acra.cash_receipt_id = acrha.cash_receipt_id
AND acra.org_id = NVL (p_org_id, acra.org_id)
AND TO_CHAR (acra.pay_from_customer) = NVL (p_cust_id, acra.pay_from_customer)
--AND acra.CASH_RECEIPT_ID = 2788856
AND acra.status = 'UNAPP'
AND acrha.status = 'CLEARED'
union all
/*** This portion picks all unapplied AR Receipt Applications ***/
select acra.cash_receipt_id cash_receipt_id,
acra.pay_from_customer customer_id,
acra.org_id org_id,
acra.receipt_date receipt_date,
acra.receipt_number receipt_number,
araa.amount_applied*-1 amount
from ar_receivable_applications_all araa,
ar_cash_receipts_all acra,
ar_cash_receipt_history_all acrha
where 1=1
AND acra.cash_receipt_id = acrha.cash_receipt_id
--AND acra.CASH_RECEIPT_ID = 2788856
and araa.CASH_RECEIPT_ID = acra.CASH_RECEIPT_ID
and acra.status = 'UNAPP'
AND acrha.status = 'CLEARED'
and araa.display = 'Y'
AND acra.org_id = NVL (p_org_id, acra.org_id)
AND TO_CHAR (acra.pay_from_customer) = NVL (p_cust_id, acra.pay_from_customer)
)
group by cash_receipt_id,
customer_id,
org_id,
receipt_date,
receipt_number
;

/*--------------------------------------------------------------
-- Cursor for Unapplied Invoices, Debit Memos, Credit Memos --
--------------------------------------------------------------*/
CURSOR unapp_transactions is
SELECT rcta.customer_trx_id,
rcta.bill_to_customer_id,
rcta.org_id,
apsa.gl_date gl_date,
rcta.trx_number,
NVL (SUM (rctla.extended_amount), 0) line_amount,
( (SELECT NVL (SUM (rctla.extended_amount), 0)
FROM ra_customer_trx_lines_all rctla
WHERE UPPER (rctla.line_type) = 'LINE'
AND rctla.customer_trx_id = rcta.customer_trx_id)
+ (SELECT NVL (SUM (rctla.extended_amount), 0)
FROM ra_customer_trx_lines_all rctla
WHERE UPPER (rctla.line_type) = 'TAX'
AND rctla.customer_trx_id = rcta.customer_trx_id)
+ (SELECT NVL (SUM (amount), 0)
FROM ar_adjustments_all aa
WHERE 1 = 1
AND aa.status = 'A'
AND aa.customer_trx_id = rcta.customer_trx_id)
- (SELECT NVL (SUM (araa.amount_applied), 0)
FROM ar_receivable_applications_all araa
WHERE UPPER (araa.display) = 'Y'
AND araa.applied_customer_trx_id = rcta.customer_trx_id)
) line_due_amount
FROM ra_customer_trx_all rcta,
ar_payment_schedules_all apsa,
ra_customer_trx_lines_all rctla,
ra_cust_trx_types_all rctta
WHERE 1=1
AND rcta.customer_trx_id = apsa.customer_trx_id
AND rcta.customer_trx_id = rctla.customer_trx_id
AND rctta.cust_trx_type_id = rcta.cust_trx_type_id
AND rctta.org_id = rcta.org_id
AND rcta.org_id = p_org_id
AND rcta.bill_to_customer_id = nvl(p_cust_id,rcta.bill_to_customer_id)
AND UPPER (rcta.complete_flag) = 'Y'
AND UPPER (rctla.line_type) = 'LINE'
AND apsa.amount_due_remaining <> 0
AND rctta.TYPE IN ('INV', 'DM', 'CM')
GROUP BY rcta.customer_trx_id,
rcta.bill_to_customer_id,
rcta.org_id,
apsa.gl_date,
rcta.trx_number,
rctta.TYPE
ORDER BY TRUNC (apsa.gl_date)
;

BEGIN

/*
This API will do the follows:

1) To-Do - Identify if there are any incomplete invoices in the passed


operating unit. If cases exist, API will not proceed further and the concurrent
request will show the cases in the log.
2) To-Do - Identify all unappied receipts of all then operating unit and apply
it to their respective invoices in a FIFO manner.
3) To-Do - Show log of Receipts that are still unapplied

*/

/* Initialization */

fnd_global.apps_initialize(18981, p_resp_id, 222);


arp_standard.enable_debug;

v_line_tax_amt := 1;

END;
/

You might also like