From 250daae990e8643b20ca9c150eb9e654607f7d4b Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 28 May 2015 13:54:26 -0400 Subject: [PATCH] LP 1198465: Set restored overdue timestamp to time of last overdue When we have our settings configured to generate new overdues on lost item return, we start generation after the most recent overdue fine. Because of this, we need the restored fine to be dated in the past, which in turn allows the fine generator to apply catch-up fines as expected. Signed-off-by: Dan Wells --- .../src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm | 3 ++- .../src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm index 4dac75ec86..541a5a8cf2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm @@ -198,7 +198,7 @@ sub reopen_xact { sub create_bill { - my($class, $e, $amount, $btype, $type, $xactid, $note) = @_; + my($class, $e, $amount, $btype, $type, $xactid, $note, $billing_ts) = @_; $logger->info("The system is charging $amount [$type] on xact $xactid"); $note ||= 'SYSTEM GENERATED'; @@ -208,6 +208,7 @@ sub create_bill { my $bill = Fieldmapper::money::billing->new; $bill->xact($xactid); $bill->amount($amount); + $bill->billing_ts($billing_ts); $bill->billing_type($type); $bill->btype($btype); $bill->note($note); 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 b128119cc8..70fb2e747a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -4036,12 +4036,15 @@ sub checkin_handle_lost_or_lo_now_found_restore_od { # restore those overdue charges voided when item was set to lost # ------------------------------------------------------------------ - my $ods = $self->editor->search_money_billing( + my $ods = $self->editor->search_money_billing([ { xact => $self->circ->id, btype => 1 + }, + { + order_by => {mb => 'billing_ts desc'} } - ); + ]); $logger->debug("returning ".scalar(@$ods)." overdue charges pre-$tag"); # Because actual users get up to all kinds of unexpectedness, we @@ -4075,7 +4078,8 @@ sub checkin_handle_lost_or_lo_now_found_restore_od { $ods->[0]->btype(), $ods->[0]->billing_type(), $self->circ->id(), - "System: $tag RETURNED - OVERDUES REINSTATED" + "System: $tag RETURNED - OVERDUES REINSTATED", + $ods->[0]->billing_ts() # date this restoration the same as the last overdue (for possible subsequent fine generation) ); } } -- 2.11.0