From 61f049a2ae8896a7b54cf95de37e91b027d4a098 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 --- 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 bb2ff5f978..1a2b5da5a2 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2106,7 +2106,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} } } ); @@ -2155,6 +2155,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