|
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 4457-4463
subtest 'AddReturn | recalls' => sub {
Link Here
|
| 4457 |
}); |
4470 |
}); |
| 4458 |
|
4471 |
|
| 4459 |
# this item can fill a recall with pickup at this branch |
4472 |
# this item can fill a recall with pickup at this branch |
| 4460 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4473 |
AddIssue( $patron1, $item1->barcode ); |
| 4461 |
my $recall1 = Koha::Recall->new( |
4474 |
my $recall1 = Koha::Recall->new( |
| 4462 |
{ patron_id => $patron2->borrowernumber, |
4475 |
{ patron_id => $patron2->borrowernumber, |
| 4463 |
biblio_id => $item1->biblionumber, |
4476 |
biblio_id => $item1->biblionumber, |
|
Lines 4471-4477
subtest 'AddReturn | recalls' => sub {
Link Here
|
| 4471 |
$recall1->set_cancelled; |
4484 |
$recall1->set_cancelled; |
| 4472 |
|
4485 |
|
| 4473 |
# this item can fill a recall but needs transfer |
4486 |
# this item can fill a recall but needs transfer |
| 4474 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4487 |
AddIssue( $patron1, $item1->barcode ); |
| 4475 |
$recall1 = Koha::Recall->new( |
4488 |
$recall1 = Koha::Recall->new( |
| 4476 |
{ patron_id => $patron2->borrowernumber, |
4489 |
{ patron_id => $patron2->borrowernumber, |
| 4477 |
biblio_id => $item1->biblionumber, |
4490 |
biblio_id => $item1->biblionumber, |
|
Lines 4485-4491
subtest 'AddReturn | recalls' => sub {
Link Here
|
| 4485 |
$recall1->set_cancelled; |
4498 |
$recall1->set_cancelled; |
| 4486 |
|
4499 |
|
| 4487 |
# this item is already in transit, do not ask to transfer |
4500 |
# this item is already in transit, do not ask to transfer |
| 4488 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4501 |
AddIssue( $patron1, $item1->barcode ); |
| 4489 |
$recall1 = Koha::Recall->new( |
4502 |
$recall1 = Koha::Recall->new( |
| 4490 |
{ patron_id => $patron2->borrowernumber, |
4503 |
{ patron_id => $patron2->borrowernumber, |
| 4491 |
biblio_id => $item1->biblionumber, |
4504 |
biblio_id => $item1->biblionumber, |
|
Lines 4563-4569
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4563 |
$context->mock( userenv => { branch => $library->id } ); |
4576 |
$context->mock( userenv => { branch => $library->id } ); |
| 4564 |
|
4577 |
|
| 4565 |
# Check the item out |
4578 |
# Check the item out |
| 4566 |
AddIssue( $patron->unblessed, $item->barcode ); |
4579 |
AddIssue( $patron, $item->barcode ); |
| 4567 |
|
4580 |
|
| 4568 |
throws_ok { |
4581 |
throws_ok { |
| 4569 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4582 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
|
Lines 4621-4627
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
| 4621 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4634 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
| 4622 |
|
4635 |
|
| 4623 |
AddReturn( $item->id, $library->id, undef, $date ); |
4636 |
AddReturn( $item->id, $library->id, undef, $date ); |
| 4624 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4637 |
AddIssue( $patron, $item->barcode, $now ); |
| 4625 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4638 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
| 4626 |
my $lines_skipped = Koha::Account::Lines->search({ |
4639 |
my $lines_skipped = Koha::Account::Lines->search({ |
| 4627 |
borrowernumber => $patron->id, |
4640 |
borrowernumber => $patron->id, |
|
Lines 4645-4651
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
| 4645 |
set_userenv( $library->unblessed ); |
4658 |
set_userenv( $library->unblessed ); |
| 4646 |
|
4659 |
|
| 4647 |
# Check the item out |
4660 |
# Check the item out |
| 4648 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
4661 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 4649 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4662 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
| 4650 |
|
4663 |
|
| 4651 |
# Renew item |
4664 |
# Renew item |
|
Lines 4729-4735
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4729 |
|
4742 |
|
| 4730 |
# Daily Tests |
4743 |
# Daily Tests |
| 4731 |
my $issue = |
4744 |
my $issue = |
| 4732 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4745 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4733 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4746 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4734 |
is( |
4747 |
is( |
| 4735 |
$accountline->amount + 0, |
4748 |
$accountline->amount + 0, |
|
Lines 4750-4756
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4750 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4763 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
| 4751 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4764 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
| 4752 |
$issue = |
4765 |
$issue = |
| 4753 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4766 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4754 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4767 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4755 |
is( |
4768 |
is( |
| 4756 |
$accountline->amount + 0, |
4769 |
$accountline->amount + 0, |
|
Lines 4781-4787
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4781 |
description => 'Test holiday' |
4794 |
description => 'Test holiday' |
| 4782 |
); |
4795 |
); |
| 4783 |
$issue = |
4796 |
$issue = |
| 4784 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4797 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4785 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4798 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4786 |
is( |
4799 |
is( |
| 4787 |
$accountline->amount + 0, |
4800 |
$accountline->amount + 0, |
|
Lines 4802-4808
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4802 |
$itemtype->rentalcharge(2)->store; |
4815 |
$itemtype->rentalcharge(2)->store; |
| 4803 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4816 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
| 4804 |
$issue = |
4817 |
$issue = |
| 4805 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4818 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4806 |
my $accountlines = |
4819 |
my $accountlines = |
| 4807 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4820 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
| 4808 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4821 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
|
Lines 4834-4840
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4834 |
|
4847 |
|
| 4835 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4848 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
| 4836 |
$issue = |
4849 |
$issue = |
| 4837 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4850 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4838 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4851 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4839 |
is( |
4852 |
is( |
| 4840 |
$accountline->amount + 0, |
4853 |
$accountline->amount + 0, |
|
Lines 4854-4860
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4854 |
|
4867 |
|
| 4855 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4868 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
| 4856 |
$issue = |
4869 |
$issue = |
| 4857 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4870 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4858 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4871 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4859 |
is( |
4872 |
is( |
| 4860 |
$accountline->amount + 0, |
4873 |
$accountline->amount + 0, |
|
Lines 4874-4880
subtest 'Incremented fee tests' => sub {
Link Here
|
| 4874 |
|
4887 |
|
| 4875 |
$calendar->delete_holiday( weekday => $closed_day ); |
4888 |
$calendar->delete_holiday( weekday => $closed_day ); |
| 4876 |
$issue = |
4889 |
$issue = |
| 4877 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4890 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
| 4878 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4891 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
| 4879 |
is( |
4892 |
is( |
| 4880 |
$accountline->amount + 0, |
4893 |
$accountline->amount + 0, |
|
Lines 4988-4994
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
| 4988 |
); |
5001 |
); |
| 4989 |
|
5002 |
|
| 4990 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
5003 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 4991 |
AddIssue( $patron->unblessed, $item->barcode ); |
5004 |
AddIssue( $patron, $item->barcode ); |
| 4992 |
|
5005 |
|
| 4993 |
my $accountline = Koha::Account::Line->new( |
5006 |
my $accountline = Koha::Account::Line->new( |
| 4994 |
{ |
5007 |
{ |
|
Lines 5003-5009
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
| 5003 |
)->store(); |
5016 |
)->store(); |
| 5004 |
|
5017 |
|
| 5005 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
5018 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
| 5006 |
AddIssue( $patron->unblessed, $item->barcode ); |
5019 |
AddIssue( $patron, $item->barcode ); |
| 5007 |
|
5020 |
|
| 5008 |
is( $patron->checkouts->count, 1, |
5021 |
is( $patron->checkouts->count, 1, |
| 5009 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
5022 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
|
Lines 5109-5115
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
| 5109 |
replacementprice => '42', |
5122 |
replacementprice => '42', |
| 5110 |
} |
5123 |
} |
| 5111 |
); |
5124 |
); |
| 5112 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5125 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5113 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5126 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5114 |
$item->_result->itemlost(1); |
5127 |
$item->_result->itemlost(1); |
| 5115 |
$item->_result->itemlost_on( $lost_on ); |
5128 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5144-5150
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
| 5144 |
replacementprice => '42', |
5157 |
replacementprice => '42', |
| 5145 |
} |
5158 |
} |
| 5146 |
); |
5159 |
); |
| 5147 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5160 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5148 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5161 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5149 |
$item->_result->itemlost(1); |
5162 |
$item->_result->itemlost(1); |
| 5150 |
$item->_result->itemlost_on( $lost_on ); |
5163 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5179-5185
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
| 5179 |
replacementprice => '42', |
5192 |
replacementprice => '42', |
| 5180 |
} |
5193 |
} |
| 5181 |
); |
5194 |
); |
| 5182 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5195 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5183 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5196 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5184 |
$item->_result->itemlost(1); |
5197 |
$item->_result->itemlost(1); |
| 5185 |
$item->_result->itemlost_on( $lost_on ); |
5198 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5214-5220
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
| 5214 |
replacementprice => '42', |
5227 |
replacementprice => '42', |
| 5215 |
} |
5228 |
} |
| 5216 |
); |
5229 |
); |
| 5217 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5230 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5218 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5231 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5219 |
$item->_result->itemlost(1); |
5232 |
$item->_result->itemlost(1); |
| 5220 |
$item->_result->itemlost_on( $lost_on ); |
5233 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5302-5308
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5302 |
replacementprice => '42', |
5315 |
replacementprice => '42', |
| 5303 |
} |
5316 |
} |
| 5304 |
); |
5317 |
); |
| 5305 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5318 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5306 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5319 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5307 |
$item->_result->itemlost(1); |
5320 |
$item->_result->itemlost(1); |
| 5308 |
$item->_result->itemlost_on( $lost_on ); |
5321 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5316-5322
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5316 |
)->next; |
5329 |
)->next; |
| 5317 |
ok( $a, "Found accountline for lost fee" ); |
5330 |
ok( $a, "Found accountline for lost fee" ); |
| 5318 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5331 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
| 5319 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5332 |
$issue = AddIssue( $patron2, $item->barcode ); |
| 5320 |
$a = $a->get_from_storage; |
5333 |
$a = $a->get_from_storage; |
| 5321 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5334 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
| 5322 |
$a->delete; |
5335 |
$a->delete; |
|
Lines 5338-5344
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5338 |
replacementprice => '42', |
5351 |
replacementprice => '42', |
| 5339 |
} |
5352 |
} |
| 5340 |
); |
5353 |
); |
| 5341 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5354 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5342 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5355 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5343 |
$item->_result->itemlost(1); |
5356 |
$item->_result->itemlost(1); |
| 5344 |
$item->_result->itemlost_on( $lost_on ); |
5357 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5352-5358
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5352 |
)->next; |
5365 |
)->next; |
| 5353 |
ok( $a, "Found accountline for lost fee" ); |
5366 |
ok( $a, "Found accountline for lost fee" ); |
| 5354 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5367 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
| 5355 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5368 |
$issue = AddIssue( $patron2, $item->barcode ); |
| 5356 |
$a = $a->get_from_storage; |
5369 |
$a = $a->get_from_storage; |
| 5357 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5370 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
| 5358 |
$a->delete; |
5371 |
$a->delete; |
|
Lines 5373-5379
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5373 |
replacementprice => '42', |
5386 |
replacementprice => '42', |
| 5374 |
} |
5387 |
} |
| 5375 |
); |
5388 |
); |
| 5376 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5389 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5377 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5390 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5378 |
$item->_result->itemlost(1); |
5391 |
$item->_result->itemlost(1); |
| 5379 |
$item->_result->itemlost_on( $lost_on ); |
5392 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5387-5393
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5387 |
)->next; |
5400 |
)->next; |
| 5388 |
ok( $a, "Found accountline for lost fee" ); |
5401 |
ok( $a, "Found accountline for lost fee" ); |
| 5389 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5402 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
| 5390 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5403 |
$issue = AddIssue( $patron2, $item->barcode ); |
| 5391 |
$a = $a->get_from_storage; |
5404 |
$a = $a->get_from_storage; |
| 5392 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5405 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
| 5393 |
$a->delete; |
5406 |
$a->delete; |
|
Lines 5408-5414
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5408 |
replacementprice => '42', |
5421 |
replacementprice => '42', |
| 5409 |
} |
5422 |
} |
| 5410 |
); |
5423 |
); |
| 5411 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5424 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 5412 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5425 |
LostItem( $item->itemnumber, 'cli', 0 ); |
| 5413 |
$item->_result->itemlost(1); |
5426 |
$item->_result->itemlost(1); |
| 5414 |
$item->_result->itemlost_on( $lost_on ); |
5427 |
$item->_result->itemlost_on( $lost_on ); |
|
Lines 5423-5429
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
| 5423 |
$a = $a->next; |
5436 |
$a = $a->next; |
| 5424 |
ok( $a, "Found accountline for lost fee" ); |
5437 |
ok( $a, "Found accountline for lost fee" ); |
| 5425 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5438 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
| 5426 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5439 |
$issue = AddIssue( $patron2, $item->barcode ); |
| 5427 |
$a = $a->get_from_storage; |
5440 |
$a = $a->get_from_storage; |
| 5428 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5441 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
| 5429 |
$a->delete; |
5442 |
$a->delete; |
|
Lines 5509-5515
subtest 'Checkout should correctly terminate a transfer' => sub {
Link Here
|
| 5509 |
is( $transfer->reason, 'Reserve' ); |
5522 |
is( $transfer->reason, 'Reserve' ); |
| 5510 |
|
5523 |
|
| 5511 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5524 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
| 5512 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5525 |
AddIssue( $patron_1, $item->barcode ); |
| 5513 |
$transfer = $transfer->get_from_storage; |
5526 |
$transfer = $transfer->get_from_storage; |
| 5514 |
isnt( $transfer->datearrived, undef ); |
5527 |
isnt( $transfer->datearrived, undef ); |
| 5515 |
$hold = $hold->get_from_storage; |
5528 |
$hold = $hold->get_from_storage; |
|
Lines 5552-5565
subtest 'AddIssue records staff who checked out item if appropriate' => sub {
Link Here
|
| 5552 |
my $dt_from = dt_from_string(); |
5565 |
my $dt_from = dt_from_string(); |
| 5553 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5566 |
my $dt_to = dt_from_string()->add( days => 7 ); |
| 5554 |
|
5567 |
|
| 5555 |
my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from ); |
5568 |
my $issue_1 = AddIssue( $patron, $item_1->barcode, $dt_to, undef, $dt_from ); |
| 5556 |
|
5569 |
|
| 5557 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5570 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
| 5558 |
|
5571 |
|
| 5559 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5572 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
| 5560 |
|
5573 |
|
| 5561 |
my $issue_2 = |
5574 |
my $issue_2 = |
| 5562 |
AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from ); |
5575 |
AddIssue( $patron, $item_2->barcode, $dt_to, undef, $dt_from ); |
| 5563 |
|
5576 |
|
| 5564 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5577 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
| 5565 |
}; |
5578 |
}; |
|
Lines 5587-5595
subtest "Item's onloan value should be set if checked out item is checked out to
Link Here
|
| 5587 |
} |
5600 |
} |
| 5588 |
); |
5601 |
); |
| 5589 |
|
5602 |
|
| 5590 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5603 |
AddIssue( $patron_1, $item->barcode ); |
| 5591 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5604 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
| 5592 |
AddIssue( $patron_2->unblessed, $item->barcode ); |
5605 |
AddIssue( $patron_2, $item->barcode ); |
| 5593 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5606 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
| 5594 |
}; |
5607 |
}; |
| 5595 |
|
5608 |
|
|
Lines 5666-5672
subtest "SendCirculationAlert" => sub {
Link Here
|
| 5666 |
})->store; |
5679 |
})->store; |
| 5667 |
|
5680 |
|
| 5668 |
# Checkout an item, mark it returned, generate a notice |
5681 |
# Checkout an item, mark it returned, generate a notice |
| 5669 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
5682 |
my $issue_1 = AddIssue( $patron, $item->barcode); |
| 5670 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5683 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
| 5671 |
C4::Circulation::SendCirculationAlert({ |
5684 |
C4::Circulation::SendCirculationAlert({ |
| 5672 |
type => 'CHECKIN', |
5685 |
type => 'CHECKIN', |
|
Lines 5680-5686
subtest "SendCirculationAlert" => sub {
Link Here
|
| 5680 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5693 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
| 5681 |
|
5694 |
|
| 5682 |
# Checkout an item, mark it returned, generate a notice |
5695 |
# Checkout an item, mark it returned, generate a notice |
| 5683 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
5696 |
my $issue_2 = AddIssue( $patron, $item->barcode); |
| 5684 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5697 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
| 5685 |
C4::Circulation::SendCirculationAlert({ |
5698 |
C4::Circulation::SendCirculationAlert({ |
| 5686 |
type => 'CHECKIN', |
5699 |
type => 'CHECKIN', |
|
Lines 5707-5713
subtest "GetSoonestRenewDate tests" => sub {
Link Here
|
| 5707 |
); |
5720 |
); |
| 5708 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
5721 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 5709 |
my $item = $builder->build_sample_item(); |
5722 |
my $item = $builder->build_sample_item(); |
| 5710 |
my $issue = AddIssue( $patron->unblessed, $item->barcode); |
5723 |
my $issue = AddIssue( $patron, $item->barcode); |
| 5711 |
my $datedue = dt_from_string( $issue->date_due() ); |
5724 |
my $datedue = dt_from_string( $issue->date_due() ); |
| 5712 |
|
5725 |
|
| 5713 |
# Bug 14395 |
5726 |
# Bug 14395 |