DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_NOTIFICATION_UTIL

Source


1 package body PO_NOTIFICATION_UTIL AS
2 /* $Header: PONOTIFUTLB.pls 120.2.12020000.3 2013/03/05 02:20:59 pla noship $ */
3 Function getTax(p_document_id po_headers_all.po_header_id%TYPE) return number
4 is
5 
6 X_precision        number;
7 X_ext_precision    number;
8 X_min_acct_unit    number;
9 lv_tax_region        varchar2(30);        --tax region code
10 ln_jai_excl_nr_tax   NUMBER;              --exclusive non-recoverable tax
11 lv_document_type     VARCHAR2(25);        --document type
12 l_currency_code    fnd_currencies.CURRENCY_CODE%TYPE;
13 l_org_id           po_headers.org_id%TYPE;
14 l_tax_amt Number;
15 
16 Begin
17 
18 select poh.org_id,poh.TYPE_LOOKUP_CODE,gls.currency_code
19 into l_org_id,lv_document_type,l_currency_code
20 from po_headers_all poh, financials_system_params_all fsp,
21   gl_sets_of_books gls
22 where poh.segment1 = '6110'
23 and fsp.set_of_books_id = gls.set_of_books_id
24 AND fsp.org_id            = poh.org_id;
25 
26   lv_tax_region      := JAI_PO_WF_UTIL_PUB.Get_Tax_Region (pn_org_id => l_org_id);
27 
28   IF (lv_tax_region ='JAI')
29   THEN
30     --Get document type
31 
32     --Indian localization tax calculation
33     IF  lv_document_type = 'RELEASE'
34     THEN
35       JAI_PO_WF_UTIL_PUB.Get_Jai_Tax_Amount
36       ( pv_document_type      => JAI_PO_WF_UTIL_PUB.G_REL_DOC_TYPE
37       , pn_document_id        => p_document_id
38       , xn_excl_tax_amount    => l_tax_amt
39       , xn_excl_nr_tax_amount => ln_jai_excl_nr_tax
40       );
41 
42     ELSE
43       JAI_PO_WF_UTIL_PUB.Get_Jai_Tax_Amount
44       ( pv_document_type      => JAI_PO_WF_UTIL_PUB.G_PO_DOC_TYPE
45       , pn_document_id        => p_document_id
46       , xn_excl_tax_amount    => l_tax_amt
47       , xn_excl_nr_tax_amount => ln_jai_excl_nr_tax
48       );
49     END IF; --(lv_document_type = 'RELEASE')
50   ELSE
51     --original tax calc code
52 
53     fnd_currency.get_info( l_currency_code,
54                             X_precision,
55                             X_ext_precision,
56                             X_min_acct_unit);
57 
58 
59     IF (x_min_acct_unit IS NOT NULL) AND
60         (x_min_acct_unit <> 0)
61     THEN
62       -- Bug#16222308
63       SELECT sum( round (POD.nonrecoverable_tax *
64                          decode(quantity_ordered,
65                                 NULL,
66                                 (nvl(POD.amount_ordered,0) - nvl(POD.amount_cancelled,0)) / decode (nvl(POD.amount_ordered, 1),0,1,nvl(POD.amount_ordered, 1) ),
67                                 (nvl(POD.quantity_ordered,0) - nvl(POD.quantity_cancelled,0)) / decode ( nvl(POD.quantity_ordered, 1),0,1,nvl(POD.quantity_ordered, 1) )
68                                ) / X_min_acct_unit
69                          ) * X_min_acct_unit
70                 )
71       INTO l_tax_amt
72       FROM po_lines pol,
73            po_distributions pod
74      WHERE pol.po_header_id = p_document_id
75        AND pod.po_line_id = pol.po_line_id;
76     ELSE
77       -- Bug#16222308
78       SELECT sum( round (POD.nonrecoverable_tax *
79                          decode(quantity_ordered,
80                                 NULL,
81                                 (nvl(POD.amount_ordered,0) - nvl(POD.amount_cancelled,0)) / decode ( nvl(POD.amount_ordered, 1),0,1,nvl(POD.amount_ordered, 1) ),
82                                 (nvl(POD.quantity_ordered,0) - nvl(POD.quantity_cancelled,0)) / decode (nvl(POD.quantity_ordered, 1),0,1,nvl(POD.quantity_ordered, 1) )
83                                ),
84                          X_precision
85                         )
86                 )
87       INTO l_tax_amt
88       FROM po_lines pol,
89            po_distributions pod
90      WHERE pol.po_header_id = p_document_id
91        AND pod.po_line_id = pol.po_line_id;
92     END IF;
93   END IF;
94 
95   return l_tax_amt;
96 end getTax;
97 
98 
99 
100 END PO_NOTIFICATION_UTIL;