Lines 90-96
sub test_debarment_on_checkout {
Link Here
|
90 |
); |
90 |
); |
91 |
my @caller = caller; |
91 |
my @caller = caller; |
92 |
my $line_number = $caller[2]; |
92 |
my $line_number = $caller[2]; |
93 |
AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
93 |
AddIssue( $patron, $item->barcode, $due_date ); |
94 |
|
94 |
|
95 |
my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); |
95 |
my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); |
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' ) |
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 2541-2548
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2541 |
my $now = dt_from_string; |
2554 |
my $now = dt_from_string; |
2542 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2555 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2543 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2556 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2544 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2557 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2545 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2558 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2546 |
; # Add another overdue |
2559 |
; # Add another overdue |
2547 |
|
2560 |
|
2548 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2561 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
Lines 2580-2587
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2580 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2593 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2581 |
|
2594 |
|
2582 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2595 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2583 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2596 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2584 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2597 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2585 |
; # Add another overdue |
2598 |
; # Add another overdue |
2586 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2599 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2587 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
2600 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
Lines 2864-2870
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2864 |
} |
2877 |
} |
2865 |
); |
2878 |
); |
2866 |
|
2879 |
|
2867 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2880 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2868 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2881 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2869 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2882 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2870 |
|
2883 |
|
Lines 2882-2888
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2882 |
} |
2895 |
} |
2883 |
); |
2896 |
); |
2884 |
|
2897 |
|
2885 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2898 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2886 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2899 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2887 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2900 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2888 |
}; |
2901 |
}; |
Lines 2919-2925
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2919 |
); |
2932 |
); |
2920 |
|
2933 |
|
2921 |
my ( $error, $question, $alerts ); |
2934 |
my ( $error, $question, $alerts ); |
2922 |
my $issue = AddIssue( $patron1->unblessed, $item->barcode ); |
2935 |
my $issue = AddIssue( $patron1, $item->barcode ); |
2923 |
|
2936 |
|
2924 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2937 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2925 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2938 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
Lines 2980-3004
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2980 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2993 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2981 |
|
2994 |
|
2982 |
# No return date specified, today will be used => 10 days overdue charged |
2995 |
# No return date specified, today will be used => 10 days overdue charged |
2983 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2996 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2984 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2997 |
AddReturn( $item->barcode, $library->{branchcode} ); |
2985 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2998 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
2986 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2999 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2987 |
|
3000 |
|
2988 |
# specify return date 5 days before => no overdue charged |
3001 |
# specify return date 5 days before => no overdue charged |
2989 |
AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago |
3002 |
AddIssue( $patron, $item->barcode, $five_days_ago ); # date due was 5d ago |
2990 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
3003 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
2991 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3004 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
2992 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3005 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2993 |
|
3006 |
|
2994 |
# specify return date 5 days later => 5 days overdue charged |
3007 |
# specify return date 5 days later => 5 days overdue charged |
2995 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3008 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
2996 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
3009 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
2997 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
3010 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
2998 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3011 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
2999 |
|
3012 |
|
3000 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
3013 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
3001 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3014 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3002 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
3015 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
3003 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3016 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3004 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3017 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
Lines 3007-3013
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3007 |
|
3020 |
|
3008 |
plan tests => 3; |
3021 |
plan tests => 3; |
3009 |
|
3022 |
|
3010 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3023 |
my $issue = AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3011 |
|
3024 |
|
3012 |
# Fake fines cronjob on this checkout |
3025 |
# Fake fines cronjob on this checkout |
3013 |
my ($fine) = |
3026 |
my ($fine) = |
Lines 3045-3051
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3045 |
|
3058 |
|
3046 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3059 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3047 |
|
3060 |
|
3048 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3061 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3049 |
|
3062 |
|
3050 |
# Fake fines cronjob on this checkout |
3063 |
# Fake fines cronjob on this checkout |
3051 |
my ($fine) = |
3064 |
my ($fine) = |
Lines 3070-3076
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3070 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3083 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3071 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3084 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3072 |
|
3085 |
|
3073 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago |
3086 |
$issue = AddIssue( $patron, $item->barcode, $two_days_ago ); # date due was 2d ago |
3074 |
|
3087 |
|
3075 |
# Fake fines cronjob on this checkout |
3088 |
# Fake fines cronjob on this checkout |
3076 |
($fine) = |
3089 |
($fine) = |
Lines 3136-3142
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3136 |
|
3149 |
|
3137 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3150 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3138 |
|
3151 |
|
3139 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3152 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3140 |
|
3153 |
|
3141 |
# Fake fines cronjob on this checkout |
3154 |
# Fake fines cronjob on this checkout |
3142 |
my ($fine) = |
3155 |
my ($fine) = |
Lines 3169-3175
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3169 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3182 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3170 |
|
3183 |
|
3171 |
my $due_date = dt_from_string; |
3184 |
my $due_date = dt_from_string; |
3172 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3185 |
my $issue = AddIssue( $patron, $item->barcode, $due_date ); |
3173 |
|
3186 |
|
3174 |
# Add fine |
3187 |
# Add fine |
3175 |
UpdateFine( |
3188 |
UpdateFine( |
Lines 3194-3200
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3194 |
ok( !$accountline, 'accountline removed as expected' ); |
3207 |
ok( !$accountline, 'accountline removed as expected' ); |
3195 |
|
3208 |
|
3196 |
# Re-issue |
3209 |
# Re-issue |
3197 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3210 |
$issue = AddIssue( $patron, $item->barcode, $due_date ); |
3198 |
|
3211 |
|
3199 |
# Add fine |
3212 |
# Add fine |
3200 |
UpdateFine( |
3213 |
UpdateFine( |
Lines 3350-3356
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3350 |
); |
3363 |
); |
3351 |
|
3364 |
|
3352 |
# Issue the item |
3365 |
# Issue the item |
3353 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3366 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3354 |
|
3367 |
|
3355 |
# Mark item as lost |
3368 |
# Mark item as lost |
3356 |
$item->itemlost(3)->store; |
3369 |
$item->itemlost(3)->store; |
Lines 3400-3406
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3400 |
); |
3413 |
); |
3401 |
|
3414 |
|
3402 |
# Issue the item |
3415 |
# Issue the item |
3403 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3416 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3404 |
|
3417 |
|
3405 |
# Mark item as lost |
3418 |
# Mark item as lost |
3406 |
$item->itemlost(3)->store; |
3419 |
$item->itemlost(3)->store; |
Lines 3460-3466
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3460 |
); |
3473 |
); |
3461 |
|
3474 |
|
3462 |
# Issue the item |
3475 |
# Issue the item |
3463 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3476 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3464 |
|
3477 |
|
3465 |
# Mark item as lost |
3478 |
# Mark item as lost |
3466 |
$item->itemlost(3)->store; |
3479 |
$item->itemlost(3)->store; |
Lines 3525-3531
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3525 |
); |
3538 |
); |
3526 |
|
3539 |
|
3527 |
# Issue the item |
3540 |
# Issue the item |
3528 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3541 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3529 |
|
3542 |
|
3530 |
# Fake fines cronjob on this checkout |
3543 |
# Fake fines cronjob on this checkout |
3531 |
my ($fine) = |
3544 |
my ($fine) = |
Lines 3608-3614
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3608 |
); |
3621 |
); |
3609 |
|
3622 |
|
3610 |
# Issue the item |
3623 |
# Issue the item |
3611 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3624 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3612 |
|
3625 |
|
3613 |
# Fake fines cronjob on this checkout |
3626 |
# Fake fines cronjob on this checkout |
3614 |
my ($fine) = |
3627 |
my ($fine) = |
Lines 3690-3696
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3690 |
); |
3703 |
); |
3691 |
|
3704 |
|
3692 |
# Issue the item |
3705 |
# Issue the item |
3693 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode , $ten_days_ago); |
3706 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode , $ten_days_ago); |
3694 |
|
3707 |
|
3695 |
# Fake fines cronjob on this checkout |
3708 |
# Fake fines cronjob on this checkout |
3696 |
my ($fine) = |
3709 |
my ($fine) = |
Lines 3787-3793
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3787 |
); |
3800 |
); |
3788 |
|
3801 |
|
3789 |
# Issue the item |
3802 |
# Issue the item |
3790 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3803 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3791 |
|
3804 |
|
3792 |
# Fake fines cronjob on this checkout |
3805 |
# Fake fines cronjob on this checkout |
3793 |
my ($fine) = |
3806 |
my ($fine) = |
Lines 4140-4146
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
4140 |
} |
4153 |
} |
4141 |
); |
4154 |
); |
4142 |
|
4155 |
|
4143 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago |
4156 |
my $issue = AddIssue( $patron, $item->barcode, $five_days_go ); # date due was 10d ago |
4144 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4157 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4145 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4158 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4146 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
4159 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
Lines 4432-4438
subtest 'AddReturn | recalls' => sub {
Link Here
|
4432 |
}); |
4445 |
}); |
4433 |
|
4446 |
|
4434 |
# this item can fill a recall with pickup at this branch |
4447 |
# this item can fill a recall with pickup at this branch |
4435 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4448 |
AddIssue( $patron1, $item1->barcode ); |
4436 |
my $recall1 = Koha::Recall->new( |
4449 |
my $recall1 = Koha::Recall->new( |
4437 |
{ patron_id => $patron2->borrowernumber, |
4450 |
{ patron_id => $patron2->borrowernumber, |
4438 |
biblio_id => $item1->biblionumber, |
4451 |
biblio_id => $item1->biblionumber, |
Lines 4446-4452
subtest 'AddReturn | recalls' => sub {
Link Here
|
4446 |
$recall1->set_cancelled; |
4459 |
$recall1->set_cancelled; |
4447 |
|
4460 |
|
4448 |
# this item can fill a recall but needs transfer |
4461 |
# this item can fill a recall but needs transfer |
4449 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4462 |
AddIssue( $patron1, $item1->barcode ); |
4450 |
$recall1 = Koha::Recall->new( |
4463 |
$recall1 = Koha::Recall->new( |
4451 |
{ patron_id => $patron2->borrowernumber, |
4464 |
{ patron_id => $patron2->borrowernumber, |
4452 |
biblio_id => $item1->biblionumber, |
4465 |
biblio_id => $item1->biblionumber, |
Lines 4460-4466
subtest 'AddReturn | recalls' => sub {
Link Here
|
4460 |
$recall1->set_cancelled; |
4473 |
$recall1->set_cancelled; |
4461 |
|
4474 |
|
4462 |
# this item is already in transit, do not ask to transfer |
4475 |
# this item is already in transit, do not ask to transfer |
4463 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4476 |
AddIssue( $patron1, $item1->barcode ); |
4464 |
$recall1 = Koha::Recall->new( |
4477 |
$recall1 = Koha::Recall->new( |
4465 |
{ patron_id => $patron2->borrowernumber, |
4478 |
{ patron_id => $patron2->borrowernumber, |
4466 |
biblio_id => $item1->biblionumber, |
4479 |
biblio_id => $item1->biblionumber, |
Lines 4538-4544
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4538 |
$context->mock( userenv => { branch => $library->id } ); |
4551 |
$context->mock( userenv => { branch => $library->id } ); |
4539 |
|
4552 |
|
4540 |
# Check the item out |
4553 |
# Check the item out |
4541 |
AddIssue( $patron->unblessed, $item->barcode ); |
4554 |
AddIssue( $patron, $item->barcode ); |
4542 |
|
4555 |
|
4543 |
throws_ok { |
4556 |
throws_ok { |
4544 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4557 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
Lines 4596-4602
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4596 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4609 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4597 |
|
4610 |
|
4598 |
AddReturn( $item->id, $library->id, undef, $date ); |
4611 |
AddReturn( $item->id, $library->id, undef, $date ); |
4599 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4612 |
AddIssue( $patron, $item->barcode, $now ); |
4600 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4613 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4601 |
my $lines_skipped = Koha::Account::Lines->search({ |
4614 |
my $lines_skipped = Koha::Account::Lines->search({ |
4602 |
borrowernumber => $patron->id, |
4615 |
borrowernumber => $patron->id, |
Lines 4620-4626
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
4620 |
set_userenv( $library->unblessed ); |
4633 |
set_userenv( $library->unblessed ); |
4621 |
|
4634 |
|
4622 |
# Check the item out |
4635 |
# Check the item out |
4623 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
4636 |
my $issue = AddIssue( $patron, $item->barcode ); |
4624 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4637 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4625 |
|
4638 |
|
4626 |
# Renew item |
4639 |
# Renew item |
Lines 4705-4711
subtest 'Incremented fee tests' => sub {
Link Here
|
4705 |
|
4718 |
|
4706 |
# Daily Tests |
4719 |
# Daily Tests |
4707 |
my $issue = |
4720 |
my $issue = |
4708 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4721 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4709 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4722 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4710 |
is( |
4723 |
is( |
4711 |
$accountline->amount + 0, |
4724 |
$accountline->amount + 0, |
Lines 4726-4732
subtest 'Incremented fee tests' => sub {
Link Here
|
4726 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4739 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4727 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4740 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4728 |
$issue = |
4741 |
$issue = |
4729 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4742 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4730 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4743 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4731 |
is( |
4744 |
is( |
4732 |
$accountline->amount + 0, |
4745 |
$accountline->amount + 0, |
Lines 4757-4763
subtest 'Incremented fee tests' => sub {
Link Here
|
4757 |
description => 'Test holiday' |
4770 |
description => 'Test holiday' |
4758 |
); |
4771 |
); |
4759 |
$issue = |
4772 |
$issue = |
4760 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4773 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4761 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4774 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4762 |
is( |
4775 |
is( |
4763 |
$accountline->amount + 0, |
4776 |
$accountline->amount + 0, |
Lines 4778-4784
subtest 'Incremented fee tests' => sub {
Link Here
|
4778 |
$itemtype->rentalcharge(2)->store; |
4791 |
$itemtype->rentalcharge(2)->store; |
4779 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4792 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4780 |
$issue = |
4793 |
$issue = |
4781 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4794 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4782 |
my $accountlines = |
4795 |
my $accountlines = |
4783 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4796 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4784 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4797 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
Lines 4810-4816
subtest 'Incremented fee tests' => sub {
Link Here
|
4810 |
|
4823 |
|
4811 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4824 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4812 |
$issue = |
4825 |
$issue = |
4813 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4826 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4814 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4827 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4815 |
is( |
4828 |
is( |
4816 |
$accountline->amount + 0, |
4829 |
$accountline->amount + 0, |
Lines 4830-4836
subtest 'Incremented fee tests' => sub {
Link Here
|
4830 |
|
4843 |
|
4831 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4844 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4832 |
$issue = |
4845 |
$issue = |
4833 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4846 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4834 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4847 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4835 |
is( |
4848 |
is( |
4836 |
$accountline->amount + 0, |
4849 |
$accountline->amount + 0, |
Lines 4850-4856
subtest 'Incremented fee tests' => sub {
Link Here
|
4850 |
|
4863 |
|
4851 |
$calendar->delete_holiday( weekday => $closed_day ); |
4864 |
$calendar->delete_holiday( weekday => $closed_day ); |
4852 |
$issue = |
4865 |
$issue = |
4853 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4866 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4854 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4867 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4855 |
is( |
4868 |
is( |
4856 |
$accountline->amount + 0, |
4869 |
$accountline->amount + 0, |
Lines 4964-4970
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4964 |
); |
4977 |
); |
4965 |
|
4978 |
|
4966 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4979 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4967 |
AddIssue( $patron->unblessed, $item->barcode ); |
4980 |
AddIssue( $patron, $item->barcode ); |
4968 |
|
4981 |
|
4969 |
my $accountline = Koha::Account::Line->new( |
4982 |
my $accountline = Koha::Account::Line->new( |
4970 |
{ |
4983 |
{ |
Lines 4979-4985
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4979 |
)->store(); |
4992 |
)->store(); |
4980 |
|
4993 |
|
4981 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
4994 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
4982 |
AddIssue( $patron->unblessed, $item->barcode ); |
4995 |
AddIssue( $patron, $item->barcode ); |
4983 |
|
4996 |
|
4984 |
is( $patron->checkouts->count, 1, |
4997 |
is( $patron->checkouts->count, 1, |
4985 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
4998 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
Lines 5085-5091
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5085 |
replacementprice => '42', |
5098 |
replacementprice => '42', |
5086 |
} |
5099 |
} |
5087 |
); |
5100 |
); |
5088 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5101 |
my $issue = AddIssue( $patron, $item->barcode ); |
5089 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5102 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5090 |
$item->_result->itemlost(1); |
5103 |
$item->_result->itemlost(1); |
5091 |
$item->_result->itemlost_on( $lost_on ); |
5104 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5120-5126
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5120 |
replacementprice => '42', |
5133 |
replacementprice => '42', |
5121 |
} |
5134 |
} |
5122 |
); |
5135 |
); |
5123 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5136 |
my $issue = AddIssue( $patron, $item->barcode ); |
5124 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5137 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5125 |
$item->_result->itemlost(1); |
5138 |
$item->_result->itemlost(1); |
5126 |
$item->_result->itemlost_on( $lost_on ); |
5139 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5155-5161
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5155 |
replacementprice => '42', |
5168 |
replacementprice => '42', |
5156 |
} |
5169 |
} |
5157 |
); |
5170 |
); |
5158 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5171 |
my $issue = AddIssue( $patron, $item->barcode ); |
5159 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5172 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5160 |
$item->_result->itemlost(1); |
5173 |
$item->_result->itemlost(1); |
5161 |
$item->_result->itemlost_on( $lost_on ); |
5174 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5190-5196
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5190 |
replacementprice => '42', |
5203 |
replacementprice => '42', |
5191 |
} |
5204 |
} |
5192 |
); |
5205 |
); |
5193 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5206 |
my $issue = AddIssue( $patron, $item->barcode ); |
5194 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5207 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5195 |
$item->_result->itemlost(1); |
5208 |
$item->_result->itemlost(1); |
5196 |
$item->_result->itemlost_on( $lost_on ); |
5209 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5278-5284
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5278 |
replacementprice => '42', |
5291 |
replacementprice => '42', |
5279 |
} |
5292 |
} |
5280 |
); |
5293 |
); |
5281 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5294 |
my $issue = AddIssue( $patron, $item->barcode ); |
5282 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5295 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5283 |
$item->_result->itemlost(1); |
5296 |
$item->_result->itemlost(1); |
5284 |
$item->_result->itemlost_on( $lost_on ); |
5297 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5292-5298
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5292 |
)->next; |
5305 |
)->next; |
5293 |
ok( $a, "Found accountline for lost fee" ); |
5306 |
ok( $a, "Found accountline for lost fee" ); |
5294 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5307 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5295 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5308 |
$issue = AddIssue( $patron2, $item->barcode ); |
5296 |
$a = $a->get_from_storage; |
5309 |
$a = $a->get_from_storage; |
5297 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5310 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5298 |
$a->delete; |
5311 |
$a->delete; |
Lines 5314-5320
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5314 |
replacementprice => '42', |
5327 |
replacementprice => '42', |
5315 |
} |
5328 |
} |
5316 |
); |
5329 |
); |
5317 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5330 |
my $issue = AddIssue( $patron, $item->barcode ); |
5318 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5331 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5319 |
$item->_result->itemlost(1); |
5332 |
$item->_result->itemlost(1); |
5320 |
$item->_result->itemlost_on( $lost_on ); |
5333 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5328-5334
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5328 |
)->next; |
5341 |
)->next; |
5329 |
ok( $a, "Found accountline for lost fee" ); |
5342 |
ok( $a, "Found accountline for lost fee" ); |
5330 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5343 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5331 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5344 |
$issue = AddIssue( $patron2, $item->barcode ); |
5332 |
$a = $a->get_from_storage; |
5345 |
$a = $a->get_from_storage; |
5333 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5346 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5334 |
$a->delete; |
5347 |
$a->delete; |
Lines 5349-5355
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5349 |
replacementprice => '42', |
5362 |
replacementprice => '42', |
5350 |
} |
5363 |
} |
5351 |
); |
5364 |
); |
5352 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5365 |
my $issue = AddIssue( $patron, $item->barcode ); |
5353 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5366 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5354 |
$item->_result->itemlost(1); |
5367 |
$item->_result->itemlost(1); |
5355 |
$item->_result->itemlost_on( $lost_on ); |
5368 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5363-5369
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5363 |
)->next; |
5376 |
)->next; |
5364 |
ok( $a, "Found accountline for lost fee" ); |
5377 |
ok( $a, "Found accountline for lost fee" ); |
5365 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5378 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5366 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5379 |
$issue = AddIssue( $patron2, $item->barcode ); |
5367 |
$a = $a->get_from_storage; |
5380 |
$a = $a->get_from_storage; |
5368 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5381 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5369 |
$a->delete; |
5382 |
$a->delete; |
Lines 5384-5390
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5384 |
replacementprice => '42', |
5397 |
replacementprice => '42', |
5385 |
} |
5398 |
} |
5386 |
); |
5399 |
); |
5387 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5400 |
my $issue = AddIssue( $patron, $item->barcode ); |
5388 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5401 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5389 |
$item->_result->itemlost(1); |
5402 |
$item->_result->itemlost(1); |
5390 |
$item->_result->itemlost_on( $lost_on ); |
5403 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5399-5405
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5399 |
$a = $a->next; |
5412 |
$a = $a->next; |
5400 |
ok( $a, "Found accountline for lost fee" ); |
5413 |
ok( $a, "Found accountline for lost fee" ); |
5401 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5414 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5402 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5415 |
$issue = AddIssue( $patron2, $item->barcode ); |
5403 |
$a = $a->get_from_storage; |
5416 |
$a = $a->get_from_storage; |
5404 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5417 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5405 |
$a->delete; |
5418 |
$a->delete; |
Lines 5485-5491
subtest 'Checkout should correctly terminate a transfer' => sub {
Link Here
|
5485 |
is( $transfer->reason, 'Reserve' ); |
5498 |
is( $transfer->reason, 'Reserve' ); |
5486 |
|
5499 |
|
5487 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5500 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5488 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5501 |
AddIssue( $patron_1, $item->barcode ); |
5489 |
$transfer = $transfer->get_from_storage; |
5502 |
$transfer = $transfer->get_from_storage; |
5490 |
isnt( $transfer->datearrived, undef ); |
5503 |
isnt( $transfer->datearrived, undef ); |
5491 |
$hold = $hold->get_from_storage; |
5504 |
$hold = $hold->get_from_storage; |
Lines 5528-5541
subtest 'AddIssue records staff who checked out item if appropriate' => sub {
Link Here
|
5528 |
my $dt_from = dt_from_string(); |
5541 |
my $dt_from = dt_from_string(); |
5529 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5542 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5530 |
|
5543 |
|
5531 |
my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from ); |
5544 |
my $issue_1 = AddIssue( $patron, $item_1->barcode, $dt_to, undef, $dt_from ); |
5532 |
|
5545 |
|
5533 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5546 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5534 |
|
5547 |
|
5535 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5548 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5536 |
|
5549 |
|
5537 |
my $issue_2 = |
5550 |
my $issue_2 = |
5538 |
AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from ); |
5551 |
AddIssue( $patron, $item_2->barcode, $dt_to, undef, $dt_from ); |
5539 |
|
5552 |
|
5540 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5553 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5541 |
}; |
5554 |
}; |
Lines 5563-5571
subtest "Item's onloan value should be set if checked out item is checked out to
Link Here
|
5563 |
} |
5576 |
} |
5564 |
); |
5577 |
); |
5565 |
|
5578 |
|
5566 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5579 |
AddIssue( $patron_1, $item->barcode ); |
5567 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5580 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5568 |
AddIssue( $patron_2->unblessed, $item->barcode ); |
5581 |
AddIssue( $patron_2, $item->barcode ); |
5569 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5582 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5570 |
}; |
5583 |
}; |
5571 |
|
5584 |
|
Lines 5642-5648
subtest "SendCirculationAlert" => sub {
Link Here
|
5642 |
})->store; |
5655 |
})->store; |
5643 |
|
5656 |
|
5644 |
# Checkout an item, mark it returned, generate a notice |
5657 |
# Checkout an item, mark it returned, generate a notice |
5645 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
5658 |
my $issue_1 = AddIssue( $patron, $item->barcode); |
5646 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5659 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5647 |
C4::Circulation::SendCirculationAlert({ |
5660 |
C4::Circulation::SendCirculationAlert({ |
5648 |
type => 'CHECKIN', |
5661 |
type => 'CHECKIN', |
Lines 5656-5662
subtest "SendCirculationAlert" => sub {
Link Here
|
5656 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5669 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5657 |
|
5670 |
|
5658 |
# Checkout an item, mark it returned, generate a notice |
5671 |
# Checkout an item, mark it returned, generate a notice |
5659 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
5672 |
my $issue_2 = AddIssue( $patron, $item->barcode); |
5660 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5673 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5661 |
C4::Circulation::SendCirculationAlert({ |
5674 |
C4::Circulation::SendCirculationAlert({ |
5662 |
type => 'CHECKIN', |
5675 |
type => 'CHECKIN', |
Lines 5690-5696
subtest "GetSoonestRenewDate tests" => sub {
Link Here
|
5690 |
} |
5703 |
} |
5691 |
); |
5704 |
); |
5692 |
my $item = $builder->build_sample_item(); |
5705 |
my $item = $builder->build_sample_item(); |
5693 |
my $issue = AddIssue( $patron->unblessed, $item->barcode); |
5706 |
my $issue = AddIssue( $patron, $item->barcode); |
5694 |
my $datedue = dt_from_string( $issue->date_due() ); |
5707 |
my $datedue = dt_from_string( $issue->date_due() ); |
5695 |
|
5708 |
|
5696 |
# Bug 14395 |
5709 |
# Bug 14395 |
Lines 5760-5766
subtest "CanBookBeIssued + needsconfirmation message" => sub {
Link Here
|
5760 |
priority => 1, |
5773 |
priority => 1, |
5761 |
found => undef, |
5774 |
found => undef, |
5762 |
suspend => 0, |
5775 |
suspend => 0, |
5763 |
item_group_id => $item->item_group |
5776 |
item_group_id => undef |
5764 |
}}); |
5777 |
}}); |
5765 |
|
5778 |
|
5766 |
my ( $error, $needsconfirmation, $alerts, $messages ); |
5779 |
my ( $error, $needsconfirmation, $alerts, $messages ); |