1 package pqh_cbr_engine AUTHID CURRENT_USER as
2 /* $Header: pqcbreng.pkh 115.1 2003/02/08 00:50:56 sgoyal noship $ */
3
4 -- this record will contain details of the rule_attribute, so that we don't have to go back again
5 -- status will be updated with the result of attribute row run
6
7 type t_rule_details is record (
8 rule_set_id pqh_rule_sets.rule_set_id%type,
9 rule_name pqh_rule_sets.rule_set_name%type,
10 rule_applicability pqh_rule_sets.rule_applicability%type,
11 rule_level_cd pqh_rule_sets.rule_level_cd%type,
12 message_cd fnd_new_messages.message_name%type,
13 txn_id number,
14 entity_id number);
15
16 type t_rule_matx is table of t_rule_details
17 index by binary_integer ;
18
19 type t_attr_row is record (
20 attribute_id pqh_attributes.attribute_id%type,
21 column_name pqh_attributes.column_name%type,
22 column_type pqh_attributes.column_type%type,
23 txn_catg_attribute_id number,
24 entity_type varchar2(30),
25 applicability varchar2(30));
26
27 type t_attr_matx is table of t_attr_row
28 index by binary_integer ;
29
30 type t_cond_details is record (
31 rule_attribute_id pqh_rule_attributes.rule_attribute_id%type,
32 attribute_id pqh_attributes.attribute_id%type,
33 column_type pqh_attributes.column_type%type,
34 column_name pqh_attributes.column_name%type,
35 operation_code pqh_rule_attributes.operation_code%type,
36 attribute_value pqh_rule_attributes.attribute_value%type,
37 transaction_value varchar2(400),
38 status varchar2(30));
39
40 type t_cond_matx is table of t_cond_details
41 index by binary_integer ;
42
43 -- globals which will be used by this package
44
45 g_package varchar2(30) := 'PQH_CBR_ENGINE.';
46 g_budget_id number;
47 g_budget_version_id number;
48 g_budget_entity varchar2(30);
49 g_business_group_id number;
50 g_folder_id number;
51 g_budget_name varchar2(30);
52 g_budget_currency varchar2(30);
53 g_budget_start_date date;
54 g_budget_end_date date;
55 g_measurement_unit varchar2(80);
56 g_budget_unit_type varchar2(15);
57 g_budget_unit_name varchar2(80);
58 g_budget_unit_num number;
59 g_budget_unit_id number;
60 g_folder_name pqh_budget_pools.name%type;
61
62 procedure populate_globals(p_transaction_id in number);
63
64 function get_transaction_value(p_entity_id in number,
65 p_attribute_id in number) return varchar2;
66 function check_attribute_result(p_rule_value in varchar2,
67 p_txn_value in varchar2,
68 p_operation_code in varchar2,
69 p_attribute_type in varchar2) return BOOLEAN;
70
71 -- routine, which will be called by page.
72 PROCEDURE apply_rules(p_transaction_type in varchar2,
73 p_business_group_id IN Number,
74 p_transaction_id IN number,
75 p_effective_date IN date DEFAULT sysdate,
76 p_status_flag OUT NOCOPY varchar2);
77
78 -- routine which cntrols reallocation related rule applications
79 PROCEDURE apply_CBR_realloc(p_transaction_id IN number,
80 p_business_group_id IN number,
81 p_effective_date IN DATE,
82 p_status_flag OUT NOCOPY varchar2);
83
84 -- process rules are applied for donor/ receivers
85 PROCEDURE apply_defined_rules(p_transaction_id IN number,
86 p_business_group_id IN number,
87 p_effective_date IN DATE,
88 p_status_flag OUT NOCOPY varchar2);
89
90 -- business rules related to Reallocation are applied
91 PROCEDURE apply_business_rules(p_transaction_id IN number,
92 p_business_group_id IN number,
93 p_effective_date IN DATE,
94 p_status_flag OUT NOCOPY BOOLEAN);
95
96 -- populates valid rule conditions for an entity
97 procedure valid_rule_conditions(p_entity_type in varchar2 ,
98 p_rule_set_id in number,
99 p_rule_applicability in varchar2,
100 p_attr_matx in t_attr_matx,
101 p_cond_matx out NOCOPY t_cond_matx);
102
103 -- populates valid rules for an entity of a transaction folder
104 procedure valid_process_rules(p_transaction_id in varchar2,
105 p_business_group_id in number,
106 p_rule_category in varchar2,
107 p_effective_date in date,
108 l_rule_matx out NOCOPY t_rule_matx);
109 --
110 -- this procedure populates the attribute matrix, which is to be used for identifying which attribute
111 -- is used for which entity and applicability.
112 --
113 procedure populate_attr_matx(p_attr_matx out nocopy t_attr_matx);
114 --
115 --
116 -- This function will be checking that rule is applicable for the provided organization and details
117 --
118 function check_org_valid_rule(p_organization_id in number,
119 p_rule_org_id in number,
120 p_rule_applicability in varchar2,
121 p_rule_category in varchar2,
122 p_rule_org_str_id in number,
123 p_rule_start_org_id in number) return boolean;
124 --
125 Procedure get_org_structure_version_id (p_org_structure_id IN NUMBER,
126 p_org_structure_version_id OUT nocopy NUMBER);
127 --
128 -- This function checks whether for this org hier and start org rule exists for this category and applicability
129 --
130 function check_rule_existence(p_organization_structure_id in number,
131 p_starting_organization_id in number,
132 p_business_group_id in number,
133 p_rule_category in varchar2,
134 p_rule_applicability in varchar2) return boolean ;
135 end;