Bugzilla – Attachment 152535 Details for
Bug 34032
Holds expirationdate left blank if waiting status is reverted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34032: Set new expirationdate if waiting status is reverted
Bug-34032-Set-new-expirationdate-if-waiting-status.patch (text/plain), 3.82 KB, created by
Sam Lau
on 2023-06-21 17:34:16 UTC
(
hide
)
Description:
Bug 34032: Set new expirationdate if waiting status is reverted
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2023-06-21 17:34:16 UTC
Size:
3.82 KB
patch
obsolete
>From 917d30692c5a1147279db2e6389edcf1435215df Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Wed, 21 Jun 2023 14:36:08 +0300 >Subject: [PATCH] Bug 34032: Set new expirationdate if waiting status is > reverted > >When one reverts holds waiting status holds expiration >date is not set even if DefaultHoldExpirationdate >syspref is enabled. This patch adds new param >hold_reverted to be used when RevertWaitingStatus is >used to determine if expiration date should be set again. > >To test: >1) Make sure you have DefaultHoldExpirationdate syspref enabled. >2) Find hold with status "Waiting". >3) Revert waiting status. >=> Note that hold has no expiration date set. >4) Apply this patch. >5) Repeat steps 2 and 3. >=> Expiration date should now be set based on reserve >date. > >Also prove t/db_dependent/Hold.t. > >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > C4/Reserves.pm | 2 +- > Koha/Hold.pm | 14 +++++++++----- > t/db_dependent/Hold.t | 21 ++++++++++++++++++++- > 3 files changed, 30 insertions(+), 7 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 51172200ab..7f004154e2 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -2139,7 +2139,7 @@ sub RevertWaitingStatus { > expirationdate => $hold->patron_expiration_date, > itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef, > } >- )->store(); >+ )->store({ hold_reverted => 1 }); > > _FixPriority( { biblionumber => $hold->biblionumber } ); > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index f275530d97..85735f691a 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -846,7 +846,9 @@ expirationdate for holds. > =cut > > sub store { >- my ($self) = @_; >+ my ($self, $params) = @_; >+ >+ my $hold_reverted = $params->{hold_reverted} // 0; > > Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode; > >@@ -867,11 +869,13 @@ sub store { > > my %updated_columns = $self->_result->get_dirty_columns; > return $self->SUPER::store unless %updated_columns; >- >- if ( exists $updated_columns{reservedate} ) { >+ if ( exists $updated_columns{reservedate} || $hold_reverted ) { > if ( >- C4::Context->preference('DefaultHoldExpirationdate') >- && ! exists $updated_columns{expirationdate} >+ ( C4::Context->preference('DefaultHoldExpirationdate') >+ && ! exists $updated_columns{expirationdate} ) >+ || ( C4::Context->preference('DefaultHoldExpirationdate') >+ && exists $updated_columns{expirationdate} >+ && $hold_reverted ) > ) > { > $self->_set_default_expirationdate; >diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t >index 73007c18a0..ce8488c844 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,25 @@ subtest "store() tests" => sub { > is( $hold->expirationdate, > $passed_date->ymd, 'Passed expiration date when updating hold correctly set (Passing both reservedate and expirationdate.' ); > >+ $passed_date = dt_from_string('2023-06-20'); >+ $hold->set( >+ { >+ reservedate => $passed_date->ymd, >+ waitingdate => $passed_date->ymd, >+ } >+ )->store(); >+ $hold->discard_changes; >+ >+ $hold->set_waiting; >+ C4::Reserves::RevertWaitingStatus( >+ { itemnumber => $item->itemnumber } >+ ); >+ $hold->discard_changes; >+ >+ $expected_date = dt_from_string( $hold->reservedate )->add( years => 2 )->ymd; >+ is( $hold->expirationdate, >+ $expected_date, 'Expiration date set after reverting holds waiting status.' ); >+ > $schema->storage->txn_rollback(); > }; > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34032
:
152516
|
152535
|
158516
|
159908
|
164823
|
164824
|
164825