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

(-)a/Koha/Hold.pm (-1 / +9 lines)
Lines 127-132 sub set_waiting { Link Here
127
        waitingdate => $today->ymd,
127
        waitingdate => $today->ymd,
128
    };
128
    };
129
129
130
    my $requested_expiration;
131
    if ($self->expirationdate) {
132
        $requested_expiration = dt_from_string($self->expirationdate);
133
    }
134
130
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
135
    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
131
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
136
        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
132
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
137
        my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
Lines 139-145 sub set_waiting { Link Here
139
            $expirationdate = $calendar->days_forward( dt_from_string($self->waitingdate), $max_pickup_delay );
144
            $expirationdate = $calendar->days_forward( dt_from_string($self->waitingdate), $max_pickup_delay );
140
        }
145
        }
141
146
142
        $values->{expirationdate} = $expirationdate->ymd;
147
        # If patron's requested expiration date is prior to the
148
        # calculated one, we keep the patron's one.
149
        my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
150
        $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
143
    }
151
    }
144
152
145
    $self->set($values)->store();
153
    $self->set($values)->store();
(-)a/t/db_dependent/Holds/WaitingReserves.t (-3 / +36 lines)
Lines 8-14 use Koha::DateUtils; Link Here
8
use t::lib::Mocks;
8
use t::lib::Mocks;
9
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
10
10
11
use Test::More tests => 10;
11
use Test::More tests => 11;
12
12
13
use_ok('C4::Reserves');
13
use_ok('C4::Reserves');
14
14
Lines 77-82 my $biblio3 = $builder->build({ Link Here
77
        title => 'Title 3',    },
77
        title => 'Title 3',    },
78
});
78
});
79
79
80
my $biblio4 = $builder->build({
81
    source => 'Biblio',
82
    value  => {
83
        title => 'Title 4',    },
84
});
85
80
my $item1 = $builder->build({
86
my $item1 = $builder->build({
81
    source => 'Item',
87
    source => 'Item',
82
    value  => {
88
    value  => {
Lines 98-103 my $item3 = $builder->build({ Link Here
98
    },
104
    },
99
});
105
});
100
106
107
my $item4 = $builder->build({
108
    source => 'Item',
109
    value  => {
110
        biblionumber => $biblio4->{biblionumber},
111
    },
112
});
113
101
my $today = dt_from_string();
114
my $today = dt_from_string();
102
115
103
my $reserve1_reservedate = $today->clone;
116
my $reserve1_reservedate = $today->clone;
Lines 167-173 my $reserve3 = $builder->build({ Link Here
167
my $special_holiday1_dt = $today->clone;
180
my $special_holiday1_dt = $today->clone;
168
$special_holiday1_dt->add(days => 2);
181
$special_holiday1_dt->add(days => 2);
169
182
170
Koha::Cache->get_instance()->flush_all();
171
my $holiday = $builder->build({
183
my $holiday = $builder->build({
172
    source => 'SpecialHoliday',
184
    source => 'SpecialHoliday',
173
    value => {
185
    value => {
Lines 205-208 $expected_expiration->add(days => 8); Link Here
205
my $r3 = Koha::Holds->find($reserve3->{reserve_id});
217
my $r3 = Koha::Holds->find($reserve3->{reserve_id});
206
is($r3->expirationdate, $expected_expiration->ymd, 'Expiration date should be set to today + 7' );
218
is($r3->expirationdate, $expected_expiration->ymd, 'Expiration date should be set to today + 7' );
207
219
220
my $reserve4_reservedate = $today->clone;
221
my $requested_expiredate = $today->clone()->add(days => 6);
222
223
my $reserve4 = $builder->build({
224
    source => 'Reserve',
225
    value => {
226
        borrowernumber => $patron2->{borrowernumber},
227
        reservedate => $reserve4_reservedate->ymd,
228
        expirationdate => $requested_expiredate->ymd,
229
        biblionumber => $biblio4->{biblionumber},
230
        branchcode => 'LIB1',
231
        priority => 1,
232
        found => '',
233
    },
234
});
235
236
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 10);
237
ModReserveAffect( $item4->{itemnumber}, $patron2->{borrowernumber}, 0, $reserve4->{reserve_id});
238
239
my $r4 = Koha::Holds->find($reserve4->{reserve_id});
240
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' );
241
208
$dbh->rollback;
242
$dbh->rollback;
209
- 

Return to bug 12063