From 588efbcad03cf9289931e54c42c0b669849ecffd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 8 Nov 2018 11:37:30 -0500 Subject: [PATCH] JBAS-2118 Lost payments auth for webstaff WIP Signed-off-by: Bill Erickson --- .../staff/circ/patron/t_lost_payment_auth.tt2 | 34 ++++++++++++++ .../web/js/ui/default/staff/circ/patron/bills.js | 54 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 diff --git a/Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 new file mode 100644 index 0000000000..8036a163b7 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 @@ -0,0 +1,34 @@ +
+ + + +
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..e62cd3e60f 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 @@ -372,6 +372,53 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, $scope.gridControls.refresh(); } + // Returns a promise resolved to the list of payments altered as + // necessary to include lost payment authorization data, rejected + // if the payment is canceled. + function handleLostPayAuth(payments) { + + var lostXacts = []; + payments.forEach(function(payment) { + var xactId = payment[0]; + var gridItem = $scope.gridControls.allItems().filter( + function(item) {return item.id == xactId})[0]; + + var stopFines = gridItem['circulation.stop_fines']; + if (stopFines === 'LOST') { + console.debug("Processing lost payment transaction ", xactId); + lostXacts.push(xactId); + } + }); + + if (lostXacts.length === 0) { + return $q.when(payments); + } + + return $uibModal.open({ + templateUrl : './circ/patron/t_lost_payment_auth', + backdrop: 'static', + controller : [ + '$scope','$uibModalInstance', + function($scope , $uibModalInstance) { + $scope.context = { + username: '', + password: '' + }; + + $scope.ok = function() { + console.log($scope.context.username); + console.log($scope.context.password); + $uibModalInstance.close(payments); + } + + $scope.cancel = function() { + $uibModalInstance.dismiss(); + } + } + ] + }).result; + } + // generates payments, collects user note if needed, and sends payment // to server. function sendPayment(note, cc_args) { @@ -379,6 +426,12 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, var make_payments = generatePayments(); var patron_credit = $scope.convert_to_credit.isChecked ? $scope.pending_change() : 0; + + // KCLS prompt for lost payment authorization. + handleLostPayAuth(make_payments) + .then(function(make_payments) { + // NOTE: avoiding indentation to reduce variation with stock. + billSvc.applyPayment($scope.payment_type, make_payments, note, $scope.check_number, cc_args, patron_credit) .then( @@ -395,6 +448,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, console.error('Payment was rejected: ' + msg); } ) + }) .finally(function() { $scope.applyingPayment = false; }) } -- 2.11.0