lp1671596 webstaff: add Adjust to Zero option to Bill UI collab/phasefx/webstaff-bugs-lp1671596
authorJason Etheridge <jason@equinoxinitiative.org>
Tue, 6 Jun 2017 20:59:02 +0000 (16:59 -0400)
committerJason Etheridge <jason@equinoxinitiative.org>
Tue, 6 Jun 2017 20:59:02 +0000 (16:59 -0400)
Signed-off-by: Jason Etheridge <jason@equinoxinitiative.org>
Open-ILS/src/templates/staff/circ/patron/index.tt2
Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index b017f19..f140dab 100644 (file)
@@ -35,6 +35,8 @@
 <script>
 angular.module('egCoreMod').run(['egStrings', function(s) {
   s.ANNOTATE_PAYMENT_MSG = "[% l('Please annotate this payment') %]";
+  s.CONFIRM_ADJUST_TO_ZERO = 
+    "[% |l('{{xactIds}}') -%]Are you sure you would like to adjust to zero the balance on bills [_1]?[% END %]";
   s.CONFIRM_REFUND_PAYMENT = 
     "[% |l('{{xactIds}}') -%]Are you sure you would like to refund excess payment on bills [_1]?  This action will simply put the amount in the Payment Pending column as a negative value.  You must still select Apply Payment!  Certain types of payments may not be refunded.  The refund may be applied to checked transactions that follow the refunded transaction.[% END %]";
   s.EDIT_BILL_PAY_NOTE = "[% l('Enter new note for #[_1]:','{{ids}}') %]";
index 36ba9e8..6d176be 100644 (file)
@@ -36,6 +36,9 @@
   <eg-grid-action label="[% l('Void All Billings') %]" 
     handler="voidAllBillings"></eg-grid-action>
 
+  <eg-grid-action label="[% l('Adjust to Zero') %]" 
+    handler="adjustToZero"></eg-grid-action>
+
   <eg-grid-action label="[% l('Refund') %]" 
     handler="refundXact"></eg-grid-action>
 
index 601956a..57bb094 100644 (file)
@@ -99,6 +99,18 @@ function($q , egCore , egWorkLog , patronSvc) {
         });
     }
 
+    service.adjustBillsToZero = function(bill_ids) {
+        return egCore.net.request(
+            'open-ils.circ',
+            'open-ils.circ.money.billable_xact.adjust_to_zero',
+            egCore.auth.token(),
+            bill_ids
+        ).then(function(resp) {
+            if (evt = egCore.evt.parse(resp)) return alert(evt);
+            return resp;
+        });
+    }
+
     service.updateBillNotes = function(note, ids) {
         return egCore.net.requestWithParamList(
             'open-ils.circ',
@@ -534,6 +546,25 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         });
     }
 
+    $scope.adjustToZero = function(items) {
+        if (items.length == 0) return;
+
+        var ids = items.map(function(item) {return item.id});
+
+        egCore.audio.play('warning.circ.adjust_to_zero_confirmation');
+        egConfirmDialog.open(
+            egCore.strings.CONFIRM_ADJUST_TO_ZERO, '', 
+            {   xactIds : ''+ids,
+                ok : function() {
+                    billSvc.adjustBillsToZero(ids).then(function() {
+                        refreshDisplay();
+                    });
+                }
+            }
+        );
+
+    }
+
     // note this is functionally equivalent to selecting a neg. transaction
     // then clicking Apply Payment -- this just adds a speed bump (ditto
     // the XUL client).