From 21eea6bef8433e368cec067e615fd2db84d9f3b7 Mon Sep 17 00:00:00 2001 From: Didier Gautheron Date: Tue, 18 Aug 2020 07:39:53 +0200 Subject: [PATCH] Bug 26232: Test for empty smart rule fine grace period Signed-off-by: Chris Cormack --- t/db_dependent/Circulation.t | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index a51349b186..51706fcf38 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2103,7 +2103,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { }; subtest 'AddReturn + suspension_chargeperiod' => sub { - plan tests => 24; + plan tests => 27; my $library = $builder->build( { source => 'Branch' } ); my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); @@ -2152,6 +2152,38 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { } ); + # Same with undef firstremind + Koha::CirculationRules->search->delete; + Koha::CirculationRules->set_rules( + { + categorycode => '*', + itemtype => '*', + branchcode => '*', + rules => { + issuelength => 1, + firstremind => undef, # 0 day of grace + finedays => 2, # 2 days of fine per day of overdue + suspension_chargeperiod => 1, + lengthunit => 'days', + } + } + ); + { + my $now = dt_from_string; + my $five_days_ago = $now->clone->subtract( days => 5 ); + # We want to charge 2 days every day, without grace + # With 5 days of overdue: 5 * Z + my $expected_expiration = $now->clone->add( days => ( 5 * 2 ) / 1 ); + test_debarment_on_checkout( + { + item => $item_1, + library => $library, + patron => $patron, + due_date => $five_days_ago, + expiration_date => $expected_expiration, + } + ); + } # We want to charge 2 days every 2 days, without grace # With 5 days of overdue: (5 * 2) / 2 Koha::CirculationRules->set_rule( -- 2.11.0