1 PACKAGE BODY ICX_AP_INVOICES_PKG AS
2 /* $Header: ICXAPINB.pls 115.0 99/08/09 17:21:48 porting ship $ */
3
4 -----------------------------------------------------------------------
5 -- Function get_po_number_list returns all the PO Numbers matched to
6 -- this invoice (comma delimited) or NULL if not matched.
7 --
8 FUNCTION get_po_number_list(l_invoice_id IN NUMBER)
9 RETURN VARCHAR2
10 IS
11 po_number VARCHAR2(20);
12 po_number_list VARCHAR2(2000) := NULL;
13
14 ---------------------------------------------------------------------
15 -- Declare cursor to retrieve the PO number
16 --
17 CURSOR po_number_cursor IS
18 SELECT DISTINCT(ph.segment1)
19 FROM ap_invoice_distributions aid,
20 po_distributions_ap_v pd,
21 po_headers ph
22 WHERE aid.invoice_id = l_invoice_id
23 AND aid.po_distribution_id = pd.po_distribution_id
24 AND pd.po_header_id = ph.po_header_id;
25
26 BEGIN
27
28 OPEN po_number_cursor;
29
30 LOOP
31 FETCH po_number_cursor INTO po_number;
32 EXIT WHEN po_number_cursor%NOTFOUND;
33
34 IF (po_number_list IS NOT NULL) THEN
35 po_number_list := po_number_list || ', ';
36 END IF;
37
38 po_number_list := po_number_list || po_number;
39
40 END LOOP;
41
42 CLOSE po_number_cursor;
43
44 RETURN(po_number_list);
45
46 END get_po_number_list;
47
48 -----------------------------------------------------------------------
49 -- Function get_amount_withheld returns the AWT withheld amount on
50 -- an invoice.
51 --
52 FUNCTION get_amount_withheld(l_invoice_id IN NUMBER)
53 RETURN NUMBER
54 IS
55 amount_withheld NUMBER := 0;
56 BEGIN
57 select (0 - sum(nvl(amount,0)))
58 into amount_withheld
59 from ap_invoice_distributions
60 where invoice_id = l_invoice_id
61 and line_type_lookup_code = 'AWT';
62
63 return(amount_withheld);
64
65 END get_amount_withheld;
66
67 END ICX_AP_INVOICES_PKG;