__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/,
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/) {
$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([
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',
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;
}
}
}
+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; }
<popupset id="payment_history_popupset">
<menupopup id="payment_history_actions" position="at_pointer">
<menuitem label="&staff.patron.bill_interface.print_selected.label;" accesskey="&staff.patron.bill_interface.full_details.accesskey;" oncommand="print_bills_from_history(true);"/>
+ <menuitem label="Reprint Lost/Paid Receipt" oncommand="print_lostpaid_from_history();"/>
</menupopup>
</popupset>
<popupset id="bill_history_popupset">