From 7d5a9e2caf8eadc23506dfd8ead656d786e7c471 Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Mon, 20 Apr 2020 11:22:11 +0200 Subject: [PATCH] Bug 22005 - DecreaseLoanHighHolds counts holds wrong There is a small error in how holds are compared to thresholds in the code related to DecreaseLoanHighHolds. This should fix the problem. To test: - Apply the first patch from this bug, which fleshes out the tests a bit. Run the tests with something like this: $ sudo koha-shell -c "prove -v t/db_dependent/DecreaseLoanHighHolds.t" kohadev The tests should fail - Read through the tests and comments and make sure you agree they make sense - Apply this second patch - Run prove on the tests again - Check that all tests pass --- C4/Circulation.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index faaa2692e8..ca9529be54 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1205,8 +1205,12 @@ sub checkHighHolds { # static means just more than a given number of holds on the record - # If the number of holds is less than the threshold, we can stop here - if ( $holds->count() < $decreaseLoanHighHoldsValue ) { + # If the number of holds is less than or equal to the threshold, we can stop here + # The sysprefs say: "[Enable] the reduction of loan period to [x] days for high + # demand items with *more than* [y] holds [on the record]." + # This must mean that if the number of holds and the value of + # decreaseLoanHighHoldsValue are equal, checkHighHolds should NOT be triggered + if ( $holds->count() <= $decreaseLoanHighHoldsValue ) { return $return_data; } } @@ -1229,7 +1233,7 @@ sub checkHighHolds { my $threshold = $items_count + $decreaseLoanHighHoldsValue; - # If the number of holds is less than the count of items we have + # If the number of holds is less than or equal to the count of items we have # plus the number of holds allowed above that count, we can stop here if ( $holds->count() <= $threshold ) { return $return_data; -- 2.11.0