@@ -, +, @@
DefaultHoldExpirationdatePeriod is left blank
---
Koha/Hold.pm | 2 ++
.../admin/preferences/circulation.pref | 1 +
t/db_dependent/Hold.t | 22 ++++++++++++++++++-
3 files changed, 24 insertions(+), 1 deletion(-)
--- a/Koha/Hold.pm
+++ a/Koha/Hold.pm
@@ -911,6 +911,7 @@ sub store {
if (
C4::Context->preference('DefaultHoldExpirationdate')
+ && C4::Context->preference('DefaultHoldExpirationdatePeriod') ne ''
&& !$self->expirationdate
)
{
@@ -925,6 +926,7 @@ sub store {
if ( exists $updated_columns{reservedate} ) {
if (
C4::Context->preference('DefaultHoldExpirationdate')
+ && C4::Context->preference('DefaultHoldExpirationdatePeriod') ne ''
&& ! exists $updated_columns{expirationdate}
)
{
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -968,6 +968,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
--- a/t/db_dependent/Hold.t
+++ a/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,26 @@ 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();
};
--