1 PACKAGE po_auto_line_process_pvt AUTHID CURRENT_USER AS
2 /* $Header: PO_AUTO_LINE_PROCESS_PVT.pls 120.1 2012/01/03 13:26:09 kkolukul ship $ */
3
4 /* ============================================================================
5 **
6 ** NAME
7 ** PO_AUTO_LINE_PROCESS_PVT.pls
8 **
9 ** DESCRIPTION
10 ** This package contains logic for AutoCreate Line processing stage
11 ** This API calls the subroutines to handle the derivation, defaulting,
12 ** validation and insert/update of the Lines.
13 **
14 ** During autocreate flow from BWC,BWC does not populate all columns of po_lines_interface including
15 ** some of the columns required for grpuping. So need to populate the interface
16 ** data before Grouping.
17 **
18 ** So Call flow modified to:
19 ** - Setup_interface_data
20 ** - Derive and Default the line
21 ** - Group lines in po_lines_interface
22 ** - Fetch data from po_lines_interface
23 ** - Validate Line
24 ** - Insert into po_lines_draft_all
25 **
26 ** The procedures of this package are called from PO_AUTOCREATE_MAINPROC_PVT.process_line
27 **
28 ** HISTORY
29 ** 06/11/09 bisdas Created
30 ============================================================================ */
31
32
33 /* ----------------------------------------------------
34 ----------------- PUBLIC PROCEDURES ----------------
35 ---------------------------------------------------- */
36
37
38 /* ============================================================================
39 NAME: setup_interface_data
40 DESC: This procedure defaults all the data required into Lines interface
41 and distributions interface from the Requisition main tables.
42 ARGS: None
43
44
45 ============================================================================ */
46 procedure setup_interface_data;
47
48 /* ============================================================================
49 NAME: fetch_lines
50 DESC: Fetch line details into line record type
51
52 ARGS: OUT : p_interface_header_id NUMBER
53 p_lines PO_AUTOCREATE_TYPES.lines_rec_type
54 - Record variable to hold the line info
55
56 ============================================================================ */
57
58 PROCEDURE fetch_lines( p_interface_header_id IN NUMBER,
59 p_lines OUT NOCOPY PO_AUTOCREATE_TYPES.lines_rec_type );
60
61
62 /* ============================================================================
63 NAME: derive_and_default_lines
64 DESC: Peform derive and defaulting on line records.
65 ARGS: IN OUT : p_lines PO_AUTOCREATE_TYPES.lines_rec_type
66
67 ALGM: Following attributes are derived / defaulted for each line record.
68 -- To be verified.
69 * Based on the requisition OU/Currency and the PO OU/Currency
70 determine the rate(s).
71 * Derive the line type attributes
72 * If the source document / document to be added has different UOM,
73 convert the quantity based on the UOM conversion.
74 * Default the item attributes (list price, market price and etc)
75 * Default the negotiated_by_preparer_flag based on the source
76 document and caller
77 * Convert the secondary quantity/uom
78 * derive the retainage rate.
79
80 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81 NOTE: Use the following procedures to derive the lines attributes:
82 - RCV_CORE_S.get_receiving_controls
83 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84 ==============================================================================*/
85
86 PROCEDURE derive_and_default_lines( p_lines IN OUT NOCOPY PO_AUTOCREATE_TYPES.lines_rec_type);
87
88
89 /* ============================================================================
90 NAME: merge_to_price_diff_draft
91 DESC: For Rate Based Temp Labour lines, populate the Price Differentials.
92
93 ARGS: IN OUT : p_lines PO_AUTOCREATE_TYPES.lines_rec_type
94
95 ALGM: This is required only if
96 - The line is Rate Based Temp Labour line
97 - The line is being created new
98 This will create the default Price Differentials draft record.
99
100 =========================================================================== */
101
102 PROCEDURE merge_to_price_diff_draft(p_lines IN OUT NOCOPY PO_AUTOCREATE_TYPES.lines_rec_type);
103
104
105 /* ============================================================================
106 NAME: merge_to_attr_values_draft
107 DESC: For Rate Based Temp Labour lines, populate the Price Differentials.
108
109 ARGS: IN OUT : p_lines PO_AUTOCREATE_TYPES.lines_rec_type
110
111 ALGM: This is required only if
112 - The line is being created new
113 - The document is a GBPA
114 This will create the attribute values draft record based on
115 item defaults, requisition and Sourcing document.
116
117 This also manages the attribute values tlp records as well.
118 =========================================================================== */
119
120 PROCEDURE merge_to_attr_values_draft (p_lines IN OUT NOCOPY PO_AUTOCREATE_TYPES.lines_rec_type);
121
122
123 /*
124 * Following two procedures are helper proocedures to be used in lines processing
125 * and line loc processing.
126 */
127
128 -------------------------------------------------------------------------------
129 --Start of Comments
130 --Name: do_currency_conversion
131 --Pre-reqs:
132 -- None.
133 --Modifies:
134 -- None.
135 --Locks:
136 -- None.
137 --Function:
138 -- This procedure performs currency conversion on the input quantity,
139 -- unit_price, or amount. Which of the previous values to convert depends
140 -- on the order_type_lookup_code and the interface_source_code.
141 --
142 -- If the Req line currency is the same as the new PO currency, we will take
143 -- the Req's currency_<unit_price/amount> directly so that conversion
144 -- calculations will not have to be performed again. Otherwise, we will
145 -- perform the conversion using the input rate.
146 --
147 --Parameters:
148 --IN:
149 --p_order_type_lookup_code
150 -- Value Basis of the Requisition/PO line.
151 --p_interface_source_code
152 -- Interface Source Code of the current Autocreate session.
153 --p_rate
154 -- Currency conversion rate to convert Req Currency to PO Currency.
155 --p_po_currency_code
156 -- Currency code of the to-be-created PO.
157 --p_requisition_line_id
158 -- Unique ID of the Requisition line being Autocreated.
159 -- (May be NULL if coming from Sourcing).
160 --IN OUT:
161 --x_quantity
162 -- Quantity to be converted.
163 --x_unit_price
164 -- Unit Price to be converted.
165 --x_base_unit_price
166 -- Base Unit Price to be converted.
167 --x_amount
168 -- Amount to be converted.
169 --Testing:
170 -- None.
171 --End of Comments
172 -------------------------------------------------------------------------------
173 PROCEDURE do_currency_conversion
174 (
175 p_order_type_lookup_code IN VARCHAR2
176 , p_interface_source_code IN VARCHAR2
177 , p_rate IN NUMBER
178 , p_po_currency_code IN VARCHAR2
179 , p_requisition_line_id IN NUMBER
180 , x_quantity IN OUT NOCOPY NUMBER
181 , x_unit_price IN OUT NOCOPY NUMBER
182 , x_base_unit_price IN OUT NOCOPY NUMBER
183 , x_amount IN OUT NOCOPY NUMBER
184 );
185
186 -------------------------------------------------------------------------------
187 --Start of Comments
188 --Name: create_pon_back_req_dist;
189
190 --Function:
191 -- This procedure create distributions using the proration logic for Line having Linked PR ref.
192 -------------------------------------------------------------------------------
193 PROCEDURE create_pon_back_req_dist;
194
195 END PO_AUTO_LINE_PROCESS_PVT;