}
}
+# ------------------------------------------------------------------
+# 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;