From 3353b7212ae1b711dde511be6808faf691920b93 Mon Sep 17 00:00:00 2001 From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Mon, 14 Dec 2009 22:11:06 +0000 Subject: [PATCH] generate fines at reservation checkin; do not stomp the circ list with reservations when gathering overdue circs git-svn-id: svn://svn.open-ils.org/ILS/trunk@15164 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Circ/Circulate.pm | 24 ++++++++++++++-------- .../Application/Storage/Publisher/action.pm | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index aabce13dd0..af28cd92bc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -229,9 +229,15 @@ sub run_method { $circulator->do_checkout(); } elsif( $circulator->is_res_checkin ) { - $circulator->do_reservation_return(); - $circulator->do_checkin(); - + my ($reservation, $evt) = $U->fetch_booking_reservation($self->reservation); + if ($evt) { + $self->bail_on_events($evt); + } else { + $self->reservation( $reservation ); + $self->generate_fines(1) + $circulator->do_reservation_return(); + $circulator->do_checkin(); + } } elsif( $api =~ /checkin/ ) { $circulator->do_checkin(); @@ -1639,10 +1645,6 @@ sub do_reservation_pickup { $self->log_me("do_reservation_pickup()"); - my ($reservation, $evt) = $U->fetch_booking_reservation($self->reservation); - return $self->bail_on_events($evt) if $evt; - - $self->reservation( $reservation ); $self->reservation->pickup_time('now'); if ( @@ -2497,21 +2499,25 @@ sub put_hold_on_shelf { sub generate_fines { my $self = shift; + my $reservation = shift; my $evt; my $obt; + my $id = $reservation ? $self->reservation->id : $self->circ->id; + my $st = OpenSRF::AppSession->connect('open-ils.storage'); $st->request( 'open-ils.storage.action.circulation.overdue.generate_fines', undef, - $self->circ->id + $id )->wait_complete; $st->disconnect; # refresh the circ in case the fine generator set the stop_fines field - $self->circ($self->editor->retrieve_action_circulation($self->circ->id)); + $self->reservation($self->editor->retrieve_booking_reservation($id)) if $reservation; + $self->circ($self->editor->retrieve_action_circulation($id)) if !$reservation; return undef; } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index 71582f252f..f3bdf2602d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -126,10 +126,10 @@ sub overdue_circs { AND cancel_time IS NULL SQL - my $sth = action::circulation->db_Main->prepare_cached($sql); + $sth = action::circulation->db_Main->prepare_cached($sql); $sth->execute($upper_interval); - my @circs = map { booking::reservation->construct($_) } $sth->fetchall_hash; + @circs = map { booking::reservation->construct($_) } $sth->fetchall_hash; } -- 2.11.0