Lines 201-209
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
201 |
my $item_1 = $builder->build_sample_item; |
201 |
my $item_1 = $builder->build_sample_item; |
202 |
my $item_2 = $builder->build_sample_item; |
202 |
my $item_2 = $builder->build_sample_item; |
203 |
my $item_3 = $builder->build_sample_item; |
203 |
my $item_3 = $builder->build_sample_item; |
204 |
my $five_days_ago = dt_from_string->subtract( days => 5 ); |
204 |
my $nine_days_ago = dt_from_string->subtract( days => 9 ); #->set_hour(23)->set_minute(59); |
205 |
my $checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
205 |
my $checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
206 |
my $checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
206 |
my $checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
207 |
my $checkout_3 = AddIssue( $patron->unblessed, $item_3->barcode ); # not overdue |
207 |
my $checkout_3 = AddIssue( $patron->unblessed, $item_3->barcode ); # not overdue |
208 |
|
208 |
|
209 |
Koha::Patron::Debarments::AddUniqueDebarment( |
209 |
Koha::Patron::Debarments::AddUniqueDebarment( |
Lines 226-235
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
226 |
|
226 |
|
227 |
t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment'); |
227 |
t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 'when_no_overdue_causing_debarment'); |
228 |
|
228 |
|
229 |
my $eleven_days_ago = dt_from_string->subtract( days => 11 ); |
229 |
my $ten_days_ago = dt_from_string->subtract( days => 10 ); |
|
|
230 |
|
231 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $ten_days_ago ); # overdue and would trigger debarment |
232 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $nine_days_ago ); # overdue, but would not trigger debarment |
230 |
|
233 |
|
231 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $eleven_days_ago ); # overdue and would trigger debarment |
234 |
print STDERR "DUEDATE: " . $nine_days_ago->stringify . "\n"; |
232 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $five_days_ago ); # overdue, but would not trigger debarment |
|
|
233 |
|
235 |
|
234 |
Koha::Patron::Debarments::AddUniqueDebarment( |
236 |
Koha::Patron::Debarments::AddUniqueDebarment( |
235 |
{ |
237 |
{ |
Lines 244-250
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
244 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
246 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
245 |
is( scalar @$debarments, 0, 'OVERDUES debarment is removed if remaning items would not result in patron debarment' ); |
247 |
is( scalar @$debarments, 0, 'OVERDUES debarment is removed if remaning items would not result in patron debarment' ); |
246 |
|
248 |
|
247 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $eleven_days_ago ); # overdue and would trigger debarment |
249 |
$checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $ten_days_ago ); # overdue and would trigger debarment |
248 |
|
250 |
|
249 |
Koha::Patron::Debarments::AddUniqueDebarment( |
251 |
Koha::Patron::Debarments::AddUniqueDebarment( |
250 |
{ |
252 |
{ |
Lines 259-270
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
259 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
261 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber }); |
260 |
is( $debarments->[0]->{type}, 'OVERDUES', 'OVERDUES debarment is not removed if patron still has overdues that would trigger debarment' ); |
262 |
is( $debarments->[0]->{type}, 'OVERDUES', 'OVERDUES debarment is not removed if patron still has overdues that would trigger debarment' ); |
261 |
|
263 |
|
262 |
my $thirteen_days_ago = dt_from_string->subtract( days => 13 ); |
264 |
my $eleven_days_ago = dt_from_string->subtract( days => 11 ); |
263 |
|
265 |
|
264 |
# overdue and would trigger debarment |
266 |
# overdue and would trigger debarment |
265 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $thirteen_days_ago ); |
267 |
$checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $eleven_days_ago ); |
266 |
|
268 |
|
267 |
# $chechout_1 should now not trigger debarment with this new rule for specific branchcode |
269 |
# $checkout_1 should now not trigger debarment with this new rule for specific branchcode |
268 |
$dbh->do(qq{ |
270 |
$dbh->do(qq{ |
269 |
INSERT INTO `overduerules` ( |
271 |
INSERT INTO `overduerules` ( |
270 |
`branchcode`, |
272 |
`branchcode`, |
Lines 276-282
subtest 'AutoRemoveOverduesRestrictions' => sub {
Link Here
|
276 |
`letter2`, |
278 |
`letter2`, |
277 |
`debarred2` |
279 |
`debarred2` |
278 |
) |
280 |
) |
279 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 12, 'ODUE2', 1) |
281 |
VALUES ('$branchcode', '$categorycode', 6, 'ODUE', 0, 11, 'ODUE2', 1) |
280 |
}); |
282 |
}); |
281 |
|
283 |
|
282 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
284 |
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber ); |
283 |
- |
|
|