View | Details | Raw Unified | Return to bug 34032
Collapse All | Expand All

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 2167-2173 sub RevertWaitingStatus { Link Here
2167
            expirationdate => $hold->patron_expiration_date,
2167
            expirationdate => $hold->patron_expiration_date,
2168
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2168
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2169
        }
2169
        }
2170
    )->store();
2170
    )->store({ hold_reverted => 1 });
2171
2171
2172
    logaction( 'HOLDS', 'MODIFY', $hold->id, $hold )
2172
    logaction( 'HOLDS', 'MODIFY', $hold->id, $hold )
2173
        if C4::Context->preference('HoldsLog');
2173
        if C4::Context->preference('HoldsLog');
(-)a/Koha/Hold.pm (-5 / +9 lines)
Lines 929-935 expirationdate for holds. Link Here
929
=cut
929
=cut
930
930
931
sub store {
931
sub store {
932
    my ($self) = @_;
932
    my ($self, $params) = @_;
933
934
    my $hold_reverted = $params->{hold_reverted} // 0;
933
935
934
    Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
936
    Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
935
937
Lines 950-960 sub store { Link Here
950
952
951
        my %updated_columns = $self->_result->get_dirty_columns;
953
        my %updated_columns = $self->_result->get_dirty_columns;
952
        return $self->SUPER::store unless %updated_columns;
954
        return $self->SUPER::store unless %updated_columns;
953
955
        if ( exists $updated_columns{reservedate} || $hold_reverted ) {
954
        if ( exists $updated_columns{reservedate} ) {
955
            if (
956
            if (
956
                C4::Context->preference('DefaultHoldExpirationdate')
957
                ( C4::Context->preference('DefaultHoldExpirationdate')
957
                && ! exists $updated_columns{expirationdate}
958
                && ! exists $updated_columns{expirationdate} )
959
                || ( C4::Context->preference('DefaultHoldExpirationdate')
960
                && exists $updated_columns{expirationdate}
961
                && $hold_reverted )
958
              )
962
              )
959
            {
963
            {
960
                $self->_set_default_expirationdate;
964
                $self->_set_default_expirationdate;
(-)a/t/db_dependent/Hold.t (-2 / +20 lines)
Lines 146-152 $schema->storage->txn_rollback(); Link Here
146
146
147
subtest "store() tests" => sub {
147
subtest "store() tests" => sub {
148
148
149
    plan tests => 5;
149
    plan tests => 6;
150
150
151
    $schema->storage->txn_begin();
151
    $schema->storage->txn_begin();
152
152
Lines 222-227 subtest "store() tests" => sub { Link Here
222
    is( $hold->expirationdate,
222
    is( $hold->expirationdate,
223
        $passed_date->ymd, 'Passed expiration date when updating hold correctly set (Passing both reservedate and expirationdate.' );
223
        $passed_date->ymd, 'Passed expiration date when updating hold correctly set (Passing both reservedate and expirationdate.' );
224
224
225
    $passed_date = dt_from_string('2023-06-20');
226
    $hold->set(
227
        {
228
            reservedate    => $passed_date->ymd,
229
            waitingdate    => $passed_date->ymd,
230
        }
231
    )->store();
232
    $hold->discard_changes;
233
234
    $hold->set_waiting;
235
    C4::Reserves::RevertWaitingStatus(
236
        { itemnumber => $item->itemnumber }
237
    );
238
    $hold->discard_changes;
239
240
    $expected_date = dt_from_string( $hold->reservedate )->add( years => 2 )->ymd;
241
    is( $hold->expirationdate,
242
        $expected_date, 'Expiration date set after reverting holds waiting status.' );
243
225
    $schema->storage->txn_rollback();
244
    $schema->storage->txn_rollback();
226
};
245
};
227
246
228
- 

Return to bug 34032