From: Bill Erickson Date: Mon, 14 Jan 2019 18:50:47 +0000 (-0500) Subject: JBAS-2118 Refundable payment receipt printing; copy filters X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1e00760de5bf77c594d19a84908fb71e6a61c4f7;p=working%2FEvergreen.git JBAS-2118 Refundable payment receipt printing; copy filters Signed-off-by: Bill Erickson --- 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 7f7de97a31..0f34ab380d 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 @@ -77,10 +77,52 @@ function($q , egCore , egWorkLog , patronSvc) { // payment API returns the update xact id so we can track it // for future payments without having to refresh the user. patronSvc.current.last_xact_id(resp.last_xact_id); - return resp.payments; + + var promise = $q.when(); + if (resp.refundable_payments && resp.refundable_payments.length) { + promise = + service.printRefundablePaymentReceipts(resp.refundable_payments); + } + + return promise.then(function() { + return resp.payments; + }); }); } + + // Returns a promise after all payments have been queued for printing. + service.printRefundablePaymentReceipts = function(mrpIds) { + + function printOne() { + mrpId = mrpIds.shift(); + if (!mrpId) { return $q.when(); } + + return egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.refundable_payment.receipt.html', + egCore.auth.token(), mrpId + ).then(function(receipt) { + if (!receipt || !receipt.template_output()) { + return alert( + 'Error creating refundable payment receipt for payment ' + + mrpId); + } + + var html = receipt.template_output().data(); + return egCore.print.print({ + context : 'default', + content_type: 'text/html', + content: html, + show_dialog: true, + scope : {} + }); + }).then(function() { return printOne() }); + } + + return printOne(); + } + service.fetchBills = function(xact_id) { var bills = []; return egCore.pcrud.search('mb', @@ -376,8 +418,17 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, // Returns a promise resolved to the list of payments altered as // necessary to include lost payment authorization data, rejected // if the payment is canceled. + + // TODO: move this designation into the database + var NO_REFUND_CIRC_MODIFIERS = ['1', '7', '45', '46', '66', '40', '41']; function handleLostPayAuth(payments) { + if ($scope.payment_type !== 'cash_payment' && + $scope.payment_type !== 'check_payment') { + // Only cash and check payments are refundable + return $q.when(null); + } + var lostXacts = []; payments.forEach(function(payment) { var xactId = payment[0]; @@ -386,7 +437,13 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, var stopFines = gridItem['circulation.stop_fines']; var ciTime = gridItem['circulation.checkin_time']; - if (stopFines === 'LOST' && !ciTime) { + var circMod = gridItem['circulation.target_copy.circ_modifier']; + var bibId = gridItem['circulation.target_copy.call_number.record.id']; + + if (stopFines === 'LOST' && + !ciTime && // Item has not been returned + Number(bibId) != -1 && // Precats are not refundable + NO_REFUND_CIRC_MODIFIERS.indexOf('' + circMod) < 0) { console.debug("Processing lost payment transaction ", xactId); lostXacts.push(xactId); }