DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_TAX_SUMMARY_PKG

Source


1 PACKAGE BODY PO_TAX_SUMMARY_PKG as
2 /* $Header: POXTAXDB.pls 115.9 2004/04/05 18:26:52 dreddy ship $ */
3   FUNCTION get_recoverable_tax
4 	(X_header_id   number, x_line_id number, x_shipment_id number, object_type varchar2, object_location varchar2) return number is
5     	 X_recoverable_tax     number;
6   BEGIN
7 /* Bug#2459080 : In order to take in to account of the tax portion associated
8 with the non-cancelled quantity of the partially and fully cancelled shipments
9 modified the select statements for the object_type 'PO' and 'REL' for all the
10 object_location. Accordingly, changed the where condition of these select
11 statement to take in to consideration of only those shipments which are not
12 fully cancelled */
13 /* Bug# 2748176 : Added the condition
14              AND  nvl(cancel_flag, 'N') <> 'Y'
15              AND  nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED'
16    for Reqs to remove tax detail lines which have beed Cancelled.  */
17 
18 -- SERVICES FPJ : Added decodes to handle amounts for service lines
19 
20     if (object_type = 'PO') then
21        if (object_location = 'HEADER') then
22            SELECT nvl(SUM(nvl(pod.recoverable_tax, 0) *
23                   decode(pol.order_type_lookup_code, 'RATE',        -- SERVICES FPJ
24                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
25                    'FIXED PRICE',
26                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
27                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
28                    / nvl(pod.quantity_ordered,0))  )),  0)
29 	      into X_recoverable_tax
30            FROM   po_distributions pod,
31                   po_lines pol,
32                   po_line_locations pll
33            WHERE  pod.po_header_id = X_header_id
34             AND   pll.po_line_id = pol.po_line_id
35             AND   pll.line_location_id = pod.line_location_id
36             AND   pod.po_release_id is null    -- Bug 3532747
37             AND   (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
38                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
39             AND   nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
40        elsif (object_location = 'LINE') then
41            SELECT nvl(SUM(nvl(pod.recoverable_tax, 0) *
42                   decode(pol.order_type_lookup_code, 'RATE',    -- SERVICES FPJ
43                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
44                    'FIXED PRICE',
45                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
46                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
47                    / nvl(pod.quantity_ordered,0))  )),  0)
48 	      into X_recoverable_tax
49            FROM   po_distributions pod,
50                   po_lines pol,
51                   po_line_locations pll
52            WHERE  pod.po_line_id = X_line_id
53             AND   pll.po_line_id = pol.po_line_id
54             AND   pll.line_location_id = pod.line_location_id
55             AND   pod.po_release_id is null    -- Bug 3532747
56             AND   (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
57                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
58             AND   nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
59        elsif (object_location = 'SHIPMENT') then
60            SELECT nvl(SUM(nvl(pod.recoverable_tax, 0) *
61                   decode(pol.order_type_lookup_code, 'RATE',  -- SERVICES FPJ
62                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
63                    'FIXED PRICE',
64                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
65                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
66                    / nvl(pod.quantity_ordered,0))  )),  0)
67 	      into X_recoverable_tax
68            FROM   po_distributions pod,
69                   po_lines pol
70            WHERE  pod.line_location_id = X_shipment_id
71             AND   pod.po_release_id is null    -- Bug 3532747
72             AND   pod.po_line_id = pol.po_line_id;
73        end if;
74     elsif (object_type = 'REL') then
75        if (object_location = 'HEADER') then
76            SELECT nvl(SUM(nvl(pod.recoverable_tax, 0) *
77                   decode(pol.order_type_lookup_code,
78                    'FIXED PRICE',                         -- SERVICES FPJ
79                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
80                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
81                    / nvl(pod.quantity_ordered,0))  )),  0)
82 	      into X_recoverable_tax
83            FROM   po_distributions  pod,
84                   po_lines pol,
85                   po_line_locations pll
86            WHERE  pod.po_release_id = X_header_id
87              AND  pll.line_location_id = pod.line_location_id
88              AND   pll.po_line_id = pol.po_line_id
89              AND  (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
90                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
91              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
92        elsif (object_location = 'SHIPMENT') then
93            SELECT nvl(SUM(nvl(pod.recoverable_tax, 0) *
94                   decode(pol.order_type_lookup_code,
95                    'FIXED PRICE',                         -- SERVICES FPJ
96                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
97                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
98                    / nvl(pod.quantity_ordered,0))  )),  0)
99 	      into X_recoverable_tax
100            FROM   po_distributions pod,
101                   po_lines pol
102            WHERE  pod.line_location_id = X_shipment_id
103             AND   pod.po_line_id = pol.po_line_id;
104        end if;
105     elsif (object_type = 'REQ') then
106        if (object_location = 'HEADER') then
107            SELECT nvl(SUM(prd.recoverable_tax), 0)
108 	      into X_recoverable_tax
109            FROM   po_req_distributions prd,
110 	  	  po_requisition_lines prl
111            WHERE  prd.requisition_line_id = prl.requisition_line_id
112 	     AND  prl.requisition_header_id = x_header_id
113              AND  nvl(prl.cancel_flag, 'N') <> 'Y'
114              AND  nvl(prl.closed_code, 'OPEN') <> 'FINALLY CLOSED';
115        elsif (object_location = 'LINE') then
116            SELECT nvl(SUM(recoverable_tax), 0)
117 	      into X_recoverable_tax
118            FROM   po_req_distributions
119            WHERE  requisition_line_id = X_line_id;
120        end if;
121     end if;
122     RETURN (X_recoverable_tax);
123 
124   EXCEPTION
125     WHEN OTHERS then
126        x_recoverable_tax := 0;
127   END get_recoverable_tax;
128 
129   FUNCTION get_nonrecoverable_tax
130 	(X_header_id   number, x_line_id number, x_shipment_id number, object_type varchar2, object_location varchar2) return number is
131     	 X_nonrecoverable_tax     number;
132   BEGIN
133 /* Bug#2459080 : In order to take in to account of the tax portion associated
134 with the non-cancelled quantity of the partially and fully cancelled shipments
135 modified the select statements for the object_type 'PO' and 'REL' for all the
136 object_location. Accordingly, changed the where condition of these select
137 statement to take in to consideration of only those shipments which are not
138 fully cancelled */
139     if (object_type = 'PO') then
140        if (object_location = 'HEADER') then
141            SELECT nvl(SUM(nvl(pod.nonrecoverable_tax, 0) *
142                   decode(pol.order_type_lookup_code, 'RATE',       -- SERVICES FPJ
143                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
144                    'FIXED PRICE',
145                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
146                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
147                    / nvl(pod.quantity_ordered,0))  )),  0)
148 	      into X_nonrecoverable_tax
149            FROM   po_distributions pod,
150                   po_lines pol,
151                   po_line_locations pll
152            WHERE  pod.po_header_id = X_header_id
153              AND   pll.po_line_id = pol.po_line_id
154              AND  pll.line_location_id = pod.line_location_id
155              AND   pod.po_release_id is null    -- Bug 3532747
156              AND  (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
157                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
158              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
159        elsif (object_location = 'LINE') then
160            SELECT nvl(SUM(nvl(pod.nonrecoverable_tax, 0) *
161                   decode(pol.order_type_lookup_code, 'RATE',          -- SERVICES FPJ
162                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
163                    'FIXED PRICE',
164                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
165                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
166                    / nvl(pod.quantity_ordered,0))  )),  0)
167 	      into X_nonrecoverable_tax
168            FROM   po_distributions pod,
169                   po_lines pol,
170                   po_line_locations pll
171            WHERE  pod.po_line_id = X_line_id
172              AND   pll.po_line_id = pol.po_line_id
173              AND  pll.line_location_id = pod.line_location_id
174              AND   pod.po_release_id is null    -- Bug 3532747
175              AND  (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
176                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
177              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
178        elsif (object_location = 'SHIPMENT') then
179            SELECT nvl(SUM(nvl(pod.nonrecoverable_tax, 0) *
180                   decode(pol.order_type_lookup_code, 'RATE',         -- SERVICES FPJ
181                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
182                    'FIXED PRICE',
183                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
184                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
185                    / nvl(pod.quantity_ordered,0))  )),  0)
186 	      into X_nonrecoverable_tax
187            FROM   po_distributions pod,
188                   po_lines pol
189            WHERE  pod.line_location_id = X_shipment_id
190              AND   pod.po_release_id is null    -- Bug 3532747
191              AND   pod.po_line_id = pol.po_line_id;
192        end if;
193     elsif (object_type = 'REL') then
194        if (object_location = 'HEADER') then
195            SELECT nvl(SUM(nvl(pod.nonrecoverable_tax, 0) *
196                   decode(pol.order_type_lookup_code,
197                    'FIXED PRICE',                       -- SERVICES FPJ
198                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
199                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
200                    / nvl(pod.quantity_ordered,0))  )),  0)
201 	      into X_nonrecoverable_tax
202            FROM   po_distributions pod,
203                   po_lines pol,
204                   po_line_locations pll
205            WHERE  pod.po_release_id = X_header_id
206              AND   pll.po_line_id = pol.po_line_id
207              AND  pll.line_location_id = pod.line_location_id
208              AND  (nvl(pll.quantity,0)-nvl(pll.quantity_cancelled,0) <>  0 OR
209                   nvl(pll.amount,0) - nvl(pll.amount_cancelled,0) <> 0)
210              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
211        elsif (object_location = 'SHIPMENT') then
212            SELECT nvl(SUM(nvl(pod.nonrecoverable_tax, 0) *
213                   decode(pol.order_type_lookup_code,
214                    'FIXED PRICE',                         -- SERVICES FPJ
215                    ((nvl(pod.amount_ordered,0) - nvl(pod.amount_cancelled,0))/nvl(pod.amount_ordered,0)),
216                    ((nvl(pod.quantity_ordered,0)-nvl(pod.quantity_cancelled,0))
217                    / nvl(pod.quantity_ordered,0))  )),  0)
218 	      into X_nonrecoverable_tax
219            FROM   po_distributions pod,
220                   po_lines pol
221            WHERE  pod.line_location_id = X_shipment_id
222             AND   pod.po_line_id = pol.po_line_id;
223        end if;
224     elsif (object_type = 'REQ') then
225        if (object_location = 'HEADER') then
226            SELECT nvl(SUM(prd.nonrecoverable_tax), 0)
227 	      into X_nonrecoverable_tax
228            FROM   po_req_distributions prd,
229 	  	  po_requisition_lines prl
230            WHERE  prd.requisition_line_id = prl.requisition_line_id
231 	     AND  prl.requisition_header_id = x_header_id
232              AND  nvl(prl.cancel_flag, 'N') <> 'Y'
233              AND  nvl(prl.closed_code, 'OPEN') <> 'FINALLY CLOSED';
234        elsif (object_location = 'LINE') then
235            SELECT nvl(SUM(nonrecoverable_tax), 0)
236 	      into X_nonrecoverable_tax
237            FROM   po_req_distributions
238            WHERE  requisition_line_id = X_line_id;
239        end if;
240     end if;
241     RETURN (X_nonrecoverable_tax);
242 
243   EXCEPTION
244     WHEN OTHERS then
245        x_nonrecoverable_tax := 0;
246   END get_nonrecoverable_tax;
247 
248   FUNCTION get_header_amount
249 	(X_header_id   number,
250          object_type varchar2,
251          X_currency_code     varchar2) return number is
252 
253          X_header_amount     number;
254          X_precision         number;   -- Bug#2767208
255          X_ext_precision     number;   -- Bug#2767208
256          X_min_acct_unit     number;   -- Bug#2767208
257 
258          l_is_local_blanket  BOOLEAN;  -- bug3426902
259 
260   BEGIN
261 
262 /* Bug#2767208 : Added the following function call to get the document
263    currency precision and minimum accountable unit */
264 
265         fnd_currency.get_info(X_currency_code,
266                               X_precision,
267                               X_ext_precision,
268                               X_min_acct_unit);
269 
270     if (object_type = 'PO') then
271 
272       -- bug3426902 START
273       -- For Local Blanket Release, we should show amount field with the
274       -- total amount released for the blanket
275 
276       l_is_local_blanket := PO_GA_PVT.is_local_document
277                             ( p_po_header_id => x_header_id,
278                               p_type_lookup_code => 'BLANKET'
279                             );
280 
281       IF (l_is_local_blanket) THEN
282 
283         IF (x_min_acct_unit IS NOT NULL) THEN
284 
285             --SQL WHAT: Calculate amount released for a blanket header.
286             --          This amount is rounded based on mau
287             --SQL WHY:  For local blanket, we return amount released as
288             --          the amount of the blanket
289             SELECT  NVL(
290                       SUM(
291                         ROUND(
292                           DECODE(POL.order_type_lookup_code,
293                                  'FIXED PRICE',
294                                  PLL.amount - NVL(PLL.amount_cancelled, 0),
295                                  (PLL.quantity -
296                                   NVL(PLL.quantity_cancelled, 0)) *
297                                    price_override
298                                 ) / x_min_acct_unit
299                         ) * x_min_acct_unit
300                       ), 0
301                     )
302             INTO    x_header_amount
303             FROM    po_line_locations PLL,
304                     po_lines POL
305             WHERE   PLL.po_line_id = POL.po_line_id
306             AND     POL.po_header_id = x_header_id
307             AND     PLL.shipment_type = 'BLANKET';
308 
309         ELSE
310 
311             --SQL WHAT: Calculate amount released for a blanket header.
312             --          This amount is rounded based on precision
313             --SQL WHY:  For local blanket, we return amount released as
314             --          the amount of the blanket
315             SELECT  NVL(
316                       SUM(
317                         ROUND(
318                           DECODE(POL.order_type_lookup_code,
319                                  'FIXED PRICE',
320                                  PLL.amount - NVL(PLL.amount_cancelled, 0),
321                                  (PLL.quantity -
322                                   NVL(PLL.quantity_cancelled, 0)) *
323                                    price_override
324                                 ),
325                           x_precision
326                         )
327                       ), 0
328                     )
329             INTO    x_header_amount
330             FROM    po_line_locations PLL,
331                     po_lines POL
332             WHERE   PLL.po_line_id = POL.po_line_id
333             AND     POL.po_header_id = x_header_id
334             AND     PLL.shipment_type = 'BLANKET';
335 
336         END IF;
337 
338       ELSE  -- if document is not a local blanket
339 
340       -- bug3426902 END
341       -- If document is not a local blanket, calculate the total amount
342       -- of its own
343 
344 /* Bug#2767208 : The line amount should be first rounded and then summed
345    up to calculate the header amount. Hence added the following if-else
346    condition which rounds the line amount to minmum accountable unit/
347    precision and then sums up the rounded line amount */
348 
349         if(X_min_acct_unit is not null) then
350 
351             SELECT nvl(SUM(round(decode(order_type_lookup_code,'RATE',amount,'FIXED PRICE', amount,
352                                         unit_price * quantity)/X_min_acct_unit)
353                                *X_min_acct_unit), 0)
354                into X_header_amount
355             FROM   po_lines
356             WHERE  po_header_id = X_header_id
357               AND  nvl(cancel_flag, 'N') <> 'Y'
358               AND  nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
359 
360        else
361             SELECT nvl(SUM(round(decode(order_type_lookup_code,'RATE',amount,'FIXED PRICE', amount,
362                                  unit_price * quantity), X_precision)), 0)
363                into X_header_amount
364             FROM   po_lines
365             WHERE  po_header_id = X_header_id
366               AND  nvl(cancel_flag, 'N') <> 'Y'
367               AND  nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
368 
369         end if;
370 
371       END IF;
372 
373     elsif (object_type = 'REL') then
374 
375 /* Bug#2767208 : The line amount should be first rounded and then summed
376    up to calculate the header amount. Hence added the following if-else
377    condition which rounds the line amount to minmum accountable unit/
378    precision and then sums up the rounded line amount */
379 
380        if(X_min_acct_unit is not null) then
381 
382            SELECT nvl(SUM(round(decode(pol.order_type_lookup_code,'FIXED PRICE',pll.amount,
383                                 pll.price_override * pll.quantity)/X_min_acct_unit)
384                               *X_min_acct_unit), 0)              -- SERVICES FPJ
385 	      into X_header_amount
386            FROM   po_line_locations pll,
387                   po_lines pol
388            WHERE  pll.po_release_id = X_header_id
389              AND  pol.po_line_id = pll.po_line_id
390              AND  nvl(pll.cancel_flag, 'N') <> 'Y'
391              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
392 
393        else
394            SELECT nvl(SUM(round(decode(pol.order_type_lookup_code,'FIXED PRICE',pll.amount,
395                           pll.price_override * pll.quantity),X_precision)), 0)       -- SERVICES FPJ
396               into X_header_amount
397            FROM   po_line_locations pll,
398                   po_lines pol
399            WHERE  pll.po_release_id = X_header_id
400              AND  pol.po_line_id = pll.po_line_id
401              AND  nvl(pll.cancel_flag, 'N') <> 'Y'
402              AND  nvl(pll.closed_code, 'OPEN') <> 'FINALLY CLOSED';
403 
404        end if;
405 
406     elsif (object_type = 'REQ') then
407 
408 /* Bug#2767208 : The line amount should be first rounded and then summed
409    up to calculate the header amount. Hence added the following if-else
410    condition which rounds the line amount to minmum accountable unit/
411    precision and then sums up the rounded line amount */
412 
413        if(X_min_acct_unit is not null) then
414 
415            SELECT nvl(SUM(round(decode(order_type_lookup_code,'RATE',amount,'FIXED PRICE', amount,
416                          unit_price * quantity)/X_min_acct_unit)
417                               *X_min_acct_unit), 0)             -- SERVICES FPJ
418 	      into X_header_amount
419            FROM   po_requisition_lines
420            WHERE  requisition_header_id = x_header_id
421              AND  nvl(cancel_flag, 'N') <> 'Y'
422              AND  nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
423 
424        else
425            SELECT nvl(SUM(round(decode(order_type_lookup_code,'RATE',amount,'FIXED PRICE', amount,
426                             unit_price * quantity),X_precision)), 0)      -- SERVICES FPJ
427               into X_header_amount
428            FROM   po_requisition_lines
429            WHERE  requisition_header_id = x_header_id;
430 
431        end if;
432 
433     end if;
434     RETURN (X_header_amount);
435 
436   EXCEPTION
437     WHEN OTHERS then
438        x_header_amount := 0;
439   END get_header_amount;
440 
441 
442 -- bug3426902 START
443 
444 -----------------------------------------------------------------------
445 --Start of Comments
446 --Name: get_line_amount
447 --Pre-reqs:
448 --Modifies:
449 --Locks:
450 --  None
451 --Function: For Standard and Planned PO, it returns the amount of
452 --          a PO line; for local blanket, it returns the amount released
453 --          of the blanket line.
454 --Parameters:
455 --IN:
456 --p_line_id
457 --  unique identifier of a line in PO_LINES_ALL
458 --p_currency_code
459 --  Currency of the document
460 --IN OUT:
461 --OUT:
462 --Returns: Amount of the line
463 --Notes:
464 --Testing:
465 --End of Comments
466 ------------------------------------------------------------------------
467 FUNCTION get_line_amount (p_line_id IN VARCHAR2,
468                           p_currency_code IN VARCHAR2)
469 RETURN NUMBER IS
470 
471 l_precision     FND_CURRENCIES.precision%TYPE;
472 l_ext_precision FND_CURRENCIES.extended_precision%TYPE;
473 l_min_acct_unit FND_CURRENCIES.minimum_accountable_unit%TYPE;
474 l_line_amount   NUMBER;
475 
476 BEGIN
477 
478     FND_CURRENCY.get_info(p_currency_code,
479                           l_precision,
480                           l_ext_precision,
481                           l_min_acct_unit);
482 
483     IF (l_min_acct_unit IS NOT NULL) THEN
484 
485         --SQL WHAT: Calculate amount released for a PO/Blanket line.
486         --          This amount is rounded based on currency mau
487         --SQL WHY:  The result is what this function returns
488         SELECT  NVL(
489                   SUM(
490                     ROUND(
491                       DECODE(POL.order_type_lookup_code,
492                              'FIXED PRICE',
493                              PLL.amount - NVL(PLL.amount_cancelled, 0),
494                              'RATE',
495                              PLL.amount - NVL(PLL.amount_cancelled, 0),
496                              (PLL.quantity - NVL(PLL.quantity_cancelled, 0)) *
497                                price_override
498                             ) / l_min_acct_unit
499                     ) * l_min_acct_unit
500                   ), 0
501                 )
502         INTO    l_line_amount
503         FROM    po_line_locations PLL,
504                 po_lines POL
505         WHERE   PLL.po_line_id = POL.po_line_id
506         AND     POL.po_line_id = p_line_id
507         AND     PLL.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET');
508 
509     ELSE
510 
511         --SQL WHAT: Calculate amount released for a PO/Blanket line.
512         --          This amount is rounded based on currency precision
513         --SQL WHY:  The result is what this function returns
514         SELECT  NVL(
515                   SUM(
516                     ROUND(
517                       DECODE(POL.order_type_lookup_code,
518                              'FIXED PRICE',
519                              PLL.amount - NVL(PLL.amount_cancelled, 0),
520                              'RATE',
521                              PLL.amount - NVL(PLL.amount_cancelled, 0),
522                              (PLL.quantity - NVL(PLL.quantity_cancelled, 0)) *
523                                price_override
524                             ),
525                       l_precision
526                     )
527                   ), 0
528                 )
529         INTO    l_line_amount
530         FROM    po_line_locations PLL,
531                 po_lines POL
532         WHERE   PLL.po_line_id = POL.po_line_id
533         AND     POL.po_line_id = p_line_id
534         AND     PLL.shipment_type IN ('STANDARD', 'PLANNED', 'BLANKET');
535 
536     END IF;
537 
538     RETURN l_line_amount;
539 
540 END get_line_amount;
541 
542 -- bug3426902 END
543 
544 END PO_TAX_SUMMARY_PKG;