DBA Data[Home] [Help]

PACKAGE BODY: APPS.CST_COMMON_HOOKS

Source


1 PACKAGE BODY  CST_Common_hooks AS
2 /* $Header: CSTCOHKB.pls 120.1.12020000.2 2012/11/27 14:54:27 mpuranik ship $ */
3 
4 /*--------------------------------------------------------------------------------
5 | FUNCTION                                                                        |
6 |  Get_NRtax_amount                                                               |
7 |  This function is used to get the additional taxes involved in PO or            |
8 |  Internal order receiving transactions that will be used to calculate the       |
9 |  Encumbrance amount that is required to create the encumbrance reversal         |
10 |  entry for PO and Internal Orders receiving  transactions to Inventory/Expense  |
11 |  destinations.                                                                  |
12 |  integer 1	Hook has been used get Recoverable and Non Recoverable tax amount |
13 |               from hook and use them for computing Encumbrance Amount.          |
14 |	   0  	No Taxes involved use original amount derived by system logic.    |
15 |         -1       Error in Hook                                                  |
16 ---------------------------------------------------------------------------------*/
17 
18 function Get_NRtax_amount(
19   I_ACCT_TXN_ID	    IN 	NUMBER,
20   I_SOURCE_DOC_TYPE IN  VARCHAR2,
21   I_SOURCE_DOC_ID   IN  NUMBER,
22   I_ACCT_SOURCE     IN  VARCHAR2,
23   I_USER_ID	    IN	NUMBER,
24   I_LOGIN_ID        IN	NUMBER,
25   I_REQ_ID	    IN	NUMBER,
26   I_PRG_APPL_ID	    IN	NUMBER,
27   I_PRG_ID	    IN 	NUMBER,
28   O_DOC_NR_TAX      OUT NOCOPY  NUMBER,
29   O_DOC_REC_TAX     OUT NOCOPY  NUMBER,
30   O_Err_Num	    OUT NOCOPY	NUMBER,
31   O_Err_Code	    OUT NOCOPY	VARCHAR2,
32   O_Err_Msg	    OUT NOCOPY	VARCHAR2
33 )
34 return integer IS
35 l_hook	          NUMBER;
36 l_err_num         NUMBER;
37 l_err_code        VARCHAR2(240);
38 l_err_msg         VARCHAR2(8000);
39 l_stmt_num        NUMBER;
40 l_currency_code   gl_sets_of_books.currency_code %TYPE;
41 undefined_source  EXCEPTION;
42 l_debug           VARCHAR2(80);
43 
44 BEGIN
45   /* Intialize local variables */
46   l_hook          :=0;
47   l_err_num       :=0;
48   l_err_code      :='';
49   l_err_msg       :='';
50   l_currency_code :='';
51 
52 l_debug := fnd_profile.value('MRP_DEBUG');
53 /* Getting Currency information for OU */
54   l_stmt_num :=10;
55 
56 IF l_debug = 'Y' THEN
57    fnd_file.put_line(fnd_file.log, 'Get_NRtax_amount <<');
58    fnd_file.put_line(fnd_file.log, 'Transaction_id  : '||I_ACCT_TXN_ID);
59    fnd_file.put_line(fnd_file.log, 'Source Doc Type : '||I_SOURCE_DOC_TYPE);
60    fnd_file.put_line(fnd_file.log, 'Source Doc ID   : '||I_SOURCE_DOC_ID);
61    fnd_file.put_line(fnd_file.log, 'Accounting Src  : '||I_ACCT_SOURCE);
62 END IF;
63 
64 
65 IF ( I_SOURCE_DOC_TYPE IN ('PO','REQ') AND  I_ACCT_SOURCE ='MMT') THEN
66 	SELECT DISTINCT cod.currency_code
67 	  INTO l_currency_code
68 	  FROM mtl_material_transactions mmt,
69 	       cst_organization_definitions cod
70 	 WHERE mmt.organization_id    =cod.organization_id
71 	   AND mmt.transaction_id     =I_ACCT_TXN_ID;
72 
73 ELSIF (I_SOURCE_DOC_TYPE IN ('PO') AND  I_ACCT_SOURCE ='RCV' ) THEN
74 	 SELECT DISTINCT gsob.currency_code
75 	   INTO l_currency_code
76 	   FROM po_distributions_all          pod,
77 		gl_sets_of_books              gsob
78 	  WHERE pod.set_of_books_id           =gsob.set_of_books_id
79 	    AND pod.po_distribution_id        =I_SOURCE_DOC_ID;
80   ELSE
81      raise undefined_source;
82 END IF;
83 
84 IF l_debug = 'Y' THEN
85    fnd_file.put_line(fnd_file.log, 'Currency Code : '||l_currency_code);
86 END IF;
87 
88   l_stmt_num :=20;
89      /* Check for Indian Local Accounting This will return
90             TRUE  - Indian Local Accounting used
91             FALSE - Indian Local Accounting not used */
92 
93      IF ( AD_EVENT_REGISTRY_PKG.Is_Event_Done( p_Owner            => 'JA',
94                                                p_Event_Name => 'JAI_EXISTENCE_OF_TABLES' ) = TRUE  )
95        AND l_currency_code = 'INR'
96      THEN
97      l_stmt_num :=20;
98      jai_encum_prc.fetch_encum_rev_amt( p_acct_txn_id        =>I_ACCT_TXN_ID,
99 				        p_source_doc_type    =>I_SOURCE_DOC_TYPE,
100 				        p_source_doc_id      =>I_SOURCE_DOC_ID,
101 				        p_acct_source        =>I_ACCT_SOURCE,
102 				        p_nr_tax_amount      =>O_DOC_NR_TAX,
103 				        p_rec_tax_amount     =>O_DOC_REC_TAX,
104 				        p_err_num            =>l_err_num,
105 				        p_err_code           =>l_err_code,
106 				        p_err_msg            =>l_err_msg);
107 	     l_hook:=1;
108 	     if(l_err_num <>0 )then
109 
110 		o_err_num  := l_err_num;
111 		o_err_code := l_err_code;
112 		o_err_msg  := substr(l_err_msg,1,240);
113 		   return -1;
114 	     end if;
115 	     return 1;
116      ELSE
117              l_hook        :=0;
118 	     O_DOC_NR_TAX  :=0;
119 	     O_DOC_REC_TAX :=0;
120    	     o_err_num     :=0;
121 	     o_err_code    :='';
122 	     o_err_msg     :='';
123 	     return 0;
124      END IF;
125 
126 EXCEPTION
127   when undefined_source then
128     o_err_num  := -1;
129     o_err_code := 'undefined_source';
130     o_err_msg  := 'CST_Common_hooks.Get_NRtax_amount: ' || to_char(l_stmt_num)|| substrb('Unrecognised Transactions Source',1,180);
131     return -1;
132 
133   when others then
134     o_err_num  := -1;
135     o_err_code := SQLCODE;
136     o_err_msg  := 'CST_Common_hooks.Get_NRtax_amount: ' || to_char(l_stmt_num)|| substrb(SQLERRM,1,180);
137     return -1;
138 END Get_NRtax_amount;
139 
140 -- FUNCTION
141 --  get_prd_cls_zeroval_option
142 --  This function can be used to turn off the summarization
143 --  and display in period close reconciliation and summary
144 --  of items that have zero value in the current period.
145 --  By default the function returns a value of 0 which means
146 --  that all items will be included.
147 --  The return value can be modified to 1 to prevent the
148 --  zero value items from being included.
149 --  The behavior can also be customized based on the organization
150 --  and accounting period.
151 --
152 --  Return Values
153 --   integer              0     Include all items
154 --                        1     Do not include zero value items
155 --                 Any other    Include all items
156 --
157 function get_prd_cls_zeroval_option (
158         i_org_id                IN      NUMBER,
159         i_acct_period_id        IN      NUMBER,
160         o_err_num               OUT NOCOPY    NUMBER,
161         o_err_code              OUT NOCOPY    VARCHAR2,
162         o_err_msg               OUT NOCOPY    VARCHAR2
163    )
164 return integer IS
165 
166 l_hook	NUMBER	:= 0;
167 l_err_num NUMBER := 0;
168 l_err_code VARCHAR2(240) := '';
169 l_err_msg  VARCHAR2(8000) := '';
170 
171 BEGIN
172 
173   o_err_num := l_err_num;
174   o_err_code := l_err_code;
175   o_err_msg := l_err_msg;
176 
177   return l_hook;
178 
179 EXCEPTION
180   when others then
181     o_err_num := -1;
182     o_err_code := SQLCODE;
183     o_err_msg := 'CSTPACHK.get_prd_cls_zeroval_option:' || substrb(SQLERRM,1,150);
184     return 0;
185 END get_prd_cls_zeroval_option;
186 
187 END CST_Common_hooks;