From 465e5562fc2f852282f7dcc4683dd0e87b0633eb Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 21 Apr 2020 13:52:40 -0400 Subject: [PATCH] Bug 25232: Add ability to skip trapping items with a given notforloan value This is a companion/alternative to bug 25184, in that it allows an explicit workflow for placing returned books into temporary storage for a few days for decontamination purposes. The idea here is to create a specific notforloan value for "In Decontamination" or something along along those lines. This notforloan value would never be trappable. At the end of decon, UpdateNotForLoanStatusOnCheckin could be used to remove the notforloan status and allow checkins to be trapped to fill holds. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Give an item a negative notforloan value 4) Place a hold on the item 5) Check the item in 6) Note the item is trapped for hold 7) Set SkipHoldTrapOnNotForLoanValue to the same notforloan value you used in step 3 8) Check the item in again 9) Note Koha did not ask you to trap the item for hold! Signed-off-by: Sally Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Reserves.pm | 3 +++ installer/data/mysql/atomicupdate/bug_25232.perl | 11 +++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 5 +++++ t/db_dependent/Holds.t | 4 +++- 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_25232.perl diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d328773b01..fb7aba2527 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -794,6 +794,9 @@ sub CheckReserves { # if item is not for loan it cannot be reserved either..... # except where items.notforloan < 0 : This indicates the item is holdable. + my $SkipHoldTrapOnNotForLoanValue = C4::Context->preference('SkipHoldTrapOnNotForLoanValue'); + return if $SkipHoldTrapOnNotForLoanValue && $notforloan_per_item eq $SkipHoldTrapOnNotForLoanValue; + my $dont_trap = C4::Context->preference('TrapHoldsOnOrder') ? ($notforloan_per_item > 0) : ($notforloan_per_item && 1 ); return if $dont_trap or $notforloan_per_itemtype; diff --git a/installer/data/mysql/atomicupdate/bug_25232.perl b/installer/data/mysql/atomicupdate/bug_25232.perl new file mode 100644 index 0000000000..2d3318591b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25232.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + # $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" ); + $dbh->do(q{ + INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer') + }); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 25184, "Items with a negative notforloan status should not be captured for holds"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 4ad73ef827..d67a02b367 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -587,6 +587,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'), ('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'), ('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'), +('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'), ('SlipCSS','',NULL,'Slips CSS url.','free'), ('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'), ('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 92137896dc..0fd5438592 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -526,6 +526,11 @@ Circulation: yes: Trap no: "Don't trap" - items that are not for loan but holdable ( notforloan < 0 ) to fill holds. + - + - Never trap items with a 'not for loan' value of + - pref: SkipHoldTrapOnNotForLoanValue + class: integer + - to fill holds. - - pref: HoldsAutoFill choices: diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 688b12f2dd..a82fa5312f 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 64; +use Test::More tests => 65; use MARC::Record; use C4::Biblio; @@ -363,6 +363,8 @@ $hold = Koha::Hold->new( ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for item that is not for loan but holdable ( notforloan < 0 )" ); t::lib::Mocks::mock_preference( 'TrapHoldsOnOrder', 1 ); ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold is trapped for item that is not for loan but holdable ( notforloan < 0 )" ); +t::lib::Mocks::mock_preference( 'SkipHoldTrapOnNotForLoanValue', '-1' ); +ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for item with notforloan value matching SkipHoldTrapOnNotForLoanValue" ); $hold->delete(); # Regression test for bug 9532 -- 2.39.5