DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGI_IAC_XLA_EVENTS_PKG

Source


1 PACKAGE BODY IGI_IAC_XLA_EVENTS_PKG as
2 /* $Header: igixlehb.pls 120.0.12000000.2 2007/10/24 16:08:44 npandya noship $   */
3 --===========================FND_LOG.START=====================================
4 
5 g_state_level NUMBER	  ;
6 g_proc_level  NUMBER	  ;
7 g_event_level NUMBER	  ;
8 g_excep_level NUMBER	  ;
9 g_error_level NUMBER	  ;
10 g_unexp_level NUMBER	  ;
11 g_path        VARCHAR2(1000) ;
12 
13 --===========================FND_LOG.END=====================================
14 
15 
16 FUNCTION create_revaluation_event
17            (p_revaluation_id         IN NUMBER,
18             p_event_id               IN OUT NOCOPY NUMBER
19            ) return boolean IS
20 
21    l_reval_source_info  XLA_EVENTS_PUB_PKG.t_event_source_info;
22    l_security_context XLA_EVENTS_PUB_PKG.t_security;
23    l_event_type_code  varchar2(30);
24    l_event_date       date;
25    l_event_status     varchar2(30);
26    l_valuation_method varchar2(30);
27    l_book_type_code   varchar2(30);
28    l_revaluation_date date;
29    l_ledger_id             gl_sets_of_books.set_of_books_id%TYPE;
30    l_chart_of_accounts_id  gl_sets_of_books.chart_of_accounts_id%TYPE;
31    l_currency_code         gl_sets_of_books.currency_code%TYPE;
32    l_precision             fnd_currencies.precision%TYPE;
33    invalid_ledger          exception;
34    l_path_name             varchar2(150) := g_path || 'create_revaluation_event';
35 
36 BEGIN
37    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
38    p_full_path => l_path_name,
39    p_string => 'create_revaluation_event....Welcome... ');
40 
41    select book_type_code,revaluation_date
42    into l_book_type_code,l_revaluation_date
43    from igi_iac_revaluations
44    where revaluation_id =p_revaluation_id;
45 
46    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
47    p_full_path => l_path_name,
48    p_string => 'l_book_type_code = ' || l_book_type_code);
49 
50    -- Find the set_of_books_id and the currency code
51    IF (igi_iac_common_utils.get_book_gl_info(l_book_type_code
52                                             ,l_ledger_id
53                                             ,l_chart_of_accounts_id
54                                             ,l_currency_code
55                                             ,l_precision))  THEN
56 
57        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
58 	   p_full_path => l_path_name,
59 	   p_string => 'GL book info found for ledger_id = '||l_ledger_id);
60     ELSE
61        raise invalid_ledger;
62     END IF;
63 
64    l_reval_source_info.application_id        := 140; --Assets
65    l_reval_source_info.legal_entity_id       := NULL;
66    l_reval_source_info.ledger_id             := l_ledger_id;
67    l_reval_source_info.transaction_number    := to_char(p_revaluation_id);
68    l_reval_source_info.source_id_int_1       := p_revaluation_id;
69    l_reval_source_info.entity_type_code      := 'TRANSACTIONS';
70    l_event_type_code                         := 'INFLATION_REVALUATION';
71    l_valuation_method                        := l_book_type_code;
72    l_event_date                              := sysdate; --l_revaluation_date;
73    l_event_status                            := XLA_EVENTS_PUB_PKG.C_EVENT_UNPROCESSED;
74 
75    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
76    p_full_path => l_path_name,
77    p_string => 'p_revaluation_id = ' || p_revaluation_id);
78 
79    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
80    p_full_path => l_path_name,
81    p_string => 'Calling xla create event api.');
82 
83    -- Call XLA API
84    p_event_id :=
85      XLA_EVENTS_PUB_PKG.create_event
86           (p_event_source_info   => l_reval_source_info,
87            p_event_type_code     => l_event_type_code,
88            p_event_date          => l_event_date,
89            p_event_status_code   => l_event_status,
90            p_event_number        => NULL,
91            p_reference_info      => NULL,
92            p_valuation_method    => l_valuation_method,
93            p_security_context    => l_security_context);
94 
95    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
96    p_full_path => l_path_name,
97    p_string => 'p_event_id = ' || p_event_id);
98 
99    igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
100    p_full_path => l_path_name,
101    p_string => 'create_revaluation_event....Bye... ');
102 
103    return true;
104 
105 EXCEPTION
106   WHEN invalid_ledger THEN
107        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
108 	   p_full_path => l_path_name,
109 	   p_string => 'GL book info not found for book = '|| l_book_type_code);
110        igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
111        return FALSE;
112 
113   WHEN OTHERS THEN
114        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
115 	   p_full_path => l_path_name,
116 	   p_string => 'Fatal Error = '|| sqlerrm);
117        igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
118        return FALSE;
119 END create_revaluation_event;
120 
121 
122 FUNCTION update_revaluation_event
123            ( p_revaluation_id         IN NUMBER ) return boolean IS
124 
125    l_reval_source_info  XLA_EVENTS_PUB_PKG.t_event_source_info;
126    l_security_context XLA_EVENTS_PUB_PKG.t_security;
127    l_event_type_code  varchar2(30);
128    l_event_date       date;
129    l_event_status     varchar2(30);
130    l_valuation_method varchar2(30);
131    l_book_type_code   varchar2(30);
132    l_revaluation_date date;
133    l_ledger_id             gl_sets_of_books.set_of_books_id%TYPE;
134    l_chart_of_accounts_id  gl_sets_of_books.chart_of_accounts_id%TYPE;
135    l_currency_code         gl_sets_of_books.currency_code%TYPE;
136    l_precision             fnd_currencies.precision%TYPE;
137    invalid_ledger          exception;
138    l_event_id          number;
139    l_path_name             varchar2(150) := g_path || 'update_revaluation_event';
140 begin
141 
142    select book_type_code,revaluation_date,event_id
143    into l_book_type_code,l_revaluation_date,l_event_id
144    from igi_iac_revaluations
145    where revaluation_id =p_revaluation_id;
146 
147    -- Find the set_of_books_id and the currency code
148    IF (igi_iac_common_utils.get_book_gl_info(l_book_type_code
149                                             ,l_ledger_id
150                                             ,l_chart_of_accounts_id
151                                             ,l_currency_code
152                                             ,l_precision))  THEN
153 
154        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
155 	   p_full_path => l_path_name,
156 	   p_string => 'GL book info found for ledger_id = '||l_ledger_id);
157     ELSE
158        raise invalid_ledger;
159     END IF;
160 
161    l_reval_source_info.application_id        := 140; --Assets
162    l_reval_source_info.legal_entity_id       := NULL;
163    l_reval_source_info.ledger_id             := l_ledger_id;
164    l_reval_source_info.transaction_number    := to_char(p_revaluation_id);
165    l_reval_source_info.source_id_int_1       := p_revaluation_id;
166    l_reval_source_info.entity_type_code      := 'TRANSACTIONS';
167    l_event_type_code                         := 'INFLATION_REVALUATION';
168 
169    XLA_EVENTS_PUB_PKG.update_event
170      (p_event_source_info            => l_reval_source_info,
171       p_event_id                     => l_event_id,
172       p_event_type_code              => l_event_type_code,
173       p_event_date                   => null, --tbd
174       p_event_status_code            => null, --tbd
175       p_valuation_method             => l_book_type_code,
176       p_security_context             => l_security_context);
177 
178   return true;
179 
180 EXCEPTION
181 WHEN OTHERS THEN
182        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
183 	   p_full_path => l_path_name,
184 	   p_string => 'Fatal Error = '|| sqlerrm);
185        igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
186        return FALSE;
187 
188 end update_revaluation_event;
189 
190 
191 FUNCTION delete_revaluation_event
192            (p_revaluation_id         IN NUMBER) return boolean IS
193 
194    l_event_id         NUMBER;
195    l_reval_source_info  XLA_EVENTS_PUB_PKG.t_event_source_info;
196    l_security_context XLA_EVENTS_PUB_PKG.t_security;
197    l_event_type_code  varchar2(30);
198    l_event_date       date;
199    l_event_status     varchar2(30);
200    l_valuation_method varchar2(30);
201    l_book_type_code   varchar2(30);
202    l_revaluation_date date;
203    l_ledger_id             gl_sets_of_books.set_of_books_id%TYPE;
204    l_chart_of_accounts_id  gl_sets_of_books.chart_of_accounts_id%TYPE;
205    l_currency_code         gl_sets_of_books.currency_code%TYPE;
206    l_precision             fnd_currencies.precision%TYPE;
207    invalid_ledger          exception;
208    l_path_name             varchar2(150) := g_path || 'create_revaluation_event';
209 
210 BEGIN
211 
212    select book_type_code,revaluation_date
213    into l_book_type_code,l_revaluation_date
214    from igi_iac_revaluations
215    where revaluation_id =p_revaluation_id;
216 
217    -- Find the set_of_books_id and the currency code
218    IF (igi_iac_common_utils.get_book_gl_info(l_book_type_code
219                                             ,l_ledger_id
220                                             ,l_chart_of_accounts_id
221                                             ,l_currency_code
222                                             ,l_precision))  THEN
223 
224        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
225 	   p_full_path => l_path_name,
226 	   p_string => 'GL book info found for ledger_id = '||l_ledger_id);
227     ELSE
228        raise invalid_ledger;
229     END IF;
230 
231    l_reval_source_info.application_id        := 140; --Assets
232    l_reval_source_info.legal_entity_id       := NULL;
233    l_reval_source_info.ledger_id             := l_ledger_id;
234    l_reval_source_info.transaction_number    := to_char(p_revaluation_id);
235    l_reval_source_info.source_id_int_1       := p_revaluation_id;
236    l_reval_source_info.entity_type_code      := 'TRANSACTIONS';
237    l_event_type_code                         := 'INFLATION_REVALUATION';
238    l_valuation_method                        := l_valuation_method;
239 
240    XLA_EVENTS_PUB_PKG.delete_event
241       (p_event_source_info            => l_reval_source_info,
242        p_event_id                     => l_event_id,
243        p_valuation_method             => l_book_type_code,
244        p_security_context             => l_security_context);
245 
246    return true;
247 
248 EXCEPTION
249 WHEN OTHERS THEN
250        igi_iac_debug_pkg.debug_other_string(p_level => g_state_level,
251 	   p_full_path => l_path_name,
252 	   p_string => 'Fatal Error = '|| sqlerrm);
253        igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
254        return FALSE;
255 
256 END delete_revaluation_event;
257 
258  BEGIN
259  --===========================FND_LOG.START=====================================
260 
261     g_state_level :=	FND_LOG.LEVEL_STATEMENT;
262     g_proc_level  :=	FND_LOG.LEVEL_PROCEDURE;
263     g_event_level :=	FND_LOG.LEVEL_EVENT;
264     g_excep_level :=	FND_LOG.LEVEL_EXCEPTION;
265     g_error_level :=	FND_LOG.LEVEL_ERROR;
266     g_unexp_level :=	FND_LOG.LEVEL_UNEXPECTED;
267     g_path        := 'IGI.PLSQL.igixevtb.igi_iac_xla_events_pkg.';
268 
269 --===========================FND_LOG.END=====================================
270 
271 END IGI_IAC_XLA_EVENTS_PKG;
272