From 0357b88421e71a5dd66c8bf985d1154cf9d621ed Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Oct 2014 17:05:46 -0400 Subject: [PATCH] KMAIN154 - KMIG45 - KCLSUPGRAD12 - Backdating Lost Item Cross-port: ec196ab Conflicts: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm --- .../lib/OpenILS/Application/Circ/Circulate.pm | 76 ++++++++++++++++++++++ 1 file changed, 76 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 73d69efda6..6b7ab5065a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -4292,4 +4292,80 @@ sub checkin_handle_lost_or_lo_now_found_restore_od { } } +# ------------------------------------------------------------------ +# Lost-then-found item checked in. This sub generates new overdue +# fines, beyond the point of any existing and possibly voided +# overdue fines, up to the point of final checkin time (or max fine +# amount). +# ------------------------------------------------------------------ +sub generate_lost_overdue_fines { + my $self = shift; + my $circ = $self->circ; + my $e = $self->editor; + my $isBackDated = 0; + + # Re-open the transaction so the fine generator can see it + if ($circ->checkin_time == $circ->checkin_scan_time) { + #Check in is not backdated + if($circ->xact_finish or $circ->stop_fines) { + $e->xact_begin; + $circ->clear_xact_finish; + $circ->clear_stop_fines; + $circ->clear_stop_fines_time; + $e->update_action_circulation($circ) or return $e->die_event; + $e->xact_commit; + } + } + else { + #Check in is backdated + $isBackDated = 1; + if($circ->xact_finish or $circ->stop_fines) { + $e->xact_begin; + $circ->clear_xact_finish; + $e->update_action_circulation($circ) or return $e->die_event; + $e->xact_commit; + } + } + + $e->xact_begin; # generate_fines expects an in-xact editor + $self->generate_fines; + $circ = $self->circ; # generate fines re-fetches the circ + + my $update = 0; + + # Re-close the transaction if no money is owed + my ($obt) = $U->fetch_mbts($circ->id, $e); + if ($obt and $obt->balance_owed == 0) { + $circ->xact_finish('now'); + $update = 1; + } + + if ($isBackDated == 1) { + #Check in is backdated + if($circ->xact_finish or $circ->stop_fines) { + $circ->clear_stop_fines; + $circ->clear_stop_fines_time; + } + } + + # Set stop fines if the fine generator didn't have to + unless($circ->stop_fines) { + $circ->stop_fines(OILS_STOP_FINES_CHECKIN); + $circ->stop_fines_time('now'); + $update = 1; + } + + # update the event data sent to the caller within the transaction + $self->checkin_flesh_events; + + if ($update) { + $e->update_action_circulation($circ) or return $e->die_event; + $e->commit; + } else { + $e->rollback; + } + + return undef; +} + 1; -- 2.11.0