From 708f926e964463163520c6bb999a2d7f3da1964c Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Thu, 23 May 2019 17:07:16 +0000 Subject: [PATCH] lp1810429 Issue Refund in Patron Bills - Conditionally determine if a selected item is valid for a refund, and swap Apply Payment button for Issue Refund button. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 modified: Open-ILS/web/js/ui/default/staff/circ/patron/bills.js --- Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 | 7 +++++++ Open-ILS/web/js/ui/default/staff/circ/patron/bills.js | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 index 52c2965b01..ee9bd123ee 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 @@ -87,8 +87,15 @@ + 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 ceda5c82d4..4fb92536d7 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 @@ -189,6 +189,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, $scope.max_amount = 100000; $scope.amount_verified = false; $scope.disable_auto_print = false; + $scope.valid_refund = false; // check receipt_on_pay setting default persisted egCore.hatch.getItem('circ.bills.receiptonpay') @@ -311,10 +312,11 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, } // update the item.payment_pending value each time the user - // selects different transactions to pay against. + // selects different transactions to pay against. Also check + // if any selected items are valid for issuing a refund. $scope.$watch( function() {return $scope.gridControls.selectedItems()}, - function() {updatePendingColumn()}, + function() {updatePendingColumn(); validateRefundability()}, true ); @@ -354,6 +356,14 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, } } + function validateRefundability() { + var is_valid = false; + angular.forEach($scope.gridControls.selectedItems(), function(item) { + if (Number(item['summary.balance_owed']) < 0) is_valid = true; + }); + $scope.valid_refund = is_valid; + } + // builds payment arrays ([xact_id, ammount]) for all transactions // which have a pending payment amount. function generatePayments() { -- 2.11.0