DBA Data[Home] [Help]

PACKAGE: APPS.AP_ALLOCATION_RULES_PKG

Source


1 PACKAGE AP_ALLOCATION_RULES_PKG AS
2 /* $Header: apalocrs.pls 120.5 2004/10/27 01:25:47 pjena noship $ */
3 
4 /*==========================================================================*/
5 /*                                                                          */
6 /* This function may be called to create an associated allocation rule of   */
7 /* type Fully Prorated (PRORATION) for a given charge (Freight/Misc) line.  */
8 /* It returns FALSE if an error is encountered, TRUE otherwise.             */
9 /* The following error codes may be returned via the X_error_code OUT       */
10 /* parameter:                                                               */
11 /*  'NO_AUTO_GENERATE_DISTS'  -  Line has flag to generate dists off        */
12 /*  'LINE_DOES_NOT_EXIST'     -  Line provided does not exist               */
13 /*  'OTHER_ALLOCATIONS_EXIST' -  Line has other allocation rule associated  */
14 /*                               with it.                                   */
15 /*  'COULD_NOT_INSERT_ALLOC_RULE' -  Could not insert allocation rule       */
16 /*                                                                          */
17 /*==========================================================================*/
18 
19 FUNCTION Insert_Fully_Prorated_Rule(
20           X_invoice_id          IN         NUMBER,
21           X_line_number         IN         NUMBER,
22           X_error_code          OUT NOCOPY VARCHAR2) RETURN BOOLEAN;
23 
24 
25 /*==========================================================================*/
26 /*                                                                          */
27 /* This function may be called to create an allocation rule and rule lines  */
28 /* of type Amount Based (AMOUNT) for a given charge (Freight/Misc) line     */
29 /* given the line group number to find the associated lines to allocate     */
30 /* across. This function should be used by the Open Interface Import process*/
31 /* It returns FALSE if an error is encountered, TRUE otherwise.             */
32 /* The following error codes may be returned via the X_error_code OUT       */
33 /* parameter:                                                               */
34 /*  'NO_AUTO_GENERATE_DISTS'  -  Line has flag to generate dists off        */
35 /*  'LINE_DOES_NOT_EXIST'     -  Line provided does not exist               */
36 /*  'CANNOT_ALLOCATE_TO_NON_ITEM' - Freight/Misc line is requesting alloca- */
37 /*                                  tion across another Freight/Misc line   */
38 /*  'CANNOT_ALLOCATE_ACROSS_ZERO' - Lines to allocate across sum up to zero */
39 /*                                  making proration impossible.            */
40 /*  'OTHER_ALLOCATIONS_EXIST' -  Line has other allocation rule associated  */
41 /*                               with it.                                   */
42 /*  'COULD_NOT_INSERT_ALLOC_RULE' -  Could not insert allocation rule       */
43 /*  'COULD_NOT_INSERT_ALLOC_LINES'-  Could not insert allocation rule lines */
44 /*  'COULD_NOT_PERFORM_ROUNDING'  -  Could not allocate the rounding due    */
45 /*                                   to proration.                          */
46 /*                                                                          */
47 /*==========================================================================*/
48 FUNCTION Insert_From_Line_Group_Number(
49           X_invoice_id          IN         NUMBER,
50 	  X_line_number         IN         NUMBER,
51           X_error_code          OUT NOCOPY VARCHAR2) RETURN BOOLEAN;
52 
53 
54 /*==========================================================================*/
55 /*                                                                          */
56 /* This function may be called to create an allocation rule and rule lines  */
57 /* of type PERCENTAGE for a given charge (Freight/Misc) line.               */
58 /*									    */
59 /*==========================================================================*/
60 PROCEDURE Insert_Percentage_Alloc_Rule(
61 	  X_Invoice_id	 	 IN	   NUMBER,
62 	  X_Chrg_Line_Number     IN	   NUMBER,
63 	  X_To_Line_Number	 IN	   NUMBER,
64 	  X_Rule_Generation_Type IN	   VARCHAR2 DEFAULT 'SYSTEM',
65 	  X_Status		 IN	   VARCHAR2 DEFAULT 'PENDING',
66 	  X_Percentage		 IN	   NUMBER,
67 	  X_Calling_Sequence     IN	   VARCHAR2);
68 
69 ------------------------------------------------------------------------------
70 --  This function is called if the user wants to view the Allocations from
71 --  the standpoint of ITEM Type of line.
72 --  This function calls : Create_Proration_Rule for every  charge line
73 --  with Auto Generate Dists = 'Y' and Match Type <> OTHER_TO_RECEIPT
74 --  Create Proration Rule when called in this context
75 --  (Window Context: ALLOCATIONS) creates temporary allocation lines for
76 --  charge line which do not have a Rule (or have a pending PRORATION rule)
77 --  associated with them.
78 --  It returns FALSE if an error is encountered, TRUE otherwise.
79 --  The following error codes may be returned via the X_error_code OUT
80 --  parameter:
81 --  'AP_NO_CHARGES_EXIST'  -  No charge lines exist for this invoice.
82 --  'AP_GENERATE_DISTS_IS_NO' - Generate Dists Flag is N for this chrg line
83 --  'AP_NO_ITEM_LINES_AVAIL' - No Item Lines exist or sum total of Item
84 --                             lines is zero for this Invoice
85 ------------------------------------------------------------------------------
86 FUNCTION Create_Allocations(
87           X_Invoice_id       IN            NUMBER,
88           X_Window_context   IN            VARCHAR2,
89           X_Error_Code          OUT NOCOPY VARCHAR2,
90           X_Debug_Info          OUT NOCOPY VARCHAR2,
91           X_Debug_Context       OUT NOCOPY VARCHAR2,
92           X_Calling_Sequence IN            VARCHAR2)
93 RETURN BOOLEAN;
94 
95 ------------------------------------------------------------------------------
96 -- This function may be called from the following:
97 --  1. Create_Allocations Function to generate temporary Allocations so
98 --     that the user can view Allocations from the standpoint of ITEM Line.
99 --  2. In the WNFI for Allocations Rule Window, to create a default
100 --     rule of type PRORATION.(If a one doesn't exist)
101 --  3. When-List-Changed of  Rule Type in the Allocation Rules window. This
102 --     function re-creates the Proration lines for the Rule Type PRORATION
103 --  It returns FALSE if an error is encountered, TRUE otherwise.
104 --  The following error codes may be returned via the X_error_code OUT
105 --  parameter:
106 --  'AP_NO_CHARGES_EXIST'  -  No charge lines exist for this invoice.
107 --  'AP_GENERATE_DISTS_IS_NO' - Generate Dists Flag is N for this chrg line
108 --  'AP_NO_ITEM_LINES_AVAIL' - No Item Lines exist or sum total of Item
109 --                             lines is zero for this Invoice
110 ------------------------------------------------------------------------------
111 FUNCTION Create_Proration_Rule(
112           X_invoice_id       IN            NUMBER,
113           X_chrg_line_number IN            NUMBER,
114           X_rule_type        IN            VARCHAR2,
115           X_Window_context   IN            VARCHAR2,
116           X_Error_Code          OUT NOCOPY VARCHAR2,
117           X_Debug_Info          OUT NOCOPY VARCHAR2,
118           X_Debug_Context       OUT NOCOPY VARCHAR2,
119           X_calling_sequence IN            VARCHAR2)
120 RETURN  BOOLEAN;
121 
122 
123 -----------------------------------------------------------------------
124 --  This procedure sums up the Allocations lines from the Standpoint of a
125 --  Item Line. This procedures sums up the Allocations lines from the
126 --  Allocation_rule_lines table(AMOUNT, PERCENTAGE and Executed PRORATION)
127 --  UNIONED with the PENDING Proration allocation rule lines from the
128 --  Global Temporary Table(AP_ALLOCATION_RULE_LINES_GT).
129 -----------------------------------------------------------------------
130 PROCEDURE select_item_summary(
131            X_Invoice_id               IN             NUMBER,
132            X_to_invoice_line_number   IN             NUMBER,
133            X_allocated_total          IN OUT NOCOPY  NUMBER,
134            X_allocated_total_rtot_db  IN OUT NOCOPY  NUMBER,
135            X_calling_sequence         IN      VARCHAR2);
136 
137 
138 -----------------------------------------------------------------------
139 -- This function Inserts/Updates/Deletes records
140 -- in the Ap_allocation_Rule_lines based on the allocation_flag
141 -- passed to this function via manual allocation for AMOUNT and
142 -- PERCENTAGE type Rules in the Allocation Rule Window.
143 ------------------------------------------------------------------------
144 FUNCTION Allocation_Rule_Lines(
145           X_Invoice_id               IN            NUMBER,
146           X_chrg_invoice_line_number IN            NUMBER,
147           X_to_invoice_line_number   IN            NUMBER,
148           X_allocated_percentage     IN            NUMBER,
149           X_allocated_amount         IN            NUMBER,
150           X_allocation_flag          IN            VARCHAR2,
151           X_Error_code                  OUT NOCOPY VARCHAR2)
152 RETURN BOOLEAN;
153 
154 
155 ------------------------------------------------------------------------
156 --  This procedure is used to get the setup and invoice information needed
157 --  by the both the sub-components(Allocation Rules Window and Allocations)
158 --  of the Allocations Form.
159 ------------------------------------------------------------------------
160 PROCEDURE form_startup(
161            X_invoice_id                    IN         NUMBER,
162            X_chart_of_accounts_id          OUT NOCOPY NUMBER,
163            X_invoice_date                  OUT NOCOPY DATE,
164            X_vendor_type_lookup_code       OUT NOCOPY VARCHAR2,
165            X_vendor_name                   OUT NOCOPY VARCHAR2,
166            X_invoice_num                   OUT NOCOPY VARCHAR2,
167            X_invoice_currency_code         OUT NOCOPY VARCHAR2,
168            X_calling_sequence              IN         VARCHAR2);
169 
170 
171 ------------------------------------------------------------------------
172 --  Table Handler for the AP_ALLOCATION RULES Table for the update of
173 --  Rule Type.
174 ------------------------------------------------------------------------
175 Procedure Update_row(
176              X_rowid     IN OUT NOCOPY  VARCHAR2,
177              X_Invoice_Id               NUMBER,
178              X_chrg_invoice_line_number NUMBER,
179              X_Rule_Type                VARCHAR2,
180              X_Rule_Generation_Type     VARCHAR2,
181              X_Status                   VARCHAR2,
182              X_last_updated_by          NUMBER,
183              X_last_update_date         DATE,
184              X_last_update_login        NUMBER,
185              X_calling_Sequence         VARCHAR2);
186 
187 
188 ------------------------------------------------------------------------
189 --  Table Handler for the AP_ALLOCATION RULES Table for the Locking of
190 --  Allocation Rule associated with the Charge Line.
191 ------------------------------------------------------------------------
192 Procedure Lock_row(
193              X_rowid     IN OUT NOCOPY  VARCHAR2,
194              X_Invoice_Id               NUMBER,
195              X_chrg_invoice_line_number NUMBER,
196              X_Rule_Type                VARCHAR2,
197              X_Rule_Generation_Type     VARCHAR2,
198              X_Status                   VARCHAR2,
199              X_calling_Sequence         VARCHAR2);
200 
201 --------------------------------------------------------------
202 
203 ------------------------------------------------------------------------------
204 -- This function is called while updating the Amount for a Charge Line
205 -- in the Invoice Window of the Invoice Workbench.
206 -- The function prorates the already allocated allocation lines for the
207 -- Pending Allocation rule(Amount and Percenatge) with respect to the new
208 -- Charge Line Amount(Amount <> 0).
209 -- The function returns TRUE and performs NO Action if the Charge Line
210 -- does not has an Allocation Rule or the Charge Line has a Pending Rule
211 -- of type Proration.
212 --  It returns FALSE if an error is encountered, TRUE otherwise.
213 --  The following error codes may be returned via the X_error_code OUT
214 --  parameter:
215 --  'AP_NO_CHARGES_EXIST'  -  No charge lines exist for this invoice.
216 --  'AP_GENERATE_DISTS_IS_NO' - Generate Dists Flag is N for this chrg line
217 --  'AP_NO_ITEM_LINES_AVAIL' - No Item Lines exist or sum total of Item
218 --                             lines is zero for this Invoice
219 --  'AP_ALLOC_EXECUTED' -- You cannot make this change because this line's
220 --                         allocation rule has been executed.
221 ------------------------------------------------------------------------------
222 FUNCTION Prorate_allocated_lines(
223           X_invoice_id        IN            NUMBER,
224           X_chrg_line_number  IN            NUMBER,
225           X_new_chrg_line_amt IN            NUMBER,
226           X_Error_Code           OUT NOCOPY VARCHAR2,
227           X_Debug_Info           OUT NOCOPY VARCHAR2,
228           X_Debug_Context        OUT NOCOPY VARCHAR2,
229           X_calling_sequence  IN            VARCHAR2)
230 RETURN BOOLEAN;
231 
232 
233 ------------------------------------------------------------------------------
234 -- This function is called while updating the Amount for a Charge Line to 0
235 -- in the Invoice Window of the Invoice Workbench.
236 -- This function
237 -- The function returns TRUE and performs NO Action if the Charge Line
238 -- does not has an Allocation Rule or the Charge Line has a Pending Rule
239 -- of type Proration.
240 --  It returns FALSE if an error is encountered, TRUE otherwise.
241 --  The following error codes may be returned via the X_error_code OUT
242 --  parameter:
243 --  'AP_NO_CHARGES_EXIST'  -  No charge lines exist for this invoice.
244 --  'AP_GENERATE_DISTS_IS_NO' - Generate Dists Flag is N for this chrg line
245 --  'AP_ALLOC_EXECUTED' -- You cannot make this change because this line's
246 --                         allocation rule has been executed.
247 ------------------------------------------------------------------------------
248 FUNCTION Delete_Allocations(
249           X_invoice_id        IN            NUMBER,
250           X_chrg_line_number  IN            NUMBER,
251           X_new_chrg_line_amt IN            NUMBER,
252           X_Error_Code           OUT NOCOPY VARCHAR2,
253           X_Debug_Info           OUT NOCOPY VARCHAR2,
254           X_Debug_Context        OUT NOCOPY VARCHAR2,
255           X_calling_sequence  IN            VARCHAR2)
256 RETURN BOOLEAN;
257 
258 
259 -------------------------------------------------------------------------
260 -- This Procedure deletes the pending Allocation Rule Lines so
261 -- that the Rule Lines can be recreated as of the latest snapshot
262 -- This function is called from the following
263 --  1.  Whenever the user changes the Rule Type of the Allocation Rule
264 --  2.  Delete Allocations(Whenever a user updates the charge line amount
265 --      to 0 in the Invoice Window).
266 -----------------------------------------------------------------------
267 PROCEDURE Delete_Allocation_Lines(
268            X_invoice_id          IN      NUMBER,
269            X_chrg_line_number    IN      NUMBER,
270            X_calling_sequence    IN      VARCHAR2);
271 
272 -------------------------------------------------------------------------
273 -- This Procedure creates Allocation Rule and Rule Lines for tax lines.
274 -- It is invoked after tax lines are inserted from the AP eTax utilities
275 -- package.
279 	  X_chrg_line_number	IN	   NUMBER,
276 -------------------------------------------------------------------------
277 FUNCTION insert_tax_allocations (
278           X_invoice_id          IN         NUMBER,
280           X_error_code          OUT NOCOPY VARCHAR2) RETURN BOOLEAN;
281 
282 END AP_ALLOCATION_RULES_PKG;