|
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 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 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 |