From c5ef3fd9f1caf95e46cc4336c7bf211117186370 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Wed, 1 May 2013 12:32:06 -0400 Subject: [PATCH] Auto re-bill forgiven overdues on lost checkin Auto re-bill forgiven overdues on checkin of a lost item. This is done by looking for a Forgive payment with a special note, then creating a new billing of type Overdue materials. Nothing is done to the previous daily billings on the transaction. Signed-off-by: Jeff Godin --- .../lib/OpenILS/Application/Circ/Circulate.pm | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index f37c0fbf44..27803fc389 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -4023,6 +4023,33 @@ sub checkin_handle_lost_or_lo_now_found_restore_od { # restore those overdue charges voided when item was set to lost # ------------------------------------------------------------------ + # first, look for a forgive payment with a special note + my $forgives = $self->editor->search_money_forgive_payment( + { + xact => $self->circ->id, + note => 'System: OVERDUES FORGIVEN ON LOST' + } + ); + + if ($forgives) { + $logger->info("Found forgive payment(s) on circ ", $self->circ->id); + # re-bill the forgiven overdue(s) + for my $payment (@$forgives) { + my $bill = Fieldmapper::money::billing->new; + my $amount = $payment->amount; + my $billing_type = OILS_BILLING_TYPE_OVERDUE_MATERIALS; + my $btype = 1; + $bill->xact($self->circ->id); + $bill->amount($amount); + $bill->note('System: re-billed previously forgiven overdues on lost checkin'); + $bill->billing_type($billing_type); + $bill->btype($btype); + $self->editor->create_money_billing($bill) or $self->bail_on_events($self->editor->event); + $logger->info("Re-billed previously forgiven overdues of $amount on circ ", $self->circ->id); + } + return; + } + my $ods = $self->editor->search_money_billing( { xact => $self->circ->id, -- 2.11.0