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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 2139-2145 sub RevertWaitingStatus { Link Here
2139
            expirationdate => $hold->patron_expiration_date,
2139
            expirationdate => $hold->patron_expiration_date,
2140
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2140
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2141
        }
2141
        }
2142
    )->store();
2142
    )->store({ hold_reverted => 1 });
2143
2143
2144
    _FixPriority( { biblionumber => $hold->biblionumber } );
2144
    _FixPriority( { biblionumber => $hold->biblionumber } );
2145
2145
(-)a/Koha/Hold.pm (-5 / +9 lines)
Lines 846-852 expirationdate for holds. Link Here
846
=cut
846
=cut
847
847
848
sub store {
848
sub store {
849
    my ($self) = @_;
849
    my ($self, $params) = @_;
850
851
    my $hold_reverted = $params->{hold_reverted} // 0;
850
852
851
    Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
853
    Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
852
854
Lines 867-877 sub store { Link Here
867
869
868
        my %updated_columns = $self->_result->get_dirty_columns;
870
        my %updated_columns = $self->_result->get_dirty_columns;
869
        return $self->SUPER::store unless %updated_columns;
871
        return $self->SUPER::store unless %updated_columns;
870
872
        if ( exists $updated_columns{reservedate} || $hold_reverted ) {
871
        if ( exists $updated_columns{reservedate} ) {
872
            if (
873
            if (
873
                C4::Context->preference('DefaultHoldExpirationdate')
874
                ( C4::Context->preference('DefaultHoldExpirationdate')
874
                && ! exists $updated_columns{expirationdate}
875
                && ! exists $updated_columns{expirationdate} )
876
                || ( C4::Context->preference('DefaultHoldExpirationdate')
877
                && exists $updated_columns{expirationdate}
878
                && $hold_reverted )
875
              )
879
              )
876
            {
880
            {
877
                $self->_set_default_expirationdate;
881
                $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