1 package GCS_RULES_PROCESSOR as
2 -- $Header: gcserups.pls 120.4 2006/08/14 18:46:24 skamdar noship $
3
4 /*
5 ** Type
6 ** contextRecord
7 ** Purpose
8 ** Arg to process_rule, below
9 ** Public so callers can declare by referencing here
10 */
11 TYPE contextRecord is Record (
12 eventType varchar2(1), -- [A|C] for AD or Consolidation, resp
13 eventKey number, -- eventType A:transaction_id, C:run_detail_id
14 eventCategory varchar2(50), -- category_display_code of the rule_id
15 parentEntity number, -- parent entity id
16 childEntity number, -- subsidiary entity id
17 elimsEntity number, -- eliminations entity id
18 datasetCode number, -- the FEM dataset_code for this hierarchy id
19 hierarchy number, -- the GCS hierarchy id
20 calPeriodId number, -- the calendar period
21 currencyCode varchar2(15), -- the consolidation reporting currency
22 relationship number, -- the GCS hierarchy relationship id
23 runName varchar2(240), -- process identifier
24 --Bugfix 4928211: Added currency precision to cache it earlier
25 currPrecision number, -- precision of functional currency
26 calPeriodEndDate date, -- end date of calendar period
27 --Bugfix 5103251: Added support for additional balance types
28 balanceTypeCode varchar2(30), -- balance type code
29 --Bugfix 5456211: Added ledger to context information for performance purposes
30 ledgerId number
31
32 );
33
34 TYPE contextTable is Table of contextRecord Index By BINARY_INTEGER;
35
36
37 /*
38 ** Type
39 ** ruleDataRecord
40 ** Purpose
41 ** Arg to process_rule, below
42 ** Public so callers can declare by referencing here
43 */
44 TYPE ruleDataRecord is Record (
45 fromPercent Number, --Old percentage ownership (AD only)
46 toPercent Number, --Current percentage owned (AD or CE)
47 consideration Number, --Monetary value of the deal (AD only)
48 netAssetValue Number --Monetary value of net assets (AD only)
49 );
50
51 TYPE ruleDataTable is Table of ruleDataRecord Index By BINARY_INTEGER;
52
53 /*
54 ** Procedure
55 ** process_rule
56 ** Arguments
57 ** p_rule_id is the rule_id to process
58 ** p_stat_flag indicates whether the rule should run twice,
59 ** once for the currency given in p_context.currencyCode
60 ** and again for STAT currency
61 ** p_context is the context record (see above)
62 ** p_rule_data rule data record (see above)
63 ** Synopsis
64 ** - Looks up the rule steps
65 ** - Resolves the distinct account sets used by the steps
66 ** - Executes step formulas using account sets and arg values
67 ** - Creates detailed outputs, one for each source account
68 ** - Aggregates the outputs across dimensions
69 ** - Writes entries to the GCS tables
70 ** - Returns 0 for success, 1 for warning and 2 for failure
71 **
72 ** NOTES:
73 ** This routine results in a populated GCS_ENTRIES_GT table with...
74 ** - Each rule step's id, name, sequence, formula text, account set
75 ** id, name and line number info
76 ** - The values for the "from" and "to" side of each dimension set line
77 ** - The account balance input amount, where applicable, for each
78 ** dimension set line
79 ** - The account balance output amount for each dimension set line
80 ** - The currency code used for each line
81 **
82 ** The GCS_ENTRIES_GT will have all the detail info necessary to create
83 ** that portion of an execution report related to rule processing. The
84 ** creation of that report is the job of the routine that calls this one.
85 */
86 Function process_rule (
87 p_rule_id IN NUMBER,
88 p_stat_flag IN VARCHAR2,
89 p_context IN contextRecord,
90 p_rule_data IN ruleDataRecord
91 ) RETURN NUMBER;
92
93
94 /*
95 ** Procedure
96 ** process_rule
97 ** Arguments
98 ** p_rules is a hash table of rule_ids to process,
99 ** with a record structure that allows each
100 ** rule to have a stat_flag and to return
101 ** an individual result code (see below)
102 ** p_context is a context record (see above)
103 ** p_rules_data table of rule data records (see above)
104 ** Synopsis
105 ** Loops through the rules table, calling process_rule above
106 ** for each rule
107 **
108 ** Returns 0 for successful execution of all rules
109 ** 1 for warnings on one or more rules
110 ** 2 for failure of any single rule
111 ** 2 if p_rules is empty
112 **
113 ** NOTE: ALL Rule IDs use the same ruleData and context values!
114 ** For example, all rules assume the same ownership percentage
115 ** between the parent and child entities, and all are executed
116 ** in the context of a single category.
117 */
118
119 TYPE ruleParmRecord IS RECORD (
120 ruleId Number,
121 result Number,
122 statFlag Varchar2(1));
123 TYPE ruleParmsTable Is TABLE Of ruleParmRecord Index By BINARY_INTEGER;
124
125 Function process_rule (
126 p_rules IN OUT NOCOPY ruleParmsTable,
127 p_context IN contextRecord,
128 p_rules_data IN ruleDataTable
129 ) RETURN NUMBER;
130
131 END GCS_RULES_PROCESSOR;