Lines 90-96
sub test_debarment_on_checkout {
Link Here
|
90 |
); |
90 |
); |
91 |
my @caller = caller; |
91 |
my @caller = caller; |
92 |
my $line_number = $caller[2]; |
92 |
my $line_number = $caller[2]; |
93 |
AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
93 |
AddIssue( $patron, $item->barcode, $due_date ); |
94 |
|
94 |
|
95 |
my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); |
95 |
my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); |
96 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
96 |
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) |
Lines 164-177
my $patron_category = $builder->build(
Link Here
|
164 |
my $CircControl = C4::Context->preference('CircControl'); |
164 |
my $CircControl = C4::Context->preference('CircControl'); |
165 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
165 |
my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch'); |
166 |
|
166 |
|
167 |
my $item = { |
167 |
my $item = $builder->build_object({ |
168 |
homebranch => $library2->{branchcode}, |
168 |
class => 'Koha::Items', |
169 |
holdingbranch => $library2->{branchcode} |
169 |
value => { |
170 |
}; |
170 |
homebranch => $library2->{branchcode}, |
|
|
171 |
holdingbranch => $library2->{branchcode} |
172 |
} |
173 |
}); |
171 |
|
174 |
|
172 |
my $borrower = { |
175 |
my $borrower = $builder->build_object({ |
173 |
branchcode => $library2->{branchcode} |
176 |
class => 'Koha::Patrons', |
174 |
}; |
177 |
value => { branchcode => $library2->{branchcode} } |
|
|
178 |
}); |
175 |
|
179 |
|
176 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
180 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
177 |
|
181 |
|
Lines 185-191
is(
Link Here
|
185 |
); |
189 |
); |
186 |
is( |
190 |
is( |
187 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
191 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
188 |
$item->{$HomeOrHoldingBranch}, |
192 |
$item->get_column($HomeOrHoldingBranch), |
189 |
'_GetCircControlBranch returned item branch (no userenv defined)' |
193 |
'_GetCircControlBranch returned item branch (no userenv defined)' |
190 |
); |
194 |
); |
191 |
|
195 |
|
Lines 198-204
is(
Link Here
|
198 |
); |
202 |
); |
199 |
is( |
203 |
is( |
200 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
204 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
201 |
$borrower->{branchcode}, |
205 |
$borrower->branchcode, |
202 |
'_GetCircControlBranch returned borrower branch' |
206 |
'_GetCircControlBranch returned borrower branch' |
203 |
); |
207 |
); |
204 |
|
208 |
|
Lines 210-216
is(
Link Here
|
210 |
'CircControl changed to ItemHomeLibrary' |
214 |
'CircControl changed to ItemHomeLibrary' |
211 |
); |
215 |
); |
212 |
is( |
216 |
is( |
213 |
$item->{$HomeOrHoldingBranch}, |
217 |
$item->get_column($HomeOrHoldingBranch), |
214 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
218 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
215 |
'_GetCircControlBranch returned item branch' |
219 |
'_GetCircControlBranch returned item branch' |
216 |
); |
220 |
); |
Lines 241-247
is(
Link Here
|
241 |
); |
245 |
); |
242 |
is( |
246 |
is( |
243 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
247 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
244 |
$borrower->{branchcode}, |
248 |
$borrower->branchcode, |
245 |
'_GetCircControlBranch returned borrower branch' |
249 |
'_GetCircControlBranch returned borrower branch' |
246 |
); |
250 |
); |
247 |
|
251 |
|
Lines 254-260
is(
Link Here
|
254 |
); |
258 |
); |
255 |
is( |
259 |
is( |
256 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
260 |
C4::Circulation::_GetCircControlBranch($item, $borrower), |
257 |
$item->{$HomeOrHoldingBranch}, |
261 |
$item->get_column($HomeOrHoldingBranch), |
258 |
'_GetCircControlBranch returned item branch' |
262 |
'_GetCircControlBranch returned item branch' |
259 |
); |
263 |
); |
260 |
|
264 |
|
Lines 329-335
subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers a
Link Here
|
329 |
homebranch => $patron_hold_1->branchcode |
333 |
homebranch => $patron_hold_1->branchcode |
330 |
}); |
334 |
}); |
331 |
|
335 |
|
332 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode); |
336 |
my $issue = AddIssue( $patron, $item_1->barcode); |
333 |
my $datedue = dt_from_string( $issue->date_due() ); |
337 |
my $datedue = dt_from_string( $issue->date_due() ); |
334 |
is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); |
338 |
is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); |
335 |
|
339 |
|
Lines 519-529
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
519 |
my $checkitem = undef; |
523 |
my $checkitem = undef; |
520 |
my $found = undef; |
524 |
my $found = undef; |
521 |
|
525 |
|
522 |
my $issue_1 = AddIssue( $renewing_borrower_obj->unblessed, $item_1->barcode); |
526 |
my $issue_1 = AddIssue( $renewing_borrower_obj, $item_1->barcode); |
523 |
my $datedue = dt_from_string( $issue_1->date_due() ); |
527 |
my $datedue = dt_from_string( $issue_1->date_due() ); |
524 |
is (defined $issue_1->date_due(), 1, "Item 1 checked out, due date: " . $issue_1->date_due() ); |
528 |
is (defined $issue_1->date_due(), 1, "Item 1 checked out, due date: " . $issue_1->date_due() ); |
525 |
|
529 |
|
526 |
my $issue_2 = AddIssue( $renewing_borrower_obj->unblessed, $item_2->barcode); |
530 |
my $issue_2 = AddIssue( $renewing_borrower_obj, $item_2->barcode); |
527 |
is (defined $issue_2, 1, "Item 2 checked out, due date: " . $issue_2->date_due()); |
531 |
is (defined $issue_2, 1, "Item 2 checked out, due date: " . $issue_2->date_due()); |
528 |
|
532 |
|
529 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
533 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
Lines 634-640
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
634 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
638 |
is( $error, 'on_reserve', '(Bug 10663) Cannot renew, reserved (returned error is on_reserve)'); |
635 |
|
639 |
|
636 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
640 |
my $reserveid = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next->reserve_id; |
637 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber )->unblessed; |
641 |
my $reserving_borrower = Koha::Patrons->find( $reserving_borrowernumber ); |
638 |
AddIssue($reserving_borrower, $item_3->barcode); |
642 |
AddIssue($reserving_borrower, $item_3->barcode); |
639 |
my $reserve = $dbh->selectrow_hashref( |
643 |
my $reserve = $dbh->selectrow_hashref( |
640 |
'SELECT * FROM old_reserves WHERE reserve_id = ?', |
644 |
'SELECT * FROM old_reserves WHERE reserve_id = ?', |
Lines 682-688
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
682 |
itype => $itemtype, |
686 |
itype => $itemtype, |
683 |
} |
687 |
} |
684 |
); |
688 |
); |
685 |
my $issue_5 = AddIssue($restricted_borrower_obj->unblessed, $item_5->barcode); |
689 |
my $issue_5 = AddIssue($restricted_borrower_obj, $item_5->barcode); |
686 |
is (defined $issue_5, 1, "Item with date due checked out, due date: ". $issue_5->date_due); |
690 |
is (defined $issue_5, 1, "Item with date due checked out, due date: ". $issue_5->date_due); |
687 |
|
691 |
|
688 |
t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); |
692 |
t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); |
Lines 711-717
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
711 |
} |
715 |
} |
712 |
); |
716 |
); |
713 |
|
717 |
|
714 |
my $issue_6 = AddIssue( $renewing_borrower_obj->unblessed, $item_6->barcode); |
718 |
my $issue_6 = AddIssue( $renewing_borrower_obj, $item_6->barcode); |
715 |
is (defined $issue_6, 1, "Item 2 checked out, due date: ".$issue_6->date_due); |
719 |
is (defined $issue_6, 1, "Item 2 checked out, due date: ".$issue_6->date_due); |
716 |
|
720 |
|
717 |
my $now = dt_from_string(); |
721 |
my $now = dt_from_string(); |
Lines 719-725
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
719 |
my $five_weeks_ago = $now - $five_weeks; |
723 |
my $five_weeks_ago = $now - $five_weeks; |
720 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
724 |
t::lib::Mocks::mock_preference('finesMode', 'production'); |
721 |
|
725 |
|
722 |
my $issue_7 = AddIssue($renewing_borrower_obj->unblessed, $item_7->barcode, $five_weeks_ago); |
726 |
my $issue_7 = AddIssue($renewing_borrower_obj, $item_7->barcode, $five_weeks_ago); |
723 |
is (defined $issue_7, 1, "Item with passed date due checked out, due date: " . $issue_7->date_due); |
727 |
is (defined $issue_7, 1, "Item with passed date due checked out, due date: " . $issue_7->date_due); |
724 |
|
728 |
|
725 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); |
729 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow'); |
Lines 812-818
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
812 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
816 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
813 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
817 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
814 |
AddIssue( |
818 |
AddIssue( |
815 |
$renewing_borrower_obj->unblessed, |
819 |
$renewing_borrower_obj, |
816 |
$item_7->barcode, |
820 |
$item_7->barcode, |
817 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
821 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
818 |
0, |
822 |
0, |
Lines 840-846
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
840 |
} |
844 |
} |
841 |
); |
845 |
); |
842 |
|
846 |
|
843 |
my $issue_4 = AddIssue( $renewing_borrower_obj->unblessed, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
847 |
my $issue_4 = AddIssue( $renewing_borrower_obj, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
844 |
my $info; |
848 |
my $info; |
845 |
( $renewokay, $error, $info ) = |
849 |
( $renewokay, $error, $info ) = |
846 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
850 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
Lines 970-976
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
970 |
|
974 |
|
971 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
975 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
972 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
976 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
973 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
977 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
974 |
|
978 |
|
975 |
Koha::CirculationRules->set_rules( |
979 |
Koha::CirculationRules->set_rules( |
976 |
{ |
980 |
{ |
Lines 1099-1105
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1099 |
|
1103 |
|
1100 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1104 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1101 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1105 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1102 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1106 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1103 |
|
1107 |
|
1104 |
Koha::CirculationRules->set_rules( |
1108 |
Koha::CirculationRules->set_rules( |
1105 |
{ |
1109 |
{ |
Lines 1209-1215
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1209 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1213 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1210 |
# => auto renew is allowed |
1214 |
# => auto renew is allowed |
1211 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1215 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1212 |
my $issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1216 |
my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1213 |
( $renewokay, $error ) = |
1217 |
( $renewokay, $error ) = |
1214 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1218 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1215 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1219 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1220-1226
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1220 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1224 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1221 |
# => auto renew is not allowed |
1225 |
# => auto renew is not allowed |
1222 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1226 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1223 |
$issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1227 |
$issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1224 |
( $renewokay, $error ) = |
1228 |
( $renewokay, $error ) = |
1225 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1229 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1226 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1230 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1230-1236
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1230 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1234 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1231 |
# => auto renew is allowed |
1235 |
# => auto renew is allowed |
1232 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1236 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1233 |
$issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1237 |
$issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1234 |
( $renewokay, $error ) = |
1238 |
( $renewokay, $error ) = |
1235 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1239 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1236 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1240 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1249-1255
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1249 |
|
1253 |
|
1250 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1254 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1251 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1255 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1252 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1256 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1253 |
Koha::CirculationRules->set_rules( |
1257 |
Koha::CirculationRules->set_rules( |
1254 |
{ |
1258 |
{ |
1255 |
categorycode => undef, |
1259 |
categorycode => undef, |
Lines 1501-1507
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1501 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1505 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1502 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1506 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1503 |
|
1507 |
|
1504 |
my $recall_issue = AddIssue( $renewing_borrower_obj->unblessed, $recall_item1->barcode ); |
1508 |
my $recall_issue = AddIssue( $renewing_borrower_obj, $recall_item1->barcode ); |
1505 |
|
1509 |
|
1506 |
# item-level and this item: renewal not allowed |
1510 |
# item-level and this item: renewal not allowed |
1507 |
my $recall = Koha::Recall->new({ |
1511 |
my $recall = Koha::Recall->new({ |
Lines 1582-1588
subtest "GetUpcomingDueIssues" => sub {
Link Here
|
1582 |
); |
1586 |
); |
1583 |
|
1587 |
|
1584 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1588 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1585 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber )->unblessed; |
1589 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber ); |
1586 |
|
1590 |
|
1587 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1591 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1588 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
1592 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
Lines 1659-1665
subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
Link Here
|
1659 |
|
1663 |
|
1660 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1664 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1661 |
|
1665 |
|
1662 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
1666 |
my $borrower = Koha::Patrons->find( $borrowernumber ); |
1663 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1667 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1664 |
UpdateFine( |
1668 |
UpdateFine( |
1665 |
{ |
1669 |
{ |
Lines 1745-1751
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1745 |
branchcode => $library2->{branchcode}, |
1749 |
branchcode => $library2->{branchcode}, |
1746 |
})->store->borrowernumber; |
1750 |
})->store->borrowernumber; |
1747 |
|
1751 |
|
1748 |
my $issue = AddIssue( $borrower1->unblessed, $item_1->barcode ); |
1752 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
1749 |
|
1753 |
|
1750 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1754 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1751 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
1755 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
Lines 1912-1918
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1912 |
branchcode => $branch, |
1916 |
branchcode => $branch, |
1913 |
})->store; |
1917 |
})->store; |
1914 |
|
1918 |
|
1915 |
my $issue = AddIssue( $borrower->unblessed, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1919 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1916 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1920 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1917 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1921 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1918 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1922 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
Lines 1932-1938
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1932 |
); |
1936 |
); |
1933 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1937 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1934 |
|
1938 |
|
1935 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
1939 |
my $issue = AddIssue( $patron, $item->barcode ); |
1936 |
UpdateFine( |
1940 |
UpdateFine( |
1937 |
{ |
1941 |
{ |
1938 |
issue_id => $issue->id, |
1942 |
issue_id => $issue->id, |
Lines 1991-1997
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1991 |
|
1995 |
|
1992 |
set_userenv($holdingbranch); |
1996 |
set_userenv($holdingbranch); |
1993 |
|
1997 |
|
1994 |
my $issue = AddIssue( $patron_1->unblessed, $item->barcode ); |
1998 |
my $issue = AddIssue( $patron_1, $item->barcode ); |
1995 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1999 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1996 |
|
2000 |
|
1997 |
my ( $error, $question, $alerts ); |
2001 |
my ( $error, $question, $alerts ); |
Lines 2066-2073
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
2066 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2070 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2067 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2071 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2068 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2072 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2069 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2073 |
|
2070 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2074 |
my $patron_1 = $builder->build_object({ |
|
|
2075 |
class => 'Koha::Patrons', |
2076 |
value => { categorycode => $patron_category->{categorycode} } |
2077 |
}); |
2078 |
|
2079 |
my $patron_2 = $builder->build_object({ |
2080 |
class => 'Koha::Patrons', |
2081 |
value => { categorycode => $patron_category->{categorycode} } |
2082 |
}); |
2083 |
|
2071 |
|
2084 |
|
2072 |
my $item = $builder->build_sample_item( |
2085 |
my $item = $builder->build_sample_item( |
2073 |
{ |
2086 |
{ |
Lines 2152-2158
subtest 'AddIssue | recalls' => sub {
Link Here
|
2152 |
pickup_library_id => $patron1->branchcode, |
2165 |
pickup_library_id => $patron1->branchcode, |
2153 |
} |
2166 |
} |
2154 |
)->store; |
2167 |
)->store; |
2155 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2168 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2156 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2169 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2157 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2170 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2158 |
AddReturn( $item->barcode, $item->homebranch ); |
2171 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2166-2172
subtest 'AddIssue | recalls' => sub {
Link Here
|
2166 |
pickup_library_id => $patron2->branchcode, |
2179 |
pickup_library_id => $patron2->branchcode, |
2167 |
} |
2180 |
} |
2168 |
)->store; |
2181 |
)->store; |
2169 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2182 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2170 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2183 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2171 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2184 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2172 |
AddReturn( $item->barcode, $item->homebranch ); |
2185 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2181-2187
subtest 'AddIssue | recalls' => sub {
Link Here
|
2181 |
} |
2194 |
} |
2182 |
)->store; |
2195 |
)->store; |
2183 |
$recall3->set_waiting; |
2196 |
$recall3->set_waiting; |
2184 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2197 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2185 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2198 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2186 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2199 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2187 |
AddReturn( $item->barcode, $item->homebranch ); |
2200 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2206-2212
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2206 |
due_date => $custom_date_due, |
2219 |
due_date => $custom_date_due, |
2207 |
})->store; |
2220 |
})->store; |
2208 |
|
2221 |
|
2209 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
2222 |
my $issue = AddIssue( $patron, $item->barcode ); |
2210 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2223 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2211 |
|
2224 |
|
2212 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2225 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 2220-2226
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2220 |
due_date => $custom_date_due, |
2233 |
due_date => $custom_date_due, |
2221 |
})->store; |
2234 |
})->store; |
2222 |
|
2235 |
|
2223 |
$issue = AddIssue( $patron->unblessed, $item->barcode ); |
2236 |
$issue = AddIssue( $patron, $item->barcode ); |
2224 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2237 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2225 |
}; |
2238 |
}; |
2226 |
|
2239 |
|
Lines 2263-2269
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
2263 |
|
2276 |
|
2264 |
# Patron cannot issue item_1, they have overdues |
2277 |
# Patron cannot issue item_1, they have overdues |
2265 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2278 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2266 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, $yesterday ); # Add an overdue |
2279 |
my $issue = AddIssue( $patron, $item_1->barcode, $yesterday ); # Add an overdue |
2267 |
|
2280 |
|
2268 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2281 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2269 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2282 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2372-2378
subtest 'MultipleReserves' => sub {
Link Here
|
2372 |
branchcode => $branch, |
2385 |
branchcode => $branch, |
2373 |
); |
2386 |
); |
2374 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2387 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2375 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode); |
2388 |
my $issue = AddIssue( $patron, $item_1->barcode); |
2376 |
my $datedue = dt_from_string( $issue->date_due() ); |
2389 |
my $datedue = dt_from_string( $issue->date_due() ); |
2377 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2390 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2378 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
2391 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
Lines 2485-2491
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
2485 |
); |
2498 |
); |
2486 |
|
2499 |
|
2487 |
my ( $error, $question, $alerts ); |
2500 |
my ( $error, $question, $alerts ); |
2488 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2501 |
my $issue = AddIssue( $patron, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2489 |
|
2502 |
|
2490 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2503 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2491 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2504 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2569-2576
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2569 |
my $now = dt_from_string; |
2582 |
my $now = dt_from_string; |
2570 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2583 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2571 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2584 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2572 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2585 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2573 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2586 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2574 |
; # Add another overdue |
2587 |
; # Add another overdue |
2575 |
|
2588 |
|
2576 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2589 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
Lines 2608-2615
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2608 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2621 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2609 |
|
2622 |
|
2610 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2623 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2611 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2624 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2612 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2625 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2613 |
; # Add another overdue |
2626 |
; # Add another overdue |
2614 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2627 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2615 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
2628 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
Lines 2892-2898
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2892 |
} |
2905 |
} |
2893 |
); |
2906 |
); |
2894 |
|
2907 |
|
2895 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2908 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2896 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2909 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2897 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2910 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2898 |
|
2911 |
|
Lines 2910-2916
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2910 |
} |
2923 |
} |
2911 |
); |
2924 |
); |
2912 |
|
2925 |
|
2913 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2926 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2914 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2927 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2915 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2928 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2916 |
}; |
2929 |
}; |
Lines 2947-2953
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2947 |
); |
2960 |
); |
2948 |
|
2961 |
|
2949 |
my ( $error, $question, $alerts ); |
2962 |
my ( $error, $question, $alerts ); |
2950 |
my $issue = AddIssue( $patron1->unblessed, $item->barcode ); |
2963 |
my $issue = AddIssue( $patron1, $item->barcode ); |
2951 |
|
2964 |
|
2952 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2965 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2953 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2966 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
Lines 3008-3032
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3008 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
3021 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
3009 |
|
3022 |
|
3010 |
# No return date specified, today will be used => 10 days overdue charged |
3023 |
# No return date specified, today will be used => 10 days overdue charged |
3011 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3024 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3012 |
AddReturn( $item->barcode, $library->{branchcode} ); |
3025 |
AddReturn( $item->barcode, $library->{branchcode} ); |
3013 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
3026 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
3014 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3027 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3015 |
|
3028 |
|
3016 |
# specify return date 5 days before => no overdue charged |
3029 |
# specify return date 5 days before => no overdue charged |
3017 |
AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago |
3030 |
AddIssue( $patron, $item->barcode, $five_days_ago ); # date due was 5d ago |
3018 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
3031 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
3019 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3032 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3020 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3033 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3021 |
|
3034 |
|
3022 |
# specify return date 5 days later => 5 days overdue charged |
3035 |
# specify return date 5 days later => 5 days overdue charged |
3023 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3036 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3024 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
3037 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
3025 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
3038 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
3026 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3039 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3027 |
|
3040 |
|
3028 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
3041 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
3029 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3042 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3030 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
3043 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
3031 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3044 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3032 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3045 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
Lines 3035-3041
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3035 |
|
3048 |
|
3036 |
plan tests => 3; |
3049 |
plan tests => 3; |
3037 |
|
3050 |
|
3038 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3051 |
my $issue = AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3039 |
|
3052 |
|
3040 |
# Fake fines cronjob on this checkout |
3053 |
# Fake fines cronjob on this checkout |
3041 |
my ($fine) = |
3054 |
my ($fine) = |
Lines 3073-3079
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3073 |
|
3086 |
|
3074 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3087 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3075 |
|
3088 |
|
3076 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3089 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3077 |
|
3090 |
|
3078 |
# Fake fines cronjob on this checkout |
3091 |
# Fake fines cronjob on this checkout |
3079 |
my ($fine) = |
3092 |
my ($fine) = |
Lines 3098-3104
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3098 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3111 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3099 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3112 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3100 |
|
3113 |
|
3101 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago |
3114 |
$issue = AddIssue( $patron, $item->barcode, $two_days_ago ); # date due was 2d ago |
3102 |
|
3115 |
|
3103 |
# Fake fines cronjob on this checkout |
3116 |
# Fake fines cronjob on this checkout |
3104 |
($fine) = |
3117 |
($fine) = |
Lines 3164-3170
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3164 |
|
3177 |
|
3165 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3178 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3166 |
|
3179 |
|
3167 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3180 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3168 |
|
3181 |
|
3169 |
# Fake fines cronjob on this checkout |
3182 |
# Fake fines cronjob on this checkout |
3170 |
my ($fine) = |
3183 |
my ($fine) = |
Lines 3197-3203
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3197 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3210 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3198 |
|
3211 |
|
3199 |
my $due_date = dt_from_string; |
3212 |
my $due_date = dt_from_string; |
3200 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3213 |
my $issue = AddIssue( $patron, $item->barcode, $due_date ); |
3201 |
|
3214 |
|
3202 |
# Add fine |
3215 |
# Add fine |
3203 |
UpdateFine( |
3216 |
UpdateFine( |
Lines 3222-3228
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3222 |
ok( !$accountline, 'accountline removed as expected' ); |
3235 |
ok( !$accountline, 'accountline removed as expected' ); |
3223 |
|
3236 |
|
3224 |
# Re-issue |
3237 |
# Re-issue |
3225 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3238 |
$issue = AddIssue( $patron, $item->barcode, $due_date ); |
3226 |
|
3239 |
|
3227 |
# Add fine |
3240 |
# Add fine |
3228 |
UpdateFine( |
3241 |
UpdateFine( |
Lines 3378-3384
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3378 |
); |
3391 |
); |
3379 |
|
3392 |
|
3380 |
# Issue the item |
3393 |
# Issue the item |
3381 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3394 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3382 |
|
3395 |
|
3383 |
# Mark item as lost |
3396 |
# Mark item as lost |
3384 |
$item->itemlost(3)->store; |
3397 |
$item->itemlost(3)->store; |
Lines 3428-3434
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3428 |
); |
3441 |
); |
3429 |
|
3442 |
|
3430 |
# Issue the item |
3443 |
# Issue the item |
3431 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3444 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3432 |
|
3445 |
|
3433 |
# Mark item as lost |
3446 |
# Mark item as lost |
3434 |
$item->itemlost(3)->store; |
3447 |
$item->itemlost(3)->store; |
Lines 3488-3494
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3488 |
); |
3501 |
); |
3489 |
|
3502 |
|
3490 |
# Issue the item |
3503 |
# Issue the item |
3491 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3504 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3492 |
|
3505 |
|
3493 |
# Mark item as lost |
3506 |
# Mark item as lost |
3494 |
$item->itemlost(3)->store; |
3507 |
$item->itemlost(3)->store; |
Lines 3553-3559
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3553 |
); |
3566 |
); |
3554 |
|
3567 |
|
3555 |
# Issue the item |
3568 |
# Issue the item |
3556 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3569 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3557 |
|
3570 |
|
3558 |
# Fake fines cronjob on this checkout |
3571 |
# Fake fines cronjob on this checkout |
3559 |
my ($fine) = |
3572 |
my ($fine) = |
Lines 3636-3642
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3636 |
); |
3649 |
); |
3637 |
|
3650 |
|
3638 |
# Issue the item |
3651 |
# Issue the item |
3639 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3652 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3640 |
|
3653 |
|
3641 |
# Fake fines cronjob on this checkout |
3654 |
# Fake fines cronjob on this checkout |
3642 |
my ($fine) = |
3655 |
my ($fine) = |
Lines 3718-3724
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3718 |
); |
3731 |
); |
3719 |
|
3732 |
|
3720 |
# Issue the item |
3733 |
# Issue the item |
3721 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode , $ten_days_ago); |
3734 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode , $ten_days_ago); |
3722 |
|
3735 |
|
3723 |
# Fake fines cronjob on this checkout |
3736 |
# Fake fines cronjob on this checkout |
3724 |
my ($fine) = |
3737 |
my ($fine) = |
Lines 3815-3821
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3815 |
); |
3828 |
); |
3816 |
|
3829 |
|
3817 |
# Issue the item |
3830 |
# Issue the item |
3818 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3831 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3819 |
|
3832 |
|
3820 |
# Fake fines cronjob on this checkout |
3833 |
# Fake fines cronjob on this checkout |
3821 |
my ($fine) = |
3834 |
my ($fine) = |
Lines 4168-4174
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
4168 |
} |
4181 |
} |
4169 |
); |
4182 |
); |
4170 |
|
4183 |
|
4171 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago |
4184 |
my $issue = AddIssue( $patron, $item->barcode, $five_days_go ); # date due was 10d ago |
4172 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4185 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4173 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4186 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4174 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
4187 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
Lines 4460-4466
subtest 'AddReturn | recalls' => sub {
Link Here
|
4460 |
}); |
4473 |
}); |
4461 |
|
4474 |
|
4462 |
# this item can fill a recall with pickup at this branch |
4475 |
# this item can fill a recall with pickup at this branch |
4463 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4476 |
AddIssue( $patron1, $item1->barcode ); |
4464 |
my $recall1 = Koha::Recall->new( |
4477 |
my $recall1 = Koha::Recall->new( |
4465 |
{ patron_id => $patron2->borrowernumber, |
4478 |
{ patron_id => $patron2->borrowernumber, |
4466 |
biblio_id => $item1->biblionumber, |
4479 |
biblio_id => $item1->biblionumber, |
Lines 4474-4480
subtest 'AddReturn | recalls' => sub {
Link Here
|
4474 |
$recall1->set_cancelled; |
4487 |
$recall1->set_cancelled; |
4475 |
|
4488 |
|
4476 |
# this item can fill a recall but needs transfer |
4489 |
# this item can fill a recall but needs transfer |
4477 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4490 |
AddIssue( $patron1, $item1->barcode ); |
4478 |
$recall1 = Koha::Recall->new( |
4491 |
$recall1 = Koha::Recall->new( |
4479 |
{ patron_id => $patron2->borrowernumber, |
4492 |
{ patron_id => $patron2->borrowernumber, |
4480 |
biblio_id => $item1->biblionumber, |
4493 |
biblio_id => $item1->biblionumber, |
Lines 4488-4494
subtest 'AddReturn | recalls' => sub {
Link Here
|
4488 |
$recall1->set_cancelled; |
4501 |
$recall1->set_cancelled; |
4489 |
|
4502 |
|
4490 |
# this item is already in transit, do not ask to transfer |
4503 |
# this item is already in transit, do not ask to transfer |
4491 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4504 |
AddIssue( $patron1, $item1->barcode ); |
4492 |
$recall1 = Koha::Recall->new( |
4505 |
$recall1 = Koha::Recall->new( |
4493 |
{ patron_id => $patron2->borrowernumber, |
4506 |
{ patron_id => $patron2->borrowernumber, |
4494 |
biblio_id => $item1->biblionumber, |
4507 |
biblio_id => $item1->biblionumber, |
Lines 4566-4572
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4566 |
$context->mock( userenv => { branch => $library->id } ); |
4579 |
$context->mock( userenv => { branch => $library->id } ); |
4567 |
|
4580 |
|
4568 |
# Check the item out |
4581 |
# Check the item out |
4569 |
AddIssue( $patron->unblessed, $item->barcode ); |
4582 |
AddIssue( $patron, $item->barcode ); |
4570 |
|
4583 |
|
4571 |
throws_ok { |
4584 |
throws_ok { |
4572 |
AddRenewal( |
4585 |
AddRenewal( |
Lines 4643-4649
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4643 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4656 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4644 |
|
4657 |
|
4645 |
AddReturn( $item->id, $library->id, undef, $date ); |
4658 |
AddReturn( $item->id, $library->id, undef, $date ); |
4646 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4659 |
AddIssue( $patron, $item->barcode, $now ); |
4647 |
AddRenewal( |
4660 |
AddRenewal( |
4648 |
{ |
4661 |
{ |
4649 |
borrowernumber => $patron->id, |
4662 |
borrowernumber => $patron->id, |
Lines 4674-4680
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
4674 |
set_userenv( $library->unblessed ); |
4687 |
set_userenv( $library->unblessed ); |
4675 |
|
4688 |
|
4676 |
# Check the item out |
4689 |
# Check the item out |
4677 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
4690 |
my $issue = AddIssue( $patron, $item->barcode ); |
4678 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4691 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4679 |
|
4692 |
|
4680 |
# Renew item |
4693 |
# Renew item |
Lines 4766-4772
subtest 'Incremented fee tests' => sub {
Link Here
|
4766 |
|
4779 |
|
4767 |
# Daily Tests |
4780 |
# Daily Tests |
4768 |
my $issue = |
4781 |
my $issue = |
4769 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4782 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4770 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4783 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4771 |
is( |
4784 |
is( |
4772 |
$accountline->amount + 0, |
4785 |
$accountline->amount + 0, |
Lines 4795-4801
subtest 'Incremented fee tests' => sub {
Link Here
|
4795 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4808 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4796 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4809 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4797 |
$issue = |
4810 |
$issue = |
4798 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4811 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4799 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4812 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4800 |
is( |
4813 |
is( |
4801 |
$accountline->amount + 0, |
4814 |
$accountline->amount + 0, |
Lines 4834-4840
subtest 'Incremented fee tests' => sub {
Link Here
|
4834 |
description => 'Test holiday' |
4847 |
description => 'Test holiday' |
4835 |
); |
4848 |
); |
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 4863-4869
subtest 'Incremented fee tests' => sub {
Link Here
|
4863 |
$itemtype->rentalcharge(2)->store; |
4876 |
$itemtype->rentalcharge(2)->store; |
4864 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4877 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4865 |
$issue = |
4878 |
$issue = |
4866 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4879 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4867 |
my $accountlines = |
4880 |
my $accountlines = |
4868 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4881 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4869 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4882 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
Lines 4903-4909
subtest 'Incremented fee tests' => sub {
Link Here
|
4903 |
|
4916 |
|
4904 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4917 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4905 |
$issue = |
4918 |
$issue = |
4906 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4919 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4907 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4920 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4908 |
is( |
4921 |
is( |
4909 |
$accountline->amount + 0, |
4922 |
$accountline->amount + 0, |
Lines 4931-4937
subtest 'Incremented fee tests' => sub {
Link Here
|
4931 |
|
4944 |
|
4932 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4945 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4933 |
$issue = |
4946 |
$issue = |
4934 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4947 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4935 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4948 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4936 |
is( |
4949 |
is( |
4937 |
$accountline->amount + 0, |
4950 |
$accountline->amount + 0, |
Lines 4959-4965
subtest 'Incremented fee tests' => sub {
Link Here
|
4959 |
|
4972 |
|
4960 |
$calendar->delete_holiday( weekday => $closed_day ); |
4973 |
$calendar->delete_holiday( weekday => $closed_day ); |
4961 |
$issue = |
4974 |
$issue = |
4962 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4975 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4963 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4976 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4964 |
is( |
4977 |
is( |
4965 |
$accountline->amount + 0, |
4978 |
$accountline->amount + 0, |
Lines 5081-5087
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
5081 |
); |
5094 |
); |
5082 |
|
5095 |
|
5083 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
5096 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
5084 |
AddIssue( $patron->unblessed, $item->barcode ); |
5097 |
AddIssue( $patron, $item->barcode ); |
5085 |
|
5098 |
|
5086 |
my $accountline = Koha::Account::Line->new( |
5099 |
my $accountline = Koha::Account::Line->new( |
5087 |
{ |
5100 |
{ |
Lines 5096-5102
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
5096 |
)->store(); |
5109 |
)->store(); |
5097 |
|
5110 |
|
5098 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
5111 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
5099 |
AddIssue( $patron->unblessed, $item->barcode ); |
5112 |
AddIssue( $patron, $item->barcode ); |
5100 |
|
5113 |
|
5101 |
is( $patron->checkouts->count, 1, |
5114 |
is( $patron->checkouts->count, 1, |
5102 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
5115 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
Lines 5202-5208
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5202 |
replacementprice => '42', |
5215 |
replacementprice => '42', |
5203 |
} |
5216 |
} |
5204 |
); |
5217 |
); |
5205 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5218 |
my $issue = AddIssue( $patron, $item->barcode ); |
5206 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5219 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5207 |
$item->_result->itemlost(1); |
5220 |
$item->_result->itemlost(1); |
5208 |
$item->_result->itemlost_on( $lost_on ); |
5221 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5237-5243
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5237 |
replacementprice => '42', |
5250 |
replacementprice => '42', |
5238 |
} |
5251 |
} |
5239 |
); |
5252 |
); |
5240 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5253 |
my $issue = AddIssue( $patron, $item->barcode ); |
5241 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5254 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5242 |
$item->_result->itemlost(1); |
5255 |
$item->_result->itemlost(1); |
5243 |
$item->_result->itemlost_on( $lost_on ); |
5256 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5272-5278
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5272 |
replacementprice => '42', |
5285 |
replacementprice => '42', |
5273 |
} |
5286 |
} |
5274 |
); |
5287 |
); |
5275 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5288 |
my $issue = AddIssue( $patron, $item->barcode ); |
5276 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5289 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5277 |
$item->_result->itemlost(1); |
5290 |
$item->_result->itemlost(1); |
5278 |
$item->_result->itemlost_on( $lost_on ); |
5291 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5307-5313
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5307 |
replacementprice => '42', |
5320 |
replacementprice => '42', |
5308 |
} |
5321 |
} |
5309 |
); |
5322 |
); |
5310 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5323 |
my $issue = AddIssue( $patron, $item->barcode ); |
5311 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5324 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5312 |
$item->_result->itemlost(1); |
5325 |
$item->_result->itemlost(1); |
5313 |
$item->_result->itemlost_on( $lost_on ); |
5326 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5395-5401
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5395 |
replacementprice => '42', |
5408 |
replacementprice => '42', |
5396 |
} |
5409 |
} |
5397 |
); |
5410 |
); |
5398 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5411 |
my $issue = AddIssue( $patron, $item->barcode ); |
5399 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5412 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5400 |
$item->_result->itemlost(1); |
5413 |
$item->_result->itemlost(1); |
5401 |
$item->_result->itemlost_on( $lost_on ); |
5414 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5409-5415
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5409 |
)->next; |
5422 |
)->next; |
5410 |
ok( $a, "Found accountline for lost fee" ); |
5423 |
ok( $a, "Found accountline for lost fee" ); |
5411 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5424 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5412 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5425 |
$issue = AddIssue( $patron2, $item->barcode ); |
5413 |
$a = $a->get_from_storage; |
5426 |
$a = $a->get_from_storage; |
5414 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5427 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5415 |
$a->delete; |
5428 |
$a->delete; |
Lines 5431-5437
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5431 |
replacementprice => '42', |
5444 |
replacementprice => '42', |
5432 |
} |
5445 |
} |
5433 |
); |
5446 |
); |
5434 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5447 |
my $issue = AddIssue( $patron, $item->barcode ); |
5435 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5448 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5436 |
$item->_result->itemlost(1); |
5449 |
$item->_result->itemlost(1); |
5437 |
$item->_result->itemlost_on( $lost_on ); |
5450 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5445-5451
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5445 |
)->next; |
5458 |
)->next; |
5446 |
ok( $a, "Found accountline for lost fee" ); |
5459 |
ok( $a, "Found accountline for lost fee" ); |
5447 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5460 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5448 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5461 |
$issue = AddIssue( $patron2, $item->barcode ); |
5449 |
$a = $a->get_from_storage; |
5462 |
$a = $a->get_from_storage; |
5450 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5463 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5451 |
$a->delete; |
5464 |
$a->delete; |
Lines 5466-5472
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5466 |
replacementprice => '42', |
5479 |
replacementprice => '42', |
5467 |
} |
5480 |
} |
5468 |
); |
5481 |
); |
5469 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5482 |
my $issue = AddIssue( $patron, $item->barcode ); |
5470 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5483 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5471 |
$item->_result->itemlost(1); |
5484 |
$item->_result->itemlost(1); |
5472 |
$item->_result->itemlost_on( $lost_on ); |
5485 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5480-5486
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5480 |
)->next; |
5493 |
)->next; |
5481 |
ok( $a, "Found accountline for lost fee" ); |
5494 |
ok( $a, "Found accountline for lost fee" ); |
5482 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5495 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5483 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5496 |
$issue = AddIssue( $patron2, $item->barcode ); |
5484 |
$a = $a->get_from_storage; |
5497 |
$a = $a->get_from_storage; |
5485 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5498 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5486 |
$a->delete; |
5499 |
$a->delete; |
Lines 5501-5507
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5501 |
replacementprice => '42', |
5514 |
replacementprice => '42', |
5502 |
} |
5515 |
} |
5503 |
); |
5516 |
); |
5504 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5517 |
my $issue = AddIssue( $patron, $item->barcode ); |
5505 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5518 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5506 |
$item->_result->itemlost(1); |
5519 |
$item->_result->itemlost(1); |
5507 |
$item->_result->itemlost_on( $lost_on ); |
5520 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5516-5522
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5516 |
$a = $a->next; |
5529 |
$a = $a->next; |
5517 |
ok( $a, "Found accountline for lost fee" ); |
5530 |
ok( $a, "Found accountline for lost fee" ); |
5518 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5531 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5519 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5532 |
$issue = AddIssue( $patron2, $item->barcode ); |
5520 |
$a = $a->get_from_storage; |
5533 |
$a = $a->get_from_storage; |
5521 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5534 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5522 |
$a->delete; |
5535 |
$a->delete; |
Lines 5602-5608
subtest 'Checkout should correctly terminate a transfer' => sub {
Link Here
|
5602 |
is( $transfer->reason, 'Reserve' ); |
5615 |
is( $transfer->reason, 'Reserve' ); |
5603 |
|
5616 |
|
5604 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5617 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5605 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5618 |
AddIssue( $patron_1, $item->barcode ); |
5606 |
$transfer = $transfer->get_from_storage; |
5619 |
$transfer = $transfer->get_from_storage; |
5607 |
isnt( $transfer->datearrived, undef ); |
5620 |
isnt( $transfer->datearrived, undef ); |
5608 |
$hold = $hold->get_from_storage; |
5621 |
$hold = $hold->get_from_storage; |
Lines 5645-5658
subtest 'AddIssue records staff who checked out item if appropriate' => sub {
Link Here
|
5645 |
my $dt_from = dt_from_string(); |
5658 |
my $dt_from = dt_from_string(); |
5646 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5659 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5647 |
|
5660 |
|
5648 |
my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from ); |
5661 |
my $issue_1 = AddIssue( $patron, $item_1->barcode, $dt_to, undef, $dt_from ); |
5649 |
|
5662 |
|
5650 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5663 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5651 |
|
5664 |
|
5652 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5665 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5653 |
|
5666 |
|
5654 |
my $issue_2 = |
5667 |
my $issue_2 = |
5655 |
AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from ); |
5668 |
AddIssue( $patron, $item_2->barcode, $dt_to, undef, $dt_from ); |
5656 |
|
5669 |
|
5657 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5670 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5658 |
}; |
5671 |
}; |
Lines 5680-5688
subtest "Item's onloan value should be set if checked out item is checked out to
Link Here
|
5680 |
} |
5693 |
} |
5681 |
); |
5694 |
); |
5682 |
|
5695 |
|
5683 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5696 |
AddIssue( $patron_1, $item->barcode ); |
5684 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5697 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5685 |
AddIssue( $patron_2->unblessed, $item->barcode ); |
5698 |
AddIssue( $patron_2, $item->barcode ); |
5686 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5699 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5687 |
}; |
5700 |
}; |
5688 |
|
5701 |
|
Lines 5759-5765
subtest "SendCirculationAlert" => sub {
Link Here
|
5759 |
})->store; |
5772 |
})->store; |
5760 |
|
5773 |
|
5761 |
# Checkout an item, mark it returned, generate a notice |
5774 |
# Checkout an item, mark it returned, generate a notice |
5762 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
5775 |
my $issue_1 = AddIssue( $patron, $item->barcode); |
5763 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5776 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5764 |
C4::Circulation::SendCirculationAlert({ |
5777 |
C4::Circulation::SendCirculationAlert({ |
5765 |
type => 'CHECKIN', |
5778 |
type => 'CHECKIN', |
Lines 5773-5779
subtest "SendCirculationAlert" => sub {
Link Here
|
5773 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5786 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5774 |
|
5787 |
|
5775 |
# Checkout an item, mark it returned, generate a notice |
5788 |
# Checkout an item, mark it returned, generate a notice |
5776 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
5789 |
my $issue_2 = AddIssue( $patron, $item->barcode); |
5777 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5790 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5778 |
C4::Circulation::SendCirculationAlert({ |
5791 |
C4::Circulation::SendCirculationAlert({ |
5779 |
type => 'CHECKIN', |
5792 |
type => 'CHECKIN', |
Lines 5807-5813
subtest "GetSoonestRenewDate tests" => sub {
Link Here
|
5807 |
} |
5820 |
} |
5808 |
); |
5821 |
); |
5809 |
my $item = $builder->build_sample_item(); |
5822 |
my $item = $builder->build_sample_item(); |
5810 |
my $issue = AddIssue( $patron->unblessed, $item->barcode); |
5823 |
my $issue = AddIssue( $patron, $item->barcode); |
5811 |
my $datedue = dt_from_string( $issue->date_due() ); |
5824 |
my $datedue = dt_from_string( $issue->date_due() ); |
5812 |
|
5825 |
|
5813 |
# Bug 14395 |
5826 |
# Bug 14395 |
Lines 5895-5900
subtest "CanBookBeIssued + needsconfirmation message" => sub {
Link Here
|
5895 |
priority => 1, |
5908 |
priority => 1, |
5896 |
found => undef, |
5909 |
found => undef, |
5897 |
suspend => 0, |
5910 |
suspend => 0, |
|
|
5911 |
item_group_id => undef |
5898 |
}}); |
5912 |
}}); |
5899 |
|
5913 |
|
5900 |
my ( $error, $needsconfirmation, $alerts, $messages ); |
5914 |
my ( $error, $needsconfirmation, $alerts, $messages ); |