// 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',
// 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];
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);
}