From 4357ab325959f2ed48b2001812b1039b6714dd9a Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Fri, 14 Aug 2015 15:11:16 -0400 Subject: [PATCH] LP#1484989 Don't close xacts with checkin-generated fines If a transaction has checkin-generated fines, and previously had a balance of zero, the rearranged billing code was prematurely closing the transaction. This commit separates the closing step to run after any possible fine generation. Signed-off-by: Dan Wells Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Circ/Circulate.pm | 18 +++++++--- .../10-lp1484989_dont_close_fined_xacts.t | 36 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t 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 f92f5b890d..d63cdc8f56 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2367,9 +2367,8 @@ sub do_checkin { } if( $self->circ ) { - $self->checkin_handle_circ; + $self->checkin_handle_circ_start; return if $self->bail_out; - $self->checkin_changed(1); if (!$dont_change_lost_zero) { # if this circ is LOST and we are configured to generate overdue @@ -2392,6 +2391,11 @@ sub do_checkin { # handle fines for this circ, including overdue gen if needed $self->handle_fines; } + + $self->checkin_handle_circ_finish; + return if $self->bail_out; + $self->checkin_changed(1); + } elsif( $self->transit ) { my $hold_transit = $self->process_received_transit; $self->checkin_changed(1); @@ -3224,7 +3228,7 @@ sub handle_fines { return undef; } -sub checkin_handle_circ { +sub checkin_handle_circ_start { my $self = shift; my $circ = $self->circ; my $copy = $self->copy; @@ -3272,9 +3276,15 @@ sub checkin_handle_circ { $self->update_copy; } + return undef; +} + +sub checkin_handle_circ_finish { + my $self = shift; + my $circ = $self->circ; # see if there are any fines owed on this circ. if not, close it - ($obt) = $U->fetch_mbts($circ->id, $self->editor); + my ($obt) = $U->fetch_mbts($circ->id, $self->editor); $circ->xact_finish('now') if( $obt and $obt->balance_owed == 0 ); $logger->debug("circulator: ".$obt->balance_owed." is owed on this circulation"); diff --git a/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t b/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t new file mode 100644 index 0000000000..0a4aa56212 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/10-lp1484989_dont_close_fined_xacts.t @@ -0,0 +1,36 @@ +#!perl + +use Test::More tests => 2; + +diag("Make sure we don't close xacts with fines"); + +use strict; +use warnings; + +use OpenILS::Utils::TestUtils; +my $script = OpenILS::Utils::TestUtils->new(); +#our $apputils = "OpenILS::Application::AppUtils"; +my $storage_ses = $script->session('open-ils.storage'); +$script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff'}); +ok( $script->authtoken, 'Have an authtoken'); + +my $barcode = 'CONC4000054'; +my $circ_id = 18; + +my $checkin_resp = $script->do_checkin_override({ + barcode => $barcode}); + +my $circ_req = $storage_ses->request('open-ils.storage.direct.action.circulation.retrieve', $circ_id); +if (my $circ_resp = $circ_req->recv) { + if (my $circ = $circ_resp->content) { + ok( + !$circ->xact_finish, + 'Circ with id = ' . $circ_id . ' is overdue with fines, so xact_finish isn\'t set' + ); + } +} + +$script->logout(); -- 2.43.2