[Home] [Help]
1: PACKAGE BODY ARP_PROCESS_WRITEOFF AS
2: /* $Header: ARPWRTFB.pls 120.13 2011/03/05 20:24:54 naneja ship $ */
3: /*========================================================================
4: | PRIVATE PROCEDURE submit_report
5: |
6: | DESCRIPTION
7: | This procedure submits the receipt write-off report.
8: |
9: | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
10: | arp_process_writeoff.create_receipt_writeoff()
11: |
12: | CALLS PROCEDURES/FUNCTIONS (local to this package body)
13: | NONE
14: | PARAMETERS
39: l_org_id NUMBER;
40:
41: BEGIN
42: IF PG_DEBUG in ('Y', 'C') THEN
43: arp_util.debug('arp_process_writeoff.submit_report()+');
44: END IF;
45:
46: l_request_id := fnd_global.conc_request_id;
47:
170: , argument99 => ''
171: , argument100 => '');
172: END IF;
173: IF PG_DEBUG in ('Y', 'C') THEN
174: arp_util.debug('arp_process_writeoff.submit_report()-');
175: END IF;
176:
177: EXCEPTION
178: WHEN OTHERS THEN
176:
177: EXCEPTION
178: WHEN OTHERS THEN
179: IF PG_DEBUG in ('Y', 'C') THEN
180: arp_util.debug('arp_process_writeoff.submit_report() '||SQLERRM);
181: END IF;
182:
183: END submit_report;
184: /*========================================================================
191: | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
192: | NONE
193: |
194: | CALLS PROCEDURES/FUNCTIONS (local to this package body)
195: | arp_process_writeoff.unapplied_amount()
196: |
197: | PARAMETERS
198: | p_receipt_currency_code IN Receipt currency code
199: | p_unapp_amount IN Unapplied amount
350: group by acr.cash_receipt_id,acr.receipt_number,acr.amount,
351: acr.exchange_rate,crh.batch_id,acr.org_id;
352:
353: BEGIN
354: arp_util.debug('arp_process_writeoff.creare_receipt_writeoff()+');
355:
356: arp_util.debug('p_receipt curreny '||p_receipt_currency_code);
357: arp_util.debug('p_unapp_amount '||p_unapp_amount);
358: arp_util.debug('p_unapp_amount_percent '||p_unapp_amount_percent);
543:
544: IF l_actual_writeoff_amount <> 0 THEN
545:
546: /*5444407*/
547: IF NOT (arp_process_writeoff.gt_rec_wrt_off_type.EXISTS(writeoff_rec.batch_id)) AND
548: writeoff_rec.batch_id is not null THEN
549: arp_process_writeoff.gt_rec_wrt_off_type(writeoff_rec.batch_id).batch_id:=writeoff_rec.batch_id;
550: END IF;
551:
545:
546: /*5444407*/
547: IF NOT (arp_process_writeoff.gt_rec_wrt_off_type.EXISTS(writeoff_rec.batch_id)) AND
548: writeoff_rec.batch_id is not null THEN
549: arp_process_writeoff.gt_rec_wrt_off_type(writeoff_rec.batch_id).batch_id:=writeoff_rec.batch_id;
550: END IF;
551:
552: --Calling Activity_application Procedure
553: ar_receipt_api_pub.activity_application(
579:
580: IF (l_return_status <> FND_API.G_RET_STS_SUCCESS )
581: THEN
582:
583: arp_util.debug('arp_process_writeoff - Failed for Receipt : '||
584: writeoff_rec.receipt_number );
585: arp_util.debug('p_return_status : ' || l_return_status);
586: arp_util.debug('p_msg_count : ' || l_msg_count);
587: arp_util.debug('p_msg_data : ' || l_msg_data);
610:
611: END LOOP;
612:
613: /*5444407*/
614: IF arp_process_writeoff.gt_rec_wrt_off_type.COUNT <> 0 THEN
615: l_cnt:=arp_process_writeoff.gt_rec_wrt_off_type.COUNT;
616: arp_util.debug(' Count of records in PL/SQL table :' || to_char(l_cnt));
617: i := arp_process_writeoff.gt_rec_wrt_off_type.FIRST;
618: WHILE i IS NOT NULL LOOP
611: END LOOP;
612:
613: /*5444407*/
614: IF arp_process_writeoff.gt_rec_wrt_off_type.COUNT <> 0 THEN
615: l_cnt:=arp_process_writeoff.gt_rec_wrt_off_type.COUNT;
616: arp_util.debug(' Count of records in PL/SQL table :' || to_char(l_cnt));
617: i := arp_process_writeoff.gt_rec_wrt_off_type.FIRST;
618: WHILE i IS NOT NULL LOOP
619: l_batch_id:=arp_process_writeoff.gt_rec_wrt_off_type(i).batch_id;
613: /*5444407*/
614: IF arp_process_writeoff.gt_rec_wrt_off_type.COUNT <> 0 THEN
615: l_cnt:=arp_process_writeoff.gt_rec_wrt_off_type.COUNT;
616: arp_util.debug(' Count of records in PL/SQL table :' || to_char(l_cnt));
617: i := arp_process_writeoff.gt_rec_wrt_off_type.FIRST;
618: WHILE i IS NOT NULL LOOP
619: l_batch_id:=arp_process_writeoff.gt_rec_wrt_off_type(i).batch_id;
620: arp_rw_batches_check_pkg.update_batch_status(l_batch_id);
621: i:=arp_process_writeoff.gt_rec_wrt_off_type.NEXT(i);
615: l_cnt:=arp_process_writeoff.gt_rec_wrt_off_type.COUNT;
616: arp_util.debug(' Count of records in PL/SQL table :' || to_char(l_cnt));
617: i := arp_process_writeoff.gt_rec_wrt_off_type.FIRST;
618: WHILE i IS NOT NULL LOOP
619: l_batch_id:=arp_process_writeoff.gt_rec_wrt_off_type(i).batch_id;
620: arp_rw_batches_check_pkg.update_batch_status(l_batch_id);
621: i:=arp_process_writeoff.gt_rec_wrt_off_type.NEXT(i);
622: END LOOP;
623: END IF;
617: i := arp_process_writeoff.gt_rec_wrt_off_type.FIRST;
618: WHILE i IS NOT NULL LOOP
619: l_batch_id:=arp_process_writeoff.gt_rec_wrt_off_type(i).batch_id;
620: arp_rw_batches_check_pkg.update_batch_status(l_batch_id);
621: i:=arp_process_writeoff.gt_rec_wrt_off_type.NEXT(i);
622: END LOOP;
623: END IF;
624:
625: IF l_number_of_records_writtenoff > 0 THEN
628:
629: COMMIT;
630:
631: --for 1644863
632: arp_process_writeoff.submit_report(l_receipt_currency_code,l_apply_date,l_gl_date);
633: END IF;
634: END IF;
635: arp_util.debug('Total Number of Receipts written off :'||to_char(l_number_of_records_writtenoff));
636:
633: END IF;
634: END IF;
635: arp_util.debug('Total Number of Receipts written off :'||to_char(l_number_of_records_writtenoff));
636:
637: arp_util.debug('arp_process_writeoff.creare_receipt_writeoff()-');
638:
639: EXCEPTION
640: WHEN OTHERS THEN
641: arp_util.debug('EXCEPTION:arp_process_writeoff.cretre_receipt_writeoff()'||SQLERRM);
637: arp_util.debug('arp_process_writeoff.creare_receipt_writeoff()-');
638:
639: EXCEPTION
640: WHEN OTHERS THEN
641: arp_util.debug('EXCEPTION:arp_process_writeoff.cretre_receipt_writeoff()'||SQLERRM);
642: RAISE;
643:
644: END;
645: /*========================================================================
648: | DESCRIPTION
649: | This procedure calculates the unapplied amount for the given receipt
650: |
651: | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
652: | arp_process_writeoff.create_receipt_writeoff()
653: |
654: | CALLS PROCEDURES/FUNCTIONS (local to this package body)
655: | NONE
656: | PARAMETERS
699: l_amount_from NUMBER;
700: l_functional_currency ar_cash_receipts.currency_code%TYPE;
701:
702: BEGIN
703: arp_util.debug('arp_process_writeoff.unapplied_amount()+');
704: l_functional_currency := arp_global.functional_currency;
705:
706: IF nvl(p_request_id,0) = 0
707: THEN
802:
803: RETURN (l_unapp_amount_balance);
804: END IF;
805:
806: arp_util.debug('arp_process_writeoff.unapplied_amount()+');
807:
808: EXCEPTION
809: WHEN OTHERS THEN
810: arp_util.debug('EXCEPTION :arp_process_writeoff.unapplied_amount()'
806: arp_util.debug('arp_process_writeoff.unapplied_amount()+');
807:
808: EXCEPTION
809: WHEN OTHERS THEN
810: arp_util.debug('EXCEPTION :arp_process_writeoff.unapplied_amount()'
811: ||SQLERRM);
812: RETURN (0);
813: END;
814: /*========================================================================
817: | DESCRIPTION
818: | This procedure calculates the applied amount for the given receipt
819: |
820: | CALLED FROM PROCEDURES/FUNCTIONS (local to this package body)
821: | arp_process_writeoff.create_receipt_writeoff()
822: |
823: | CALLS PROCEDURES/FUNCTIONS (local to this package body)
824: | NONE
825: | PARAMETERS
846:
847: l_applied_amount NUMBER;
848:
849: BEGIN
850: arp_util.debug('arp_process_writeoff.applied_amount()+');
851:
852: IF NVL(p_request_id,0) <> 0
853: THEN
854: --Sum of the applied amount excluding the current one with the request id
888: ar_receivable_applications ra
889: WHERE ra.cash_receipt_id = p_cash_receipt_id;
890: END IF;
891:
892: arp_util.debug('arp_process_writeoff.applied_amount()-');
893: RETURN (l_applied_amount);
894:
895: EXCEPTION
896: WHEN OTHERS THEN
893: RETURN (l_applied_amount);
894:
895: EXCEPTION
896: WHEN OTHERS THEN
897: arp_util.debug('EXCEPTION :arp_process_writeoff.applied_amount()'||SQLERRM);
898: RETURN (0);
899:
900: END;
901:
929:
930: l_on_account_amount NUMBER;
931:
932: BEGIN
933: arp_util.debug('arp_process_writeoff.on_account_amount()+');
934:
935: SELECT
936: SUM(DECODE(ra.status,'ACC', NVL(ra.amount_applied, 0),
937: 0)) on_account_amount
939: FROM
940: ar_receivable_applications ra
941: WHERE ra.cash_receipt_id = p_cash_receipt_id;
942:
943: arp_util.debug('arp_process_writeoff.on_account_amount()-');
944:
945: RETURN (l_on_account_amount);
946: EXCEPTION
947: WHEN OTHERS THEN
944:
945: RETURN (l_on_account_amount);
946: EXCEPTION
947: WHEN OTHERS THEN
948: arp_util.debug('arp_process_writeoff.on_account_amount() '||SQLERRM);
949: RETURN (0);
950:
951: END;
952:
983: l_segment_value varchar2(25);
984:
985: BEGIN
986:
987: arp_util.debug('arp_process_writeoff.balancing_segment()+');
988:
989: SELECT fa_rx_flex_pkg.flex_sql(101,'GL#',chart_of_accounts_id,NULL,
990: 'SELECT','GL_BALANCING')
991: INTO l_balancing_segment
996: FROM gl_code_combinations where code_combination_id=:bind_ccid';
997:
998: EXECUTE IMMEDIATE l_str INTO l_segment_value USING p_code_combination_id;
999:
1000: arp_util.debug('arp_process_writeoff.balancing_segment()-');
1001:
1002: RETURN l_segment_value;
1003:
1004: EXCEPTION
1002: RETURN l_segment_value;
1003:
1004: EXCEPTION
1005: WHEN OTHERS THEN
1006: arp_util.debug('arp_process_writeoff.balancing_segment() '||SQLERRM);
1007: RETURN (NULL);
1008: END;
1009: BEGIN
1010: arp_global.init_global;
1007: RETURN (NULL);
1008: END;
1009: BEGIN
1010: arp_global.init_global;
1011: END ARP_PROCESS_WRITEOFF;