[open-ils-commits] r16852 - in trunk/Open-ILS/src/sql/Pg: . upgrade (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 6 12:00:11 EDT 2010
Author: phasefx
Date: 2010-07-06 12:00:08 -0400 (Tue, 06 Jul 2010)
New Revision: 16852
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0326.data.payment_receipt_format.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
augment these payment receipt templates with more info
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-06 15:56:17 UTC (rev 16851)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-07-06 16:00:08 UTC (rev 16852)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0325'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0326'); -- phasefx
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-07-06 15:56:17 UTC (rev 16851)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-07-06 16:00:08 UTC (rev 16852)
@@ -5200,6 +5200,7 @@
;
-- 0289.data.payment_receipt_format.sql
+-- 0326.data.payment_receipt_format.sql
INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES (
'money.format.payment_receipt.email',
@@ -5253,23 +5254,60 @@
From: [%- params.sender_email || default_sender %]
Subject: Payment Receipt
- [% FOR mp IN target %]
+[% date.format -%]
+[%- SET xact_mp_hash = {} -%]
+[%- FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions -%]
+ [%- SET xact_id = mp.xact.id -%]
+ [%- IF ! xact_mp_hash.defined( xact_id ) -%][%- xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } -%][%- END -%]
+ [%- xact_mp_hash.$xact_id.payments.push(mp) -%]
+[%- END -%]
+[%- FOR xact_id IN xact_mp_hash.keys.sort -%]
+ [%- SET xact = xact_mp_hash.$xact_id.xact %]
+Transaction ID: [% xact_id %]
+ [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
+ [% ELSE %]Miscellaneous
+ [% END %]
+ Line item billings:
+ [%- SET mb_type_hash = {} -%]
+ [%- FOR mb IN xact.billings %][%# Group billings by their btype -%]
+ [%- IF mb.voided == 'f' -%]
+ [%- SET mb_type = mb.btype.id -%]
+ [%- IF ! mb_type_hash.defined( mb_type ) -%][%- mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } -%][%- END -%]
+ [%- IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) -%][%- mb_type_hash.$mb_type.first_ts = mb.billing_ts -%][%- END -%]
+ [%- mb_type_hash.$mb_type.last_ts = mb.billing_ts -%]
+ [%- mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount -%]
+ [%- mb_type_hash.$mb_type.billings.push( mb ) -%]
+ [%- END -%]
+ [%- END -%]
+ [%- FOR mb_type IN mb_type_hash.keys.sort -%]
+ [%- IF mb_type == 1 %][%-# Consolidated view of overdue billings -%]
+ $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
+ on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
+ [%- ELSE -%][%# all other billings show individually %]
+ [% FOR mb IN mb_type_hash.$mb_type.billings %]
+ $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
+ [% END %]
+ [% END %]
+ [% END %]
+ Line item payments:
+ [% FOR mp IN xact_mp_hash.$xact_id.payments %]
Payment ID: [% mp.id %]
- Paid [% mp.amount %] via [% SWITCH mp.payment_type %]
- [% CASE "cash_payment" %]cash
- [% CASE "check_payment" %]check
- [% CASE "credit_card_payment" %]credit card
- [% CASE "credit_payment" %]credit
- [% CASE "forgive_payment" %]forgiveness
- [% CASE "goods_payment" %]goods
- [% CASE "work_payment" %]work
- [% END %] on [% mp.payment_ts %] for
- [% IF mp.xact.circulation %]
- [% helpers.get_copy_bib_basics(mp.xact.circulation.target_copy).title %]
- [% ELSE %]
- grocery
- [% END %]
- [% END %]
+ Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
+ [% CASE "cash_payment" %]cash
+ [% CASE "check_payment" %]check
+ [% CASE "credit_card_payment" %]credit card (
+ [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
+ [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
+ [% cc_chunks.last -%]
+ exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
+ )
+ [% CASE "credit_payment" %]credit
+ [% CASE "forgive_payment" %]forgiveness
+ [% CASE "goods_payment" %]goods
+ [% CASE "work_payment" %]work
+ [%- END %] on [% mp.payment_ts %] [% mp.note %]
+ [% END %]
+[% END %]
$$
)
,(
@@ -5283,31 +5321,65 @@
'xact.usr',
'print-on-demand',
$$
-[%- USE date -%]
-[%- SET user = target.0.xact.usr -%]
-<div>
- <style> li { padding: 8px; margin 5px; }</style>
- <div>[% date.format %]</div>
- <br/>
-
+[%- USE date -%][%- SET user = target.0.xact.usr -%]
+<div style="li { padding: 8px; margin 5px; }">
+ <div>[% date.format %]</div><br/>
<ol>
- [% FOR mp IN target %]
- <li>
- Payment ID: [% mp.id %]
- Paid [% mp.amount %] via [% SWITCH mp.payment_type %]
- [% CASE "cash_payment" %]cash
- [% CASE "check_payment" %]check
- [% CASE "credit_card_payment" %]credit card
- [% CASE "credit_payment" %]credit
- [% CASE "forgive_payment" %]forgiveness
- [% CASE "goods_payment" %]goods
- [% CASE "work_payment" %]work
- [% END %] on [% mp.payment_ts %] for
- [% IF mp.xact.circulation %]
- [% helpers.get_copy_bib_basics(mp.xact.circulation.target_copy).title %]
- [% ELSE %]
- grocery
+ [% SET xact_mp_hash = {} %]
+ [% FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions %]
+ [% SET xact_id = mp.xact.id %]
+ [% IF ! xact_mp_hash.defined( xact_id ) %][% xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } %][% END %]
+ [% xact_mp_hash.$xact_id.payments.push(mp) %]
+ [% END %]
+ [% FOR xact_id IN xact_mp_hash.keys.sort %]
+ [% SET xact = xact_mp_hash.$xact_id.xact %]
+ <li>Transaction ID: [% xact_id %]
+ [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
+ [% ELSE %]Miscellaneous
[% END %]
+ Line item billings:<ol>
+ [% SET mb_type_hash = {} %]
+ [% FOR mb IN xact.billings %][%# Group billings by their btype %]
+ [% IF mb.voided == 'f' %]
+ [% SET mb_type = mb.btype.id %]
+ [% IF ! mb_type_hash.defined( mb_type ) %][% mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } %][% END %]
+ [% IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) %][% mb_type_hash.$mb_type.first_ts = mb.billing_ts %][% END %]
+ [% mb_type_hash.$mb_type.last_ts = mb.billing_ts %]
+ [% mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount %]
+ [% mb_type_hash.$mb_type.billings.push( mb ) %]
+ [% END %]
+ [% END %]
+ [% FOR mb_type IN mb_type_hash.keys.sort %]
+ <li>[% IF mb_type == 1 %][%# Consolidated view of overdue billings %]
+ $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
+ on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
+ [% ELSE %][%# all other billings show individually %]
+ [% FOR mb IN mb_type_hash.$mb_type.billings %]
+ $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
+ [% END %]
+ [% END %]</li>
+ [% END %]
+ </ol>
+ Line item payments:<ol>
+ [% FOR mp IN xact_mp_hash.$xact_id.payments %]
+ <li>Payment ID: [% mp.id %]
+ Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
+ [% CASE "cash_payment" %]cash
+ [% CASE "check_payment" %]check
+ [% CASE "credit_card_payment" %]credit card (
+ [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
+ [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
+ [% cc_chunks.last -%]
+ exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
+ )
+ [% CASE "credit_payment" %]credit
+ [% CASE "forgive_payment" %]forgiveness
+ [% CASE "goods_payment" %]goods
+ [% CASE "work_payment" %]work
+ [%- END %] on [% mp.payment_ts %] [% mp.note %]
+ </li>
+ [% END %]
+ </ol>
</li>
[% END %]
</ol>
@@ -5325,11 +5397,17 @@
,( 29, 'xact.grocery' )
,( 29, 'xact.circulation' )
,( 29, 'xact.summary' )
+ ,( 29, 'credit_card_payment')
+ ,( 29, 'xact.billings')
+ ,( 29, 'xact.billings.btype')
,( 30, 'xact')
,( 30, 'xact.usr')
,( 30, 'xact.grocery' )
,( 30, 'xact.circulation' )
,( 30, 'xact.summary' )
+ ,( 30, 'credit_card_payment')
+ ,( 30, 'xact.billings')
+ ,( 30, 'xact.billings.btype')
;
-- 0294.data.bre_format.sql
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0326.data.payment_receipt_format.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0326.data.payment_receipt_format.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0326.data.payment_receipt_format.sql 2010-07-06 16:00:08 UTC (rev 16852)
@@ -0,0 +1,152 @@
+BEGIN;
+
+-- Replaces and augments some of the data from 0289.data.payment_receipt_format.sql
+INSERT INTO config.upgrade_log (version) VALUES ('0326'); -- phasefx
+
+UPDATE action_trigger.event_definition SET template =
+$$
+[%- USE date -%]
+[%- SET user = target.0.xact.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Payment Receipt
+
+[% date.format -%]
+[%- SET xact_mp_hash = {} -%]
+[%- FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions -%]
+ [%- SET xact_id = mp.xact.id -%]
+ [%- IF ! xact_mp_hash.defined( xact_id ) -%][%- xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } -%][%- END -%]
+ [%- xact_mp_hash.$xact_id.payments.push(mp) -%]
+[%- END -%]
+[%- FOR xact_id IN xact_mp_hash.keys.sort -%]
+ [%- SET xact = xact_mp_hash.$xact_id.xact %]
+Transaction ID: [% xact_id %]
+ [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
+ [% ELSE %]Miscellaneous
+ [% END %]
+ Line item billings:
+ [%- SET mb_type_hash = {} -%]
+ [%- FOR mb IN xact.billings %][%# Group billings by their btype -%]
+ [%- IF mb.voided == 'f' -%]
+ [%- SET mb_type = mb.btype.id -%]
+ [%- IF ! mb_type_hash.defined( mb_type ) -%][%- mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } -%][%- END -%]
+ [%- IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) -%][%- mb_type_hash.$mb_type.first_ts = mb.billing_ts -%][%- END -%]
+ [%- mb_type_hash.$mb_type.last_ts = mb.billing_ts -%]
+ [%- mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount -%]
+ [%- mb_type_hash.$mb_type.billings.push( mb ) -%]
+ [%- END -%]
+ [%- END -%]
+ [%- FOR mb_type IN mb_type_hash.keys.sort -%]
+ [%- IF mb_type == 1 %][%-# Consolidated view of overdue billings -%]
+ $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
+ on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
+ [%- ELSE -%][%# all other billings show individually %]
+ [% FOR mb IN mb_type_hash.$mb_type.billings %]
+ $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
+ [% END %]
+ [% END %]
+ [% END %]
+ Line item payments:
+ [% FOR mp IN xact_mp_hash.$xact_id.payments %]
+ Payment ID: [% mp.id %]
+ Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
+ [% CASE "cash_payment" %]cash
+ [% CASE "check_payment" %]check
+ [% CASE "credit_card_payment" %]credit card (
+ [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
+ [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
+ [% cc_chunks.last -%]
+ exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
+ )
+ [% CASE "credit_payment" %]credit
+ [% CASE "forgive_payment" %]forgiveness
+ [% CASE "goods_payment" %]goods
+ [% CASE "work_payment" %]work
+ [%- END %] on [% mp.payment_ts %] [% mp.note %]
+ [% END %]
+[% END %]
+$$
+WHERE id = 29;
+
+UPDATE action_trigger.event_definition SET template =
+$$
+[%- USE date -%][%- SET user = target.0.xact.usr -%]
+<div style="li { padding: 8px; margin 5px; }">
+ <div>[% date.format %]</div><br/>
+ <ol>
+ [% SET xact_mp_hash = {} %]
+ [% FOR mp IN target %][%# Template is hooked around payments, but let us make the receipt focused on transactions %]
+ [% SET xact_id = mp.xact.id %]
+ [% IF ! xact_mp_hash.defined( xact_id ) %][% xact_mp_hash.$xact_id = { 'xact' => mp.xact, 'payments' => [] } %][% END %]
+ [% xact_mp_hash.$xact_id.payments.push(mp) %]
+ [% END %]
+ [% FOR xact_id IN xact_mp_hash.keys.sort %]
+ [% SET xact = xact_mp_hash.$xact_id.xact %]
+ <li>Transaction ID: [% xact_id %]
+ [% IF xact.circulation %][% helpers.get_copy_bib_basics(xact.circulation.target_copy).title %]
+ [% ELSE %]Miscellaneous
+ [% END %]
+ Line item billings:<ol>
+ [% SET mb_type_hash = {} %]
+ [% FOR mb IN xact.billings %][%# Group billings by their btype %]
+ [% IF mb.voided == 'f' %]
+ [% SET mb_type = mb.btype.id %]
+ [% IF ! mb_type_hash.defined( mb_type ) %][% mb_type_hash.$mb_type = { 'sum' => 0.00, 'billings' => [] } %][% END %]
+ [% IF ! mb_type_hash.$mb_type.defined( 'first_ts' ) %][% mb_type_hash.$mb_type.first_ts = mb.billing_ts %][% END %]
+ [% mb_type_hash.$mb_type.last_ts = mb.billing_ts %]
+ [% mb_type_hash.$mb_type.sum = mb_type_hash.$mb_type.sum + mb.amount %]
+ [% mb_type_hash.$mb_type.billings.push( mb ) %]
+ [% END %]
+ [% END %]
+ [% FOR mb_type IN mb_type_hash.keys.sort %]
+ <li>[% IF mb_type == 1 %][%# Consolidated view of overdue billings %]
+ $[% mb_type_hash.$mb_type.sum %] for [% mb_type_hash.$mb_type.billings.0.btype.name %]
+ on [% mb_type_hash.$mb_type.first_ts %] through [% mb_type_hash.$mb_type.last_ts %]
+ [% ELSE %][%# all other billings show individually %]
+ [% FOR mb IN mb_type_hash.$mb_type.billings %]
+ $[% mb.amount %] for [% mb.btype.name %] on [% mb.billing_ts %] [% mb.note %]
+ [% END %]
+ [% END %]</li>
+ [% END %]
+ </ol>
+ Line item payments:<ol>
+ [% FOR mp IN xact_mp_hash.$xact_id.payments %]
+ <li>Payment ID: [% mp.id %]
+ Paid [% mp.amount %] via [% SWITCH mp.payment_type -%]
+ [% CASE "cash_payment" %]cash
+ [% CASE "check_payment" %]check
+ [% CASE "credit_card_payment" %]credit card (
+ [%- SET cc_chunks = mp.credit_card_payment.cc_number.replace(' ','').chunk(4); -%]
+ [%- cc_chunks.slice(0, -1+cc_chunks.max).join.replace('\S','X') -%]
+ [% cc_chunks.last -%]
+ exp [% mp.credit_card_payment.expire_month %]/[% mp.credit_card_payment.expire_year -%]
+ )
+ [% CASE "credit_payment" %]credit
+ [% CASE "forgive_payment" %]forgiveness
+ [% CASE "goods_payment" %]goods
+ [% CASE "work_payment" %]work
+ [%- END %] on [% mp.payment_ts %] [% mp.note %]
+ </li>
+ [% END %]
+ </ol>
+ </li>
+ [% END %]
+ </ol>
+</div>
+$$
+WHERE id = 30;
+
+INSERT INTO action_trigger.environment (
+ event_def,
+ path
+ ) VALUES -- for fleshing mp objects
+ ( 29, 'credit_card_payment')
+ ,( 29, 'xact.billings')
+ ,( 29, 'xact.billings.btype')
+ ,( 30, 'credit_card_payment')
+ ,( 30, 'xact.billings')
+ ,( 30, 'xact.billings.btype')
+;
+
+COMMIT;
+
More information about the open-ils-commits
mailing list