From: Bill Erickson Date: Thu, 18 Oct 2018 19:21:10 +0000 (-0400) Subject: JBAS-1306 Reprint lost/paid from payment history X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=afa0ec547a775beb15bc862340c592ffdfa65035;p=working%2FEvergreen.git JBAS-1306 Reprint lost/paid from payment history Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/RefundablePayment.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/RefundablePayment.pm index 10ee7574ae..18bad4be65 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/RefundablePayment.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/RefundablePayment.pm @@ -373,6 +373,23 @@ __PACKAGE__->register_method( __PACKAGE__->register_method( method => 'generate_refundable_payment_receipt', + api_name => 'open-ils.circ.refundable_payment.receipt.by_pay.html', + signature => { + desc => q/Generate a printable HTML refundable payment receipt + for the requested money.payment entry/, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'Source Payment ID', type => 'number'} + ], + return => { + desc => 'A/T event with fleshed outputs on success, event on error' + } + } +); + + +__PACKAGE__->register_method( + method => 'generate_refundable_payment_receipt', api_name => 'open-ils.circ.refundable_payment.receipt.email', signature => { desc => q/Generate an email refundable payment receipt/, @@ -390,7 +407,7 @@ sub generate_refundable_payment_receipt { my ($self, $client, $auth, $target_id) = @_; my $e = new_editor(authtoken => $auth); - return $e->die_event unless $e->checkauth; + return $e->event unless $e->checkauth; my $mrps; if ($self->api_name =~ /by_xact/) { @@ -415,6 +432,13 @@ sub generate_refundable_payment_receipt { $mrxs->clear_refundable_payments; $mrps->refundable_xact($mrxs); + } elsif ($self->api_name =~ /by_pay/) { + + $mrps = $e->search_money_refundable_payment_summary([ + {payment => $target_id}, + {flesh => 1, flesh_fields => {mrps => ['refundable_xact']}} + ])->[0] or return $e->event; + } else { $mrps = $e->retrieve_money_refundable_payment_summary([ diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index 8750c0629f..73831cac70 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -914,7 +914,7 @@ function handle_printlostpaid() { var xact_ids = selected.map(function(sel) { return sel.mbts_id }); for (var i = 0; i < xact_ids.length; i++) { - xact_id = xact_ids[0]; + xact_id = xact_ids[i]; var receipt = g.network.request( 'open-ils.circ', @@ -924,7 +924,7 @@ function handle_printlostpaid() { if (receipt && receipt.textcode == 'MONEY_REFUNDABLE_XACT_SUMMARY_NOT_FOUND') { - alert('Transaction ' + xact_id + ' has no lost payments'); + alert('Cannot generate lost/paid receipt for transaction #' + xact_id); continue; } diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.js b/Open-ILS/xul/staff_client/server/patron/bill_history.js index 2a2604ac91..e5c017302f 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.js @@ -412,6 +412,41 @@ function print_bills_from_history(selected) { } } +function print_lostpaid_from_history() { + var selected = g.payments_list.dump_selected_with_keys(0); + var pay_ids = selected.map(function(sel) { return sel.mp_id }); + + for (var i = 0; i < pay_ids.length; i++) { + pay_id = pay_ids[i]; + + var receipt = g.network.request( + 'open-ils.circ', + 'open-ils.circ.refundable_payment.receipt.by_pay.html', + [ses(), pay_id] + ); + + if (receipt && + receipt.textcode == 'MONEY_REFUNDABLE_PAYMENT_SUMMARY_NOT_FOUND') { + alert('Cannot generate lost/paid receipt for payment #' + pay_id); + continue; + } + + if (!receipt || !receipt.template_output()) { + return alert( + 'Error creating refundable payment receipt for payment ' + pay_id); + } + + var html = receipt.template_output().data(); + JSAN.use('util.print'); + var print = new util.print('mail'); + + print.simple(html , { + no_prompt: false, // always prompt for lost payment receipts + content_type: 'text/html' + }); + } +} + function payment_history_init() { try { if (payment_history_fetched) { return; } else { payment_history_fetched = true; } diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.xul b/Open-ILS/xul/staff_client/server/patron/bill_history.xul index 4a505b9eba..eb7a29401a 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.xul +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.xul @@ -146,6 +146,7 @@ +