LP#1639022 Webstaff convert change to credit
authorBill Erickson <berickxx@gmail.com>
Wed, 16 May 2018 21:24:05 +0000 (17:24 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 23 May 2018 13:53:34 +0000 (09:53 -0400)
Add support for converting change to patron credit in the patron bills
interface, consistent with the XUL feature.  When the
'circ.disable_patron_credit' org unit setting is applied, the option is
hidden.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Laura Sachjen <sachjenl@branchdistrictlibrary.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/circ/patron/t_bills.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index bdc6c27..d37f336 100644 (file)
@@ -105,6 +105,14 @@ off to the right.  flex-row is honoring the boundaries better.
 not sure what's up, there. -->
 <div class="flex-row" ng-if="!disable_auto_print">
   <div class="flex-cell"></div>
 not sure what's up, there. -->
 <div class="flex-row" ng-if="!disable_auto_print">
   <div class="flex-cell"></div>
+  <div ng-hide="disablePatronCredit" class="pad-right">
+    <div class="checkbox">
+      <label>
+        <input type="checkbox" ng-model="convert_to_credit.isChecked">
+        [% l('Convert Change to Patron Credit') %]
+      </label>
+    </div>
+  </div>
   <form class="form-inline" role="form">
    <div class="checkbox">
       <label>
   <form class="form-inline" role="form">
    <div class="checkbox">
       <label>
index 392b696..e1d1686 100644 (file)
@@ -12,9 +12,12 @@ function($q , egCore , egWorkLog , patronSvc) {
     // fetch org unit settings specific to the bills display
     service.fetchBillSettings = function() {
         if (service.settings) return $q.when(service.settings);
     // fetch org unit settings specific to the bills display
     service.fetchBillSettings = function() {
         if (service.settings) return $q.when(service.settings);
-        return egCore.org.settings(
-            ['ui.circ.billing.uncheck_bills_and_unfocus_payment_box','ui.circ.billing.amount_warn','ui.circ.billing.amount_limit','circ.staff_client.do_not_auto_attempt_print']
-        ).then(function(s) {return service.settings = s});
+        return egCore.org.settings([
+            'ui.circ.billing.uncheck_bills_and_unfocus_payment_box',
+            'ui.circ.billing.amount_warn', 'ui.circ.billing.amount_limit',
+            'circ.staff_client.do_not_auto_attempt_print',
+            'circ.disable_patron_credit'
+        ]).then(function(s) {return service.settings = s});
     }
 
     // user billing summary
     }
 
     // user billing summary
@@ -24,7 +27,9 @@ function($q , egCore , egWorkLog , patronSvc) {
         .then(function(summary) {return service.summary = summary})
     }
 
         .then(function(summary) {return service.summary = summary})
     }
 
-    service.applyPayment = function(type, payments, note, check, cc_args) {
+    service.applyPayment = function(
+        type, payments, note, check, cc_args, patron_credit) {
+
         return egCore.net.request(
             'open-ils.circ',
             'open-ils.circ.money.payment',
         return egCore.net.request(
             'open-ils.circ',
             'open-ils.circ.money.payment',
@@ -34,7 +39,7 @@ function($q , egCore , egWorkLog , patronSvc) {
                 payment_type : type,
                 check_number : check,
                 payments : payments,
                 payment_type : type,
                 check_number : check,
                 payments : payments,
-                patron_credit : 0,
+                patron_credit : patron_credit,
                 cc_args : cc_args
             },
             patronSvc.current.last_xact_id()
                 cc_args : cc_args
             },
             patronSvc.current.last_xact_id()
@@ -179,6 +184,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     $scope.annotate_payment = false;
     $scope.receipt_count = 1;
     $scope.receipt_on_pay = { isChecked: false };
     $scope.annotate_payment = false;
     $scope.receipt_count = 1;
     $scope.receipt_on_pay = { isChecked: false };
+    $scope.convert_to_credit = {isChecked: false};
     $scope.warn_amount = 1000;
     $scope.max_amount = 100000;
     $scope.amount_verified = false;
     $scope.warn_amount = 1000;
     $scope.max_amount = 100000;
     $scope.amount_verified = false;
@@ -338,8 +344,10 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     function sendPayment(note, cc_args) {
         $scope.applyingPayment = true;
         var make_payments = generatePayments();
     function sendPayment(note, cc_args) {
         $scope.applyingPayment = true;
         var make_payments = generatePayments();
+        var patron_credit = $scope.convert_to_credit.isChecked ?
+            $scope.pending_change() : 0; 
         billSvc.applyPayment($scope.payment_type, 
         billSvc.applyPayment($scope.payment_type, 
-            make_payments, note, $scope.check_number, cc_args)
+            make_payments, note, $scope.check_number, cc_args, patron_credit)
         .then(
             function(payment_ids) {
 
         .then(
             function(payment_ids) {
 
@@ -479,6 +487,9 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                 s['circ.staff_client.do_not_auto_attempt_print'].indexOf('Bill Pay') > -1
             );
         }
                 s['circ.staff_client.do_not_auto_attempt_print'].indexOf('Bill Pay') > -1
             );
         }
+        if (s['circ.disable_patron_credit']) {
+            $scope.disablePatronCredit = true;
+        }
     });
 
     $scope.gridControls.allItemsRetrieved = function() {
     });
 
     $scope.gridControls.allItemsRetrieved = function() {