596: l_nao_flag ra_cust_trx_types.natural_application_only_flag%TYPE;
597: l_creation_sign ra_cust_trx_types.creation_sign%TYPE;
598:
599: l_acctd_app_amount_to
600: ar_receivable_applications.acctd_amount_applied_to%TYPE;
601: l_acctd_app_amount_from
602: ar_receivable_applications.acctd_amount_applied_from%TYPE;
603:
604: l_ae_doc_rec ae_doc_rec_type;
598:
599: l_acctd_app_amount_to
600: ar_receivable_applications.acctd_amount_applied_to%TYPE;
601: l_acctd_app_amount_from
602: ar_receivable_applications.acctd_amount_applied_from%TYPE;
603:
604: l_ae_doc_rec ae_doc_rec_type;
605:
606: l_app_id ar_receivable_applications.receivable_application_id%TYPE;
602: ar_receivable_applications.acctd_amount_applied_from%TYPE;
603:
604: l_ae_doc_rec ae_doc_rec_type;
605:
606: l_app_id ar_receivable_applications.receivable_application_id%TYPE;
607:
608:
609: -- Following two parametes and the currency cursor is introduced By
610: -- RAM-C (ORASHID)
620:
621:
622: -- Define cursor for applications:
623:
624: CURSOR ar_receivable_applications_C (
625: p_cr_id ar_cash_receipts.cash_receipt_id%TYPE
626: ) IS
627: SELECT *
628: FROM ar_receivable_applications
624: CURSOR ar_receivable_applications_C (
625: p_cr_id ar_cash_receipts.cash_receipt_id%TYPE
626: ) IS
627: SELECT *
628: FROM ar_receivable_applications
629: WHERE cash_receipt_id = p_cr_id
630: AND status = 'APP'
631: AND reversal_gl_date IS NULL;
632:
644: l_max_dates.max_ra_gl_date := p_confirm_gl_date;
645:
646: -- process every application record for the given cash receipt:
647:
648: FOR l_ra_rec IN ar_receivable_applications_C(p_cr_rec.cash_receipt_id)
649: LOOP
650:
651: -- Bug 768935: initially set l_acctd_app_amount_from to NULL,
652: -- let calc_acctd_amount calculate.
769: -- Update receivable applications record. Use the return values
770: -- of the previous function call to fill the line, tax, freight,
771: -- and charges applied columns.
772:
773: UPDATE ar_receivable_applications
774: SET confirmed_flag = 'Y',
775: postable = 'Y',
776: gl_date = l_max_dates.max_ra_gl_date,
777: apply_date = l_max_dates.max_ra_apply_date,
866: l_ra_rec.receivable_application_id);
867: END LOOP;
868:
869:
870: -- update UNAPP record of the cash receipt in ar_receivable_applications:
871:
872: modify_update_ra_rec( p_cr_rec.cash_receipt_id,
873: p_cr_rec.amount,
874: p_acctd_amount,
883: l_max_dates.max_gl_date);
884:
885:
886: -- create matching UNAPP records for APP records in
887: -- ar_receivable_applications (negative amounts).
888: -- as part of 11.5 changes, the APP id also needs to be passed
889: -- as UNAPP records are paired with their APP records
890:
891: create_matching_unapp_records(p_cr_rec.cash_receipt_id, l_app_id);
952: ) IS
953:
954: -- Define cursor for applications:
955:
956: CURSOR ar_receivable_applications_C (
957: p_cr_id ar_cash_receipts.cash_receipt_id%TYPE
958: ) IS
959: SELECT *
960: FROM ar_receivable_applications
956: CURSOR ar_receivable_applications_C (
957: p_cr_id ar_cash_receipts.cash_receipt_id%TYPE
958: ) IS
959: SELECT *
960: FROM ar_receivable_applications
961: WHERE cash_receipt_id = p_cr_id
962: AND status = 'APP'
963: AND reversal_gl_date IS NULL;
964:
965: BEGIN
966:
967: -- process every application record for the given cash receipt:
968:
969: FOR l_app_rec IN ar_receivable_applications_C(p_cr_rec.cash_receipt_id)
970: LOOP
971:
972: -- Update invoice payment schedule to which this application record
973: -- is applied. This step basically reverses the application of the
982:
983: END LOOP;
984:
985:
986: -- create reversing records in ar_receivable_applications
987:
988: reverse_ra_recs( p_cr_rec,
989: p_confirm_gl_date,
990: p_confirm_date);
1265: | modify_update_ra_rec |
1266: | |
1267: | DESCRIPTION |
1268: | This function updates the original UNAPP record for the cash receipt |
1269: | in ar_receivable_applications. |
1270: | It also determines the payment schedule id for the receipt, which is |
1271: | returned for future use. |
1272: | |
1273: | SCOPE - PRIVATE |
1301: p_confirm_gl_date IN DATE,
1302: p_confirm_date IN DATE
1303: ) IS
1304:
1305: l_receivable_application_id ar_receivable_applications.receivable_application_id%TYPE;
1306: l_ae_doc_rec ae_doc_rec_type;
1307:
1308: BEGIN
1309:
1313: --moved where clause from update to select
1314:
1315: SELECT app.receivable_application_id
1316: INTO l_receivable_application_id
1317: FROM ar_receivable_applications app
1318: WHERE app.cash_receipt_id = p_cr_id
1319: AND app.status = 'UNAPP'
1320: AND app.confirmed_flag = 'N'
1321: AND app.reversal_gl_date IS NULL
1324: -- update record
1325:
1326: arp_standard.debug('arp_confirmation.modify_update_ra_rec()+');
1327:
1328: UPDATE ar_receivable_applications
1329: SET gl_date = p_confirm_gl_date,
1330: apply_date = p_confirm_date,
1331: amount_applied = p_amount_applied,
1332: acctd_amount_applied_from = p_acctd_amount_applied,
1405: +===========================================================================*/
1406:
1407: PROCEDURE create_matching_unapp_records(
1408: p_cr_id IN ar_cash_receipts.cash_receipt_id%TYPE,
1409: p_app_id IN ar_receivable_applications.receivable_application_id%TYPE
1410: ) IS
1411:
1412: l_unapp_id ar_receivable_applications.receivable_application_id%TYPE;
1413: l_ae_doc_rec ae_doc_rec_type;
1408: p_cr_id IN ar_cash_receipts.cash_receipt_id%TYPE,
1409: p_app_id IN ar_receivable_applications.receivable_application_id%TYPE
1410: ) IS
1411:
1412: l_unapp_id ar_receivable_applications.receivable_application_id%TYPE;
1413: l_ae_doc_rec ae_doc_rec_type;
1414:
1415: /* Bug Fix 1640890. Fix invloves creating the following cursor
1416: and inserting the UNAPP record and calling the accounting package
1436: app.cash_receipt_id app_cr_id,
1437: app.comments app_comments,
1438: app.days_late app_days_late,
1439: app.org_id app_org_id
1440: FROM ar_receivable_applications app,
1441: ar_receivable_applications unapp
1442: WHERE app.cash_receipt_id = p_cr_id
1443: AND app.status||'' = 'APP'
1444: AND app.reversal_gl_date IS NULL
1437: app.comments app_comments,
1438: app.days_late app_days_late,
1439: app.org_id app_org_id
1440: FROM ar_receivable_applications app,
1441: ar_receivable_applications unapp
1442: WHERE app.cash_receipt_id = p_cr_id
1443: AND app.status||'' = 'APP'
1444: AND app.reversal_gl_date IS NULL
1445: AND app.cash_receipt_id = unapp.cash_receipt_id
1456: --Retrieve sequence id for receivable application id of UNAPP record
1457: --Note as this procedure creates a single UNAPP record hence this kind
1458: --of select from dual for sequence id is done
1459:
1460: SELECT ar_receivable_applications_s.nextval
1461: INTO l_unapp_id
1462: FROM dual;
1463:
1464: --Insert negative UNAPP record for confirmed APP record
1461: INTO l_unapp_id
1462: FROM dual;
1463:
1464: --Insert negative UNAPP record for confirmed APP record
1465: INSERT INTO ar_receivable_applications (
1466: receivable_application_id,
1467: acctd_amount_applied_from,
1468: amount_applied,
1469: application_rule,
1908:
1909:
1910: PROCEDURE reverse_application_to_ps(
1911: p_ra_id IN
1912: ar_receivable_applications.receivable_application_id%TYPE,
1913: p_confirm_gl_date IN DATE,
1914: p_confirm_date IN DATE,
1915: p_batch_id IN
1916: ar_payment_schedules.selected_for_receipt_batch_id%TYPE
1974: FND_GLOBAL.user_id,
1975: trunc(sysdate),
1976: FND_GLOBAL.user_id
1977: FROM
1978: ar_receivable_applications ra,
1979: ar_payment_schedules ps2,
1980: ar_adjustments adj2,
1981: ar_receivable_applications ra2
1982: WHERE
1977: FROM
1978: ar_receivable_applications ra,
1979: ar_payment_schedules ps2,
1980: ar_adjustments adj2,
1981: ar_receivable_applications ra2
1982: WHERE
1983: ra.receivable_application_id = p_ra_id
1984: AND ra.applied_payment_schedule_id = ps2.payment_schedule_id
1985: AND ps2.payment_schedule_id =ps.payment_schedule_id
2007: ra.receivables_charges_applied)
2008: WHERE ps.payment_schedule_id in ( SELECT
2009: ra3.applied_payment_schedule_id
2010: FROM
2011: ar_receivable_applications ra3
2012: WHERE
2013: ra3.receivable_application_id =
2014: p_ra_id)
2015: RETURNING ps.payment_schedule_id
2071: p_confirm_date IN DATE
2072: ) IS
2073: CURSOR get_app IS
2074: SELECT app.receivable_application_id old_app_id
2075: FROM ar_receivable_applications app
2076: WHERE app.cash_receipt_id = p_cr_rec.cash_receipt_id
2077: AND app.reversal_gl_date IS NULL
2078: ORDER BY decode(app.status,
2079: 'APP' ,1,
2081: 'UNID' ,3,
2082: 'UNAPP',4); --This ordering is required for pairing UNAPP with APP record
2083:
2084: l_app_rec get_app%ROWTYPE;
2085: l_new_app_id ar_receivable_applications.receivable_application_id%TYPE;
2086: l_ae_doc_rec ae_doc_rec_type;
2087:
2088: n_new_con_data new_con_data; /* to store values retrieved from bulk collect */
2089:
2093:
2094: FOR l_app_rec IN get_app LOOP
2095:
2096: --retrieve sequence
2097: SELECT ar_receivable_applications_s.nextval
2098: INTO l_new_app_id
2099: FROM dual;
2100:
2101: --Create actual reversing apps
2098: INTO l_new_app_id
2099: FROM dual;
2100:
2101: --Create actual reversing apps
2102: INSERT INTO ar_receivable_applications
2103: (receivable_application_id,
2104: acctd_amount_applied_from,
2105: amount_applied,
2106: application_rule,
2232: attribute15,
2233: ussgl_transaction_code_context,
2234: p_confirm_gl_date,
2235: org_id
2236: FROM ar_receivable_applications
2237: WHERE receivable_application_id = l_app_rec.old_app_id;
2238:
2239: -- Call mrc engine to create the data in mc tables
2240: ar_mrc_engine3.reverse_ra_recs(
2270: -- create new unconfirmed records from old confirmed records:
2271:
2272: SELECT
2273: receivable_application_id,
2274: ar_receivable_applications_s.nextval,
2275: acctd_amount_applied_from,
2276: amount_applied,
2277: DECODE(status,
2278: 'UNAPP', '40.0',
2428: n_new_con_data.l_attribute15,
2429: n_new_con_data.l_ussgl_transaction_code_cntxt,
2430: n_new_con_data.l_reversal_gl_date,
2431: n_new_con_data.l_org_id
2432: FROM ar_receivable_applications
2433: WHERE cash_receipt_id = p_cr_rec.cash_receipt_id
2434: AND ( status = 'APP'
2435: OR
2436: ( status = 'UNAPP'
2442:
2443: -- MRC trigger replacement.. Do a bulk collect and pass
2444:
2445: FORALL i IN 1..n_new_con_data.l_reversal_gl_date.COUNT
2446: INSERT INTO ar_receivable_applications
2447: (receivable_application_id,
2448: acctd_amount_applied_from,
2449: amount_applied,
2450: application_rule,
2589: --records are unconfirmed
2590:
2591: -- mark all old records as reversed
2592:
2593: UPDATE ar_receivable_applications
2594: SET reversal_gl_date = p_confirm_gl_date,
2595: display = 'N',
2596: last_update_date = TRUNC(SYSDATE),
2597: last_updated_by = FND_GLOBAL.user_id