LP1211473 YAOUS : disable patron credit payments
authorBill Erickson <berick@esilibrary.com>
Mon, 12 Aug 2013 19:02:57 +0000 (15:02 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 26 Sep 2013 13:48:03 +0000 (09:48 -0400)
New org unit setting circ.disable_patron_credit.

This prevents "patron_credit" payments in the payment creation API and
hides all patron credit related actions in the patron payment interface.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaous-disable-patron-credit.sql [new file with mode: 0644]
Open-ILS/xul/staff_client/server/patron/bill2.js

index b8e3086..4fd8490 100644 (file)
 
        <!-- ================================================================ -->
 
+    <event code='11105' textcode='PATRON_CREDIT_DISABLED'>
+        <desc xml:lang="en-US">Payments by patron credit are not allowed 
+            for the selected transaction</desc>
+    </event>
+
+
 </ils_events>
 
 
index ec9f052..b46e578 100644 (file)
@@ -142,6 +142,7 @@ sub make_payments {
     my $this_ou = $e->requestor->ws_ou || $e->requestor->home_ou;
     my %orgs;
 
+
     # unless/until determined by payment processor API
     my ($approval_code, $cc_processor, $cc_type, $cc_order_number) = (undef,undef,undef, undef);
 
@@ -184,7 +185,18 @@ sub make_payments {
 
         $total_paid += $amount;
 
-        $orgs{$U->xact_org($transid, $e)} = 1;
+        my $org_id = $U->xact_org($transid, $e);
+
+        if (!$orgs{$org_id}) {
+            $orgs{$org_id} = 1;
+
+            # patron credit has to be allowed at all orgs receiving payment
+            if ($type eq 'credit_payment' and $U->ou_ancestor_setting_value(
+                    $org_id, 'circ.disable_patron_credit', $e)) {
+                $e->rollback;
+                return OpenILS::Event->new('PATRON_CREDIT_DISABLED');
+            }
+        }
 
         # A negative payment is a refund.  
         if( $amount < 0 ) {
index be69078..78fc099 100644 (file)
@@ -13492,3 +13492,24 @@ VALUES (
     )
 );
 
+-- YAOUS patron credit disable
+INSERT INTO config.org_unit_setting_type 
+    (grp, name, datatype, label, description) 
+VALUES (
+    'finance',
+    'circ.disable_patron_credit',
+    'bool',
+    oils_i18n_gettext(
+        'circ.disable_patron_credit',
+        'Disable Patron Credit',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.disable_patron_credit',
+        'Do not allow patrons to accrue credit or pay fines/fees with accrued credit',
+        'coust',
+        'description'
+    )
+);
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaous-disable-patron-credit.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaous-disable-patron-credit.sql
new file mode 100644 (file)
index 0000000..3113e40
--- /dev/null
@@ -0,0 +1,25 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type 
+    (grp, name, datatype, label, description) 
+VALUES (
+    'finance',
+    'circ.disable_patron_credit',
+    'bool',
+    oils_i18n_gettext(
+        'circ.disable_patron_credit',
+        'Disable Patron Credit',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.disable_patron_credit',
+        'Do not allow patrons to accrue credit or pay fines/fees with accrued credit',
+        'coust',
+        'description'
+    )
+);
+
+COMMIT;
index dde0fe8..8a248f3 100644 (file)
@@ -41,6 +41,12 @@ function my_init() {
             $('credit_forward').setAttribute('value',util.money.sanitize( g.patron.credit_forward_balance() ));
         }
 
+        if (g.data.hash.aous['circ.disable_patron_credit']) {
+            var nodes = document.getElementsByClassName('hide_patron_credit');
+            for (var i = 0; i < nodes.length; i++) 
+                nodes[i].setAttribute('hidden', true);
+        }
+
         if (g.data.hash.aous['ui.circ.billing.uncheck_bills_and_unfocus_payment_box']) {
             g.funcs.push(
                 function() {
@@ -983,6 +989,13 @@ function pay(payment_blob) {
                 case 'INVALID_USER_XACT_ID' :
                     refresh(); default_focus();
                     alert($("patronStrings").getFormattedString('staff.patron.bills.pay.invalid_user_xact_id', [robj.desc])); return false; break;
+                case 'PATRON_CREDIT_DISABLED' :
+                    refresh(); 
+                    default_focus();
+                    alert(robj.desc);
+                    return false;
+                    break;
+
                 default: throw(robj); break;
             }
         }