From e23c60426f2c91357c151bb066aaa8a7f15ce515 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Feb 2019 17:49:21 -0300 Subject: [PATCH] Bug 18936: new suspension_chargeperiod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Minna Kivinen Signed-off-by: Joonas Kylmälä --- C4/Circulation.pm | 1 + Koha/CirculationRules.pm | 3 +++ t/db_dependent/Circulation.t | 41 ++++++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0027f81a9e..813c064fd6 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2269,6 +2269,7 @@ sub _calculate_new_debar_dt { 'lengthunit', 'firstremind', 'maxsuspensiondays', + 'suspension_chargeperiod', ] } ); diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 2f6da8816d..9d38f19a16 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -148,6 +148,9 @@ our $RULE_KINDS = { reservesallowed => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, + suspension_chargeperiod => { + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + }, # Not included (deprecated?): # * accountsent # * reservecharge diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index e4550cedc5..7df409c2ce 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2065,7 +2065,16 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { # We want to charge 2 days every 2 days, without grace # With 5 days of overdue: (5 * 2) / 2 - $rule->suspension_chargeperiod(2)->store; + Koha::CirculationRules->set_rule( + { + categorycode => undef, + branchcode => undef, + itemtype => undef, + rule_name => 'suspension_chargeperiod', + rule_value => '2', + } + ); + $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 ); test_debarment_on_checkout( { @@ -2079,8 +2088,17 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { # We want to charge 2 days every 3 days, with 1 day of grace # With 5 days of overdue: ((5-1) / 3 ) * 2 - $rule->suspension_chargeperiod(3)->store; - $rule->firstremind(1)->store; + Koha::CirculationRules->set_rules( + { + categorycode => undef, + branchcode => undef, + itemtype => undef, + rules => { + suspension_chargeperiod => 3, + firstremind => 1, + } + } + ); $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); test_debarment_on_checkout( { @@ -2094,9 +2112,18 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { # Use finesCalendar to know if holiday must be skipped to calculate the due date # We want to charge 2 days every days, with 0 day of grace (to not burn brains) - $rule->finedays(2)->store; - $rule->suspension_chargeperiod(1)->store; - $rule->firstremind(0)->store; + Koha::CirculationRules->set_rules( + { + categorycode => undef, + branchcode => undef, + itemtype => undef, + rules => { + finedays => 2, + suspension_chargeperiod => 1, + firstremind => 0, + } + } + ); t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed'); t::lib::Mocks::mock_preference('SuspensionsCalendar', 'noSuspensionsWhenClosed'); @@ -2241,7 +2268,7 @@ subtest 'AddReturn | is_overdue' => sub { )->unblessed; Koha::CirculationRules->search->delete; - my $rule = Koha::CirculationRules->set_rules( + Koha::CirculationRules->set_rules( { categorycode => undef, itemtype => undef, -- 2.11.0