From 1fe9180c41f1a5d225640c6c20f5933b0e0b6ab4 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 12 Apr 2024 07:11:00 -0400 Subject: [PATCH] Bug 34032: (QA follow-up) Tidy code Signed-off-by: Katrin Fischer --- C4/Reserves.pm | 10 +++++----- Koha/Hold.pm | 12 +++++++----- t/db_dependent/Hold.t | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index f972109e86..97374d9514 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -2161,13 +2161,13 @@ sub RevertWaitingStatus { ## Fix up the currently waiting reserve $hold->set( { - priority => 1, - found => undef, - waitingdate => undef, + priority => 1, + found => undef, + waitingdate => undef, expirationdate => $hold->patron_expiration_date, - itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef, + itemnumber => $hold->item_level_hold ? $hold->itemnumber : undef, } - )->store({ hold_reverted => 1 }); + )->store( { hold_reverted => 1 } ); logaction( 'HOLDS', 'MODIFY', $hold->id, $hold ) if C4::Context->preference('HoldsLog'); diff --git a/Koha/Hold.pm b/Koha/Hold.pm index ba737349c4..4017e56417 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -966,12 +966,14 @@ sub store { return $self->SUPER::store unless %updated_columns; if ( exists $updated_columns{reservedate} || $hold_reverted ) { if ( - ( C4::Context->preference('DefaultHoldExpirationdate') - && ( ! exists $updated_columns{expirationdate} || $hold_reverted ) ) - ) + ( + C4::Context->preference('DefaultHoldExpirationdate') + && ( !exists $updated_columns{expirationdate} || $hold_reverted ) + ) + ) { - if($self->patron_expiration_date){ - $self->expirationdate($self->patron_expiration_date); + if ( $self->patron_expiration_date ) { + $self->expirationdate( $self->patron_expiration_date ); } else { $self->_set_default_expirationdate; } diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index fa607a5c2e..15c61a31fa 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -225,21 +225,21 @@ subtest "store() tests" => sub { $passed_date = dt_from_string('2023-06-20'); $hold->set( { - reservedate => $passed_date->ymd, - waitingdate => $passed_date->ymd, + reservedate => $passed_date->ymd, + waitingdate => $passed_date->ymd, } )->store(); $hold->discard_changes; $hold->set_waiting; - C4::Reserves::RevertWaitingStatus( - { itemnumber => $item->itemnumber } - ); + 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.' ); + is( + $hold->expirationdate, + $expected_date, 'Expiration date set after reverting holds waiting status.' + ); my $patron_expiration_date = dt_from_string('2023-11-06')->ymd; $hold = Koha::Hold->new( @@ -258,13 +258,14 @@ subtest "store() tests" => sub { $hold->discard_changes; $hold->set_waiting; - C4::Reserves::RevertWaitingStatus( - { itemnumber => $item->itemnumber } - ); + C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); $hold->discard_changes; - is( $hold->expirationdate, - $patron_expiration_date, 'Expiration date set same as patron_expiration_date after reverting holds waiting status.' ); + is( + $hold->expirationdate, + $patron_expiration_date, + 'Expiration date set same as patron_expiration_date after reverting holds waiting status.' + ); $schema->storage->txn_rollback(); }; -- 2.39.5