DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_CA_BALANCE_PKG

Source


1 PACKAGE BODY pay_ca_balance_pkg AS
2 /* $Header: pycabals.pkb 115.24 2003/05/23 20:44:10 vpandya ship $ */
3 /*
4  +======================================================================+
5  |                Copyright (c) 1997 Oracle Corporation                 |
6  |                   Redwood Shores, California, USA                    |
7  |                        All rights reserved.                          |
8  +======================================================================+
9  Package Body Name :  pay_ca_balance_pkg
10  Package File Name :  pycabals.pkb
11  Description : This package declares functions which are ....
12                        call_ca_balance_get_value
13                        get_current_balance
14 
15  Change List:
16  ------------
17 
18  Name           Date       Version Bug     Text
19  -------------- ---------- ------- ------- ------------------------------
20  RThirlby      23-Oct-98   110.0           Initial Version
21  RThirlby      17-Nov-98   110.1           Added p_jurisdiction_code
22                                            and removed p_tax_unit.
23  RThirlby      11-Apr-99   110.2           Set default to p_business_group
24                                            to 0, so that will run if one
25                                            is not set. Also set p_report_
26                                            level to ASG for same reason.
27                                            NB Need Header file aswell,
28                                            pycabals.pkh v.110.2.
29  MMUKHERJ      12-MAY-99   110.3           1) Called get_defined_balance from
30                                            Canadian package which takes
31                                            business_group_id as an additional
32                                            parameter. 2)Changed the default
33                                            value of the business_group_id
34                                            parameter from 0 to NULL. To
35                                            ensure that set_context does not
36                                            fail, a local parameter of
37                                            l_business_group_id has been used.
38  JARTHURT      07-OCT-99   110.4           Remove 'upper' from balance_name
39                                            due to changes in
40                                            get_defined_balance function.
41                                            Set SOURCE_ID context.
42  JARTHURT      11-NOV-99   110.5           Return NULL if the
43                                            get_defined_balance routine
44                                            returns NULL
45  JARTHURT      24-NOV-99   110.6           Calculate CURRENT balance
46  jgoswami      06-DEC-1999 110.7           Overloading call_ca_balance_get_value,
47                                            added parameter p_source_id.
48                                            added l_report_unit in
49                                            l_dimension_suffix
50  JARTHURT      26-JAN-2000 110.8           Change hard-coding of balance
51                                            dimension in get_current_balance.
52  JARTHURT      28-JAN-2000 110.9           Correct building of dimension
53                                            suffix string.
54  RThirlby      11-FEB-2000 115.10          Changed all references to
55                                            pay_us_balance_view_pkg to
56                                            pay_ca_balance_view_pkg, except
57                                            for calls to debug procedures.
58                                            Added new procedure payments_bal-
59                                            ance_required. (This is a copy
60                                            from pay_us_taxbal_view_pkg).
61  RThirlby      05-JUN-2000 115.11          Added turn_off_dimension function
62                                            and turn_off_report_dimension
63                                            procedure. To help SOE view
64                                            performance.
65  MMUKHERJ      25-JAN-01   115.12          dbdrv command added
66  vpandya       03-May-02   115.15          Modified get_current_balance function
67                                            Added cursor csr_check_sep_chk, check
68                                            whether p_run_action_id is of sep
69                                            check or not, if yes then pass it
70                                            directly for calling get_value.
71                                            Modified cursor csr_get_aa_ids,
72                                            get all run aa id except sep chk.
73  TCLEWIS       09-SEP-02   115.16          Re-wrote payments_balance_required
74                                            to work with the umbrella process,
75                                            though I'm not sure it will be used
76                                            anymore.
77                                            Added code in call_ca_balance_get_value
78                                            to check for the ASG_PAYMENTS dimension
79                                            suffix.  IF the Dimension Suffix is
80                                            ASG_PAYMENTS call the core balance
81                                            user_exit (Get_VALUE) function.
82                                            Modified the code in
83                                            call_ca_balance_get_value, it a view
84                                            still attempts to fetch the current
85                                            value, change the defined balance to
86                                            <Element_name>_ASG_PAYMENTS and call
87                                            the core balance user exit (get_value)
88                                            instead of the get_current_value
89                                            function.  (Which I don't believe works).
90  TCLEWIS       29-OCT-02   115.17          modified the get_value function to check
91                                            the get current code if l_jd_context =
92                                            'NOT SET' he defined balance
93                                            to <element_name>_ASG_PAYMENTS if
94                                            l_jd_context <> 'NOT SET' then
95                                            the defined balance to
96                                            <element_name>_ASG_PAYMENTS_JD.
97 
98  TCLEWIS       11-NOV-02   115.18         modified get value function to
99                                           check for null value of l_jd_context.
100  tclewis       12-NOV-02   115.19         added calls to the pay_balance_pkg.
101                                           set_context.
102  tclewis       14-nov-2002 115.21         modified payments balance required
103                                           to return true if pre-payments has
104                                           been run.  It will no longer count
105                                           runs.
106  tclewis       03-mar-2003 115.22         modified the get value function to
107                                           determine it the assignment_action_id
108                                           passed to the procedure is a sep check
109                                           or regular run.  IF sep check use
110                                           the assignment action, if not then use
111                                           master AA.
112  vpandya       23-May-2003 115.24         Changed for Multi GRE functionality:
113                                           Passing sub master asg act id to
114                                           Assignment Payments for Standard Run
115                                           and Tax Separate run and sepcheck asg
116                                           act id for separate payment run. if
117                                           TAX_GROUP is set then passing master
118                                           asg act id to it. Setting context for
119                                           Tax Group if TAX_GROUP is set.
120  ========================================================================
121 
122 */
123 -- 'Current' balance dimension info for
124 -- prepayments related to many payroll runs
125 l_run_action_id NUMBER;
126 l_prepay_action_id NUMBER;
127 
128 -- 'Current' balance dimension info for
129 -- prepayments related to many payroll runs
130 g_run_action_id NUMBER;
131 g_prepay_action_id NUMBER;
132 ------------------------------------------------------------------------
133 -- GET_CURRENT_BALANCE calculates the CURRENT balance given a run
134 -- assignment action id. From this it calculates the pre-payment and
135 -- then it finds all the runs included in this pre-payment.
136 -------------------------------------------------------------------------
137 FUNCTION get_current_balance (p_defined_balance_id NUMBER
138                              ,p_run_action_id      NUMBER)
139 RETURN NUMBER IS
140 --
141 CURSOR csr_get_aa_ids (p_prepay_aa_id NUMBER) IS
142   SELECT pai.locked_action_id
143   FROM   pay_payroll_actions    ppa,
144          pay_assignment_actions paa,
145          pay_action_interlocks  pai
146   WHERE  pai.locking_action_id = p_prepay_aa_id
147   AND    paa.assignment_action_id = pai.locked_action_id
148   AND    ppa.payroll_action_id = paa.payroll_action_id
149   AND    ppa.action_type IN ('R', 'Q')
150   and    not exists ( select 1 from pay_run_types_f prt
151                        where   prt.legislation_code = 'CA'
152                          and   prt.run_method = 'S'
153                          and   prt.run_type_id  = paa.run_type_id );
154 
155 CURSOR csr_get_prepay_id (p_run_id NUMBER) IS
156   SELECT pai.locking_action_id
157   FROM   pay_payroll_actions    ppa,
158          pay_assignment_actions paa,
159          pay_action_interlocks  pai
160   WHERE  pai.locked_action_id = p_run_id
161   AND    paa.assignment_action_id = pai.locking_action_id
162   AND    ppa.payroll_action_id = paa.payroll_action_id
163   AND    ppa.action_type IN ('P', 'U');
164 
165 CURSOR csr_check_sep_chk (p_run_aa_id NUMBER) IS
166   SELECT 1
167   FROM   pay_assignment_actions    paa
168      ,   pay_run_types_f prt
169   WHERE  paa.assignment_action_id = p_run_aa_id
170     and  prt.legislation_code = 'CA'
171     and  prt.run_method = 'S'
172     and  prt.run_type_id  = paa.run_type_id;
173 
174 l_defined_balance_id   NUMBER;
175 l_bal_value            NUMBER := 0;
176 l_prepay_action_id     NUMBER;
177 l_check_sep_chk_aa     NUMBER := 0;
178 
179 BEGIN
180 
181   OPEN csr_check_sep_chk (p_run_action_id);
182   FETCH csr_check_sep_chk INTO l_check_sep_chk_aa;
183   CLOSE csr_check_sep_chk;
184 
185   IF l_check_sep_chk_aa = 1 THEN
186 
187       l_bal_value := l_bal_value + pay_ca_balance_view_pkg.get_value
188                                       (p_run_action_id
189                                       ,p_defined_balance_id);
190 
191   ELSE
192     pay_us_balance_view_pkg.debug_msg('  p_def_bal: '||l_defined_balance_id);
193     OPEN csr_get_prepay_id (p_run_action_id);
194     FETCH csr_get_prepay_id INTO l_prepay_action_id;
195     CLOSE csr_get_prepay_id;
196 
197     FOR v_runs IN csr_get_aa_ids(l_prepay_action_id) LOOP
198 
199       l_bal_value := l_bal_value + pay_ca_balance_view_pkg.get_value
200                                       (v_runs.locked_action_id,
201                                        p_defined_balance_id);
202 
203     END LOOP;
204   END IF;
205 
206   RETURN l_bal_value;
207 
208 END get_current_balance;
209 
210 ------------------------------------------------------------------------
211 -- CALL_CA_BALANCE_GET_VALUE is the wrapper function for calls to
212 -- get_value. It is used for ASG and PER level balances. Group Level balance
213 -- wrapper in pycatxbv.pkb.
214 -------------------------------------------------------------------------
215 FUNCTION call_ca_balance_get_value (p_balance_name      VARCHAR2
216                            ,p_time_period               VARCHAR2
217                            ,p_assignment_action_id      NUMBER
218                            ,p_assignment_id             NUMBER
219                            ,p_virtual_date              DATE
220                            ,p_report_level              VARCHAR2
221                            ,p_gre_id                    NUMBER
222                            ,p_business_group_id         NUMBER
223                            ,p_jurisdiction_code         VARCHAR2 )
224 RETURN number IS
225 --
226 BEGIN
227 --
228 
229 return call_ca_balance_get_value( p_balance_name
230                            ,p_time_period
231                            ,p_assignment_action_id
232                            ,p_assignment_id
233                            ,p_virtual_date
234                            ,p_report_level
235                            ,p_gre_id
236                            ,p_business_group_id
237                            ,p_jurisdiction_code
238                            ,NULL);
239 --
240 END call_ca_balance_get_value;
241 --------------------------------------------------------------------
242 -- Overloaded Version of call_ca_balance_get_value
243 -- for parameter p_source_id
244 -- CALL_CA_BALANCE_GET_VALUE is the wrapper function for calls to
245 -- get_value. It is used for ASG and PER level balances. Group Level balances
246 -- are in package pycatxbv.pkb.
247 -------------------------------------------------------------------------
248 FUNCTION call_ca_balance_get_value (p_balance_name      VARCHAR2
249                            ,p_time_period               VARCHAR2
250                            ,p_assignment_action_id      NUMBER
251                            ,p_assignment_id             NUMBER
252                            ,p_virtual_date              DATE
253                            ,p_report_level              VARCHAR2
254                            ,p_gre_id                    NUMBER
255                            ,p_business_group_id         NUMBER
256                            ,p_jurisdiction_code         VARCHAR2
257                            ,p_source_id                 NUMBER    )
258 RETURN number IS
259 --
260 
261 CURSOR C_GET_MASTER_AAID (cp_prepay_action_id in number,
262                           cp_assignment_id    in number) is
263      select max(paa.assignment_action_id)
264      from   pay_assignment_actions paa,  -- assignment_action for master payroll run
265             pay_action_interlocks pai
266      where  pai.locking_action_id = cp_prepay_action_id
267      and    pai.locked_action_id = paa.assignment_action_id
268      and    paa.assignment_id    = cp_assignment_id
269      and    paa.source_action_id is null -- master assignment_action
270      group by assignment_id;
271 
272 g_prepay_action_id	NUMBER;
273 l_defined_balance_id	NUMBER;
274 l_business_group_id	NUMBER;
275 l_report_level		VARCHAR2(4);
276 l_tax_group		VARCHAR2(30);
277 l_gre			VARCHAR2(30);
278 l_dimension_suffix	VARCHAR2(30);
279 l_jd_code		VARCHAR2(10);
280 l_balance_value		NUMBER;
281 l_jd_context            VARCHAR2(10);
282 l_report_unit		VARCHAR2(30);
283 l_time_period           VARCHAR2(80);
284 l_gre_tg_or_rpt_unit    VARCHAR2(80);
285 l_current_bal_flag      BOOLEAN := FALSE;
286 l_sep_check         VARCHAR2(1) := 'N';
287 l_assignment_action_id  NUMBER;
288 l_pre_pay_aaid          NUMBER;
289 l_assignment_id         number;
290 l_tax_group_id          number;
291 --
292 BEGIN
293   pay_us_balance_view_pkg.debug_msg( '=======================================');
294   pay_us_balance_view_pkg.debug_msg('call_ca_balance_get_value entry:');
295   pay_us_balance_view_pkg.debug_msg('  p_balance_name:    ' || p_balance_name);
296   pay_us_balance_view_pkg.debug_msg('  p_time_period:     ' || p_time_period);
297   pay_us_balance_view_pkg.debug_msg('  p_assignment_action_id: ' ||
298                                                TO_CHAR(p_assignment_action_id));
299   pay_us_balance_view_pkg.debug_msg('  p_assignment_id:   ' ||
300                                                TO_CHAR(p_assignment_id));
301   pay_us_balance_view_pkg.debug_msg('  p_virtual_date:    ' ||
302                                                TO_CHAR(p_virtual_date));
303   pay_us_balance_view_pkg.debug_msg('  p_report_level:    ' || p_report_level);
304   pay_us_balance_view_pkg.debug_msg('  p_gre_id:          ' ||
305                                                TO_CHAR(p_gre_id));
306   pay_us_balance_view_pkg.debug_msg('  p_business_group_id: ' ||
307                                                TO_CHAR(p_business_group_id));
308   pay_us_balance_view_pkg.debug_msg('  p_jurisdiction_code: ' ||
309                                                       p_jurisdiction_code);
310   pay_us_balance_view_pkg.debug_msg('  p_source_id:       ' ||
311                                                TO_CHAR(p_source_id));
312 
313   --
314   --Set contexts
315   --
316   pay_ca_balance_view_pkg.set_context('TAX_UNIT_ID',
317                                       p_gre_id);
318   pay_balance_pkg.set_context('TAX_UNIT_ID', p_gre_id);
319 
320   IF p_jurisdiction_code IS NULL THEN
321     l_jd_context := nvl(pay_ca_balance_view_pkg.get_session_var
322                             ('JURISDICTION_CODE'), 'Not_Set');
323   ELSE
324     l_jd_context := p_jurisdiction_code;
325   END IF;
326 
327   IF p_business_group_id is NULL then
328     l_business_group_id := 0;
329   ELSE
330     l_business_group_id := p_business_group_id;
331   END IF;
332 
333   IF l_jd_context = 'Not_Set'  THEN
334     l_jd_code := '';
335     l_jd_context := NULL;
336   ELSE
337     IF p_source_id IS NULL THEN
338       l_jd_code := 'JD_';
339     ELSE
340       --
341       -- Balances with a Reporting Unit level dimension can not be at the
342       -- jurisdiction level aswell.
343       --
344       l_jd_code := '';
345     END IF;
346   END IF;
347   --
348   -- derive the dimension_suffix
349   -- set session var REPORT_LEVEL to default of ASG if not already set.
350   --
351   IF p_report_level IS NULL THEN
352     pay_ca_balance_view_pkg.set_session_var('REPORT_LEVEL','ASG');
353 
354     l_report_level :=
355              pay_ca_balance_view_pkg.get_session_var('REPORT_LEVEL')||'_';
356   ELSE
357     l_report_level := p_report_level||'_';
358   END IF;
359 
360   IF p_source_id IS NULL THEN
361     IF pay_ca_balance_view_pkg.get_session_var('TAX_GROUP') = 'Y' then
362       l_gre_tg_or_rpt_unit := 'TG_';
363 
364       begin
365         select pac.context_value
366           into l_tax_group
367           from pay_action_contexts pac
368               ,ff_contexts fc
369          where pac.assignment_action_id = p_assignment_action_id
370          and   fc.context_name = 'TAX_GROUP'
371          and   pac.context_id  = fc.context_id;
372 
373          if l_tax_group <> 'No Tax Group' then
374             l_tax_group_id := l_tax_group;
375             pay_ca_balance_view_pkg.set_context('TAX_GROUP',l_tax_group_id);
376             pay_balance_pkg.set_context('TAX_GROUP',l_tax_group_id);
377          end if;
378 
379        exception
380        when others then
381             null;
382       end;
383 
384     ELSE
385       l_gre_tg_or_rpt_unit := 'GRE_';
386     END IF;
387   ELSE
388     l_gre_tg_or_rpt_unit := 'RPT_UNIT_';
389   END IF;
390 
391   pay_ca_balance_view_pkg.set_context('JURISDICTION_CODE',l_jd_context);
392   pay_ca_balance_view_pkg.set_context('ASSIGNMENT_ACTION_ID'
393                                       ,p_assignment_action_id);
394   pay_ca_balance_view_pkg.set_context('BUSINESS_GROUP_ID',l_business_group_id);
395   pay_ca_balance_view_pkg.set_context('DATE_EARNED',p_virtual_date);
396   pay_ca_balance_view_pkg.set_context('SOURCE_ID',p_source_id);
397 
398   pay_balance_pkg.set_context('JURISDICTION_CODE',l_jd_context);
399   pay_balance_pkg.set_context('ASSIGNMENT_ACTION_ID'
400                                       ,p_assignment_action_id);
401   pay_balance_pkg.set_context('BUSINESS_GROUP_ID',l_business_group_id);
402   pay_balance_pkg.set_context('DATE_EARNED',p_virtual_date);
403   pay_balance_pkg.set_context('SOURCE_ID',p_source_id);
404 
405   l_time_period := p_time_period;
406   pay_us_balance_view_pkg.debug_msg('  l_time_period:     ' || l_time_period);
407 
408   IF p_time_period = 'CURRENT' THEN
409     l_gre_tg_or_rpt_unit := 'GRE_';
410     l_time_period := 'RUN';
411     l_current_bal_flag := TRUE;
412   END IF;
413 
414   --
415   -- Build the dimension suffix string
416   --
417   l_dimension_suffix := l_report_level||l_jd_code||l_gre_tg_or_rpt_unit||l_time_period;
418   --
419   -- Determine which dimensions should be returned.
420   -- turn_off_dimension is TRUE then don't get the balance.
421   --
422   IF turn_off_dimension(p_time_period)
423   --
424     THEN RETURN NULL;
425     --
426   ELSE -- turn_off_dimension is FALSE so get the balance.
427   --
428   -- Get the defined balance
429   --
430   pay_us_balance_view_pkg.debug_msg('  p_balance_name: ' || p_balance_name);
431   pay_us_balance_view_pkg.debug_msg
432                           ('  p_dimension_suffix: ' || l_dimension_suffix);
433   l_defined_balance_id := pay_ca_group_level_bal_pkg.get_defined_balance
434                               (p_balance_name      => p_balance_name
435                               ,p_dimension         => l_dimension_suffix
436                               ,p_business_group_id => p_business_group_id);
437 
438   --
439   -- The 'CURRENT' Dimension is for the current payment method amount.
440   -- This is needed for checks, deposit advice, and the payroll register.
441   --
442   IF l_current_bal_flag = TRUE AND
443     payments_balance_required(p_assignment_action_id)
444     THEN
445 
446       l_assignment_action_id := p_assignment_action_id;
447 
448       BEGIN
449 
450         SELECT DECODE(prt.shortname,'SEP_PAY','Y','N'),
451                paa.assignment_id
452         INTO   l_sep_check,
453                l_assignment_id
454         FROM   pay_assignment_actions paa
455               ,pay_run_types_f        prt
456         WHERE  paa.assignment_action_id = p_assignment_action_id
457         AND    prt.run_type_id          = paa.run_type_id
458         AND    prt.legislation_code     = 'CA';
459 
460       EXCEPTION
461 
462         WHEN NO_DATA_FOUND THEN
463           l_sep_check := 'N';
464       END;
465 
466       IF l_sep_check <> 'Y' THEN
467 
468          IF pay_ca_balance_view_pkg.get_session_var('TAX_GROUP') = 'Y' then
469             select paa_master.source_action_id
470             into   l_assignment_action_id
471             from   pay_assignment_actions paa_master
472                   ,pay_assignment_actions paa_sm
473             where  paa_sm.assignment_action_id = p_assignment_action_id
474             and    paa_master.assignment_action_id = paa_sm.source_action_id;
475          ELSE
476             select paa.source_action_id
477             into   l_assignment_action_id
478             from   pay_assignment_actions paa
479             where  paa.assignment_action_id = p_assignment_action_id;
480          END IF;
481 
482          IF nvl(l_jd_context,'Not_Set') = 'Not_Set'  THEN
483             l_defined_balance_id :=
484                                pay_ca_group_level_bal_pkg.get_defined_balance
485                                    (p_balance_name      => p_balance_name
486                                    ,p_dimension         => 'ASG_PAYMENTS'
487                                    ,p_business_group_id => p_business_group_id);
488          ELSE
489             l_defined_balance_id :=
490                                pay_ca_group_level_bal_pkg.get_defined_balance
491                                    (p_balance_name      => p_balance_name
492                                    ,p_dimension         => 'ASG_PAYMENTS_JD'
493                                    ,p_business_group_id => p_business_group_id);
494          END IF;
495 
496       END IF;
497 
498       RETURN pay_balance_pkg.get_value
499                                  (l_defined_balance_id
500                                  ,l_assignment_action_id);
501 
502   END IF;
503 
504   IF p_time_period =  'ASG_PAYMENTS' THEN
505 
506      l_defined_balance_id := pay_ca_group_level_bal_pkg.get_defined_balance
507                             (p_balance_name      => p_balance_name
508                             ,p_dimension         => 'ASG_PAYMENTS'
509                             ,p_business_group_id => p_business_group_id);
510 
511       RETURN pay_balance_pkg.get_value
512                 (l_defined_balance_id
513                 ,p_assignment_action_id);
514 
515   END IF;
516 
517   IF p_time_period =  'ASG_PAYMENTS_JD' THEN
518 
519      l_defined_balance_id := pay_ca_group_level_bal_pkg.get_defined_balance
520                             (p_balance_name      => p_balance_name
521                             ,p_dimension         => 'ASG_PAYMENTS_JD'
522                             ,p_business_group_id => p_business_group_id);
523 
524       RETURN pay_balance_pkg.get_value
525                 (l_defined_balance_id
526                 ,p_assignment_action_id);
527 
528   END IF;
529 
530   IF l_defined_balance_id IS NULL THEN
531     pay_us_balance_view_pkg.debug_msg('The Defined Balance does not exist');
532     RETURN NULL;
533   ELSE
534 
535     RETURN pay_ca_balance_view_pkg.get_value
536                                  (p_assignment_action_id
537                                  ,l_defined_balance_id);
538 
539   END IF;
540   --
541   END IF; -- Determine which dimensions to return using turn_off_dimension
542   --
543 END call_ca_balance_get_value;
544 -----------------------------------------------------------------------------
545 -- FUNCTION Payments_Balance_Required
546 --  This function caches information related to an assignment action
547 --  for a payroll run related to a pre-payment composed of multiple
548 --  runs.  This is to support the 'CURRENT' balance value displayed
549 --  on checkwriter and related reports(PAYRPCHK, PAYRPPST, PAYRPREG)
550 --
551 --  Returns:
552 --  TRUE if multiple runs exists and sets global prepayment id
553 --  FALSE if a single run exists and clears global prepayment id
554 --------------------------------------------------------------------------
555 FUNCTION payments_balance_required(p_assignment_action_id NUMBER)
556 RETURN boolean IS
557 --
558 CURSOR c_count_runs(p_asgact_id NUMBER) IS
559 SELECT pai.locking_action_id, count(pai2.locked_action_id)
560 FROM   pay_action_interlocks pai,
561        pay_action_interlocks pai2,
562        pay_assignment_actions paa,
563        pay_payroll_actions    ppa
564 WHERE  pai.locked_action_id = p_asgact_id
565 AND    pai.locking_action_id = pai2.locking_action_id
566 AND    pai.locking_action_id = paa.assignment_action_id
567 AND    paa.payroll_action_id = ppa.payroll_action_id
568 AND    ppa.action_type in ('P', 'U')
569 GROUP BY pai.locking_action_id;
570 
571 l_count_runs NUMBER;
572 
573 BEGIN
574 
575 IF l_run_action_id = p_assignment_action_id
576    AND l_prepay_action_id IS NOT NULL THEN
577    -- Have processed this assignment
578    -- and it does have multiple RUNS
579    RETURN TRUE;
580 ELSIF  l_run_action_id = p_assignment_action_id
581    AND l_prepay_action_id IS NULL THEN
582    -- Have processed this assignment
583    -- and it does not have multiple RUNS
584    RETURN FALSE;
585 ELSE
586    l_run_action_id := p_assignment_action_id;  -- set Run action id
587    OPEN c_count_runs(p_assignment_action_id);
588    FETCH c_count_runs INTO l_prepay_action_id, l_count_runs;
589    CLOSE c_count_runs;
590    IF l_count_runs > 1 THEN
591        -- Set asg_act_ids if multple runs
592        l_run_action_id := p_assignment_action_id;
593        RETURN TRUE;
594    ELSE
595        -- Clear asg_act_ids if they do not
596        l_prepay_action_id := NULL;
597        RETURN FALSE;
598    END IF;
599 END IF;
600 
601 
602 
603 
604 
605 END payments_balance_required;
606 -----------------------------------------------------------------------------
607 -- FUNCTION turn_off_dimension
608 -----------------------------------------------------------------------------
609 FUNCTION turn_off_dimension (p_dimension varchar2)
610 RETURN BOOLEAN IS
611 --
612 BEGIN
613 --
614 IF nvl(pay_ca_balance_view_pkg.get_session_var(p_dimension),'ON') = 'OFF' THEN
615 --
616   RETURN TRUE;
617   --
618 ELSE
619   RETURN FALSE;
620   --
621 END IF;
622 --
623 END turn_off_dimension;
624 -----------------------------------------------------------------------------
625 -- PROCEDURE turn_off_report_dimension
626 -----------------------------------------------------------------------------
627 PROCEDURE turn_off_report_dimension (p_report_name varchar2)
628 is
629 --
630 BEGIN
631 --
632 /*
633 IF p_report_name = 'SOE'
634 --
635   THEN pay_ca_balance_view_pkg.set_session_var(PTD','OFF');
636        pay_ca_balance_view_pkg.set_session_var('MONTH','OFF');
637        pay_ca_balance_view_pkg.set_session_var('QTD','OFF');
638        pay_ca_balance_view_pkg.set_session_var('YTD','ON');
639 -- Need to check if need both CURRENT and RUN
640        pay_ca_balance_view_pkg.set_session_var('CURRENT','ON');
641        pay_ca_balance_view_pkg.set_session_var('RUN','ON');
642        --
643 END IF;
644 */
645 null;
646 END turn_off_report_dimension;
647 -----------------------------------------------------------------------------
648 END pay_ca_balance_pkg;