1 PACKAGE BODY fv_ap_match_pkg AS
2 -- $Header: FVAPPOMB.pls 120.0 2006/01/04 19:49:09 ksriniva noship $
3 g_module_name VARCHAR2(100) := 'fv.plsql.FV_AP_MATCH_PKG.';
4
5 procedure get_default_qty(p_line_location_id in number,
6 p_qty_ord in number,
7 p_qty_received in number,
8 p_qty_billed in number,
9 p_qty_cancelled in number,
10 p_qty_accepted in number,
11 p_qty_outstanding out nocopy number) is
12 l_module_name VARCHAR2(200) := g_module_name || 'get_default_qty';
13 l_errbuf VARCHAR2(1024);
14 v_rec_flag varchar2(1);
15 v_ins_flag varchar2(1);
16
17 begin
18
19 /* find out two_way , three_way ,four way matching */
20
21 select receipt_required_flag,inspection_required_flag
22 into v_rec_flag ,v_ins_flag
23 from po_line_locations
24 where line_location_id = p_line_location_id;
25
26
27 if v_rec_flag = 'Y' and v_ins_flag = 'Y' then
28 /** four way matching */
29 p_qty_outstanding := p_qty_accepted - p_qty_cancelled - p_qty_billed;
30 /** three way matching */
31 elsif v_rec_flag = 'Y' and v_ins_flag = 'N' then
32 p_qty_outstanding := p_qty_received - p_qty_cancelled - p_qty_billed;
33 else
34 /** two way matching */
35 p_qty_outstanding := p_qty_ord - p_qty_cancelled - p_qty_billed;
36 End if;
37
38 /* return 0 if qty is overbiled ,AP will handle this scenario */
39 if p_qty_outstanding < 0 then
40 p_qty_outstanding := 0;
41 End if;
42 EXCEPTION
43 WHEN NO_DATA_FOUND THEN
44 p_qty_outstanding := NULL;
45 WHEN OTHERS THEN
46 l_errbuf := SQLERRM;
47 FV_UTILITY.LOG_MESG(FND_LOG.LEVEL_UNEXPECTED, l_module_name||'.final_exception',l_errbuf);
48 RAISE;
49 End get_default_qty;
50 -------------------------------------------------------------------------------
51 --This procedure is used to check the tolerance of a purchase order amount
52 --when an invoice line amount is matched with the purchase order.
53 --The tolerance percentage is defined on the Define Federal Options form.
54 -------------------------------------------------------------------------------
55 PROCEDURE shipment_tolerance(p_diff_amount IN NUMBER,
56 p_po_shipment_amount IN NUMBER,
57 p_tolerance_check_status OUT NOCOPY VARCHAR2) IS
58
59
60 l_module_name VARCHAR2(200) := g_module_name || 'shipment_tolerance';
61 l_errbuf VARCHAR2(1024);
62 l_payables_tolerance_flag VARCHAR2(1);
63 l_payables_tolerance NUMBER;
64 l_billed_amount NUMBER;
65 l_total_amount NUMBER;
66 l_remain_amount NUMBER;
67
68 BEGIN
69
70 p_tolerance_check_status := 'Y';
71
72 SELECT NVL(payables_tolerance_flag, 'N'), payables_tolerance
73 INTO l_payables_tolerance_flag, l_payables_tolerance
74 FROM fv_operating_units;
75
76 IF l_payables_tolerance_flag = 'Y' THEN
77 IF p_diff_amount >
78 ((p_po_shipment_amount * l_payables_tolerance) / 100)
79 THEN
80 p_tolerance_check_status := 'N';
81 END IF;
82 END IF;
83
84 EXCEPTION
85
86 WHEN NO_DATA_FOUND THEN
87 -- No OPTION defined for this org so pass the check
88 NULL;
89
90 WHEN OTHERS THEN
91 p_tolerance_check_status := 'N';
92 l_errbuf := SQLERRM;
93 FV_UTILITY.LOG_MESG(FND_LOG.LEVEL_UNEXPECTED, l_module_name||'.final_exception',l_errbuf);
94
95 END shipment_tolerance;
96 -----------------------------------------------------------------------
97 End fv_ap_match_pkg;