From d7c44144f3ec0f153b31bae77752b8b486dd18be Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Mon, 14 Nov 2022 08:37:47 +0200 Subject: [PATCH] Bug 29074: Do not set default expiration date for hold if DefaultHoldExpirationdatePeriod is left blank If DefaultHoldExpirationdate is on and DefaultHoldExpirationdatePeriod is blank, the blank is treated as a zero and all holds are created with an expiration date of today. This patch changes expiration dates storing so that if DefaultHoldExpirationdatePeriod is left blank, expiration date is not set. Users are informed about this with a note in syspref. To test: 1. Set DefaultHoldExpirationdate on but leave DefaultHoldExpirationdatePeriod blank. 2. Add hold for patron. => Note that expiration date is set as today. 3. Apply this patch => Confirm following note is now added after sysprefs: "NOTE: If DefaultHoldExpirationdatePeriod is left blank default expiration date is not set." 4. Add new hold for patron. => Note that expiration date is not set. Also prove t/db_dependent/Hold.t. Sponsored-by: Koha-Suomi Oy Signed-off-by: stina --- Koha/Hold.pm | 2 ++ .../admin/preferences/circulation.pref | 1 + t/db_dependent/Hold.t | 20 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index a5a9d03003..ff581cd044 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -863,6 +863,7 @@ sub store { if ( C4::Context->preference('DefaultHoldExpirationdate') + && C4::Context->preference('DefaultHoldExpirationdatePeriod') ne '' && !$self->expirationdate ) { @@ -877,6 +878,7 @@ sub store { if ( exists $updated_columns{reservedate} ) { if ( C4::Context->preference('DefaultHoldExpirationdate') + && C4::Context->preference('DefaultHoldExpirationdatePeriod') ne '' && ! exists $updated_columns{expirationdate} ) { 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 cafd44be51..e3f7f8f4f0 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 @@ -979,6 +979,7 @@ Circulation: months: months years: years - from reserve date. + -
NOTE: If DefaultHoldExpirationdatePeriod is left blank default expiration date is not set.
- - When placing a hold via the staff interface default the pickup location to the - pref: DefaultHoldPickupLocation diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 73007c18a0..bfa1207ac5 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -146,7 +146,7 @@ $schema->storage->txn_rollback(); subtest "store() tests" => sub { - plan tests => 5; + plan tests => 6; $schema->storage->txn_begin(); @@ -222,6 +222,24 @@ subtest "store() tests" => sub { is( $hold->expirationdate, $passed_date->ymd, 'Passed expiration date when updating hold correctly set (Passing both reservedate and expirationdate.' ); + # Do not set expiration date for hold if no period is set + t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdatePeriod', '' ); + $hold = Koha::Hold->new( + { + biblionumber => $biblio->biblionumber, + itemnumber => $item->id, + reservedate => '2022-12-14', + waitingdate => '2022-12-14', + borrowernumber => $borrower->borrowernumber, + branchcode => $library->branchcode, + suspend => 0, + } + )->store; + $hold->discard_changes; + + is( $hold->expirationdate, + undef, 'Expiration date not set if "DefaultHoldExpirationdatePeriod" is left empty.' ); + $schema->storage->txn_rollback(); }; -- 2.30.2