[open-ils-commits] [GIT] Evergreen ILS branch master updated. 4ae3fa1a24e1e1bbfbd8b1ba77c8cc8e5d5b99a0

Evergreen Git git at git.evergreen-ils.org
Fri Feb 19 12:44:52 EST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  4ae3fa1a24e1e1bbfbd8b1ba77c8cc8e5d5b99a0 (commit)
       via  92471802fcc3f67f9356f6d62d6fe8476972c51c (commit)
       via  a8cb9b93402a140ee0b9037849cef2fae69cc72b (commit)
       via  c23f145ddc73b180adc41fc31d386c6ddfde7844 (commit)
       via  4718bf46ea51b3d86a17cca982859e3cd18dbcd2 (commit)
      from  24cf9388cac8254c603ce46896304963cb12709e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4ae3fa1a24e1e1bbfbd8b1ba77c8cc8e5d5b99a0
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Fri Feb 19 12:41:43 2016 -0500

    LP#1474051 Stamping upgrade script for drop-cc-data
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index ab33a79..1559923 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0955', :eg_version); --mpeters/christineb/kmlussier
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0957', :eg_version); --berick/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql b/Open-ILS/src/sql/Pg/upgrade/0956.schema.drop_cc_cols.sql
similarity index 75%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql
rename to Open-ILS/src/sql/Pg/upgrade/0956.schema.drop_cc_cols.sql
index c24ab04..fc8fb1b 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0956.schema.drop_cc_cols.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0956', :eg_version);
 
 ALTER TABLE money.credit_card_payment 
     DROP COLUMN cc_type,
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql b/Open-ILS/src/sql/Pg/upgrade/0957.data.drop_cc_cols.sql
similarity index 99%
rename from Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql
rename to Open-ILS/src/sql/Pg/upgrade/0957.data.drop_cc_cols.sql
index 763dcbd..3612417 100644
--- a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0957.data.drop_cc_cols.sql
@@ -1,7 +1,7 @@
 
 BEGIN;
 
--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0957', :eg_version);
 
 -- Remove references to dropped CC payment columns in the print/email 
 -- payment receipt templates, but only if the in-db template matches 

