From 606028935f730200f8ac26fa27ed092bf79f09c8 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Fri, 5 Dec 2014 13:57:12 -0500 Subject: [PATCH] LP#1198465 Stop using storage wrapper for generate_fines() With pieces now in place, let's stop using the storage wrapper for generate_fines() and call the code directly. Also, to avoid potential confusion, rename the calling function in Circulate.pm from generate_fines() to handle_fines(). This function may also be taking on more than just fine generation in the near future. Finally, since the new generate_fines() expects one or more pre-filtered circ objects, add the requisite stop_fines check to handle_fines(). Signed-off-by: Dan Wells --- .../lib/OpenILS/Application/Circ/Circulate.pm | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) 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 bc939d2668..d9d89b94ab 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2107,7 +2107,7 @@ sub do_reservation_return { $self->reservation($reservation); } - $self->generate_fines(1); + $self->handle_fines(1); $self->reservation->return_time('now'); $self->update_reservation(); $self->reshelve_copy if $self->copy; @@ -2526,7 +2526,7 @@ sub do_checkin { } # run the fine generator against this circ - $self->generate_fines(undef, $ignore_stop_fines); + $self->handle_fines(undef, $ignore_stop_fines); } if( $self->checkin_check_holds_shelf() ) { @@ -3336,7 +3336,7 @@ sub put_hold_on_shelf { -sub generate_fines { +sub handle_fines { my $self = shift; my $reservation = shift; my $ignore_stop_fines = shift; @@ -3344,6 +3344,8 @@ sub generate_fines { my $obj = $reservation ? $self->reservation : $self->circ; + return undef if (!$ignore_stop_fines and $obj->stop_fines); + # If we have a grace period if($obj->can('grace_period')) { # Parse out the due date @@ -3354,15 +3356,7 @@ sub generate_fines { return undef if ($due_date > DateTime->now); } - if (!exists($self->{_gen_fines_req})) { - $self->{_gen_fines_req} = OpenSRF::AppSession->create('open-ils.storage') - ->request( - 'open-ils.storage.action.circulation.overdue.generate_fines', - $obj->id, $ignore_stop_fines - ); - } - $self->{_gen_fines_req}->wait_complete; - delete($self->{_gen_fines_req}); + $CC->generate_fines({circs => [$obj], editor => $self->editor}); # refresh the circ in case the fine generator set the stop_fines field $self->reservation($self->editor->retrieve_booking_reservation($id)) if $reservation; @@ -3803,7 +3797,7 @@ sub do_renew { } # Run the fine generator against the old circ - $self->generate_fines; + $self->do_generate_fines; $self->run_renew_permit; -- 2.11.0