From 203c125173b66ccfc0521e7dfd6c5aaf84f2507c Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Wed, 25 Apr 2018 15:57:12 -0400 Subject: [PATCH] Bug 20660: AddReturn uses return_date override for new debarments This patches is a minor tweak (single line) to C4::Circulation to use the return_date value as $today when calculating new debarments in AddReturn. I've also added a test in t/db_dependent/Circulation.t TEST PLAN 1) comment out line 1988 in Circulation.pm ("$today = $return_date if $return_date") 2) prove t/db_dependent/Circulation.t (Fail) 3) uncomment the line 4) prove t/db_dependent/Circulation.t (Pass) --- C4/Circulation.pm | 1 + t/db_dependent/Circulation.t | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 2deb367..0b0945d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1985,6 +1985,7 @@ sub AddReturn { if ( $issue and $issue->is_overdue ) { # fix fine days + $today = $return_date if $return_date; $today = $dropboxdate if $dropbox; my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today ); if ($reminder){ diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index d8de2e2..99d1ae0 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -1764,7 +1764,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { }; subtest 'AddReturn + suspension_chargeperiod' => sub { - plan tests => 12; + plan tests => 14; my $library = $builder->build( { source => 'Branch' } ); my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); @@ -1915,6 +1915,16 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { expiration_date => $expected_expiration_dt->clone->add( days => 1 ), } ); + + test_debarment_on_checkout( + { + item => $item_1, + library => $library, + patron => $patron, + return_date => dt_from_string->add(days => 5), + expiration_date => dt_from_string->add(days => 5 + (5 * 2 - 1) ), + } + ); }; subtest 'AddReturn | is_overdue' => sub { @@ -2261,6 +2271,7 @@ sub test_debarment_on_checkout { my $library = $params->{library}; my $patron = $params->{patron}; my $due_date = $params->{due_date} || dt_from_string; + my $return_date = $params->{return_date} || dt_from_string; my $expected_expiration_date = $params->{expiration_date}; $expected_expiration_date = output_pref( @@ -2275,7 +2286,7 @@ sub test_debarment_on_checkout { AddIssue( $patron, $item->{barcode}, $due_date ); AddReturn( $item->{barcode}, $library->{branchcode}, - undef, undef, dt_from_string ); + undef, undef, $return_date ); my $debarments = Koha::Patron::Debarments::GetDebarments( { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); -- 2.7.4