commit 92471802fcc3f67f9356f6d62d6fe8476972c51c
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jul 13 15:29:25 2015 -0400

    LP#1474051 Release/Upgrade Notes on dropped CC fields
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/docs/RELEASE_NOTES_NEXT/Administration/drop-cc-columns.txt b/docs/RELEASE_NOTES_NEXT/Administration/drop-cc-columns.txt
new file mode 100644
index 0000000..194964c
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Administration/drop-cc-columns.txt
@@ -0,0 +1,66 @@
+UPGRADE NOTES - Credit Card Receipts and Privacy
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To improve privacy and security, Evergreen now stores less data 
+about credit card transactions.  The following fields are no 
+longer stored:
+
+ * cc_type
+ * cc_first_name
+ * cc_last_name
+ * expire_month
+ * expire_year
+
+NOTE: All existing data within these fields will be deleted during
+the upgrade.  Reports using this data will no longer function.
+
+Additionally, a tool has been added to Evergreen for clearing the 
+last 4 digits of the credit payment from the database after payments
+reach a certain age.
+
+Print/Email Templates
++++++++++++++++++++++
+
+The stock print and email payment templates have been modified to no 
+longer use these fields, but only when the existing templates matched
+the stock templates.  If local changes have been applied, it will
+be necessary to modify local templates to avoid referencing these
+fields which no longer exist.
+
+Any templates whose hook is "money.format.payment_receipt.print" or 
+"money.format.payment_receipt.email" may need modification.  In stock
+Evergreen, these are templates:
+
+1. "money.payment_receipt.email" (stock id 29)
+2. "money.payment_receipt.print" (stock id 30)
+
+Example diff:
+
+[source,diff]
+---------------------------------------------
+-  [% 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_card_payment" %]credit card
++  [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
+---------------------------------------------
+
+Clearing the Last 4 of the CC Number
+++++++++++++++++++++++++++++++++++++
+
+To active automatic CC number clearing, add the following to opensrf's
+crontab.  Change timing to suit.
+
+[source,sh]
+---------------------------------------------
+5  4  * * *   . ~/.bashrc && $EG_BIN_DIR/clear_cc_number.srfsh
+---------------------------------------------
+
+The default retention age is 1 year, but this can be changed by modifying
+clear_cc_number.srfsh (typically found in /openils/bin/).  Replace "1 year"
+with the age of your choice.
+
+

commit a8cb9b93402a140ee0b9037849cef2fae69cc72b
Author: Bill Erickson <berickxx at gmail.com>
Date:   Wed Oct 14 11:59:32 2015 -0400

    LP#1474051 CRON script for clearing CC numbers
    
    Adds a new srfsh script which calls a new open-ils.storage API call
    which sets the cc_number value to NULL on all credit card payments
    older than the age specified in the srfsh script.
    
    Adds example CRON entry.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/examples/crontab.example b/Open-ILS/examples/crontab.example
index 1060f77..f68575d 100644
--- a/Open-ILS/examples/crontab.example
+++ b/Open-ILS/examples/crontab.example
@@ -61,6 +61,9 @@ EG_BIN_DIR = /openils/bin
 # Run the hard due date updater
 2  3  * * *   . ~/.bashrc && $EG_BIN_DIR/update_hard_due_dates.srfsh
 
+# Run the credit card number clearing script
+#5  4  * * *   . ~/.bashrc && $EG_BIN_DIR/clear_cc_number.srfsh
+
 # Action/Trigger entries ----
 
 # Runs all pending A/T events every half hour
diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am
index 6c4cf07..00740f3 100644
--- a/Open-ILS/src/Makefile.am
+++ b/Open-ILS/src/Makefile.am
@@ -69,6 +69,7 @@ core_scripts =   $(examples)/oils_ctl.sh \
 		 $(supportscr)/purge_holds.srfsh \
 		 $(supportscr)/purge_circulations.srfsh \
 		 $(supportscr)/purge_pending_users.srfsh \
+		 $(supportscr)/clear_cc_number.srfsh \
 		 $(supportscr)/sitemap_generator \
 		 $(srcdir)/extras/eg_config \
 		 $(srcdir)/extras/openurl_map.pl \
@@ -271,6 +272,7 @@ ilscore-install:
 	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/long-overdue-status-update.pl'
 	sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@bindir@/long-overdue-status-update.pl'
 	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/thaw_expired_frozen_holds.srfsh'
+	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/clear_cc_number.srfsh'
 	sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@bindir@/oils_ctl.sh'
 	sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@bindir@/oils_ctl.sh'
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm
index 6507db9..d2db7ae 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm
@@ -522,4 +522,38 @@ __PACKAGE__->register_method(
 );
 
 
+sub clear_cc_number {
+    my $self = shift;
+    my $client = shift;
+    my $payment_age = shift;
+
+    # using NOW() in the AGE() calculation lets us modify payments 
+    # that occurred today without having to specify negative ages.
+
+    my $sql = <<"    SQL";
+        UPDATE money.credit_card_payment
+        SET cc_number = NULL 
+        WHERE AGE(NOW(), payment_ts) > ?::INTERVAL;
+    SQL
+
+    my $sth = actor::user->db_Main->prepare_cached($sql);
+    $sth->execute($payment_age);
+
+    return $sth->rows;
+}
+
+__PACKAGE__->register_method(
+    api_name  => 'open-ils.storage.money.clear_cc_number',
+    method    => 'clear_cc_number',
+    api_level => 1,
+    signature => q/
+        Credit card payments store the last 4 digits of the card
+        number.  This API call set the credit card number field
+        to NULL to remove this data after the payment has
+        reached the specified age.
+        @param payment_age The age as a string.
+    /
+);
+
+
 1;
diff --git a/Open-ILS/src/support-scripts/clear_cc_number.srfsh b/Open-ILS/src/support-scripts/clear_cc_number.srfsh
new file mode 100755
index 0000000..6939d7f
--- /dev/null
+++ b/Open-ILS/src/support-scripts/clear_cc_number.srfsh
@@ -0,0 +1,2 @@
+#!BINDIR/srfsh
+request open-ils.storage open-ils.storage.money.clear_cc_number "1 year"

commit c23f145ddc73b180adc41fc31d386c6ddfde7844
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jul 13 15:19:35 2015 -0400

    LP#1474051 PGTAP test checking dropped columns
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/t/lp1474051-drop-cc-columns.pg b/Open-ILS/src/sql/Pg/t/lp1474051-drop-cc-columns.pg
new file mode 100644
index 0000000..9314237
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/lp1474051-drop-cc-columns.pg
@@ -0,0 +1,26 @@
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(6);
+
+-- Run the tests.
+
+SELECT hasnt_column('money', 'credit_card_payment', 'cc_type', 
+    'Column "cc_type" on money.credit_card_payment should not exist');
+SELECT hasnt_column('money', 'credit_card_payment', 'expire_month', 
+    'Column "expire_month" on money.credit_card_payment should not exist');
+SELECT hasnt_column('money', 'credit_card_payment', 'expire_year', 
+    'Column "expire_year" on money.credit_card_payment should not exist');
+SELECT hasnt_column('money', 'credit_card_payment', 'cc_first_name', 
+    'Column "cc_first_name" on money.credit_card_payment should not exist');
+SELECT hasnt_column('money', 'credit_card_payment', 'cc_last_name', 
+    'Column "cc_last_name" on money.credit_card_payment should not exist');
+
+-- make sure at least one column does exist
+SELECT has_column('money', 'credit_card_payment', 'approval_code', 
+    'Column "approval_code" on money.credit_card_payment should exist');
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;

commit 4718bf46ea51b3d86a17cca982859e3cd18dbcd2
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Jul 13 14:00:06 2015 -0400

    LP#1474051 Drop unneeded CC payment fields
    
    Avoid storing the following credit card fields:
    
    expire month
    expire year
    first name
    last name
    credit card type
    
    Print and email receipts for credit card data modified to avoid
    referencing these fields.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index 85b485f..42b66f2 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -2591,14 +2591,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 			<field name="amount_collected" reporter:datatype="money" />
 			<field name="approval_code" reporter:datatype="text"/>
 			<field name="cash_drawer" reporter:datatype="link"/>
-			<field name="cc_first_name" reporter:datatype="text"/>
-			<field name="cc_last_name" reporter:datatype="text"/>
 			<field name="cc_number" reporter:datatype="text"/>
 			<field name="cc_order_number" reporter:datatype="text"/>
-			<field name="cc_type" reporter:datatype="text"/>
 			<field name="cc_processor" reporter:datatype="text"/>
-			<field name="expire_month" reporter:datatype="int" />
-			<field name="expire_year" reporter:datatype="int" />
 			<field name="id" reporter:datatype="id" />
 			<field name="note" reporter:datatype="text"/>
 			<field name="payment_ts" reporter:datatype="timestamp"/>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
index 2cd07f8..a558777 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
@@ -269,7 +269,7 @@ sub make_payments {
 
 
     # unless/until determined by payment processor API
-    my ($approval_code, $cc_processor, $cc_type, $cc_order_number) = (undef,undef,undef, undef);
+    my ($approval_code, $cc_processor, $cc_order_number) = (undef,undef,undef, undef);
 
     my $patron = $e->retrieve_actor_user($user_id) or return $e->die_event;
 
@@ -382,16 +382,13 @@ sub make_payments {
 
         if ($payobj->has_field('accepting_usr')) { $payobj->accepting_usr($e->requestor->id); }
         if ($payobj->has_field('cash_drawer')) { $payobj->cash_drawer($drawer); }
-        if ($payobj->has_field('cc_type')) { $payobj->cc_type($cc_args->{type}); }
         if ($payobj->has_field('check_number')) { $payobj->check_number($check_number); }
 
         # Store the last 4 digits of the CC number
         if ($payobj->has_field('cc_number')) {
             $payobj->cc_number(substr($cc_args->{number}, -4));
         }
-        if ($payobj->has_field('expire_month')) { $payobj->expire_month($cc_args->{expire_month}); $logger->info("LFW XXX expire_month is $cc_args->{expire_month}"); }
-        if ($payobj->has_field('expire_year')) { $payobj->expire_year($cc_args->{expire_year}); }
-        
+
         # Note: It is important not to set approval_code
         # on the fieldmapper object yet.
 
@@ -434,7 +431,6 @@ sub make_payments {
 
                 {
                     no warnings 'uninitialized';
-                    $cc_type = $cc_payload->{card_type};
                     $approval_code = $cc_payload->{authorization} ||
                         $cc_payload->{id};
                     $cc_processor = $cc_payload->{processor} ||
@@ -523,17 +519,12 @@ sub make_payments {
 
         # Urgh, clean up this mega-function one day.
         if ($cc_processor eq 'Stripe' and $approval_code and $cc_payload) {
-            $payment->expire_month($cc_payload->{card}{exp_month});
-            $payment->expire_year($cc_payload->{card}{exp_year});
             $payment->cc_number($cc_payload->{card}{last4});
         }
 
         $payment->approval_code($approval_code) if $approval_code;
         $payment->cc_order_number($cc_order_number) if $cc_order_number;
-        $payment->cc_type($cc_type) if $cc_type;
         $payment->cc_processor($cc_processor) if $cc_processor;
-        $payment->cc_first_name($cc_args->{'billing_first'}) if $cc_args->{'billing_first'};
-        $payment->cc_last_name($cc_args->{'billing_last'}) if $cc_args->{'billing_last'};
         if (!$e->$create_money_method($payment)) {
             return _recording_failure(
                 $e, "$create_money_method failed", $payment, $cc_payload
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/money.pm
index c3e65fc..c9d7247 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/money.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/money.pm
@@ -116,9 +116,8 @@ use base qw/money/;
 __PACKAGE__->table('money_credit_card_payment');
 __PACKAGE__->columns(Primary => 'id');
 __PACKAGE__->columns(Essential => qw/xact amount payment_ts cash_drawer
-                     accepting_usr amount_collected cc_type
-                     cc_number expire_month expire_year
-                     approval_code note/);
+                     accepting_usr amount_collected cc_processor
+                     approval_code note voided cc_number/);
 #-------------------------------------------------------------------------------
 
 package money::forgive_payment;
diff --git a/Open-ILS/src/sql/Pg/080.schema.money.sql b/Open-ILS/src/sql/Pg/080.schema.money.sql
index 3bba2ed..e67c0a7 100644
--- a/Open-ILS/src/sql/Pg/080.schema.money.sql
+++ b/Open-ILS/src/sql/Pg/080.schema.money.sql
@@ -640,14 +640,9 @@ CREATE TRIGGER mat_summary_del_tgr BEFORE DELETE ON money.check_payment FOR EACH
 
 
 CREATE TABLE money.credit_card_payment (
-	cc_type		TEXT,
-	cc_number	TEXT,
+    cc_number     TEXT,
     cc_processor TEXT,
-    cc_first_name TEXT,
-    cc_last_name TEXT,
     cc_order_number TEXT,
-	expire_month	INT,
-	expire_year	INT,
 	approval_code	TEXT
 ) INHERITS (money.bnm_desk_payment);
 ALTER TABLE money.credit_card_payment ADD PRIMARY KEY (id);
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index df34cce..2505f50 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -9726,12 +9726,8 @@ Transaction ID: [% xact_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_card_payment" %]credit card
+                    [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
                     [% CASE "credit_payment" %]credit
                     [% CASE "forgive_payment" %]forgiveness
                     [% CASE "goods_payment" %]goods
@@ -9797,12 +9793,8 @@ $$
                         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_card_payment" %]credit card
+                            [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
                             [% CASE "credit_payment" %]credit
                             [% CASE "forgive_payment" %]forgiveness
                             [% CASE "goods_payment" %]goods
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql
new file mode 100644
index 0000000..c24ab04
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.drop_cc_cols.sql
@@ -0,0 +1,13 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE money.credit_card_payment 
+    DROP COLUMN cc_type,
+    DROP COLUMN expire_month,
+    DROP COLUMN expire_year,
+    DROP COLUMN cc_first_name,
+    DROP COLUMN cc_last_name;
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql
new file mode 100644
index 0000000..763dcbd
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.drop_cc_cols.sql
@@ -0,0 +1,270 @@
+
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- Remove references to dropped CC payment columns in the print/email 
+-- payment receipt templates, but only if the in-db template matches 
+-- the stock template.
+-- The actual diff here is only about 8 lines.
+
+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
+                    [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
+                    [% 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 AND 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 %]
+$$;
+
+
+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
+                            [%- IF mp.credit_card_payment.cc_number %] ([% mp.credit_card_payment.cc_number %])[% END %]
+                            [% 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 AND 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>
+$$;
+
+
+--ROLLBACK;
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/crontab.example                  |    3 +
 Open-ILS/examples/fm_IDL.xml                       |    5 -
 Open-ILS/src/Makefile.am                           |    2 +
 .../perlmods/lib/OpenILS/Application/Circ/Money.pm |   13 +-
 .../lib/OpenILS/Application/Storage/CDBI/money.pm  |    5 +-
 .../OpenILS/Application/Storage/Publisher/money.pm |   34 +++
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/080.schema.money.sql           |    7 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   16 +-
 Open-ILS/src/sql/Pg/t/lp1474051-drop-cc-columns.pg |   26 ++
 .../sql/Pg/upgrade/0956.schema.drop_cc_cols.sql    |   13 +
 .../src/sql/Pg/upgrade/0957.data.drop_cc_cols.sql  |  270 ++++++++++++++++++++
 Open-ILS/src/support-scripts/clear_cc_number.srfsh |    2 +
 .../Administration/drop-cc-columns.txt             |   66 +++++
 14 files changed, 426 insertions(+), 38 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/lp1474051-drop-cc-columns.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0956.schema.drop_cc_cols.sql
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0957.data.drop_cc_cols.sql
 create mode 100755 Open-ILS/src/support-scripts/clear_cc_number.srfsh
 create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/drop-cc-columns.txt


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list