Lines 96-108
sub test_debarment_on_checkout {
Link Here
|
96 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
96 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
97 |
or diag('AddReturn returned message ' . Dumper $message ); |
97 |
or diag('AddReturn returned message ' . Dumper $message ); |
98 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
98 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
99 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
99 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
100 |
is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); |
100 |
is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); |
101 |
|
101 |
|
102 |
is( $debarments->[0]->{expiration}, |
102 |
is( $debarments->[0]->{expiration}, |
103 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
103 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
104 |
Koha::Patron::Debarments::DelUniqueDebarment( |
104 |
Koha::Patron::Debarments::DelUniqueDebarment( |
105 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
105 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
106 |
}; |
106 |
}; |
107 |
|
107 |
|
108 |
my $schema = Koha::Database->schema; |
108 |
my $schema = Koha::Database->schema; |
Lines 164-177
my $patron_category = $builder->build(
Link Here
|
164 |
my $CircControl = C4::Context->preference('CircControl'); |
164 |
my $CircControl = C4::Context->preference('CircControl'); |
165 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
165 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
166 |
|
166 |
|
167 |
my $item = { |
167 |
my $item = $builder->build_object({ |
168 |
homebranch => $library2->{branchcode}, |
168 |
class => 'Koha::Items', |
169 |
holdingbranch => $library2->{branchcode} |
169 |
value => { |
170 |
}; |
170 |
homebranch => $library2->{branchcode}, |
|
|
171 |
holdingbranch => $library2->{branchcode} |
172 |
} |
173 |
}); |
171 |
|
174 |
|
172 |
my $borrower = { |
175 |
my $borrower = $builder->build_object({ |
173 |
branchcode => $library2->{branchcode} |
176 |
class => 'Koha::Patrons', |
174 |
}; |
177 |
value => { branchcode => $library2->{branchcode} } |
|
|
178 |
}); |
175 |
|
179 |
|
176 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
180 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
177 |
|
181 |
|
Lines 185-191
is(
Link Here
|
185 |
); |
189 |
); |
186 |
is( |
190 |
is( |
187 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
191 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
188 |
$item->{$HomeOrHoldingBranch}, |
192 |
$item->get_column($HomeOrHoldingBranch), |
189 |
'_GetCircControlBranch returned item branch (no userenv defined)' |
193 |
'_GetCircControlBranch returned item branch (no userenv defined)' |
190 |
); |
194 |
); |
191 |
|
195 |
|
Lines 198-204
is(
Link Here
|
198 |
); |
202 |
); |
199 |
is( |
203 |
is( |
200 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
204 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
201 |
$borrower->{branchcode}, |
205 |
$borrower->branchcode, |
202 |
'_GetCircControlBranch returned borrower branch' |
206 |
'_GetCircControlBranch returned borrower branch' |
203 |
); |
207 |
); |
204 |
|
208 |
|
Lines 210-216
is(
Link Here
|
210 |
'CircControl changed to ItemHomeLibrary' |
214 |
'CircControl changed to ItemHomeLibrary' |
211 |
); |
215 |
); |
212 |
is( |
216 |
is( |
213 |
$item->{$HomeOrHoldingBranch}, |
217 |
$item->get_column($HomeOrHoldingBranch), |
214 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
218 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
215 |
'_GetCircControlBranch returned item branch' |
219 |
'_GetCircControlBranch returned item branch' |
216 |
); |
220 |
); |
Lines 241-247
is(
Link Here
|
241 |
); |
245 |
); |
242 |
is( |
246 |
is( |
243 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
247 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
244 |
$borrower->{branchcode}, |
248 |
$borrower->branchcode, |
245 |
'_GetCircControlBranch returned borrower branch' |
249 |
'_GetCircControlBranch returned borrower branch' |
246 |
); |
250 |
); |
247 |
|
251 |
|
Lines 254-260
is(
Link Here
|
254 |
); |
258 |
); |
255 |
is( |
259 |
is( |
256 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
260 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
257 |
$item->{$HomeOrHoldingBranch}, |
261 |
$item->get_column($HomeOrHoldingBranch), |
258 |
'_GetCircControlBranch returned item branch' |
262 |
'_GetCircControlBranch returned item branch' |
259 |
); |
263 |
); |
260 |
|
264 |
|
Lines 329-335
subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
Link Here
|
329 |
homebranch => $patron_hold_1->branchcode |
333 |
homebranch => $patron_hold_1->branchcode |
330 |
}); |
334 |
}); |
331 |
|
335 |
|
332 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode); |
336 |
my $issue = AddIssue( $patron, $item_1->barcode); |
333 |
my $datedue = dt_from_string( $issue->date_due() ); |
337 |
my $datedue = dt_from_string( $issue->date_due() ); |
334 |
is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); |
338 |
is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); |
335 |
|
339 |
|
Lines 512-522
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
512 |
my $checkitem = undef; |
516 |
my $checkitem = undef; |
513 |
my $found = undef; |
517 |
my $found = undef; |
514 |
|
518 |
|
515 |
my $issue_1 = AddIssue( $renewing_borrower_obj->unblessed, $item_1->barcode); |
519 |
my $issue_1 = AddIssue( $renewing_borrower_obj, $item_1->barcode); |
516 |
my $datedue = dt_from_string( $issue_1->date_due() ); |
520 |
my $datedue = dt_from_string( $issue_1->date_due() ); |
517 |
is (defined $issue_1->date_due(), 1, "Item 1 checked out, due date: " . $issue_1->date_due() ); |
521 |
is (defined $issue_1->date_due(), 1, "Item 1 checked out, due date: " . $issue_1->date_due() ); |
518 |
|
522 |
|
519 |
my $issue_2 = AddIssue( $renewing_borrower_obj->unblessed, $item_2->barcode); |
523 |
my $issue_2 = AddIssue( $renewing_borrower_obj, $item_2->barcode); |
520 |
is (defined $issue_2, 1, "Item 2 checked out, due date: " . $issue_2->date_due()); |
524 |
is (defined $issue_2, 1, "Item 2 checked out, due date: " . $issue_2->date_due()); |
521 |
|
525 |
|
522 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
526 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
Lines 627-633
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
627 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
631 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
628 |
|
632 |
|
629 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
633 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
630 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
634 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber ); |
631 |
AddIssue($reserving_borrower, $item_3->barcode); |
635 |
AddIssue($reserving_borrower, $item_3->barcode); |
632 |
my $reserve = $dbh->selectrow_hashref( |
636 |
my $reserve = $dbh->selectrow_hashref( |
633 |
'SELECT * FROM old_reserves WHERE reserve_id = ?', |
637 |
'SELECT * FROM old_reserves WHERE reserve_id = ?', |
Lines 675-681
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
675 |
itype => $itemtype, |
679 |
itype => $itemtype, |
676 |
} |
680 |
} |
677 |
); |
681 |
); |
678 |
my $issue_5 = AddIssue($restricted_borrower_obj->unblessed, $item_5->barcode); |
682 |
my $issue_5 = AddIssue($restricted_borrower_obj, $item_5->barcode); |
679 |
is (defined $issue_5, 1, "Item with date due checked out, due date: ". $issue_5->date_due); |
683 |
is (defined $issue_5, 1, "Item with date due checked out, due date: ". $issue_5->date_due); |
680 |
|
684 |
|
681 |
t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); |
685 |
t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); |
Lines 704-710
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
704 |
} |
708 |
} |
705 |
); |
709 |
); |
706 |
|
710 |
|
707 |
my $issue_6 = AddIssue( $renewing_borrower_obj->unblessed, $item_6->barcode); |
711 |
my $issue_6 = AddIssue( $renewing_borrower_obj, $item_6->barcode); |
708 |
is (defined $issue_6, 1, "Item 2 checked out, due date: ".$issue_6->date_due); |
712 |
is (defined $issue_6, 1, "Item 2 checked out, due date: ".$issue_6->date_due); |
709 |
|
713 |
|
710 |
my $now = dt_from_string(); |
714 |
my $now = dt_from_string(); |
Lines 712-718
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
712 |
my $five_weeks_ago = $now - $five_weeks; |
716 |
my $five_weeks_ago = $now - $five_weeks; |
713 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
717 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
714 |
|
718 |
|
715 |
my $issue_7 = AddIssue($renewing_borrower_obj->unblessed, $item_7->barcode, $five_weeks_ago); |
719 |
my $issue_7 = AddIssue($renewing_borrower_obj, $item_7->barcode, $five_weeks_ago); |
716 |
is (defined $issue_7, 1, "Item with passed date due checked out, due date: " . $issue_7->date_due); |
720 |
is (defined $issue_7, 1, "Item with passed date due checked out, due date: " . $issue_7->date_due); |
717 |
|
721 |
|
718 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); |
722 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); |
Lines 793-799
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
793 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
797 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
794 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
798 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
795 |
AddIssue( |
799 |
AddIssue( |
796 |
$renewing_borrower_obj->unblessed, |
800 |
$renewing_borrower_obj, |
797 |
$item_7->barcode, |
801 |
$item_7->barcode, |
798 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
802 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
799 |
0, |
803 |
0, |
Lines 821-827
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
821 |
} |
825 |
} |
822 |
); |
826 |
); |
823 |
|
827 |
|
824 |
my $issue_4 = AddIssue( $renewing_borrower_obj->unblessed, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
828 |
my $issue_4 = AddIssue( $renewing_borrower_obj, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
825 |
my $info; |
829 |
my $info; |
826 |
( $renewokay, $error, $info ) = |
830 |
( $renewokay, $error, $info ) = |
827 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
831 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
Lines 951-957
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
951 |
|
955 |
|
952 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
956 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
953 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
957 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
954 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
958 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
955 |
|
959 |
|
956 |
Koha::CirculationRules->set_rules( |
960 |
Koha::CirculationRules->set_rules( |
957 |
{ |
961 |
{ |
Lines 1080-1086
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1080 |
|
1084 |
|
1081 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1085 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1082 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1086 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1083 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1087 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1084 |
|
1088 |
|
1085 |
Koha::CirculationRules->set_rules( |
1089 |
Koha::CirculationRules->set_rules( |
1086 |
{ |
1090 |
{ |
Lines 1190-1196
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1190 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1194 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1191 |
# => auto renew is allowed |
1195 |
# => auto renew is allowed |
1192 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1196 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1193 |
my $issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1197 |
my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1194 |
( $renewokay, $error ) = |
1198 |
( $renewokay, $error ) = |
1195 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1199 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1196 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1200 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1201-1207
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1201 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1205 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1202 |
# => auto renew is not allowed |
1206 |
# => auto renew is not allowed |
1203 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1207 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1204 |
$issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1208 |
$issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1205 |
( $renewokay, $error ) = |
1209 |
( $renewokay, $error ) = |
1206 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1210 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1207 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1211 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1211-1217
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1211 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1215 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1212 |
# => auto renew is allowed |
1216 |
# => auto renew is allowed |
1213 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1217 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1214 |
$issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1218 |
$issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1215 |
( $renewokay, $error ) = |
1219 |
( $renewokay, $error ) = |
1216 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1220 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1217 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1221 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1230-1236
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1230 |
|
1234 |
|
1231 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1235 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1232 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1236 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1233 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1237 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1234 |
Koha::CirculationRules->set_rules( |
1238 |
Koha::CirculationRules->set_rules( |
1235 |
{ |
1239 |
{ |
1236 |
categorycode => undef, |
1240 |
categorycode => undef, |
Lines 1482-1488
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1482 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1486 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1483 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1487 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1484 |
|
1488 |
|
1485 |
my $recall_issue = AddIssue( $renewing_borrower_obj->unblessed, $recall_item1->barcode ); |
1489 |
my $recall_issue = AddIssue( $renewing_borrower_obj, $recall_item1->barcode ); |
1486 |
|
1490 |
|
1487 |
# item-level and this item: renewal not allowed |
1491 |
# item-level and this item: renewal not allowed |
1488 |
my $recall = Koha::Recall->new({ |
1492 |
my $recall = Koha::Recall->new({ |
Lines 1563-1569
subtest "GetUpcomingDueIssues" => sub {
Link Here
|
1563 |
); |
1567 |
); |
1564 |
|
1568 |
|
1565 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1569 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1566 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber )->unblessed; |
1570 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber ); |
1567 |
|
1571 |
|
1568 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1572 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1569 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
1573 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
Lines 1640-1646
subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
Link Here
|
1640 |
|
1644 |
|
1641 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1645 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1642 |
|
1646 |
|
1643 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
1647 |
my $borrower = Koha::Patrons->find( $borrowernumber ); |
1644 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1648 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1645 |
UpdateFine( |
1649 |
UpdateFine( |
1646 |
{ |
1650 |
{ |
Lines 1726-1732
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1726 |
branchcode => $library2->{branchcode}, |
1730 |
branchcode => $library2->{branchcode}, |
1727 |
})->store->borrowernumber; |
1731 |
})->store->borrowernumber; |
1728 |
|
1732 |
|
1729 |
my $issue = AddIssue( $borrower1->unblessed, $item_1->barcode ); |
1733 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
1730 |
|
1734 |
|
1731 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1735 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1732 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
1736 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
Lines 1893-1899
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1893 |
branchcode => $branch, |
1897 |
branchcode => $branch, |
1894 |
})->store; |
1898 |
})->store; |
1895 |
|
1899 |
|
1896 |
my $issue = AddIssue( $borrower->unblessed, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1900 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1897 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1901 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1898 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1902 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1899 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1903 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
Lines 1913-1919
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1913 |
); |
1917 |
); |
1914 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1918 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1915 |
|
1919 |
|
1916 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
1920 |
my $issue = AddIssue( $patron, $item->barcode ); |
1917 |
UpdateFine( |
1921 |
UpdateFine( |
1918 |
{ |
1922 |
{ |
1919 |
issue_id => $issue->id, |
1923 |
issue_id => $issue->id, |
Lines 1972-1978
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1972 |
|
1976 |
|
1973 |
set_userenv($holdingbranch); |
1977 |
set_userenv($holdingbranch); |
1974 |
|
1978 |
|
1975 |
my $issue = AddIssue( $patron_1->unblessed, $item->barcode ); |
1979 |
my $issue = AddIssue( $patron_1, $item->barcode ); |
1976 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1980 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1977 |
|
1981 |
|
1978 |
my ( $error, $question, $alerts ); |
1982 |
my ( $error, $question, $alerts ); |
Lines 2047-2054
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
2047 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2051 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2048 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2052 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2049 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2053 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2050 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2054 |
|
2051 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2055 |
my $patron_1 = $builder->build_object({ |
|
|
2056 |
class => 'Koha::Patrons', |
2057 |
value => { categorycode => $patron_category->{categorycode} } |
2058 |
}); |
2059 |
|
2060 |
my $patron_2 = $builder->build_object({ |
2061 |
class => 'Koha::Patrons', |
2062 |
value => { categorycode => $patron_category->{categorycode} } |
2063 |
}); |
2064 |
|
2052 |
|
2065 |
|
2053 |
my $item = $builder->build_sample_item( |
2066 |
my $item = $builder->build_sample_item( |
2054 |
{ |
2067 |
{ |
Lines 2133-2139
subtest 'AddIssue | recalls' => sub {
Link Here
|
2133 |
pickup_library_id => $patron1->branchcode, |
2146 |
pickup_library_id => $patron1->branchcode, |
2134 |
} |
2147 |
} |
2135 |
)->store; |
2148 |
)->store; |
2136 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2149 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2137 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2150 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2138 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2151 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2139 |
AddReturn( $item->barcode, $item->homebranch ); |
2152 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2147-2153
subtest 'AddIssue | recalls' => sub {
Link Here
|
2147 |
pickup_library_id => $patron2->branchcode, |
2160 |
pickup_library_id => $patron2->branchcode, |
2148 |
} |
2161 |
} |
2149 |
)->store; |
2162 |
)->store; |
2150 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2163 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2151 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2164 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2152 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2165 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2153 |
AddReturn( $item->barcode, $item->homebranch ); |
2166 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2162-2168
subtest 'AddIssue | recalls' => sub {
Link Here
|
2162 |
} |
2175 |
} |
2163 |
)->store; |
2176 |
)->store; |
2164 |
$recall3->set_waiting; |
2177 |
$recall3->set_waiting; |
2165 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2178 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2166 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2179 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2167 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2180 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2168 |
AddReturn( $item->barcode, $item->homebranch ); |
2181 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2187-2193
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2187 |
due_date => $custom_date_due, |
2200 |
due_date => $custom_date_due, |
2188 |
})->store; |
2201 |
})->store; |
2189 |
|
2202 |
|
2190 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
2203 |
my $issue = AddIssue( $patron, $item->barcode ); |
2191 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2204 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2192 |
|
2205 |
|
2193 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2206 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 2201-2207
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2201 |
due_date => $custom_date_due, |
2214 |
due_date => $custom_date_due, |
2202 |
})->store; |
2215 |
})->store; |
2203 |
|
2216 |
|
2204 |
$issue = AddIssue( $patron->unblessed, $item->barcode ); |
2217 |
$issue = AddIssue( $patron, $item->barcode ); |
2205 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2218 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2206 |
}; |
2219 |
}; |
2207 |
|
2220 |
|
Lines 2245-2251
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
2245 |
|
2258 |
|
2246 |
# Patron cannot issue item_1, they have overdues |
2259 |
# Patron cannot issue item_1, they have overdues |
2247 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2260 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2248 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, $yesterday ); # Add an overdue |
2261 |
my $issue = AddIssue( $patron, $item_1->barcode, $yesterday ); # Add an overdue |
2249 |
|
2262 |
|
2250 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2263 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2251 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2264 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2344-2350
subtest 'MultipleReserves' => sub {
Link Here
|
2344 |
branchcode => $branch, |
2357 |
branchcode => $branch, |
2345 |
); |
2358 |
); |
2346 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2359 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2347 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode); |
2360 |
my $issue = AddIssue( $patron, $item_1->barcode); |
2348 |
my $datedue = dt_from_string( $issue->date_due() ); |
2361 |
my $datedue = dt_from_string( $issue->date_due() ); |
2349 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2362 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2350 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
2363 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
Lines 2457-2463
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
2457 |
); |
2470 |
); |
2458 |
|
2471 |
|
2459 |
my ( $error, $question, $alerts ); |
2472 |
my ( $error, $question, $alerts ); |
2460 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2473 |
my $issue = AddIssue( $patron, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2461 |
|
2474 |
|
2462 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2475 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2463 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2476 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2500-2506
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2500 |
plan tests => 8; |
2513 |
plan tests => 8; |
2501 |
|
2514 |
|
2502 |
my $library = $builder->build( { source => 'Branch' } ); |
2515 |
my $library = $builder->build( { source => 'Branch' } ); |
2503 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2516 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2504 |
|
2517 |
|
2505 |
# Add 2 items |
2518 |
# Add 2 items |
2506 |
my $biblionumber = $builder->build_sample_biblio( |
2519 |
my $biblionumber = $builder->build_sample_biblio( |
Lines 2548-2554
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2548 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2561 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2549 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2562 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2550 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
2563 |
my $debarments = Koha::Patron::Debarments::GetDebarments( |
2551 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2564 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2552 |
is( scalar(@$debarments), 1 ); |
2565 |
is( scalar(@$debarments), 1 ); |
2553 |
|
2566 |
|
2554 |
# FIXME Is it right? I'd have expected 5 * 2 - 1 instead |
2567 |
# FIXME Is it right? I'd have expected 5 * 2 - 1 instead |
Lines 2564-2570
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2564 |
|
2577 |
|
2565 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2578 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2566 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2579 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2567 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2580 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2568 |
is( scalar(@$debarments), 1 ); |
2581 |
is( scalar(@$debarments), 1 ); |
2569 |
$expected_expiration = output_pref( |
2582 |
$expected_expiration = output_pref( |
2570 |
{ |
2583 |
{ |
Lines 2576-2582
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2576 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2589 |
is( $debarments->[0]->{expiration}, $expected_expiration ); |
2577 |
|
2590 |
|
2578 |
Koha::Patron::Debarments::DelUniqueDebarment( |
2591 |
Koha::Patron::Debarments::DelUniqueDebarment( |
2579 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2592 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2580 |
|
2593 |
|
2581 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2594 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2582 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2595 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
Lines 2584-2590
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2584 |
; # Add another overdue |
2597 |
; # Add another overdue |
2585 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2598 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2586 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2599 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2587 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2600 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2588 |
is( scalar(@$debarments), 1 ); |
2601 |
is( scalar(@$debarments), 1 ); |
2589 |
$expected_expiration = output_pref( |
2602 |
$expected_expiration = output_pref( |
2590 |
{ |
2603 |
{ |
Lines 2597-2603
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2597 |
|
2610 |
|
2598 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2611 |
AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); |
2599 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2612 |
$debarments = Koha::Patron::Debarments::GetDebarments( |
2600 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2613 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2601 |
is( scalar(@$debarments), 1 ); |
2614 |
is( scalar(@$debarments), 1 ); |
2602 |
$expected_expiration = output_pref( |
2615 |
$expected_expiration = output_pref( |
2603 |
{ |
2616 |
{ |
Lines 2613-2619
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2613 |
plan tests => 27; |
2626 |
plan tests => 27; |
2614 |
|
2627 |
|
2615 |
my $library = $builder->build( { source => 'Branch' } ); |
2628 |
my $library = $builder->build( { source => 'Branch' } ); |
2616 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2629 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); |
2617 |
|
2630 |
|
2618 |
my $biblionumber = $builder->build_sample_biblio( |
2631 |
my $biblionumber = $builder->build_sample_biblio( |
2619 |
{ |
2632 |
{ |
Lines 2874-2880
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2874 |
); |
2887 |
); |
2875 |
|
2888 |
|
2876 |
my ( $error, $question, $alerts ); |
2889 |
my ( $error, $question, $alerts ); |
2877 |
my $issue = AddIssue( $patron1->unblessed, $item->barcode ); |
2890 |
my $issue = AddIssue( $patron1, $item->barcode ); |
2878 |
|
2891 |
|
2879 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2892 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2880 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2893 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
Lines 2931-2955
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2931 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2944 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
2932 |
|
2945 |
|
2933 |
# No return date specified, today will be used => 10 days overdue charged |
2946 |
# No return date specified, today will be used => 10 days overdue charged |
2934 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2947 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2935 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2948 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2936 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2949 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2937 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2950 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2938 |
|
2951 |
|
2939 |
# specify return date 5 days before => no overdue charged |
2952 |
# specify return date 5 days before => no overdue charged |
2940 |
AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago |
2953 |
AddIssue( $patron, $item->barcode, $five_days_ago ); # date due was 5d ago |
2941 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
2954 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
2942 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2955 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2943 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2956 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2944 |
|
2957 |
|
2945 |
# specify return date 5 days later => 5 days overdue charged |
2958 |
# specify return date 5 days later => 5 days overdue charged |
2946 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2959 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2947 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
2960 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
2948 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
2961 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
2949 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2962 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2950 |
|
2963 |
|
2951 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
2964 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
2952 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2965 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2953 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
2966 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
2954 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2967 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2955 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2968 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
Lines 2958-2964
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2958 |
|
2971 |
|
2959 |
plan tests => 3; |
2972 |
plan tests => 3; |
2960 |
|
2973 |
|
2961 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2974 |
my $issue = AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2962 |
|
2975 |
|
2963 |
# Fake fines cronjob on this checkout |
2976 |
# Fake fines cronjob on this checkout |
2964 |
my ($fine) = |
2977 |
my ($fine) = |
Lines 2996-3002
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2996 |
|
3009 |
|
2997 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3010 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
2998 |
|
3011 |
|
2999 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3012 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3000 |
|
3013 |
|
3001 |
# Fake fines cronjob on this checkout |
3014 |
# Fake fines cronjob on this checkout |
3002 |
my ($fine) = |
3015 |
my ($fine) = |
Lines 3021-3027
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3021 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3034 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3022 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3035 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3023 |
|
3036 |
|
3024 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago |
3037 |
$issue = AddIssue( $patron, $item->barcode, $two_days_ago ); # date due was 2d ago |
3025 |
|
3038 |
|
3026 |
# Fake fines cronjob on this checkout |
3039 |
# Fake fines cronjob on this checkout |
3027 |
($fine) = |
3040 |
($fine) = |
Lines 3087-3093
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3087 |
|
3100 |
|
3088 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3101 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3089 |
|
3102 |
|
3090 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3103 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3091 |
|
3104 |
|
3092 |
# Fake fines cronjob on this checkout |
3105 |
# Fake fines cronjob on this checkout |
3093 |
my ($fine) = |
3106 |
my ($fine) = |
Lines 3120-3126
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3120 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3133 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3121 |
|
3134 |
|
3122 |
my $due_date = dt_from_string; |
3135 |
my $due_date = dt_from_string; |
3123 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3136 |
my $issue = AddIssue( $patron, $item->barcode, $due_date ); |
3124 |
|
3137 |
|
3125 |
# Add fine |
3138 |
# Add fine |
3126 |
UpdateFine( |
3139 |
UpdateFine( |
Lines 3145-3151
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3145 |
ok( !$accountline, 'accountline removed as expected' ); |
3158 |
ok( !$accountline, 'accountline removed as expected' ); |
3146 |
|
3159 |
|
3147 |
# Re-issue |
3160 |
# Re-issue |
3148 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3161 |
$issue = AddIssue( $patron, $item->barcode, $due_date ); |
3149 |
|
3162 |
|
3150 |
# Add fine |
3163 |
# Add fine |
3151 |
UpdateFine( |
3164 |
UpdateFine( |
Lines 3301-3307
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3301 |
); |
3314 |
); |
3302 |
|
3315 |
|
3303 |
# Issue the item |
3316 |
# Issue the item |
3304 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3317 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3305 |
|
3318 |
|
3306 |
# Mark item as lost |
3319 |
# Mark item as lost |
3307 |
$item->itemlost(3)->store; |
3320 |
$item->itemlost(3)->store; |
Lines 3351-3357
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3351 |
); |
3364 |
); |
3352 |
|
3365 |
|
3353 |
# Issue the item |
3366 |
# Issue the item |
3354 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3367 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3355 |
|
3368 |
|
3356 |
# Mark item as lost |
3369 |
# Mark item as lost |
3357 |
$item->itemlost(3)->store; |
3370 |
$item->itemlost(3)->store; |
Lines 3411-3417
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3411 |
); |
3424 |
); |
3412 |
|
3425 |
|
3413 |
# Issue the item |
3426 |
# Issue the item |
3414 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3427 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3415 |
|
3428 |
|
3416 |
# Mark item as lost |
3429 |
# Mark item as lost |
3417 |
$item->itemlost(3)->store; |
3430 |
$item->itemlost(3)->store; |
Lines 3476-3482
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3476 |
); |
3489 |
); |
3477 |
|
3490 |
|
3478 |
# Issue the item |
3491 |
# Issue the item |
3479 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3492 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3480 |
|
3493 |
|
3481 |
# Fake fines cronjob on this checkout |
3494 |
# Fake fines cronjob on this checkout |
3482 |
my ($fine) = |
3495 |
my ($fine) = |
Lines 3559-3565
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3559 |
); |
3572 |
); |
3560 |
|
3573 |
|
3561 |
# Issue the item |
3574 |
# Issue the item |
3562 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3575 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3563 |
|
3576 |
|
3564 |
# Fake fines cronjob on this checkout |
3577 |
# Fake fines cronjob on this checkout |
3565 |
my ($fine) = |
3578 |
my ($fine) = |
Lines 3641-3647
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3641 |
); |
3654 |
); |
3642 |
|
3655 |
|
3643 |
# Issue the item |
3656 |
# Issue the item |
3644 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode , $ten_days_ago); |
3657 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode , $ten_days_ago); |
3645 |
|
3658 |
|
3646 |
# Fake fines cronjob on this checkout |
3659 |
# Fake fines cronjob on this checkout |
3647 |
my ($fine) = |
3660 |
my ($fine) = |
Lines 3738-3744
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3738 |
); |
3751 |
); |
3739 |
|
3752 |
|
3740 |
# Issue the item |
3753 |
# Issue the item |
3741 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3754 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3742 |
|
3755 |
|
3743 |
# Fake fines cronjob on this checkout |
3756 |
# Fake fines cronjob on this checkout |
3744 |
my ($fine) = |
3757 |
my ($fine) = |
Lines 4091-4097
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
4091 |
} |
4104 |
} |
4092 |
); |
4105 |
); |
4093 |
|
4106 |
|
4094 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago |
4107 |
my $issue = AddIssue( $patron, $item->barcode, $five_days_go ); # date due was 10d ago |
4095 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4108 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4096 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4109 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4097 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
4110 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
Lines 4383-4389
subtest 'AddReturn | recalls' => sub {
Link Here
|
4383 |
}); |
4396 |
}); |
4384 |
|
4397 |
|
4385 |
# this item can fill a recall with pickup at this branch |
4398 |
# this item can fill a recall with pickup at this branch |
4386 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4399 |
AddIssue( $patron1, $item1->barcode ); |
4387 |
my $recall1 = Koha::Recall->new( |
4400 |
my $recall1 = Koha::Recall->new( |
4388 |
{ patron_id => $patron2->borrowernumber, |
4401 |
{ patron_id => $patron2->borrowernumber, |
4389 |
biblio_id => $item1->biblionumber, |
4402 |
biblio_id => $item1->biblionumber, |
Lines 4397-4403
subtest 'AddReturn | recalls' => sub {
Link Here
|
4397 |
$recall1->set_cancelled; |
4410 |
$recall1->set_cancelled; |
4398 |
|
4411 |
|
4399 |
# this item can fill a recall but needs transfer |
4412 |
# this item can fill a recall but needs transfer |
4400 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4413 |
AddIssue( $patron1, $item1->barcode ); |
4401 |
$recall1 = Koha::Recall->new( |
4414 |
$recall1 = Koha::Recall->new( |
4402 |
{ patron_id => $patron2->borrowernumber, |
4415 |
{ patron_id => $patron2->borrowernumber, |
4403 |
biblio_id => $item1->biblionumber, |
4416 |
biblio_id => $item1->biblionumber, |
Lines 4411-4417
subtest 'AddReturn | recalls' => sub {
Link Here
|
4411 |
$recall1->set_cancelled; |
4424 |
$recall1->set_cancelled; |
4412 |
|
4425 |
|
4413 |
# this item is already in transit, do not ask to transfer |
4426 |
# this item is already in transit, do not ask to transfer |
4414 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4427 |
AddIssue( $patron1, $item1->barcode ); |
4415 |
$recall1 = Koha::Recall->new( |
4428 |
$recall1 = Koha::Recall->new( |
4416 |
{ patron_id => $patron2->borrowernumber, |
4429 |
{ patron_id => $patron2->borrowernumber, |
4417 |
biblio_id => $item1->biblionumber, |
4430 |
biblio_id => $item1->biblionumber, |
Lines 4489-4495
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4489 |
$context->mock( userenv => { branch => $library->id } ); |
4502 |
$context->mock( userenv => { branch => $library->id } ); |
4490 |
|
4503 |
|
4491 |
# Check the item out |
4504 |
# Check the item out |
4492 |
AddIssue( $patron->unblessed, $item->barcode ); |
4505 |
AddIssue( $patron, $item->barcode ); |
4493 |
|
4506 |
|
4494 |
throws_ok { |
4507 |
throws_ok { |
4495 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4508 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
Lines 4547-4553
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4547 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4560 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4548 |
|
4561 |
|
4549 |
AddReturn( $item->id, $library->id, undef, $date ); |
4562 |
AddReturn( $item->id, $library->id, undef, $date ); |
4550 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4563 |
AddIssue( $patron, $item->barcode, $now ); |
4551 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4564 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4552 |
my $lines_skipped = Koha::Account::Lines->search({ |
4565 |
my $lines_skipped = Koha::Account::Lines->search({ |
4553 |
borrowernumber => $patron->id, |
4566 |
borrowernumber => $patron->id, |
Lines 4571-4577
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
4571 |
set_userenv( $library->unblessed ); |
4584 |
set_userenv( $library->unblessed ); |
4572 |
|
4585 |
|
4573 |
# Check the item out |
4586 |
# Check the item out |
4574 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
4587 |
my $issue = AddIssue( $patron, $item->barcode ); |
4575 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4588 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4576 |
|
4589 |
|
4577 |
# Renew item |
4590 |
# Renew item |
Lines 4655-4661
subtest 'Incremented fee tests' => sub {
Link Here
|
4655 |
|
4668 |
|
4656 |
# Daily Tests |
4669 |
# Daily Tests |
4657 |
my $issue = |
4670 |
my $issue = |
4658 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4671 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4659 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4672 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4660 |
is( |
4673 |
is( |
4661 |
$accountline->amount + 0, |
4674 |
$accountline->amount + 0, |
Lines 4676-4682
subtest 'Incremented fee tests' => sub {
Link Here
|
4676 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4689 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4677 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4690 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4678 |
$issue = |
4691 |
$issue = |
4679 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4692 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4680 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4693 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4681 |
is( |
4694 |
is( |
4682 |
$accountline->amount + 0, |
4695 |
$accountline->amount + 0, |
Lines 4707-4713
subtest 'Incremented fee tests' => sub {
Link Here
|
4707 |
description => 'Test holiday' |
4720 |
description => 'Test holiday' |
4708 |
); |
4721 |
); |
4709 |
$issue = |
4722 |
$issue = |
4710 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4723 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4711 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4724 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4712 |
is( |
4725 |
is( |
4713 |
$accountline->amount + 0, |
4726 |
$accountline->amount + 0, |
Lines 4728-4734
subtest 'Incremented fee tests' => sub {
Link Here
|
4728 |
$itemtype->rentalcharge(2)->store; |
4741 |
$itemtype->rentalcharge(2)->store; |
4729 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4742 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4730 |
$issue = |
4743 |
$issue = |
4731 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4744 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4732 |
my $accountlines = |
4745 |
my $accountlines = |
4733 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4746 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4734 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4747 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
Lines 4760-4766
subtest 'Incremented fee tests' => sub {
Link Here
|
4760 |
|
4773 |
|
4761 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4774 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4762 |
$issue = |
4775 |
$issue = |
4763 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4776 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4764 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4777 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4765 |
is( |
4778 |
is( |
4766 |
$accountline->amount + 0, |
4779 |
$accountline->amount + 0, |
Lines 4780-4786
subtest 'Incremented fee tests' => sub {
Link Here
|
4780 |
|
4793 |
|
4781 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4794 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4782 |
$issue = |
4795 |
$issue = |
4783 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4796 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4784 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4797 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4785 |
is( |
4798 |
is( |
4786 |
$accountline->amount + 0, |
4799 |
$accountline->amount + 0, |
Lines 4800-4806
subtest 'Incremented fee tests' => sub {
Link Here
|
4800 |
|
4813 |
|
4801 |
$calendar->delete_holiday( weekday => $closed_day ); |
4814 |
$calendar->delete_holiday( weekday => $closed_day ); |
4802 |
$issue = |
4815 |
$issue = |
4803 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4816 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4804 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4817 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4805 |
is( |
4818 |
is( |
4806 |
$accountline->amount + 0, |
4819 |
$accountline->amount + 0, |
Lines 4914-4920
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4914 |
); |
4927 |
); |
4915 |
|
4928 |
|
4916 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4929 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4917 |
AddIssue( $patron->unblessed, $item->barcode ); |
4930 |
AddIssue( $patron, $item->barcode ); |
4918 |
|
4931 |
|
4919 |
my $accountline = Koha::Account::Line->new( |
4932 |
my $accountline = Koha::Account::Line->new( |
4920 |
{ |
4933 |
{ |
Lines 4929-4935
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4929 |
)->store(); |
4942 |
)->store(); |
4930 |
|
4943 |
|
4931 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
4944 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
4932 |
AddIssue( $patron->unblessed, $item->barcode ); |
4945 |
AddIssue( $patron, $item->barcode ); |
4933 |
|
4946 |
|
4934 |
is( $patron->checkouts->count, 1, |
4947 |
is( $patron->checkouts->count, 1, |
4935 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
4948 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
Lines 5035-5041
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5035 |
replacementprice => '42', |
5048 |
replacementprice => '42', |
5036 |
} |
5049 |
} |
5037 |
); |
5050 |
); |
5038 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5051 |
my $issue = AddIssue( $patron, $item->barcode ); |
5039 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5052 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5040 |
$item->_result->itemlost(1); |
5053 |
$item->_result->itemlost(1); |
5041 |
$item->_result->itemlost_on( $lost_on ); |
5054 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5070-5076
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5070 |
replacementprice => '42', |
5083 |
replacementprice => '42', |
5071 |
} |
5084 |
} |
5072 |
); |
5085 |
); |
5073 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5086 |
my $issue = AddIssue( $patron, $item->barcode ); |
5074 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5087 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5075 |
$item->_result->itemlost(1); |
5088 |
$item->_result->itemlost(1); |
5076 |
$item->_result->itemlost_on( $lost_on ); |
5089 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5105-5111
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5105 |
replacementprice => '42', |
5118 |
replacementprice => '42', |
5106 |
} |
5119 |
} |
5107 |
); |
5120 |
); |
5108 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5121 |
my $issue = AddIssue( $patron, $item->barcode ); |
5109 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5122 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5110 |
$item->_result->itemlost(1); |
5123 |
$item->_result->itemlost(1); |
5111 |
$item->_result->itemlost_on( $lost_on ); |
5124 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5140-5146
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5140 |
replacementprice => '42', |
5153 |
replacementprice => '42', |
5141 |
} |
5154 |
} |
5142 |
); |
5155 |
); |
5143 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5156 |
my $issue = AddIssue( $patron, $item->barcode ); |
5144 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5157 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5145 |
$item->_result->itemlost(1); |
5158 |
$item->_result->itemlost(1); |
5146 |
$item->_result->itemlost_on( $lost_on ); |
5159 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5228-5234
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5228 |
replacementprice => '42', |
5241 |
replacementprice => '42', |
5229 |
} |
5242 |
} |
5230 |
); |
5243 |
); |
5231 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5244 |
my $issue = AddIssue( $patron, $item->barcode ); |
5232 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5245 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5233 |
$item->_result->itemlost(1); |
5246 |
$item->_result->itemlost(1); |
5234 |
$item->_result->itemlost_on( $lost_on ); |
5247 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5242-5248
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5242 |
)->next; |
5255 |
)->next; |
5243 |
ok( $a, "Found accountline for lost fee" ); |
5256 |
ok( $a, "Found accountline for lost fee" ); |
5244 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5257 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5245 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5258 |
$issue = AddIssue( $patron2, $item->barcode ); |
5246 |
$a = $a->get_from_storage; |
5259 |
$a = $a->get_from_storage; |
5247 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5260 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5248 |
$a->delete; |
5261 |
$a->delete; |
Lines 5264-5270
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5264 |
replacementprice => '42', |
5277 |
replacementprice => '42', |
5265 |
} |
5278 |
} |
5266 |
); |
5279 |
); |
5267 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5280 |
my $issue = AddIssue( $patron, $item->barcode ); |
5268 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5281 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5269 |
$item->_result->itemlost(1); |
5282 |
$item->_result->itemlost(1); |
5270 |
$item->_result->itemlost_on( $lost_on ); |
5283 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5278-5284
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5278 |
)->next; |
5291 |
)->next; |
5279 |
ok( $a, "Found accountline for lost fee" ); |
5292 |
ok( $a, "Found accountline for lost fee" ); |
5280 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5293 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5281 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5294 |
$issue = AddIssue( $patron2, $item->barcode ); |
5282 |
$a = $a->get_from_storage; |
5295 |
$a = $a->get_from_storage; |
5283 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5296 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5284 |
$a->delete; |
5297 |
$a->delete; |
Lines 5299-5305
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5299 |
replacementprice => '42', |
5312 |
replacementprice => '42', |
5300 |
} |
5313 |
} |
5301 |
); |
5314 |
); |
5302 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5315 |
my $issue = AddIssue( $patron, $item->barcode ); |
5303 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5316 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5304 |
$item->_result->itemlost(1); |
5317 |
$item->_result->itemlost(1); |
5305 |
$item->_result->itemlost_on( $lost_on ); |
5318 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5313-5319
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5313 |
)->next; |
5326 |
)->next; |
5314 |
ok( $a, "Found accountline for lost fee" ); |
5327 |
ok( $a, "Found accountline for lost fee" ); |
5315 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5328 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5316 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5329 |
$issue = AddIssue( $patron2, $item->barcode ); |
5317 |
$a = $a->get_from_storage; |
5330 |
$a = $a->get_from_storage; |
5318 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5331 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5319 |
$a->delete; |
5332 |
$a->delete; |
Lines 5334-5340
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5334 |
replacementprice => '42', |
5347 |
replacementprice => '42', |
5335 |
} |
5348 |
} |
5336 |
); |
5349 |
); |
5337 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5350 |
my $issue = AddIssue( $patron, $item->barcode ); |
5338 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5351 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5339 |
$item->_result->itemlost(1); |
5352 |
$item->_result->itemlost(1); |
5340 |
$item->_result->itemlost_on( $lost_on ); |
5353 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5349-5355
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5349 |
$a = $a->next; |
5362 |
$a = $a->next; |
5350 |
ok( $a, "Found accountline for lost fee" ); |
5363 |
ok( $a, "Found accountline for lost fee" ); |
5351 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5364 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5352 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5365 |
$issue = AddIssue( $patron2, $item->barcode ); |
5353 |
$a = $a->get_from_storage; |
5366 |
$a = $a->get_from_storage; |
5354 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5367 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5355 |
$a->delete; |
5368 |
$a->delete; |
Lines 5435-5441
subtest 'Checkout should correctly terminate a transfer' => sub {
Link Here
|
5435 |
is( $transfer->reason, 'Reserve' ); |
5448 |
is( $transfer->reason, 'Reserve' ); |
5436 |
|
5449 |
|
5437 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5450 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5438 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5451 |
AddIssue( $patron_1, $item->barcode ); |
5439 |
$transfer = $transfer->get_from_storage; |
5452 |
$transfer = $transfer->get_from_storage; |
5440 |
isnt( $transfer->datearrived, undef ); |
5453 |
isnt( $transfer->datearrived, undef ); |
5441 |
$hold = $hold->get_from_storage; |
5454 |
$hold = $hold->get_from_storage; |
Lines 5478-5491
subtest 'AddIssue records staff who checked out item if appropriate' => sub {
Link Here
|
5478 |
my $dt_from = dt_from_string(); |
5491 |
my $dt_from = dt_from_string(); |
5479 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5492 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5480 |
|
5493 |
|
5481 |
my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from ); |
5494 |
my $issue_1 = AddIssue( $patron, $item_1->barcode, $dt_to, undef, $dt_from ); |
5482 |
|
5495 |
|
5483 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5496 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5484 |
|
5497 |
|
5485 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5498 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5486 |
|
5499 |
|
5487 |
my $issue_2 = |
5500 |
my $issue_2 = |
5488 |
AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from ); |
5501 |
AddIssue( $patron, $item_2->barcode, $dt_to, undef, $dt_from ); |
5489 |
|
5502 |
|
5490 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5503 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5491 |
}; |
5504 |
}; |
Lines 5513-5521
subtest "Item's onloan value should be set if checked out item is checked out to
Link Here
|
5513 |
} |
5526 |
} |
5514 |
); |
5527 |
); |
5515 |
|
5528 |
|
5516 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5529 |
AddIssue( $patron_1, $item->barcode ); |
5517 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5530 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5518 |
AddIssue( $patron_2->unblessed, $item->barcode ); |
5531 |
AddIssue( $patron_2, $item->barcode ); |
5519 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5532 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5520 |
}; |
5533 |
}; |
5521 |
|
5534 |
|
Lines 5592-5598
subtest "SendCirculationAlert" => sub {
Link Here
|
5592 |
})->store; |
5605 |
})->store; |
5593 |
|
5606 |
|
5594 |
# Checkout an item, mark it returned, generate a notice |
5607 |
# Checkout an item, mark it returned, generate a notice |
5595 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
5608 |
my $issue_1 = AddIssue( $patron, $item->barcode); |
5596 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5609 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5597 |
C4::Circulation::SendCirculationAlert({ |
5610 |
C4::Circulation::SendCirculationAlert({ |
5598 |
type => 'CHECKIN', |
5611 |
type => 'CHECKIN', |
Lines 5606-5612
subtest "SendCirculationAlert" => sub {
Link Here
|
5606 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5619 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5607 |
|
5620 |
|
5608 |
# Checkout an item, mark it returned, generate a notice |
5621 |
# Checkout an item, mark it returned, generate a notice |
5609 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
5622 |
my $issue_2 = AddIssue( $patron, $item->barcode); |
5610 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5623 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5611 |
C4::Circulation::SendCirculationAlert({ |
5624 |
C4::Circulation::SendCirculationAlert({ |
5612 |
type => 'CHECKIN', |
5625 |
type => 'CHECKIN', |
Lines 5640-5646
subtest "GetSoonestRenewDate tests" => sub {
Link Here
|
5640 |
} |
5653 |
} |
5641 |
); |
5654 |
); |
5642 |
my $item = $builder->build_sample_item(); |
5655 |
my $item = $builder->build_sample_item(); |
5643 |
my $issue = AddIssue( $patron->unblessed, $item->barcode); |
5656 |
my $issue = AddIssue( $patron, $item->barcode); |
5644 |
my $datedue = dt_from_string( $issue->date_due() ); |
5657 |
my $datedue = dt_from_string( $issue->date_due() ); |
5645 |
|
5658 |
|
5646 |
# Bug 14395 |
5659 |
# Bug 14395 |
Lines 5710-5716
subtest "CanBookBeIssued + needsconfirmation message" => sub {
Link Here
|
5710 |
priority => 1, |
5723 |
priority => 1, |
5711 |
found => undef, |
5724 |
found => undef, |
5712 |
suspend => 0, |
5725 |
suspend => 0, |
5713 |
item_group_id => $item->item_group |
5726 |
item_group_id => undef |
5714 |
}}); |
5727 |
}}); |
5715 |
|
5728 |
|
5716 |
my ( $error, $needsconfirmation, $alerts, $messages ); |
5729 |
my ( $error, $needsconfirmation, $alerts, $messages ); |