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 800-806
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
800 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
804 |
my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue ); |
801 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
805 |
my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal ); |
802 |
AddIssue( |
806 |
AddIssue( |
803 |
$renewing_borrower_obj->unblessed, |
807 |
$renewing_borrower_obj, |
804 |
$item_7->barcode, |
808 |
$item_7->barcode, |
805 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
809 |
Koha::DateUtils::output_pref({str=>$issue_6->date_due, dateformat =>'iso'}), |
806 |
0, |
810 |
0, |
Lines 828-834
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
828 |
} |
832 |
} |
829 |
); |
833 |
); |
830 |
|
834 |
|
831 |
my $issue_4 = AddIssue( $renewing_borrower_obj->unblessed, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
835 |
my $issue_4 = AddIssue( $renewing_borrower_obj, $item_4->barcode, undef, undef, undef, undef, { auto_renew => 1 } ); |
832 |
my $info; |
836 |
my $info; |
833 |
( $renewokay, $error, $info ) = |
837 |
( $renewokay, $error, $info ) = |
834 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
838 |
CanBookBeRenewed( $renewing_borrower_obj, $issue_4 ); |
Lines 958-964
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
958 |
|
962 |
|
959 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
963 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
960 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
964 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
961 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
965 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
962 |
|
966 |
|
963 |
Koha::CirculationRules->set_rules( |
967 |
Koha::CirculationRules->set_rules( |
964 |
{ |
968 |
{ |
Lines 1087-1093
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1087 |
|
1091 |
|
1088 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1092 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1089 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1093 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1090 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1094 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1091 |
|
1095 |
|
1092 |
Koha::CirculationRules->set_rules( |
1096 |
Koha::CirculationRules->set_rules( |
1093 |
{ |
1097 |
{ |
Lines 1197-1203
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1197 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1201 |
# Patron is expired and BlockExpiredPatronOpacActions=0 |
1198 |
# => auto renew is allowed |
1202 |
# => auto renew is allowed |
1199 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1203 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); |
1200 |
my $issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1204 |
my $issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1201 |
( $renewokay, $error ) = |
1205 |
( $renewokay, $error ) = |
1202 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1206 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1203 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1207 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1208-1214
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1208 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1212 |
# Patron is expired and BlockExpiredPatronOpacActions=1 |
1209 |
# => auto renew is not allowed |
1213 |
# => auto renew is not allowed |
1210 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1214 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1211 |
$issue = AddIssue( $expired_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1215 |
$issue = AddIssue( $expired_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1212 |
( $renewokay, $error ) = |
1216 |
( $renewokay, $error ) = |
1213 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1217 |
CanBookBeRenewed( $expired_borrower_obj, $issue ); |
1214 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1218 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1218-1224
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1218 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1222 |
# Patron is not expired and BlockExpiredPatronOpacActions=1 |
1219 |
# => auto renew is allowed |
1223 |
# => auto renew is allowed |
1220 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1224 |
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); |
1221 |
$issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1225 |
$issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1222 |
( $renewokay, $error ) = |
1226 |
( $renewokay, $error ) = |
1223 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1227 |
CanBookBeRenewed( $renewing_borrower_obj, $issue ); |
1224 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
1228 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 1237-1243
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1237 |
|
1241 |
|
1238 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1242 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
1239 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1243 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
1240 |
my $issue = AddIssue( $renewing_borrower_obj->unblessed, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1244 |
my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
1241 |
Koha::CirculationRules->set_rules( |
1245 |
Koha::CirculationRules->set_rules( |
1242 |
{ |
1246 |
{ |
1243 |
categorycode => undef, |
1247 |
categorycode => undef, |
Lines 1489-1495
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1489 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1493 |
my $recall_item1 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1490 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1494 |
my $recall_item2 = $builder->build_sample_item({ biblionumber => $recall_biblio->biblionumber }); |
1491 |
|
1495 |
|
1492 |
my $recall_issue = AddIssue( $renewing_borrower_obj->unblessed, $recall_item1->barcode ); |
1496 |
my $recall_issue = AddIssue( $renewing_borrower_obj, $recall_item1->barcode ); |
1493 |
|
1497 |
|
1494 |
# item-level and this item: renewal not allowed |
1498 |
# item-level and this item: renewal not allowed |
1495 |
my $recall = Koha::Recall->new({ |
1499 |
my $recall = Koha::Recall->new({ |
Lines 1570-1576
subtest "GetUpcomingDueIssues" => sub {
Link Here
|
1570 |
); |
1574 |
); |
1571 |
|
1575 |
|
1572 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1576 |
my $a_borrower_borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1573 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber )->unblessed; |
1577 |
my $a_borrower = Koha::Patrons->find( $a_borrower_borrowernumber ); |
1574 |
|
1578 |
|
1575 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1579 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
1576 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
1580 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
Lines 1647-1653
subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
Link Here
|
1647 |
|
1651 |
|
1648 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1652 |
my $borrowernumber = Koha::Patron->new(\%a_borrower_data)->store->borrowernumber; |
1649 |
|
1653 |
|
1650 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
1654 |
my $borrower = Koha::Patrons->find( $borrowernumber ); |
1651 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1655 |
my $issue = AddIssue( $borrower, $item->barcode ); |
1652 |
UpdateFine( |
1656 |
UpdateFine( |
1653 |
{ |
1657 |
{ |
Lines 1733-1739
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1733 |
branchcode => $library2->{branchcode}, |
1737 |
branchcode => $library2->{branchcode}, |
1734 |
})->store->borrowernumber; |
1738 |
})->store->borrowernumber; |
1735 |
|
1739 |
|
1736 |
my $issue = AddIssue( $borrower1->unblessed, $item_1->barcode ); |
1740 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
1737 |
|
1741 |
|
1738 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1742 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
1739 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
1743 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with no hold on the record' ); |
Lines 1900-1906
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1900 |
branchcode => $branch, |
1904 |
branchcode => $branch, |
1901 |
})->store; |
1905 |
})->store; |
1902 |
|
1906 |
|
1903 |
my $issue = AddIssue( $borrower->unblessed, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1907 |
my $issue = AddIssue( $borrower, $item->barcode, undef, undef, undef, undef, { onsite_checkout => 1 } ); |
1904 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1908 |
my ( $renewed, $error ) = CanBookBeRenewed( $borrower, $issue ); |
1905 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1909 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew on-site checkout' ); |
1906 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1910 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
Lines 1920-1926
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1920 |
); |
1924 |
); |
1921 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1925 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode} } } ); |
1922 |
|
1926 |
|
1923 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
1927 |
my $issue = AddIssue( $patron, $item->barcode ); |
1924 |
UpdateFine( |
1928 |
UpdateFine( |
1925 |
{ |
1929 |
{ |
1926 |
issue_id => $issue->id, |
1930 |
issue_id => $issue->id, |
Lines 1979-1985
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
Link Here
|
1979 |
|
1983 |
|
1980 |
set_userenv($holdingbranch); |
1984 |
set_userenv($holdingbranch); |
1981 |
|
1985 |
|
1982 |
my $issue = AddIssue( $patron_1->unblessed, $item->barcode ); |
1986 |
my $issue = AddIssue( $patron_1, $item->barcode ); |
1983 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1987 |
is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); |
1984 |
|
1988 |
|
1985 |
my ( $error, $question, $alerts ); |
1989 |
my ( $error, $question, $alerts ); |
Lines 2054-2061
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
2054 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2058 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2055 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2059 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2056 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2060 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
2057 |
my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2061 |
|
2058 |
my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
2062 |
my $patron_1 = $builder->build_object({ |
|
|
2063 |
class => 'Koha::Patrons', |
2064 |
value => { categorycode => $patron_category->{categorycode} } |
2065 |
}); |
2066 |
|
2067 |
my $patron_2 = $builder->build_object({ |
2068 |
class => 'Koha::Patrons', |
2069 |
value => { categorycode => $patron_category->{categorycode} } |
2070 |
}); |
2071 |
|
2059 |
|
2072 |
|
2060 |
my $item = $builder->build_sample_item( |
2073 |
my $item = $builder->build_sample_item( |
2061 |
{ |
2074 |
{ |
Lines 2140-2146
subtest 'AddIssue | recalls' => sub {
Link Here
|
2140 |
pickup_library_id => $patron1->branchcode, |
2153 |
pickup_library_id => $patron1->branchcode, |
2141 |
} |
2154 |
} |
2142 |
)->store; |
2155 |
)->store; |
2143 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2156 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2144 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2157 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2145 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2158 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2146 |
AddReturn( $item->barcode, $item->homebranch ); |
2159 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2154-2160
subtest 'AddIssue | recalls' => sub {
Link Here
|
2154 |
pickup_library_id => $patron2->branchcode, |
2167 |
pickup_library_id => $patron2->branchcode, |
2155 |
} |
2168 |
} |
2156 |
)->store; |
2169 |
)->store; |
2157 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2170 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2158 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2171 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2159 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2172 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2160 |
AddReturn( $item->barcode, $item->homebranch ); |
2173 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2169-2175
subtest 'AddIssue | recalls' => sub {
Link Here
|
2169 |
} |
2182 |
} |
2170 |
)->store; |
2183 |
)->store; |
2171 |
$recall3->set_waiting; |
2184 |
$recall3->set_waiting; |
2172 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2185 |
AddIssue( $patron1, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2173 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2186 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2174 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2187 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2175 |
AddReturn( $item->barcode, $item->homebranch ); |
2188 |
AddReturn( $item->barcode, $item->homebranch ); |
Lines 2194-2200
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2194 |
due_date => $custom_date_due, |
2207 |
due_date => $custom_date_due, |
2195 |
})->store; |
2208 |
})->store; |
2196 |
|
2209 |
|
2197 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
2210 |
my $issue = AddIssue( $patron, $item->barcode ); |
2198 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2211 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2199 |
|
2212 |
|
2200 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2213 |
$patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 2208-2214
subtest 'AddIssue & illrequests.due_date' => sub {
Link Here
|
2208 |
due_date => $custom_date_due, |
2221 |
due_date => $custom_date_due, |
2209 |
})->store; |
2222 |
})->store; |
2210 |
|
2223 |
|
2211 |
$issue = AddIssue( $patron->unblessed, $item->barcode ); |
2224 |
$issue = AddIssue( $patron, $item->barcode ); |
2212 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2225 |
is( $issue->date_due, $expected_date_due, 'Custom illrequest date due has been set for this issue'); |
2213 |
}; |
2226 |
}; |
2214 |
|
2227 |
|
Lines 2251-2257
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
2251 |
|
2264 |
|
2252 |
# Patron cannot issue item_1, they have overdues |
2265 |
# Patron cannot issue item_1, they have overdues |
2253 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2266 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
2254 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, $yesterday ); # Add an overdue |
2267 |
my $issue = AddIssue( $patron, $item_1->barcode, $yesterday ); # Add an overdue |
2255 |
|
2268 |
|
2256 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2269 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
2257 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2270 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2360-2366
subtest 'MultipleReserves' => sub {
Link Here
|
2360 |
branchcode => $branch, |
2373 |
branchcode => $branch, |
2361 |
); |
2374 |
); |
2362 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2375 |
my $patron = Koha::Patron->new(\%renewing_borrower_data)->store; |
2363 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode); |
2376 |
my $issue = AddIssue( $patron, $item_1->barcode); |
2364 |
my $datedue = dt_from_string( $issue->date_due() ); |
2377 |
my $datedue = dt_from_string( $issue->date_due() ); |
2365 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2378 |
is (defined $issue->date_due(), 1, "item 1 checked out"); |
2366 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
2379 |
my $borrowing_borrowernumber = Koha::Checkouts->find({ itemnumber => $item_1->itemnumber })->borrowernumber; |
Lines 2473-2479
subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub {
Link Here
|
2473 |
); |
2486 |
); |
2474 |
|
2487 |
|
2475 |
my ( $error, $question, $alerts ); |
2488 |
my ( $error, $question, $alerts ); |
2476 |
my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2489 |
my $issue = AddIssue( $patron, $item_1->barcode, dt_from_string->add( days => 1 ) ); |
2477 |
|
2490 |
|
2478 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2491 |
t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); |
2479 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
2492 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); |
Lines 2557-2564
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2557 |
my $now = dt_from_string; |
2570 |
my $now = dt_from_string; |
2558 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2571 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2559 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2572 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2560 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2573 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2561 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2574 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2562 |
; # Add another overdue |
2575 |
; # Add another overdue |
2563 |
|
2576 |
|
2564 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
2577 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); |
Lines 2596-2603
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2596 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2609 |
{ borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); |
2597 |
|
2610 |
|
2598 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2611 |
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); |
2599 |
AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue |
2612 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2600 |
AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) |
2613 |
AddIssue( $patron, $item_2->barcode, $ten_days_ago ) |
2601 |
; # Add another overdue |
2614 |
; # Add another overdue |
2602 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2615 |
AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2603 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
2616 |
$suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); |
Lines 2880-2886
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2880 |
} |
2893 |
} |
2881 |
); |
2894 |
); |
2882 |
|
2895 |
|
2883 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2896 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2884 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2897 |
my ( undef, $message ) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2885 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2898 |
is( $message->{WasReturned} && exists $message->{ForeverDebarred}, 1, 'Forever debarred message for Addreturn when overdue'); |
2886 |
|
2899 |
|
Lines 2898-2904
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2898 |
} |
2911 |
} |
2899 |
); |
2912 |
); |
2900 |
|
2913 |
|
2901 |
AddIssue( $patron->unblessed, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2914 |
AddIssue( $patron, $item_1->barcode, $now->clone->subtract( days => 1 ) ); |
2902 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2915 |
(undef, $message) = AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); |
2903 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2916 |
is( $message->{WasReturned} && exists $message->{PrevDebarred}, 1, 'Previously debarred message for Addreturn when overdue'); |
2904 |
}; |
2917 |
}; |
Lines 2935-2941
subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
Link Here
|
2935 |
); |
2948 |
); |
2936 |
|
2949 |
|
2937 |
my ( $error, $question, $alerts ); |
2950 |
my ( $error, $question, $alerts ); |
2938 |
my $issue = AddIssue( $patron1->unblessed, $item->barcode ); |
2951 |
my $issue = AddIssue( $patron1, $item->barcode ); |
2939 |
|
2952 |
|
2940 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2953 |
t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); |
2941 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
2954 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); |
Lines 2996-3020
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2996 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
3009 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2997 |
|
3010 |
|
2998 |
# No return date specified, today will be used => 10 days overdue charged |
3011 |
# No return date specified, today will be used => 10 days overdue charged |
2999 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3012 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3000 |
AddReturn( $item->barcode, $library->{branchcode} ); |
3013 |
AddReturn( $item->barcode, $library->{branchcode} ); |
3001 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
3014 |
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); |
3002 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3015 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3003 |
|
3016 |
|
3004 |
# specify return date 5 days before => no overdue charged |
3017 |
# specify return date 5 days before => no overdue charged |
3005 |
AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago |
3018 |
AddIssue( $patron, $item->barcode, $five_days_ago ); # date due was 5d ago |
3006 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
3019 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); |
3007 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3020 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); |
3008 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3021 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
3009 |
|
3022 |
|
3010 |
# specify return date 5 days later => 5 days overdue charged |
3023 |
# specify return date 5 days later => 5 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}, undef, $five_days_ago ); |
3025 |
AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); |
3013 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
3026 |
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); |
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 later, specify exemptfine => no overdue charge |
3029 |
# specify return date 5 days later, specify exemptfine => no overdue charge |
3017 |
AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3030 |
AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3018 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); |
3031 |
AddReturn( $item->barcode, $library->{branchcode}, 1, $five_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; |
Lines 3023-3029
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3023 |
|
3036 |
|
3024 |
plan tests => 3; |
3037 |
plan tests => 3; |
3025 |
|
3038 |
|
3026 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3039 |
my $issue = AddIssue( $patron, $item->barcode, $ten_days_ago ); # date due was 10d ago |
3027 |
|
3040 |
|
3028 |
# Fake fines cronjob on this checkout |
3041 |
# Fake fines cronjob on this checkout |
3029 |
my ($fine) = |
3042 |
my ($fine) = |
Lines 3061-3067
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3061 |
|
3074 |
|
3062 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3075 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3063 |
|
3076 |
|
3064 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3077 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3065 |
|
3078 |
|
3066 |
# Fake fines cronjob on this checkout |
3079 |
# Fake fines cronjob on this checkout |
3067 |
my ($fine) = |
3080 |
my ($fine) = |
Lines 3086-3092
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3086 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3099 |
my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); |
3087 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3100 |
is( $lines->count, 0, "Overdue fine accountline has been removed"); |
3088 |
|
3101 |
|
3089 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago |
3102 |
$issue = AddIssue( $patron, $item->barcode, $two_days_ago ); # date due was 2d ago |
3090 |
|
3103 |
|
3091 |
# Fake fines cronjob on this checkout |
3104 |
# Fake fines cronjob on this checkout |
3092 |
($fine) = |
3105 |
($fine) = |
Lines 3152-3158
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3152 |
|
3165 |
|
3153 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3166 |
t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); |
3154 |
|
3167 |
|
3155 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago |
3168 |
my $issue = AddIssue( $patron, $item->barcode, $one_day_ago ); # date due was 1d ago |
3156 |
|
3169 |
|
3157 |
# Fake fines cronjob on this checkout |
3170 |
# Fake fines cronjob on this checkout |
3158 |
my ($fine) = |
3171 |
my ($fine) = |
Lines 3185-3191
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3185 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3198 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
3186 |
|
3199 |
|
3187 |
my $due_date = dt_from_string; |
3200 |
my $due_date = dt_from_string; |
3188 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3201 |
my $issue = AddIssue( $patron, $item->barcode, $due_date ); |
3189 |
|
3202 |
|
3190 |
# Add fine |
3203 |
# Add fine |
3191 |
UpdateFine( |
3204 |
UpdateFine( |
Lines 3210-3216
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3210 |
ok( !$accountline, 'accountline removed as expected' ); |
3223 |
ok( !$accountline, 'accountline removed as expected' ); |
3211 |
|
3224 |
|
3212 |
# Re-issue |
3225 |
# Re-issue |
3213 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
3226 |
$issue = AddIssue( $patron, $item->barcode, $due_date ); |
3214 |
|
3227 |
|
3215 |
# Add fine |
3228 |
# Add fine |
3216 |
UpdateFine( |
3229 |
UpdateFine( |
Lines 3366-3372
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3366 |
); |
3379 |
); |
3367 |
|
3380 |
|
3368 |
# Issue the item |
3381 |
# Issue the item |
3369 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3382 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3370 |
|
3383 |
|
3371 |
# Mark item as lost |
3384 |
# Mark item as lost |
3372 |
$item->itemlost(3)->store; |
3385 |
$item->itemlost(3)->store; |
Lines 3416-3422
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3416 |
); |
3429 |
); |
3417 |
|
3430 |
|
3418 |
# Issue the item |
3431 |
# Issue the item |
3419 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3432 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3420 |
|
3433 |
|
3421 |
# Mark item as lost |
3434 |
# Mark item as lost |
3422 |
$item->itemlost(3)->store; |
3435 |
$item->itemlost(3)->store; |
Lines 3476-3482
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3476 |
); |
3489 |
); |
3477 |
|
3490 |
|
3478 |
# Issue the item |
3491 |
# Issue the item |
3479 |
$issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
3492 |
$issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
3480 |
|
3493 |
|
3481 |
# Mark item as lost |
3494 |
# Mark item as lost |
3482 |
$item->itemlost(3)->store; |
3495 |
$item->itemlost(3)->store; |
Lines 3541-3547
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3541 |
); |
3554 |
); |
3542 |
|
3555 |
|
3543 |
# Issue the item |
3556 |
# Issue the item |
3544 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3557 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3545 |
|
3558 |
|
3546 |
# Fake fines cronjob on this checkout |
3559 |
# Fake fines cronjob on this checkout |
3547 |
my ($fine) = |
3560 |
my ($fine) = |
Lines 3624-3630
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3624 |
); |
3637 |
); |
3625 |
|
3638 |
|
3626 |
# Issue the item |
3639 |
# Issue the item |
3627 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3640 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3628 |
|
3641 |
|
3629 |
# Fake fines cronjob on this checkout |
3642 |
# Fake fines cronjob on this checkout |
3630 |
my ($fine) = |
3643 |
my ($fine) = |
Lines 3706-3712
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3706 |
); |
3719 |
); |
3707 |
|
3720 |
|
3708 |
# Issue the item |
3721 |
# Issue the item |
3709 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode , $ten_days_ago); |
3722 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode , $ten_days_ago); |
3710 |
|
3723 |
|
3711 |
# Fake fines cronjob on this checkout |
3724 |
# Fake fines cronjob on this checkout |
3712 |
my ($fine) = |
3725 |
my ($fine) = |
Lines 3803-3809
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
3803 |
); |
3816 |
); |
3804 |
|
3817 |
|
3805 |
# Issue the item |
3818 |
# Issue the item |
3806 |
my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); |
3819 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, $ten_days_ago ); |
3807 |
|
3820 |
|
3808 |
# Fake fines cronjob on this checkout |
3821 |
# Fake fines cronjob on this checkout |
3809 |
my ($fine) = |
3822 |
my ($fine) = |
Lines 4156-4162
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
4156 |
} |
4169 |
} |
4157 |
); |
4170 |
); |
4158 |
|
4171 |
|
4159 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago |
4172 |
my $issue = AddIssue( $patron, $item->barcode, $five_days_go ); # date due was 10d ago |
4160 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4173 |
my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
4161 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4174 |
is( output_pref({ str => $actualissue->date_due, dateonly => 1}), output_pref({ str => $five_days_go, dateonly => 1}), "First issue works"); |
4162 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
4175 |
my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron, $item->barcode, $ten_days_go, undef, undef, undef); |
Lines 4448-4454
subtest 'AddReturn | recalls' => sub {
Link Here
|
4448 |
}); |
4461 |
}); |
4449 |
|
4462 |
|
4450 |
# this item can fill a recall with pickup at this branch |
4463 |
# this item can fill a recall with pickup at this branch |
4451 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4464 |
AddIssue( $patron1, $item1->barcode ); |
4452 |
my $recall1 = Koha::Recall->new( |
4465 |
my $recall1 = Koha::Recall->new( |
4453 |
{ patron_id => $patron2->borrowernumber, |
4466 |
{ patron_id => $patron2->borrowernumber, |
4454 |
biblio_id => $item1->biblionumber, |
4467 |
biblio_id => $item1->biblionumber, |
Lines 4462-4468
subtest 'AddReturn | recalls' => sub {
Link Here
|
4462 |
$recall1->set_cancelled; |
4475 |
$recall1->set_cancelled; |
4463 |
|
4476 |
|
4464 |
# this item can fill a recall but needs transfer |
4477 |
# this item can fill a recall but needs transfer |
4465 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4478 |
AddIssue( $patron1, $item1->barcode ); |
4466 |
$recall1 = Koha::Recall->new( |
4479 |
$recall1 = Koha::Recall->new( |
4467 |
{ patron_id => $patron2->borrowernumber, |
4480 |
{ patron_id => $patron2->borrowernumber, |
4468 |
biblio_id => $item1->biblionumber, |
4481 |
biblio_id => $item1->biblionumber, |
Lines 4476-4482
subtest 'AddReturn | recalls' => sub {
Link Here
|
4476 |
$recall1->set_cancelled; |
4489 |
$recall1->set_cancelled; |
4477 |
|
4490 |
|
4478 |
# this item is already in transit, do not ask to transfer |
4491 |
# this item is already in transit, do not ask to transfer |
4479 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4492 |
AddIssue( $patron1, $item1->barcode ); |
4480 |
$recall1 = Koha::Recall->new( |
4493 |
$recall1 = Koha::Recall->new( |
4481 |
{ patron_id => $patron2->borrowernumber, |
4494 |
{ patron_id => $patron2->borrowernumber, |
4482 |
biblio_id => $item1->biblionumber, |
4495 |
biblio_id => $item1->biblionumber, |
Lines 4554-4560
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4554 |
$context->mock( userenv => { branch => $library->id } ); |
4567 |
$context->mock( userenv => { branch => $library->id } ); |
4555 |
|
4568 |
|
4556 |
# Check the item out |
4569 |
# Check the item out |
4557 |
AddIssue( $patron->unblessed, $item->barcode ); |
4570 |
AddIssue( $patron, $item->barcode ); |
4558 |
|
4571 |
|
4559 |
throws_ok { |
4572 |
throws_ok { |
4560 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
4573 |
AddRenewal( $patron->borrowernumber, $item->itemnumber, $library->id, undef, {break=>"the_renewal"} ); |
Lines 4612-4618
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
4612 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4625 |
is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); |
4613 |
|
4626 |
|
4614 |
AddReturn( $item->id, $library->id, undef, $date ); |
4627 |
AddReturn( $item->id, $library->id, undef, $date ); |
4615 |
AddIssue( $patron->unblessed, $item->barcode, $now ); |
4628 |
AddIssue( $patron, $item->barcode, $now ); |
4616 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4629 |
AddRenewal( $patron->id, $item->id, $library->id, undef, undef, 1 ); |
4617 |
my $lines_skipped = Koha::Account::Lines->search({ |
4630 |
my $lines_skipped = Koha::Account::Lines->search({ |
4618 |
borrowernumber => $patron->id, |
4631 |
borrowernumber => $patron->id, |
Lines 4636-4642
subtest 'AddRenewal() adds to renewals' => sub {
Link Here
|
4636 |
set_userenv( $library->unblessed ); |
4649 |
set_userenv( $library->unblessed ); |
4637 |
|
4650 |
|
4638 |
# Check the item out |
4651 |
# Check the item out |
4639 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
4652 |
my $issue = AddIssue( $patron, $item->barcode ); |
4640 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4653 |
is(ref($issue), 'Koha::Checkout', 'Issue added'); |
4641 |
|
4654 |
|
4642 |
# Renew item |
4655 |
# Renew item |
Lines 4721-4727
subtest 'Incremented fee tests' => sub {
Link Here
|
4721 |
|
4734 |
|
4722 |
# Daily Tests |
4735 |
# Daily Tests |
4723 |
my $issue = |
4736 |
my $issue = |
4724 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4737 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4725 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4738 |
my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4726 |
is( |
4739 |
is( |
4727 |
$accountline->amount + 0, |
4740 |
$accountline->amount + 0, |
Lines 4742-4748
subtest 'Incremented fee tests' => sub {
Link Here
|
4742 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4755 |
t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' ); |
4743 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4756 |
$itemtype->rentalcharge_daily_calendar(1)->store(); |
4744 |
$issue = |
4757 |
$issue = |
4745 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4758 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4746 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4759 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4747 |
is( |
4760 |
is( |
4748 |
$accountline->amount + 0, |
4761 |
$accountline->amount + 0, |
Lines 4773-4779
subtest 'Incremented fee tests' => sub {
Link Here
|
4773 |
description => 'Test holiday' |
4786 |
description => 'Test holiday' |
4774 |
); |
4787 |
); |
4775 |
$issue = |
4788 |
$issue = |
4776 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4789 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4777 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4790 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4778 |
is( |
4791 |
is( |
4779 |
$accountline->amount + 0, |
4792 |
$accountline->amount + 0, |
Lines 4794-4800
subtest 'Incremented fee tests' => sub {
Link Here
|
4794 |
$itemtype->rentalcharge(2)->store; |
4807 |
$itemtype->rentalcharge(2)->store; |
4795 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4808 |
is( $itemtype->rentalcharge + 0, 2, 'Rental charge updated and retreived correctly' ); |
4796 |
$issue = |
4809 |
$issue = |
4797 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4810 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4798 |
my $accountlines = |
4811 |
my $accountlines = |
4799 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4812 |
Koha::Account::Lines->search( { itemnumber => $item->id } ); |
4800 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
4813 |
is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly" ); |
Lines 4826-4832
subtest 'Incremented fee tests' => sub {
Link Here
|
4826 |
|
4839 |
|
4827 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4840 |
$itemtype->rentalcharge_hourly_calendar(0)->store(); |
4828 |
$issue = |
4841 |
$issue = |
4829 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4842 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4830 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4843 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4831 |
is( |
4844 |
is( |
4832 |
$accountline->amount + 0, |
4845 |
$accountline->amount + 0, |
Lines 4846-4852
subtest 'Incremented fee tests' => sub {
Link Here
|
4846 |
|
4859 |
|
4847 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4860 |
$itemtype->rentalcharge_hourly_calendar(1)->store(); |
4848 |
$issue = |
4861 |
$issue = |
4849 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4862 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4850 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4863 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4851 |
is( |
4864 |
is( |
4852 |
$accountline->amount + 0, |
4865 |
$accountline->amount + 0, |
Lines 4866-4872
subtest 'Incremented fee tests' => sub {
Link Here
|
4866 |
|
4879 |
|
4867 |
$calendar->delete_holiday( weekday => $closed_day ); |
4880 |
$calendar->delete_holiday( weekday => $closed_day ); |
4868 |
$issue = |
4881 |
$issue = |
4869 |
AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
4882 |
AddIssue( $patron, $item->barcode, $dt_to, undef, $dt_from ); |
4870 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4883 |
$accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); |
4871 |
is( |
4884 |
is( |
4872 |
$accountline->amount + 0, |
4885 |
$accountline->amount + 0, |
Lines 4980-4986
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4980 |
); |
4993 |
); |
4981 |
|
4994 |
|
4982 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4995 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
4983 |
AddIssue( $patron->unblessed, $item->barcode ); |
4996 |
AddIssue( $patron, $item->barcode ); |
4984 |
|
4997 |
|
4985 |
my $accountline = Koha::Account::Line->new( |
4998 |
my $accountline = Koha::Account::Line->new( |
4986 |
{ |
4999 |
{ |
Lines 4995-5001
subtest 'Do not return on renewal (LOST charge)' => sub {
Link Here
|
4995 |
)->store(); |
5008 |
)->store(); |
4996 |
|
5009 |
|
4997 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
5010 |
# AddRenewal doesn't call _FixAccountForLostAndFound |
4998 |
AddIssue( $patron->unblessed, $item->barcode ); |
5011 |
AddIssue( $patron, $item->barcode ); |
4999 |
|
5012 |
|
5000 |
is( $patron->checkouts->count, 1, |
5013 |
is( $patron->checkouts->count, 1, |
5001 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
5014 |
'Renewal should not return the item even if a LOST payment has been made earlier' |
Lines 5101-5107
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5101 |
replacementprice => '42', |
5114 |
replacementprice => '42', |
5102 |
} |
5115 |
} |
5103 |
); |
5116 |
); |
5104 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5117 |
my $issue = AddIssue( $patron, $item->barcode ); |
5105 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5118 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5106 |
$item->_result->itemlost(1); |
5119 |
$item->_result->itemlost(1); |
5107 |
$item->_result->itemlost_on( $lost_on ); |
5120 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5136-5142
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5136 |
replacementprice => '42', |
5149 |
replacementprice => '42', |
5137 |
} |
5150 |
} |
5138 |
); |
5151 |
); |
5139 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5152 |
my $issue = AddIssue( $patron, $item->barcode ); |
5140 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5153 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5141 |
$item->_result->itemlost(1); |
5154 |
$item->_result->itemlost(1); |
5142 |
$item->_result->itemlost_on( $lost_on ); |
5155 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5171-5177
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5171 |
replacementprice => '42', |
5184 |
replacementprice => '42', |
5172 |
} |
5185 |
} |
5173 |
); |
5186 |
); |
5174 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5187 |
my $issue = AddIssue( $patron, $item->barcode ); |
5175 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5188 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5176 |
$item->_result->itemlost(1); |
5189 |
$item->_result->itemlost(1); |
5177 |
$item->_result->itemlost_on( $lost_on ); |
5190 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5206-5212
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
5206 |
replacementprice => '42', |
5219 |
replacementprice => '42', |
5207 |
} |
5220 |
} |
5208 |
); |
5221 |
); |
5209 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5222 |
my $issue = AddIssue( $patron, $item->barcode ); |
5210 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5223 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5211 |
$item->_result->itemlost(1); |
5224 |
$item->_result->itemlost(1); |
5212 |
$item->_result->itemlost_on( $lost_on ); |
5225 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5294-5300
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5294 |
replacementprice => '42', |
5307 |
replacementprice => '42', |
5295 |
} |
5308 |
} |
5296 |
); |
5309 |
); |
5297 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5310 |
my $issue = AddIssue( $patron, $item->barcode ); |
5298 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5311 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5299 |
$item->_result->itemlost(1); |
5312 |
$item->_result->itemlost(1); |
5300 |
$item->_result->itemlost_on( $lost_on ); |
5313 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5308-5314
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5308 |
)->next; |
5321 |
)->next; |
5309 |
ok( $a, "Found accountline for lost fee" ); |
5322 |
ok( $a, "Found accountline for lost fee" ); |
5310 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5323 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5311 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5324 |
$issue = AddIssue( $patron2, $item->barcode ); |
5312 |
$a = $a->get_from_storage; |
5325 |
$a = $a->get_from_storage; |
5313 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5326 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5314 |
$a->delete; |
5327 |
$a->delete; |
Lines 5330-5336
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5330 |
replacementprice => '42', |
5343 |
replacementprice => '42', |
5331 |
} |
5344 |
} |
5332 |
); |
5345 |
); |
5333 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5346 |
my $issue = AddIssue( $patron, $item->barcode ); |
5334 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5347 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5335 |
$item->_result->itemlost(1); |
5348 |
$item->_result->itemlost(1); |
5336 |
$item->_result->itemlost_on( $lost_on ); |
5349 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5344-5350
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5344 |
)->next; |
5357 |
)->next; |
5345 |
ok( $a, "Found accountline for lost fee" ); |
5358 |
ok( $a, "Found accountline for lost fee" ); |
5346 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5359 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5347 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5360 |
$issue = AddIssue( $patron2, $item->barcode ); |
5348 |
$a = $a->get_from_storage; |
5361 |
$a = $a->get_from_storage; |
5349 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5362 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
5350 |
$a->delete; |
5363 |
$a->delete; |
Lines 5365-5371
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5365 |
replacementprice => '42', |
5378 |
replacementprice => '42', |
5366 |
} |
5379 |
} |
5367 |
); |
5380 |
); |
5368 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5381 |
my $issue = AddIssue( $patron, $item->barcode ); |
5369 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5382 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5370 |
$item->_result->itemlost(1); |
5383 |
$item->_result->itemlost(1); |
5371 |
$item->_result->itemlost_on( $lost_on ); |
5384 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5379-5385
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5379 |
)->next; |
5392 |
)->next; |
5380 |
ok( $a, "Found accountline for lost fee" ); |
5393 |
ok( $a, "Found accountline for lost fee" ); |
5381 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5394 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5382 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5395 |
$issue = AddIssue( $patron2, $item->barcode ); |
5383 |
$a = $a->get_from_storage; |
5396 |
$a = $a->get_from_storage; |
5384 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5397 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5385 |
$a->delete; |
5398 |
$a->delete; |
Lines 5400-5406
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5400 |
replacementprice => '42', |
5413 |
replacementprice => '42', |
5401 |
} |
5414 |
} |
5402 |
); |
5415 |
); |
5403 |
my $issue = AddIssue( $patron->unblessed, $item->barcode ); |
5416 |
my $issue = AddIssue( $patron, $item->barcode ); |
5404 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5417 |
LostItem( $item->itemnumber, 'cli', 0 ); |
5405 |
$item->_result->itemlost(1); |
5418 |
$item->_result->itemlost(1); |
5406 |
$item->_result->itemlost_on( $lost_on ); |
5419 |
$item->_result->itemlost_on( $lost_on ); |
Lines 5415-5421
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub {
Link Here
|
5415 |
$a = $a->next; |
5428 |
$a = $a->next; |
5416 |
ok( $a, "Found accountline for lost fee" ); |
5429 |
ok( $a, "Found accountline for lost fee" ); |
5417 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5430 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
5418 |
$issue = AddIssue( $patron2->unblessed, $item->barcode ); |
5431 |
$issue = AddIssue( $patron2, $item->barcode ); |
5419 |
$a = $a->get_from_storage; |
5432 |
$a = $a->get_from_storage; |
5420 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5433 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
5421 |
$a->delete; |
5434 |
$a->delete; |
Lines 5501-5507
subtest 'Checkout should correctly terminate a transfer' => sub {
Link Here
|
5501 |
is( $transfer->reason, 'Reserve' ); |
5514 |
is( $transfer->reason, 'Reserve' ); |
5502 |
|
5515 |
|
5503 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5516 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
5504 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5517 |
AddIssue( $patron_1, $item->barcode ); |
5505 |
$transfer = $transfer->get_from_storage; |
5518 |
$transfer = $transfer->get_from_storage; |
5506 |
isnt( $transfer->datearrived, undef ); |
5519 |
isnt( $transfer->datearrived, undef ); |
5507 |
$hold = $hold->get_from_storage; |
5520 |
$hold = $hold->get_from_storage; |
Lines 5544-5557
subtest 'AddIssue records staff who checked out item if appropriate' => sub {
Link Here
|
5544 |
my $dt_from = dt_from_string(); |
5557 |
my $dt_from = dt_from_string(); |
5545 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5558 |
my $dt_to = dt_from_string()->add( days => 7 ); |
5546 |
|
5559 |
|
5547 |
my $issue_1 = AddIssue( $patron->unblessed, $item_1->barcode, $dt_to, undef, $dt_from ); |
5560 |
my $issue_1 = AddIssue( $patron, $item_1->barcode, $dt_to, undef, $dt_from ); |
5548 |
|
5561 |
|
5549 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5562 |
is( $issue_1->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" ); |
5550 |
|
5563 |
|
5551 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5564 |
t::lib::Mocks::mock_preference('RecordStaffUserOnCheckout', 1); |
5552 |
|
5565 |
|
5553 |
my $issue_2 = |
5566 |
my $issue_2 = |
5554 |
AddIssue( $patron->unblessed, $item_2->barcode, $dt_to, undef, $dt_from ); |
5567 |
AddIssue( $patron, $item_2->barcode, $dt_to, undef, $dt_from ); |
5555 |
|
5568 |
|
5556 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5569 |
is( $issue_2->issuer->borrowernumber, $issuer->borrowernumber, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); |
5557 |
}; |
5570 |
}; |
Lines 5579-5587
subtest "Item's onloan value should be set if checked out item is checked out to
Link Here
|
5579 |
} |
5592 |
} |
5580 |
); |
5593 |
); |
5581 |
|
5594 |
|
5582 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
5595 |
AddIssue( $patron_1, $item->barcode ); |
5583 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5596 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); |
5584 |
AddIssue( $patron_2->unblessed, $item->barcode ); |
5597 |
AddIssue( $patron_2, $item->barcode ); |
5585 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5598 |
ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); |
5586 |
}; |
5599 |
}; |
5587 |
|
5600 |
|
Lines 5658-5664
subtest "SendCirculationAlert" => sub {
Link Here
|
5658 |
})->store; |
5671 |
})->store; |
5659 |
|
5672 |
|
5660 |
# Checkout an item, mark it returned, generate a notice |
5673 |
# Checkout an item, mark it returned, generate a notice |
5661 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
5674 |
my $issue_1 = AddIssue( $patron, $item->barcode); |
5662 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5675 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5663 |
C4::Circulation::SendCirculationAlert({ |
5676 |
C4::Circulation::SendCirculationAlert({ |
5664 |
type => 'CHECKIN', |
5677 |
type => 'CHECKIN', |
Lines 5672-5678
subtest "SendCirculationAlert" => sub {
Link Here
|
5672 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5685 |
is($notice->to_address, $patron->smsalertnumber, "Letter has the correct to_address set to smsalertnumber for SMS type notices"); |
5673 |
|
5686 |
|
5674 |
# Checkout an item, mark it returned, generate a notice |
5687 |
# Checkout an item, mark it returned, generate a notice |
5675 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
5688 |
my $issue_2 = AddIssue( $patron, $item->barcode); |
5676 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5689 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
5677 |
C4::Circulation::SendCirculationAlert({ |
5690 |
C4::Circulation::SendCirculationAlert({ |
5678 |
type => 'CHECKIN', |
5691 |
type => 'CHECKIN', |
Lines 5706-5712
subtest "GetSoonestRenewDate tests" => sub {
Link Here
|
5706 |
} |
5719 |
} |
5707 |
); |
5720 |
); |
5708 |
my $item = $builder->build_sample_item(); |
5721 |
my $item = $builder->build_sample_item(); |
5709 |
my $issue = AddIssue( $patron->unblessed, $item->barcode); |
5722 |
my $issue = AddIssue( $patron, $item->barcode); |
5710 |
my $datedue = dt_from_string( $issue->date_due() ); |
5723 |
my $datedue = dt_from_string( $issue->date_due() ); |
5711 |
|
5724 |
|
5712 |
# Bug 14395 |
5725 |
# Bug 14395 |
Lines 5776-5781
subtest "CanBookBeIssued + needsconfirmation message" => sub {
Link Here
|
5776 |
priority => 1, |
5789 |
priority => 1, |
5777 |
found => undef, |
5790 |
found => undef, |
5778 |
suspend => 0, |
5791 |
suspend => 0, |
|
|
5792 |
item_group_id => undef |
5779 |
}}); |
5793 |
}}); |
5780 |
|
5794 |
|
5781 |
my ( $error, $needsconfirmation, $alerts, $messages ); |
5795 |
my ( $error, $needsconfirmation, $alerts, $messages ); |