DBA Data[Home] [Help]

PACKAGE BODY: APPS.JAI_RGM_GST_ACCOUNTING_PKG

Source


1 PACKAGE BODY jai_rgm_gst_accounting_pkg AS
2 /* $Header: jai_gst_acct_pkg.plb 120.1 2010/09/07 07:55:29 boboli noship $ */
3 --+=======================================================================+
4 --|               Copyright (c) 1998 Oracle Corporation                   |
5 --|                       Redwood Shores, CA, USA                         |
6 --|                         All rights reserved.                          |
7 --+=======================================================================+
8 --| FILENAME                                                              |
9 --|     jai_gst_acct_pkg.plb                                    |
10 --|                                                                       |
11 --| DESCRIPTION                                                           |
12 --|     This package is API for generate accounting entry and insert      |
13 --|     repository table                                                  |
14 --|                                                                       |
15 --| TDD REFERENCE                                                         |
16 --|     Take reference  TDD_12_2_FIN_JAI_Enhanced_GST.doc                 |
17 --|                                                                       |
18 --|                                                                       |
19 --| PURPOSE                                                               |
20 --|     PROCEDURE create_repository_entry                                 |
21 --|     FUNCTION  create_gl_entry                                         |
22 --|                                                                       |
23 --| HISTORY                                                               |
24 --|     02-Sep-2010  Created by Bo Li for  bug#10043656                   |
25 --|                  GST Enhancement for R12.1.3                          |
26 --|                                                                       |
27 --+======================================================================*/
28 
29   PROCEDURE create_repository_entry(
30     pn_repository_id           OUT NOCOPY NUMBER,
31     pn_regime_id               IN      NUMBER,
32     pv_tax_type                IN      VARCHAR2,
33     pv_organization_type       IN      VARCHAR2,
34     pn_organization_id         IN      NUMBER,
35     pn_location_id             IN      NUMBER,
36     pv_source                  IN      VARCHAR2,
37     pv_source_trx_type         IN      VARCHAR2,
38     pv_source_table_name       IN      VARCHAR2,
39     pn_source_document_id      IN      NUMBER,
40     pd_transaction_date        IN      DATE,
41     pv_account_name            IN      VARCHAR2,
42     pn_charge_account_id       IN      NUMBER,
43     pn_balancing_account_id    IN      NUMBER,
44     pn_amount                  IN      NUMBER,
45     pn_assessable_value        IN      NUMBER,
46     pn_tax_rate                IN      NUMBER,
47     pn_reference_id            IN      NUMBER,
48     pn_batch_id                IN      NUMBER,
49     pv_called_from             IN      VARCHAR2,
50     pn_inv_organization_id     IN      NUMBER    DEFAULT NULL,
51     pn_settlement_id           IN      NUMBER    DEFAULT NULL,
52     pv_balancing_orgn_type     IN      VARCHAR2  DEFAULT NULL,
53     pn_balancing_orgn_id       IN      NUMBER    DEFAULT NULL,
54     pn_balancing_location_id   IN      NUMBER    DEFAULT NULL,
55     pv_balancing_tax_type      IN      VARCHAR2  DEFAULT NULL,
56     pv_balancing_accnt_name    IN      VARCHAR2  DEFAULT NULL,
57     pv_currency_code           IN      VARCHAR2  DEFAULT jai_constants.func_curr,
58     pd_curr_conv_date          IN      DATE      DEFAULT NULL,
59     pv_curr_conv_type          IN      VARCHAR2  DEFAULT NULL,
60     pn_curr_conv_rate          IN      VARCHAR2  DEFAULT NULL,
61     pn_trx_amount              IN      NUMBER    DEFAULT NULL,
62     pv_trx_reference_context   IN      VARCHAR2  DEFAULT NULL,
63     pv_trx_reference1          IN      VARCHAR2  DEFAULT NULL,
64     pv_trx_reference2          IN      VARCHAR2  DEFAULT NULL,
65     pv_trx_reference3          IN      VARCHAR2  DEFAULT NULL,
66     pv_trx_reference4          IN      VARCHAR2  DEFAULT NULL,
67     pv_trx_reference5          IN      VARCHAR2  DEFAULT NULL,
68     pv_service_type_code       IN      VARCHAR2  DEFAULT NULL,
69     pv_distribution_type       IN      VARCHAR2  DEFAULT NULL,
70     pv_process_flag            OUT NOCOPY VARCHAR2,
71     pv_process_message         OUT NOCOPY VARCHAR2
72 /* Would need to include invoice no, invoice date, assessable value  -- Shyam */
73   ) IS
74 
75     lv_regime_code              JAI_RGM_DEFINITIONS.regime_code%TYPE;
76     lv_statement                VARCHAR2(4);
77     lv_codepath                 VARCHAR2(500) := '';
78     ln_org_id                   NUMBER;
79     ln_bal_org_id               NUMBER;
80     ln_trx_amount               NUMBER;
81     ln_amount                   NUMBER;
82 
83     ln_credit                   NUMBER;
84     ln_debit                    NUMBER;
85     ln_trx_credit               NUMBER;
86     ln_trx_debit                NUMBER;
87 
88     lv_register_entry_type      VARCHAR2(2);
89     lv_account_name             JAI_RGM_TRX_RECORDS.account_name%TYPE;
90 
91     ln_charge_account_id        JAI_RGM_TRX_RECORDS.charge_account_id%TYPE;
92     ln_balancing_account_id     JAI_RGM_TRX_RECORDS.charge_account_id%TYPE;
93     lv_primary_regime_regno     JAI_RGM_REGISTRATIONS.ATTRIBUTE_VALUE%TYPE;
94 
95     lv_balancing_tax_type       JAI_RGM_TRX_RECORDS.tax_type%TYPE;
96     lv_balancing_orgn_type      JAI_RGM_TRX_RECORDS.organization_type%TYPE;
97     ln_balancing_orgn_id        JAI_RGM_TRX_RECORDS.organization_id%TYPE;
98     ln_balancing_location_id    JAI_RGM_TRX_RECORDS.location_id%TYPE;
99     lv_balancing_accnt_name     JAI_RGM_TRX_RECORDS.account_name%TYPE;
100 
101 
102     /*
103       Cursor to fetch the primary registration number
104     */
105 
106     CURSOR cur_primary_regno IS
107     SELECT attribute_value
108     FROM   jai_rgm_org_regns_v
109     WHERE  regime_id           = pn_regime_id
110     AND    organization_id     = pn_organization_id
111     AND    organization_type   = pv_organization_type
112     AND    registration_type   = jai_constants.regn_type_others
113     AND    attribute_Type_code = 'PRIMARY';
114 
115     CURSOR cur_fetch_ou(cpn_organization_id NUMBER)
116     IS
117     SELECT org_information3
118     FROM   hr_organization_information
119     WHERE  upper(ORG_INFORMATION_CONTEXT) = 'ACCOUNTING INFORMATION'
120     AND    organization_id                = cpn_organization_id;
121 
122    CURSOR   cur_interorg_accts
123             (cpn_organization_id NUMBER) IS
124    SELECT   interorg_payables_account,
125             interorg_receivables_account
126    FROM      mtl_parameters_view
127    WHERE     organization_id = cpn_organization_id;
128 
129     r_interorg_accts      cur_interorg_accts%rowtype;
130 
131   BEGIN
132 
133     lv_statement := '0';
134     lv_codepath := jai_general_pkg.plot_codepath(1, lv_codepath, 'Insert_Repository_Entry', 'START');
135 
136     lv_regime_code := JAI_GST_GENERAL_PKG.get_regime_code(pn_regime_id);
137 
138     OPEN  cur_fetch_ou(pn_organization_id);
139     FETCH cur_fetch_ou INTO ln_org_id;
140     CLOSE cur_fetch_ou;
141 
142     OPEN  cur_fetch_ou(pn_balancing_orgn_id);
143     FETCH cur_fetch_ou INTO ln_bal_org_id;
144     CLOSE cur_fetch_ou;
145 
146     lv_statement := '1';
147 
148     -- Rounding of Service Tax that is hitting repository
149     ln_amount := round(pn_amount, jai_constants.service_rgm_rnd_factor);
150 
151     IF pn_trx_amount = 0 OR pn_trx_amount IS NULL THEN
152       ln_trx_amount := NULL;
153     ELSE
154       ln_trx_amount := round(pn_trx_amount, jai_constants.service_rgm_rnd_factor);
155     END IF;
156 
157     lv_statement            := '2';
158 
159     lv_codepath := jai_general_pkg.plot_codepath(2.1, lv_codepath);
160 
161     lv_statement := '2.1';
162 
163     IF pv_source = jai_constants.source_ap THEN
164       lv_statement := '3';
165       lv_codepath := jai_general_pkg.plot_codepath(3, lv_codepath);
166       lv_register_entry_type  := jai_constants.credit;
167       lv_account_name         := jai_constants.recovery;
168       lv_balancing_accnt_name := jai_constants.recovery_interim;
169 
170 
171     ELSIF pv_source = jai_constants.source_ar THEN
172       lv_statement := '4';
173       lv_codepath := jai_general_pkg.plot_codepath(4, lv_codepath);
174       lv_register_entry_type  := jai_constants.debit;
175       lv_account_name         := jai_constants.liability;
176       lv_balancing_accnt_name := jai_constants.liability_interim;
177 
178 
179     ELSIF pv_source = jai_constants.source_manual_entry THEN
180       lv_statement := '5';
181       lv_codepath := jai_general_pkg.plot_codepath(5, lv_codepath);
182       lv_account_name := pv_account_name;
183       IF lv_account_name IN (jai_constants.recovery, jai_constants.recovery_interim) THEN
184         lv_codepath := jai_general_pkg.plot_codepath(6, lv_codepath);
185         lv_register_entry_type  := jai_constants.credit;
186       ELSIF lv_account_name IN (jai_constants.liability, jai_constants.liability_interim) THEN
187         lv_codepath := jai_general_pkg.plot_codepath(7, lv_codepath);
188         lv_register_entry_type  := jai_constants.debit;
189       END IF;
190 
191     /* Incase of Distributions and settlements, we hit only recovery account and decrease/increase
192     repository amounts as per _OUT/_IN trxns*/
193     ELSIF (pv_source IN (jai_constants.service_src_distribute_out) AND nvl(pv_distribution_type,'X')='S-S'
194     AND nvl(ln_org_id,0)=nvl(ln_bal_org_id,0)) or (pv_source in( jai_constants.source_settle_out,jai_constants.service_src_distribute_out)
195     AND nvl(pv_distribution_type,'X')='X' )
196     THEN
197       lv_statement := '6';
198       lv_codepath := jai_general_pkg.plot_codepath(8, lv_codepath);
199       lv_register_entry_type    := jai_constants.debit;
200       lv_account_name           := jai_constants.recovery;
201       lv_balancing_accnt_name   := jai_constants.recovery;
202 
203       IF (pv_source = jai_constants.source_settle_out) THEN
204         lv_balancing_accnt_name := jai_constants.liability;
205       END IF;
206 
207     ELSIF (pv_source IN (jai_constants.service_src_distribute_in)
208     AND NVL(pv_distribution_type,'X')='S-S'
209     AND nvl(ln_org_id,0)=nvl(ln_bal_org_id,0)) OR (pv_source in( jai_constants.source_settle_in,jai_constants.service_src_distribute_in)
210     AND nvl(pv_distribution_type,'X')='X')
211     THEN
212       lv_statement := '7';
213       lv_codepath := jai_general_pkg.plot_codepath(9, lv_codepath);
214       lv_register_entry_type    := jai_constants.credit;
215       lv_account_name           := jai_constants.recovery;
216       lv_balancing_accnt_name   := jai_constants.recovery;
217       IF (pv_source = jai_constants.source_settle_in) THEN
218         lv_account_name := jai_constants.liability;
219       END IF;
220 
221     ELSIF ( pv_source IN (jai_constants.service_src_distribute_out)
222     AND NVL(pv_distribution_type,'X')='S-S'
223     AND  nvl(ln_org_id,0)<>nvl(ln_bal_org_id,0) )
224     THEN
225 
226      OPEN  cur_interorg_accts(pn_organization_id);
227      FETCH cur_interorg_accts into r_interorg_accts;
228      CLOSE cur_interorg_accts;
229 
230       lv_statement := '8';
231       lv_codepath := jai_general_pkg.plot_codepath(10, lv_codepath);
232       lv_register_entry_type    := jai_constants.debit;
233       lv_account_name           := jai_constants.recovery;
234       lv_balancing_accnt_name   :='InterOrg Receivable Account';
235       ln_balancing_account_id   :=r_interorg_accts.interorg_receivables_account;
236 
237     ELSIF ( pv_source IN (jai_constants.service_src_distribute_in)
238     AND NVL(pv_distribution_type,'X')='S-S'
239     AND  nvl(ln_org_id,0)<>nvl(ln_bal_org_id,0) )  THEN
240 
241      open  cur_interorg_accts(pn_organization_id);
242      fetch cur_interorg_accts into r_interorg_accts;
243      close cur_interorg_accts;
244       lv_statement := '9';
245       lv_codepath := jai_general_pkg.plot_codepath(11, lv_codepath);
246       lv_register_entry_type    := jai_constants.credit;
247       lv_account_name           := jai_constants.recovery;
248 
249       lv_balancing_accnt_name   := 'Interorg Payable Account';
250       ln_balancing_account_id   :=r_interorg_accts.interorg_payables_account;
251     END IF;
252 
253     IF lv_register_entry_type = jai_constants.debit THEN
254       lv_statement := '10';
255       lv_codepath := jai_general_pkg.plot_codepath(10, lv_codepath);
256       ln_debit      := ln_amount;
257       ln_credit     := NULL;
258       ln_trx_debit  := nvl(ln_trx_amount, ln_amount);
259       ln_trx_credit := null;
260     ELSE
261       lv_statement := '11';
262       lv_codepath := jai_general_pkg.plot_codepath(11, lv_codepath);
263       ln_debit      := NULL;
264       ln_credit     := ln_amount;
265       ln_trx_debit  := null;
266       ln_trx_credit := nvl(ln_trx_amount, ln_amount);
267     END IF;
268 
269     lv_statement := '12';
270     IF pn_charge_account_id IS NULL THEN
271       lv_codepath := jai_general_pkg.plot_codepath(12, lv_codepath);
272 
273       ln_charge_account_id := JAI_GST_GENERAL_PKG.get_account(
274                                 p_regime_id         => pn_regime_id,
275                                 p_organization_type => pv_organization_type,
276                                 p_organization_id   => pn_organization_id,
277                                 p_location_id       => pn_location_id,
278                                 p_tax_type          => pv_tax_type,
279                                 p_account_name      => lv_account_name
280                               );
281 
282     ELSE
283       lv_statement := '13';
284       ln_charge_account_id := pn_charge_account_id;
285     END IF;
286 
287     lv_statement := '14';
288     lv_balancing_orgn_type      := pv_balancing_orgn_type;
289     ln_balancing_orgn_id        := pn_balancing_orgn_id;
290     ln_balancing_location_id    := pn_balancing_location_id;
291     lv_balancing_tax_type       := pv_balancing_tax_type;
292     lv_balancing_accnt_name     := nvl(pv_balancing_accnt_name, lv_balancing_accnt_name);
293 
294     lv_statement := '15';
295     IF ln_balancing_orgn_id IS NULL THEN
296       lv_codepath := jai_general_pkg.plot_codepath(13, lv_codepath);
297       lv_balancing_orgn_type      := pv_organization_type;
298       ln_balancing_orgn_id        := pn_organization_id;
299       ln_balancing_location_id    := pn_location_id;
300       lv_balancing_tax_type       := pv_tax_type;
301     END IF;
302 
303     lv_statement := '16';
304     IF pn_balancing_account_id IS NULL then
305        IF ln_balancing_account_id IS NULL THEN
306          lv_codepath := jai_general_pkg.plot_codepath(14, lv_codepath);
307 
308          ln_balancing_account_id := JAI_GST_GENERAL_PKG.get_account(
309                                                 p_regime_id         => pn_regime_id,
310                                                 p_organization_type => lv_balancing_orgn_type,
311                                                 p_organization_id   => ln_balancing_orgn_id,
312                                                 p_location_id       => ln_balancing_location_id,
313                                                 p_tax_type          => lv_balancing_tax_type,
314                                                 p_account_name      => lv_balancing_accnt_name
315                                                );
316        END IF;
317 
318     ELSE
319       ln_balancing_account_id := pn_balancing_account_id;
320     END IF;
321 
322     lv_statement := '17';
323 
324     OPEN   cur_primary_regno;
325     FETCH  cur_primary_regno into lv_primary_regime_regno;
326     CLOSE  cur_primary_regno;
327 
328     lv_codepath := jai_general_pkg.plot_codepath(15, lv_codepath);
329     INSERT INTO jai_rgm_trx_records (
330       repository_id,
331       regime_code,
332       tax_type,
333       source,
334       source_document_id,
335       source_table_name,
336       transaction_date,
337       debit_amount,
338       credit_amount,
339       settled_amount,
340       settled_flag,
341       settlement_id,
342       organization_type,
343       organization_id,
344       location_id,
345       account_name,
346       charge_account_id,
347       balancing_account_id,
348       reference_id,
349       source_trx_type,
350       tax_rate,
351       assessable_value,
352       batch_id,
353       trx_currency,
354       curr_conv_date,
355       curr_conv_rate,
356       trx_credit_amount,
357       trx_debit_amount,
358       creation_date,
359       created_by,
360       last_update_date,
361       last_updated_by,
362       last_update_login,
363       attribute_context,
364       attribute1,
365       attribute2,
366       attribute3,
367       attribute4,
368       attribute5,
369       inv_organization_id,
370       regime_primary_regno,
371       service_type_code
372     )
373     VALUES
374     (
375       jai_rgm_trx_records_s.nextval,         /*      repository_id,         */
376       lv_regime_code,                        /*      regime_code,           */
377       pv_tax_type,                            /*      tax_type,              */
378       pv_source,                              /*      source,                */
379       pn_source_document_id,                  /*      source_document_id,    */
380       pv_source_table_name,                   /*      source_table_name,     */
381       pd_transaction_date,                    /*      transaction_date,      */
382       ln_debit,                              /*      debit_amount,          */
383       ln_credit,                             /*      credit_amount,         */
384       null,                                  /*      settled_amount,        */
385       null,                                  /*      settled_flag,          */
386       pn_settlement_id,                       /*      settlement_id,         */
387       pv_organization_type,                   /*      organization_type,     */
388       pn_organization_id,                     /*      organization_id,       */
389       pn_location_id,                         /*      location_id,           */
390       pv_account_name,                        /*      account_name,          */
391       ln_charge_account_id,                  /*      charge_account_id,     */
392       ln_balancing_account_id,               /*      balancing_account_id,  */
393       pn_reference_id,                        /*      reference_id,          */
394       pv_source_trx_type,                     /*      source_trx_type,       */
395       pn_tax_rate,                            /*      tax_rate,              */
396       pn_assessable_value,                    /*      assessable_value,      */
397       pn_batch_id,                            /*      batch_id,              */
398       pv_currency_code,                       /*      trx_currency,          */
399       pd_curr_conv_date,                      /*      curr_conv_date,        */
400       pn_curr_conv_rate,                      /*      curr_conv_rate,        */
401       ln_trx_credit,                         /*      trx_credit_amount,     */
402       ln_trx_debit,                          /*      trx_debit_amount,      */
403       sysdate,                               /*      creation_date,         */
404       FND_GLOBAL.user_id,                    /*      created_by,            */
405       sysdate,                               /*      last_update_date,      */
406       FND_GLOBAL.user_id,                    /*      last_updated_by,       */
407       FND_GLOBAL.login_id,                   /*      last_update_login,     */
408       pv_trx_reference_context,
409       pv_trx_reference1,
410       pv_trx_reference2,
411       pv_trx_reference3,
412       pv_trx_reference4,
413       pv_trx_reference5,
414       pn_inv_organization_id,                 /*      inv_organization_id,   */
415       lv_primary_regime_regno,               /*      regime_primary_regno,  */
416       pv_service_type_code                    /*      service_type_code      */
417     ) RETURNING repository_id INTO pn_repository_id;
418 
419     lv_statement := '18';
420     pv_process_flag    := jai_constants.successful;
421     pv_process_message := 'Successful';
422 
423   EXCEPTION
424     WHEN OTHERS THEN
425       pv_process_flag    := jai_constants.unexpected_error;
426       pv_process_message := 'Repository Error(Stmt:'||lv_statement||') Occured:'||SQLERRM;
427       lv_codepath := jai_general_pkg.plot_codepath(-999, lv_codepath);
428 
429   END create_repository_entry;
430 
431   PROCEDURE create_gl_entry
432           (pn_organization_id            NUMBER,
433            pn_credit_amount              NUMBER,
434            pn_debit_amount               NUMBER,
435            pn_cc_id                      NUMBER,
436            pv_je_source_name             VARCHAR2,
437            pv_je_category_name           VARCHAR2,
438            pd_accounting_date            DATE        DEFAULT NULL,
439            pd_currency_conversion_date   DATE        DEFAULT NULL,
440            pv_currency_conversion_type   VARCHAR2    DEFAULT NULL,
441            pn_currency_conversion_rate   NUMBER      DEFAULT NULL,
442            pv_reference_10               VARCHAR2    DEFAULT NULL,
443            pv_reference_23               VARCHAR2    DEFAULT NULL,
444            pv_reference_24               VARCHAR2    DEFAULT NULL,
445            pv_reference_25               VARCHAR2    DEFAULT NULL,
446            pv_reference_26               VARCHAR2    DEFAULT NULL
447            ) IS
448 
449   ld_creation_date              date   := sysdate;
450   ln_created_by                 number := fnd_global.user_id;
451   ln_set_of_books_id            number;
452   ld_accounting_date            date;
453   lv_organization_code          org_organization_definitions.organization_code%type;
454   lv_reference_entry            varchar2(240) := 'India Localization Entry';
455   lv_reference_1                gl_interface.reference1%type;
456   lv_reference_10               gl_interface.reference10%type;
457   lv_reference_23               gl_interface.reference23%type;
458   lv_reference_24               gl_interface.reference24%type;
459   lv_reference_25               gl_interface.reference25%type;
460   lv_reference_26               gl_interface.reference26%type;
461   lv_reference_27               gl_interface.reference27%type;
462 
463  cursor cur_curr_code (cpn_Set_of_books_id fnd_currencies.currency_code%type )is
464  select currency_Code
465  from   gl_Sets_of_books
466  where  set_of_books_id = cpn_Set_of_books_id;
467 
468  lv_currency_code fnd_currencies.currency_code%type;
469 
470 BEGIN
471 
472   For set_rec IN (SELECT set_of_books_id, organization_code
473                     FROM org_organization_definitions
474                    WHERE organization_id = pn_organization_id)
475   LOOP
476     ln_set_of_books_id := set_rec.set_of_books_id;
477     lv_organization_code := set_rec.organization_code;
478   END LOOP;
479 
480   lv_reference_10 := pv_reference_10 || ' for the Organization code ' || lv_organization_code;
481 
482   open cur_curr_code(ln_set_of_books_id);
483   fetch cur_curr_code into lv_currency_code;
484   close cur_curr_code;
485 
486   --This is introduced to ensure that if the reference values goes beyond the specified width,
487   --then the value would be restriced to an width of 240 so that exception would not occur.
488 
489   lv_reference_10   := substr(lv_reference_10,1,240);
490   lv_reference_23   := substr(pv_reference_23,1,240);
491   lv_reference_24   := substr(pv_reference_24,1,240);
492   lv_reference_25   := substr(pv_reference_25,1,240);
493   lv_reference_26   := substr(pv_reference_26,1,240);
494 
495 
496   IF gv_debug='Y' THEN
497    FND_FILE.PUT_LINE(FND_FILE.LOG, '**********Inside create_gl_entry Procedure' );
498    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.0 The Value of v_reference_1 is  ' || lv_reference_1 );
499    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.0 The Value of v_reference_10 is ' || lv_reference_10 );
500    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.1 The Value of v_reference_23 is ' || lv_reference_23 );
501    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.2 The Value of v_reference_24 is ' || lv_reference_24 );
502    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.3 The Value of v_reference_25 is ' || lv_reference_25 );
503    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of v_reference_26 is ' || lv_reference_26 );
504    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of v_reference_27 is ' || lv_reference_27 );
505    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of v_set_of_books_id is ' || ln_set_of_books_id );
506    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of v_organization_code is ' || lv_organization_code );
507    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of p_organization_id is ' || pn_organization_id);
508    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of p_credit_amount is ' || pn_credit_amount);
509    FND_FILE.PUT_LINE(FND_FILE.LOG, '9.4 The Value of p_debit_amount is ' || pn_debit_amount);
510   END IF;
511 
512   IF pd_accounting_date is null
513   THEN
514     ld_accounting_date := sysdate;
515   ELSE
516     ld_accounting_date := pd_accounting_date;
517   END IF;
518 
519   ld_accounting_date := trunc(ld_accounting_date);
520 
521   IF pn_cc_id is NULL THEN
522     RAISE_APPLICATION_ERROR(-20000,'Error raised in create_gl_entry. Code Combination Id Cannot be Populated as Null. Please Check.');
523   END IF;
524 
525 
526   IF NVL(pn_credit_amount, 0) <> 0 OR
527      NVL(pn_debit_amount, 0) <> 0
528   THEN
529 
530     INSERT into gl_interface
531            (status,
532            set_of_books_id,
533            user_je_source_name,
534            user_je_category_name,
535            accounting_date,
536            currency_code,
537            date_created,
538            created_by,
539            actual_flag,
540            entered_cr,
541            entered_dr,
542            transaction_date,
543            code_combination_id,
544            currency_conversion_date,
545            user_currency_conversion_type,
546            currency_conversion_rate,
547            reference1,
548            reference10,
549            reference22,
550            reference23,
551            reference24,
552            reference25,
553            reference26,
554            reference27
555            )
556     VALUES ('NEW',
557            ln_set_of_books_id,
558            pv_je_source_name,
559            pv_je_category_name,
560            ld_accounting_date,
561            lv_currency_code ,
562            ld_creation_date,
563            ln_created_by,
564            'A',
565            pn_credit_amount,
566            pn_debit_amount,
567            sysdate,
568            pn_cc_id,
569            pd_currency_conversion_date,
570            pv_currency_conversion_type,
571            pn_currency_conversion_rate,
572            lv_organization_code,  /* p_reference_1 */
573            lv_reference_10,
574            lv_reference_entry,    /* p_reference_22 */
575            lv_reference_23,
576            lv_reference_24,
577            lv_reference_25,
578            lv_reference_26,
579            to_char(pn_organization_id)  /* p_reference_27 */
580            );
581   END IF;
582   IF gv_debug='Y' THEN
583    FND_FILE.PUT_LINE(FND_FILE.LOG, '**********End of create_gl_entry Procedure' );
584   END IF;
585 
586  EXCEPTION
587  when others then
588    IF gv_debug='Y' THEN
589      FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error is raised in create_gl_entry procedure ' || sqlerrm );
590   END IF;
591   raise_application_error(-20106,'Error is raised in create_gl_entry procedure ' || sqlerrm);
592 
593 END create_gl_entry;
594 
595 END jai_rgm_gst_accounting_pkg;