From 87ac04ae7241c52e17eec8d224dd74ffeb64d8fe Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 12 Jun 2017 11:07:59 -0400 Subject: [PATCH] lp1671603 webstaff: add confirm step for voiding billings This patch adds a confirmation step for both Void All Bills in the main billing UI, and Void Billings in the Full Details UI Signed-off-by: Jason Etheridge Signed-off-by: Andrea Neiman Signed-off-by: Galen Charlton --- .../src/templates/staff/circ/patron/index.tt2 | 2 + .../js/ui/default/staff/circ/patron/bills.js | 89 ++++++++++++------- 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index f140dab054..88c5dcabc3 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -37,6 +37,8 @@ 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_VOID_BILLINGS = + "[% l('Are you sure you would like to void $[_1] for these line-item billings? [_2]','{{amount|number:2}}','{{billIds}}') %]"; 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}}') %]"; diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js index 57bb094505..c365c8228c 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js @@ -517,32 +517,43 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, } $scope.voidAllBillings = function(items) { + var promises = []; + var bill_ids = []; + var cents = 0; angular.forEach(items, function(item) { + promises.push( + billSvc.fetchBills(item.id).then(function(bills) { + angular.forEach(bills, function(b) { + if (b.voided() != 't') { + cents += b.amount() * 100; + bill_ids.push(b.id()) + } + }); - billSvc.fetchBills(item.id).then(function(bills) { - var bill_ids = []; - var cents = 0; - angular.forEach(bills, function(b) { - if (b.voided() != 't') { - cents += b.amount() * 100; - bill_ids.push(b.id()) + if (bill_ids.length == 0) { + // TODO: warn + return; } - }); - $scope.session_voided = - ($scope.session_voided * 100 + cents) / 100; + }) + ); + }); - if (bill_ids.length == 0) { - // TODO: warn - return; + $q.all(promises).then(function(){ + egCore.audio.play('warning.circ.void_billings_confirmation'); + egConfirmDialog.open( + egCore.strings.CONFIRM_VOID_BILLINGS, '', + { billIds : ''+bill_ids, + amount : ''+(cents/100), + ok : function() { + billSvc.voidBills(bill_ids).then(function() { + $scope.session_voided = + ($scope.session_voided * 100 + cents) / 100; + refreshDisplay(); + }); + } } - - // TODO: alert of pending voiding - - billSvc.voidBills(bill_ids).then(function() { - refreshDisplay(); - }); - }); + ); }); } @@ -607,8 +618,8 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, * Displays details of a single transaction */ .controller('XactDetailsCtrl', - ['$scope','$q','$routeParams','egCore','egGridDataProvider','patronSvc','billSvc','egPromptDialog','egBilling', -function($scope, $q , $routeParams , egCore , egGridDataProvider , patronSvc , billSvc , egPromptDialog , egBilling) { + ['$scope','$q','$routeParams','egCore','egGridDataProvider','patronSvc','billSvc','egPromptDialog','egBilling','egConfirmDialog', +function($scope, $q , $routeParams , egCore , egGridDataProvider , patronSvc , billSvc , egPromptDialog , egBilling , egConfirmDialog ) { $scope.initTab('bills', $routeParams.id); var xact_id = $routeParams.xact_id; @@ -626,8 +637,12 @@ function($scope, $q , $routeParams , egCore , egGridDataProvider , patronSvc , // -- actions $scope.voidBillings = function(bill_list) { var bill_ids = []; + var cents = 0; angular.forEach(bill_list, function(b) { - if (b.voided != 't') bill_ids.push(b.id); + if (b.voided != 't') { + cents += b.amount * 100; + bill_ids.push(b.id) + } }); if (bill_ids.length == 0) { @@ -635,18 +650,28 @@ function($scope, $q , $routeParams , egCore , egGridDataProvider , patronSvc , return; } - billSvc.voidBills(bill_ids).then(function() { + egCore.audio.play('warning.circ.void_billings_confirmation'); + egConfirmDialog.open( + egCore.strings.CONFIRM_VOID_BILLINGS, '', + { billIds : ''+bill_ids, + amount : ''+(cents/100), + ok : function() { + billSvc.voidBills(bill_ids).then(function() { + // TODO? $scope.session_voided = ... - // refresh bills and summary data - // note: no need to update payments - patronSvc.fetchUserStats(); + // refresh bills and summary data + // note: no need to update payments + patronSvc.fetchUserStats(); - egBilling.fetchXact(xact_id).then(function(xact) { - $scope.xact = xact - }); + egBilling.fetchXact(xact_id).then(function(xact) { + $scope.xact = xact + }); - xactGrid.refresh(); - }); + xactGrid.refresh(); + }); + } + } + ); } // batch-edit billing and payment notes, depending on 'type' -- 2.43.2