4 SELECT evergreen.upgrade_deps_block_check('0957', :eg_version);
6 -- Remove references to dropped CC payment columns in the print/email
7 -- payment receipt templates, but only if the in-db template matches
9 -- The actual diff here is only about 8 lines.
11 UPDATE action_trigger.event_definition SET template =
14 [%- SET user = target.0.xact.usr -%]
15 To: [%- params.recipient_email || user.email %]
16 From: [%- params.sender_email || default_sender %]
17 Subject: Payment Receipt
20 [%- SET xact_mp_hash = {} -%]
21 [%- FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions -%]
22 [%- SET xact_id = mp.xact.id -%]
23 [%- IF ! xact_mp_hash.defined( xact_id ) -%][%- xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } -%][%- END -%]
24 [%- xact_mp_hash.$xact_id.payments.push(mp) -%]
26 [%- FOR xact_id IN xact_mp_hash.keys.sort -%]
27 [%- SET xact = xact_mp_hash.$xact_id.xact %]
28 Transaction ID: [% xact_id %]
29 [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
30 [% ELSE %]Miscellaneous
33 [%- SET mb_type_hash = {} -%]
34 [%- FOR mb IN xact.billings %][%# Group billings by their btype -%]
35 [%- IF mb.voided == 'f' -%]
36 [%- SET mb_type = mb.btype.id -%]
37 [%- IF ! mb_type_hash.defined( mb_type ) -%][%- mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } -%][%- END -%]
38 [%- IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) -%][%- mb_type_hash.$mb_type.first_ts = mb.billing_ts -%][%- END -%]
39 [%- mb_type_hash.$mb_type.last_ts = mb.billing_ts -%]
40 [%- mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount -%]
41 [%- mb_type_hash.$mb_type.billings.push( mb ) -%]
44 [%- FOR mb_type IN mb_type_hash.keys.sort -%]
45 [%- IF mb_type == 1 %][%-# Consolidated view of overdue billings -%]
46 $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
47 on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
48 [%- ELSE -%][%# all other billings show individually %]
49 [% FOR mb IN mb_type_hash.$mb_type.billings %]
50 $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
55 [% FOR mp IN xact_mp_hash.$xact_id.payments %]
56 Payment ID: [% mp.id %]
57 Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
58 [% CASE "cash_payment" %]cash
59 [% CASE "check_payment" %]check
60 [% CASE "credit_card_payment" %]credit card
61 [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
62 [% CASE "credit_payment" %]credit
63 [% CASE "forgive_payment" %]forgiveness
64 [% CASE "goods_payment" %]goods
65 [% CASE "work_payment" %]work
66 [%- END %] on [% mp.payment_ts %] [% mp.note %]
71 WHERE id = 29 AND template =
75 [%- SET user = target.0.xact.usr -%]
76 To: [%- params.recipient_email || user.email %]
77 From: [%- params.sender_email || default_sender %]
78 Subject: Payment Receipt
81 [%- SET xact_mp_hash = {} -%]
82 [%- FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions -%]
83 [%- SET xact_id = mp.xact.id -%]
84 [%- IF ! xact_mp_hash.defined( xact_id ) -%][%- xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } -%][%- END -%]
85 [%- xact_mp_hash.$xact_id.payments.push(mp) -%]
87 [%- FOR xact_id IN xact_mp_hash.keys.sort -%]
88 [%- SET xact = xact_mp_hash.$xact_id.xact %]
89 Transaction ID: [% xact_id %]
90 [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
91 [% ELSE %]Miscellaneous
94 [%- SET mb_type_hash = {} -%]
95 [%- FOR mb IN xact.billings %][%# Group billings by their btype -%]
96 [%- IF mb.voided == 'f' -%]
97 [%- SET mb_type = mb.btype.id -%]
98 [%- IF ! mb_type_hash.defined( mb_type ) -%][%- mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } -%][%- END -%]
99 [%- IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) -%][%- mb_type_hash.$mb_type.first_ts = mb.billing_ts -%][%- END -%]
100 [%- mb_type_hash.$mb_type.last_ts = mb.billing_ts -%]
101 [%- mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount -%]
102 [%- mb_type_hash.$mb_type.billings.push( mb ) -%]
105 [%- FOR mb_type IN mb_type_hash.keys.sort -%]
106 [%- IF mb_type == 1 %][%-# Consolidated view of overdue billings -%]
107 $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
108 on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
109 [%- ELSE -%][%# all other billings show individually %]
110 [% FOR mb IN mb_type_hash.$mb_type.billings %]
111 $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
116 [% FOR mp IN xact_mp_hash.$xact_id.payments %]
117 Payment ID: [% mp.id %]
118 Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
119 [% CASE "cash_payment" %]cash
120 [% CASE "check_payment" %]check
121 [% CASE "credit_card_payment" %]credit card (
122 [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
123 [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
124 [% cc_chunks.last -%]
125 exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
127 [% CASE "credit_payment" %]credit
128 [% CASE "forgive_payment" %]forgiveness
129 [% CASE "goods_payment" %]goods
130 [% CASE "work_payment" %]work
131 [%- END %] on [% mp.payment_ts %] [% mp.note %]
137 UPDATE action_trigger.event_definition SET template =
139 [%- USE date -%][%- SET user = target.0.xact.usr -%]
140 <div style="li { padding: 8px; margin 5px; }">
141 <div>[% date.format %]</div><br/>
143 [% SET xact_mp_hash = {} %]
144 [% FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions %]
145 [% SET xact_id = mp.xact.id %]
146 [% IF ! xact_mp_hash.defined( xact_id ) %][% xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } %][% END %]
147 [% xact_mp_hash.$xact_id.payments.push(mp) %]
149 [% FOR xact_id IN xact_mp_hash.keys.sort %]
150 [% SET xact = xact_mp_hash.$xact_id.xact %]
151 <li>Transaction ID: [% xact_id %]
152 [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
153 [% ELSE %]Miscellaneous
155 Line item billings:<ol>
156 [% SET mb_type_hash = {} %]
157 [% FOR mb IN xact.billings %][%# Group billings by their btype %]
158 [% IF mb.voided == 'f' %]
159 [% SET mb_type = mb.btype.id %]
160 [% IF ! mb_type_hash.defined( mb_type ) %][% mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } %][% END %]
161 [% IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) %][% mb_type_hash.$mb_type.first_ts = mb.billing_ts %][% END %]
162 [% mb_type_hash.$mb_type.last_ts = mb.billing_ts %]
163 [% mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount %]
164 [% mb_type_hash.$mb_type.billings.push( mb ) %]
167 [% FOR mb_type IN mb_type_hash.keys.sort %]
168 <li>[% IF mb_type == 1 %][%# Consolidated view of overdue billings %]
169 $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
170 on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
171 [% ELSE %][%# all other billings show individually %]
172 [% FOR mb IN mb_type_hash.$mb_type.billings %]
173 $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
178 Line item payments:<ol>
179 [% FOR mp IN xact_mp_hash.$xact_id.payments %]
180 <li>Payment ID: [% mp.id %]
181 Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
182 [% CASE "cash_payment" %]cash
183 [% CASE "check_payment" %]check
184 [% CASE "credit_card_payment" %]credit card
185 [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
186 [% CASE "credit_payment" %]credit
187 [% CASE "forgive_payment" %]forgiveness
188 [% CASE "goods_payment" %]goods
189 [% CASE "work_payment" %]work
190 [%- END %] on [% mp.payment_ts %] [% mp.note %]
200 WHERE id = 30 AND template =
203 [%- USE date -%][%- SET user = target.0.xact.usr -%]
204 <div style="li { padding: 8px; margin 5px; }">
205 <div>[% date.format %]</div><br/>
207 [% SET xact_mp_hash = {} %]
208 [% FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions %]
209 [% SET xact_id = mp.xact.id %]
210 [% IF ! xact_mp_hash.defined( xact_id ) %][% xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } %][% END %]
211 [% xact_mp_hash.$xact_id.payments.push(mp) %]
213 [% FOR xact_id IN xact_mp_hash.keys.sort %]
214 [% SET xact = xact_mp_hash.$xact_id.xact %]
215 <li>Transaction ID: [% xact_id %]
216 [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
217 [% ELSE %]Miscellaneous
219 Line item billings:<ol>
220 [% SET mb_type_hash = {} %]
221 [% FOR mb IN xact.billings %][%# Group billings by their btype %]
222 [% IF mb.voided == 'f' %]
223 [% SET mb_type = mb.btype.id %]
224 [% IF ! mb_type_hash.defined( mb_type ) %][% mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } %][% END %]
225 [% IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) %][% mb_type_hash.$mb_type.first_ts = mb.billing_ts %][% END %]
226 [% mb_type_hash.$mb_type.last_ts = mb.billing_ts %]
227 [% mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount %]
228 [% mb_type_hash.$mb_type.billings.push( mb ) %]
231 [% FOR mb_type IN mb_type_hash.keys.sort %]
232 <li>[% IF mb_type == 1 %][%# Consolidated view of overdue billings %]
233 $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
234 on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
235 [% ELSE %][%# all other billings show individually %]
236 [% FOR mb IN mb_type_hash.$mb_type.billings %]
237 $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
242 Line item payments:<ol>
243 [% FOR mp IN xact_mp_hash.$xact_id.payments %]
244 <li>Payment ID: [% mp.id %]
245 Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
246 [% CASE "cash_payment" %]cash
247 [% CASE "check_payment" %]check
248 [% CASE "credit_card_payment" %]credit card (
249 [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
250 [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
251 [% cc_chunks.last -%]
252 exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
254 [% CASE "credit_payment" %]credit
255 [% CASE "forgive_payment" %]forgiveness
256 [% CASE "goods_payment" %]goods
257 [% CASE "work_payment" %]work
258 [%- END %] on [% mp.payment_ts %] [% mp.note %]