-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathplugin_rcpt_importprocess_100match.qy
More file actions
208 lines (202 loc) · 6.27 KB
/
plugin_rcpt_importprocess_100match.qy
File metadata and controls
208 lines (202 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
$Version=2$
plugin_rcpt_importprocess_100match "system/query"
{
module_sequence=100;
module_letter='M';
module_code='Match';
module_desc='Remember and Match Prior Designations, Donors, and GL Accounts';
// just an example of how to specify a module config component:
// module_config_cmp='/apps/kardia/modules/rcpt/field_donor_with_new.cmp';
ledger "query/parameter" { type=string; }
sql = " -- Try to set donor key correlation based on prior data
--
update
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e1
set
:p_donor_partner_key = (
select
:e2:p_donor_partner_key
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
(:e1:i_eg_donor_uuid = :e2:i_eg_donor_uuid or isnull(:e1:i_eg_donor_alt_id, 'NOTEXIST1') = isnull(:e2:i_eg_donor_alt_id, 'NOTEXIST2')) and
:e2:i_eg_donormap_future = 1 and
:e2:i_eg_donormap_confidence = 2 and
:e2:p_donor_partner_key is not null
order by
:e2:i_eg_gift_trx_date desc
),
:i_eg_donormap_confidence = condition(
( select
:e2:p_donor_partner_key
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
(:e1:i_eg_donor_uuid = :e2:i_eg_donor_uuid or isnull(:e1:i_eg_donor_alt_id, 'NOTEXIST1') = isnull(:e2:i_eg_donor_alt_id, 'NOTEXIST2')) and
:e2:i_eg_donormap_future = 1 and
:e2:i_eg_donormap_confidence = 2 and
:e2:p_donor_partner_key is not null
order by
:e2:i_eg_gift_trx_date desc
) is null,
null,
2
)
where
substring(:i_eg_postprocess, 1, 1) = 'M' and
:p_donor_partner_key is null and
char_length(rtrim(:i_eg_trx_uuid)) > 1 and
:i_eg_donor_uuid != '0' and
:a_ledger_number = :parameters:ledger
;
-- Try to make the designation assignment based on prior data
--
update
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e1
set
:a_fund = (
select
:e2:a_fund
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e2:i_eg_fundmap_future = 1 and
:e2:i_eg_fundmap_confidence = 2 and
:e2:a_fund is not null
order by
:e2:i_eg_gift_trx_date desc
),
:i_eg_fundmap_confidence = condition(
( select
:e2:a_fund
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e2:i_eg_fundmap_future = 1 and
:e2:i_eg_fundmap_confidence = 2 and
:e2:a_fund is not null
order by
:e2:i_eg_gift_trx_date desc
) is null,
null,
2
)
where
substring(:i_eg_postprocess, 1, 1) = 'M' and
:a_fund is null and
char_length(rtrim(:i_eg_trx_uuid)) > 1 and
:a_ledger_number = :parameters:ledger
;
-- Try to make the GL account code assignment based on prior data,
-- first checking both donor and fund match, and second checking
-- just fund match.
--
update
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e1
set
:a_account_code = (
select
:e2:a_account_code
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e1:a_fund = :e2:a_fund and
:e2:i_eg_acctmap_future = 1 and
:e2:i_eg_acctmap_confidence = 2 and
(:e1:i_eg_donor_uuid = :e2:i_eg_donor_uuid or isnull(:e1:i_eg_donor_alt_id, 'NOTEXIST1') = isnull(:e2:i_eg_donor_alt_id, 'NOTEXIST2')) and
:e2:a_account_code is not null
order by
:e2:i_eg_gift_trx_date desc
),
:i_eg_acctmap_confidence = condition(
(
select
:e2:a_account_code
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e1:a_fund = :e2:a_fund and
:e2:i_eg_acctmap_future = 1 and
:e2:i_eg_acctmap_confidence = 2 and
(:e1:i_eg_donor_uuid = :e2:i_eg_donor_uuid or isnull(:e1:i_eg_donor_alt_id, 'NOTEXIST1') = isnull(:e2:i_eg_donor_alt_id, 'NOTEXIST2')) and
:e2:a_account_code is not null
order by
:e2:i_eg_gift_trx_date desc
) is null,
null,
2
)
where
substring(:i_eg_postprocess, 1, 1) = 'M' and
:a_account_code is null and
char_length(rtrim(:i_eg_trx_uuid)) > 1 and
:a_ledger_number = :parameters:ledger
;
-- Now try to set account by just fund match.
--
update
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e1
set
:a_account_code = (
select
:e2:a_account_code
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e1:a_fund = :e2:a_fund and
:e2:i_eg_acctmap_future = 1 and
:e2:i_eg_acctmap_confidence = 2 and
:e2:a_account_code is not null
order by
:e2:i_eg_gift_trx_date desc
),
:i_eg_acctmap_confidence = condition(
(
select
:e2:a_account_code
from
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e2
where
upper(:e1:i_eg_desig_uuid) = upper(:e2:i_eg_desig_uuid) and
:e1:a_ledger_number = :e2:a_ledger_number and
:e1:a_fund = :e2:a_fund and
:e2:i_eg_acctmap_future = 1 and
:e2:i_eg_acctmap_confidence = 2 and
:e2:a_account_code is not null
order by
:e2:i_eg_gift_trx_date desc
) is null,
null,
2
)
where
substring(:i_eg_postprocess, 1, 1) = 'M' and
:a_account_code is null and
char_length(rtrim(:i_eg_trx_uuid)) > 1 and
:a_ledger_number = :parameters:ledger
;
-- Mark these items complete.
--
update
/apps/kardia/data/Kardia_DB/i_eg_gift_import/rows e1
set
:i_eg_postprocess = condition(
:a_account_code is not null and :a_fund is not null and :p_donor_partner_key is not null,
substring(:i_eg_postprocess, 2, 99),
substring(:i_eg_postprocess, 2, 99) + 'M'
)
where
substring(:i_eg_postprocess, 1, 1) = 'M' and
:a_ledger_number = :parameters:ledger
";
}