3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 53;
21 use DateTime::Duration;
24 use t::lib::TestBuilder;
26 use C4::Biblio qw( AddBiblio );
27 use C4::Circulation qw( AddIssue AddIssuingCharge AddRenewal AddReturn GetIssuingCharges GetRenewCount GetUpcomingDueIssues );
30 use C4::Reserves qw( AddReserve );
33 use Koha::DateUtils qw( dt_from_string output_pref );
38 use Koha::CirculationRules;
42 require_ok('C4::Circulation');
58 my $schema = Koha::Database->schema;
59 $schema->storage->txn_begin;
60 my $dbh = C4::Context->dbh;
62 my $builder = t::lib::TestBuilder->new();
64 $dbh->do(q|DELETE FROM issues|);
65 $dbh->do(q|DELETE FROM items|);
66 $dbh->do(q|DELETE FROM borrowers|);
67 $dbh->do(q|DELETE FROM categories|);
68 $dbh->do(q|DELETE FROM accountlines|);
69 $dbh->do(q|DELETE FROM circulation_rules|);
70 $dbh->do(q|DELETE FROM reserves|);
71 $dbh->do(q|DELETE FROM old_reserves|);
72 $dbh->do(q|DELETE FROM statistics|);
74 # Generate sample datas
75 my $itemtype = $builder->build(
76 { source => 'Itemtype',
77 value => { notforloan => undef, rentalcharge => 0 }
80 my $itemtype2 = $builder->build(
81 { source => 'Itemtype',
82 value => { notforloan => undef }
85 my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
86 my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
87 my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode};
88 my $categorycode = $builder->build({
90 value => { enrolmentfee => undef }
93 # A default issuingrule should always be present
94 Koha::CirculationRules->set_rules(
100 lengthunit => 'days',
109 my $dt_today = dt_from_string;
110 my $today = output_pref(
113 timeformat => '24hr',
118 my $dt_today2 = dt_from_string;
119 my $dur10 = DateTime::Duration->new( days => -10 );
120 $dt_today2->add_duration($dur10);
121 my $daysago10 = output_pref(
124 timeformat => '24hr',
129 # Add biblio and item
130 my $record = MARC::Record->new();
131 my $record2 = MARC::Record->new();
132 $record->append_fields(
133 MARC::Field->new( '942', '0', '0', c => $itemtype ),
134 MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) );
136 $record2->append_fields(
137 MARC::Field->new( '942', '0', '0', c => $itemtype2 ),
138 MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) );
140 my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' );
141 my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' );
143 my $barcode_1 = 'barcode_1';
144 my $barcode_2 = 'barcode_2';
145 my $item_id1 = Koha::Item->new(
147 biblionumber => $biblionumber,
148 barcode => $barcode_1,
149 itemcallnumber => 'callnumber1',
150 homebranch => $branchcode_1,
151 holdingbranch => $branchcode_1,
154 )->store->itemnumber;
155 my $item_id2 = Koha::Item->new(
157 biblionumber => $biblionumber,
158 barcode => $barcode_2,
159 itemcallnumber => 'callnumber2',
160 homebranch => $branchcode_2,
161 holdingbranch => $branchcode_2,
165 )->store->itemnumber;
168 my $borrower_id1 = Koha::Patron->new({
169 firstname => 'firstname1',
170 surname => 'surname1 ',
171 categorycode => $categorycode,
172 branchcode => $branchcode_1
173 })->store->borrowernumber;
174 my $patron_1 = Koha::Patrons->find( $borrower_id1 );
175 my $borrower_id2 = Koha::Patron->new({
176 firstname => 'firstname2',
177 surname => 'surname2 ',
178 categorycode => $categorycode,
179 branchcode => $branchcode_2,
180 })->store->borrowernumber;
181 my $patron_2 = Koha::Patrons->find( $borrower_id2 );
183 t::lib::Mocks::mock_userenv({ patron => $patron_1 });
188 my $query = " SELECT count(*) FROM issues";
189 my $sth = $dbh->prepare($query);
191 my $countissue = $sth->fetchrow_array;
192 is ($countissue ,0, "there is no issue");
193 my $issue1 = C4::Circulation::AddIssue( $patron_1, $barcode_1, $daysago10, 0, $today, '' );
194 is( ref $issue1, 'Koha::Checkout',
195 'AddIssue returns a Koha::Checkout object' );
196 my $datedue1 = dt_from_string( $issue1->date_due() );
199 qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
200 "Koha::Checkout->date_due() returns a date"
202 my $issue_id1 = $issue1->issue_id;
204 my $issue2 = C4::Circulation::AddIssue( $patron_1, 'nonexistent_barcode' );
205 is( $issue2, undef, "AddIssue returns undef if no datedue is specified" );
208 $countissue = $sth->fetchrow_array;
209 is ($countissue,1,"1 issues have been added");
211 #Test AddIssuingCharge
212 $query = " SELECT count(*) FROM accountlines";
213 $sth = $dbh->prepare($query);
215 my $countaccount = $sth->fetchrow_array;
216 is ($countaccount,0,"0 accountline exists");
217 my $checkout = Koha::Checkouts->find( $issue_id1 );
218 my $charge = C4::Circulation::AddIssuingCharge( $checkout, 10, 'RENT' );
219 is( ref( $charge ), 'Koha::Account::Line', "An issuing charge has been added" );
220 is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' );
221 my $offset = Koha::Account::Offsets->find( { debit_id => $charge->id } );
222 is( $offset->credit_id, undef, 'Offset was created');
224 $countaccount = $sth->fetchrow_array;
225 is ($countaccount,1,"1 accountline has been added");
229 my $se = Test::MockModule->new( 'C4::Context' );
230 $se->mock( 'interface', sub {return 'intranet'});
232 # Let's renew this one at a different library for statistical purposes to test Bug 17781
233 # Mocking userenv with a different branchcode
234 t::lib::Mocks::mock_userenv({ patron => $patron_2, branchcode => $branchcode_3 });
236 my $datedue3 = AddRenewal(
238 borrowernumber => $borrower_id1,
239 itemnumber => $item_id1,
240 branch => $branchcode_1,
241 datedue => $datedue1,
242 lastreneweddate => $daysago10
246 # Restoring the userenv with the original branchcode
247 t::lib::Mocks::mock_userenv({ patron => $patron_1});
251 qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
252 "AddRenewal returns a date"
255 my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 );
256 ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" );
258 subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub {
261 my $item_library = $builder->build_object( { class => 'Koha::Libraries' } );
262 my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
263 my $logged_in_user = $builder->build_object( { class => 'Koha::Patrons' } );
264 t::lib::Mocks::mock_userenv( { patron => $logged_in_user } );
266 my $OpacRenewalBranch = {
267 opacrenew => "OPACRenew",
268 checkoutbranch => $logged_in_user->branchcode,
269 patronhomebranch => $patron->branchcode,
270 itemhomebranch => $item_library->branchcode,
274 while ( my ( $syspref, $expected_branchcode ) = each %$OpacRenewalBranch ) {
276 t::lib::Mocks::mock_preference( 'OpacRenewalBranch', $syspref );
279 $se->mock( 'interface', sub { return 'opac' } );
281 my $item = $builder->build_sample_item(
282 { library => $item_library->branchcode, itype => $itemtype } );
283 my $opac_renew_issue =
284 C4::Circulation::AddIssue( $patron, $item->barcode );
288 borrowernumber => $patron->borrowernumber,
289 itemnumber => $item->itemnumber,
290 branch => "Stavromula",
291 datedue => $datedue1,
292 lastreneweddate => $daysago10
296 my $stat = Koha::Statistics->search(
297 { itemnumber => $item->itemnumber, type => 'renew' } )->next;
298 is( $stat->branch, $expected_branchcode,
299 "->renewal_branchcode is respected for OpacRenewalBranch = $syspref"
304 $se->mock( 'interface', sub { return 'intranet' } );
306 my $item = $builder->build_sample_item(
307 { library => $item_library->branchcode, itype => $itemtype } );
308 my $opac_renew_issue =
309 C4::Circulation::AddIssue( $patron, $item->barcode );
313 borrowernumber => $patron->borrowernumber,
314 itemnumber => $item->itemnumber,
315 branch => "Stavromula",
316 datedue => $datedue1,
317 lastreneweddate => $daysago10
321 my $stat = Koha::Statistics->search(
322 { itemnumber => $item->itemnumber, type => 'renew' } )->next;
323 is( $stat->branch, $logged_in_user->branchcode,
324 "->renewal_branchcode is always logged in branch for intranet"
333 my $issue3 = C4::Circulation::AddIssue( $patron_1, $barcode_1 );
334 #Without anything in DB
335 @renewcount = C4::Circulation::GetRenewCount();
338 [ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount
339 "Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
341 @renewcount = C4::Circulation::GetRenewCount(-1);
344 [ 0, 0, 0, 0, 0, 0 ], # FIXME Need to be fixed
345 "Without issuing rules and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
347 @renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
350 [ 2, 0, 0, 0, 0, 0 ],
351 "Without issuing rules and with a valid parameter, renewcount = 2, renewsallowed = undef, renewsleft = 0"
354 #With something in DB
355 @renewcount = C4::Circulation::GetRenewCount();
358 [ 0, 0, 0, 0, 0, 0 ],
359 "With issuing rules (renewal disallowed) and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
361 @renewcount = C4::Circulation::GetRenewCount(-1);
364 [ 0, 0, 0, 0, 0, 0 ],
365 "With issuing rules (renewal disallowed) and without wrong parameter, GetRenewCount returns renewcount = 0, renewsallowed = 0, renewsleft = 0"
367 @renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
370 [ 2, 0, 0, 0, 0, 0 ],
371 "With issuing rules (renewal disallowed) and with a valid parameter, Getrenewcount returns renewcount = 2, renewsallowed = 0, renewsleft = 0"
374 # Add a default rule: renewal is allowed
375 Koha::CirculationRules->set_rules(
377 categorycode => undef,
381 renewalsallowed => 3,
385 @renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
388 [ 2, 3, 1, 0, 0, 0 ],
389 "With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left"
394 borrowernumber => $borrower_id1,
395 itemnumber => $item_id1,
396 branch => $branchcode_1,
397 datedue => $datedue3,
398 lastreneweddate => $daysago10
401 @renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1);
404 [ 3, 3, 0, 0, 0, 0 ],
405 "With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left"
408 $dbh->do("DELETE FROM old_issues");
409 AddReturn($barcode_1);
410 my $return = $dbh->selectrow_hashref("SELECT DATE(returndate) AS return_date, CURRENT_DATE() AS today FROM old_issues LIMIT 1" );
411 ok( $return->{return_date} eq $return->{today}, "Item returned with no return date specified has todays date" );
413 $dbh->do("DELETE FROM old_issues");
414 C4::Circulation::AddIssue( $patron_1, $barcode_1, $daysago10, 0, $today );
415 AddReturn($barcode_1, undef, undef, dt_from_string('2014-04-01 23:42'));
416 $return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" );
417 ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" );
419 my $itemnumber = Koha::Item->new(
421 biblionumber => $biblionumber,
422 barcode => 'barcode_3',
423 itemcallnumber => 'callnumber3',
424 homebranch => $branchcode_1,
425 holdingbranch => $branchcode_1,
428 biblioitemnumber => $biblioitemnumber
430 )->store->itemnumber;
432 t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} );
433 t::lib::Mocks::mock_preference( 'CataloguingLog', 1 );
434 my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count();
436 AddReturn( 'barcode_3', $branchcode_1 );
437 my $item = Koha::Items->find( $itemnumber );
438 ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' );
440 my $updatenotforloanstatusoncheckin = "
447 t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin );
448 AddReturn( 'barcode_3', $branchcode_1 );
449 $item = Koha::Items->find( $itemnumber );
450 ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} );
451 my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count();
452 is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged");
454 AddReturn( 'barcode_3', $branchcode_1 );
455 $item = Koha::Items->find( $itemnumber );
456 ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} );
458 # Change the returning item to an item type without a rule
459 Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store;
460 Koha::Items->find( $itemnumber )->notforloan( 1 )->store;
461 AddReturn( 'barcode_3', $branchcode_1 );
462 $item = Koha::Items->find( $itemnumber );
463 ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} );
465 t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' );
466 $item->notforloan(1)->store;
467 AddReturn( 'barcode_3', $branchcode_1 );
468 $item = Koha::Items->find( $itemnumber );
469 ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 with setting "1: ONLYMESSAGE"} );
471 my $itemnumber2 = Koha::Item->new(
473 biblionumber => $biblionumber,
474 barcode => 'barcode_4',
475 itemcallnumber => 'callnumber4',
476 homebranch => $branchcode_1,
477 holdingbranch => $branchcode_1,
481 )->store->itemnumber;
483 t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} );
484 AddReturn( 'barcode_4', $branchcode_1 );
485 my $item2 = Koha::Items->find( $itemnumber2 );
486 ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' );
488 t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' );
489 $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count();
490 AddReturn( 'barcode_4', $branchcode_1 );
491 $item2 = Koha::Items->find( $itemnumber2 );
492 is( $item2->location, 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} );
493 is( $item2->permanent_location, 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} );
494 $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count();
495 is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged");
496 AddReturn( 'barcode_4', $branchcode_1 );
497 $item2 = Koha::Items->find( $itemnumber2 );
498 ok( $item2->location eq 'GEN', q{UpdateItemLocationOnCheckin does not update location value from 'GEN' with setting "FIC: GEN"} );
500 t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' );
501 AddReturn( 'barcode_4', $branchcode_1 );
502 $item2 = Koha::Items->find( $itemnumber2 );
503 ok( $item2->location eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART"} );
504 Koha::Item::Transfer->new({
505 itemnumber => $itemnumber2,
506 frombranch => $branchcode_2,
507 tobranch => $branchcode_1,
508 datesent => '2020-01-01'
510 AddReturn( 'barcode_4', $branchcode_1 );
511 $item2 = Koha::Items->find( $itemnumber2 );
512 ok( $item2->location eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART" when transfer filled} );
514 ok( $item2->permanent_location eq 'GEN', q{UpdateItemLocationOnCheckin does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} );
515 AddIssue( $patron_1, 'barcode_4', $daysago10,0, $today, '' );
516 $item2 = Koha::Items->find( $itemnumber2 );
517 ok( $item2->location eq 'GEN', q{Location updates from 'CART' to permanent location on issue} );
519 t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" );
520 AddReturn( 'barcode_4', $branchcode_1 );
521 $item2 = Koha::Items->find( $itemnumber2 );
522 ok( $item2->location eq '', q{UpdateItemLocationOnCheckin updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} );
523 AddReturn( 'barcode_4', $branchcode_1 );
524 $item2 = Koha::Items->find( $itemnumber2 );
525 ok( $item2->location eq 'PROC' , q{UpdateItemLocationOnCheckin updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} );
526 ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} );
527 AddReturn( 'barcode_4', $branchcode_1 );
528 $item2 = Koha::Items->find( $itemnumber2 );
529 ok( $item2->location eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } );
530 ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } );
533 my $itemnumber3 = Koha::Item->new(
535 biblionumber => $biblionumber,
536 barcode => 'barcode_5',
537 itemcallnumber => 'callnumber5',
538 homebranch => $branchcode_1,
539 holdingbranch => $branchcode_1,
543 )->store->itemnumber;
545 t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' );
546 AddReturn( 'barcode_5', $branchcode_1 );
547 my $item3 = Koha::Items->find( $itemnumber3 );
548 is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location value from NULL (i.e. the item has no shelving location set) to 'CART' with setting "_ALL_: CART"} );
552 # Bug 14640 - Cancel the hold on checking out if asked
553 Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store;
554 my $reserve_id = AddReserve(
556 branchcode => $branchcode_1,
557 borrowernumber => $borrower_id1,
558 biblionumber => $biblionumber,
564 ok( $reserve_id, 'The reserve should have been inserted' );
565 AddIssue( $patron_2, $barcode_1, dt_from_string, 'cancel' );
566 my $hold = Koha::Holds->find( $reserve_id );
567 is( $hold, undef, 'The reserve should have been correctly cancelled' );
570 t::lib::Mocks::mock_preference('UnseenRenewals', 1);
571 # Add a default circ rule: 3 unseen renewals allowed
572 Koha::CirculationRules->set_rules(
574 categorycode => undef,
578 renewalsallowed => 10,
579 unseen_renewals_allowed => 3
584 my $unseen_library = $builder->build_object( { class => 'Koha::Libraries' } );
585 my $unseen_patron = $builder->build_object( { class => 'Koha::Patrons' } );
586 my $unseen_item = $builder->build_sample_item(
587 { library => $unseen_library->branchcode, itype => $itemtype } );
588 my $unseen_issue = C4::Circulation::AddIssue( $unseen_patron, $unseen_item->barcode );
590 # Does an unseen renewal increment the issue's count
591 my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
594 borrowernumber => $unseen_patron->borrowernumber,
595 itemnumber => $unseen_item->itemnumber,
596 branch => $branchcode_1,
600 my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
601 is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' );
603 # Does a seen renewal reset the unseen count
606 borrowernumber => $unseen_patron->borrowernumber,
607 itemnumber => $unseen_item->itemnumber,
608 branch => $branchcode_1,
612 my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3];
613 is( $unseen_reset, 0, 'seen renewal resets the unseen count' );
615 my $itemnumber4 = Koha::Item->new(
617 biblionumber => $biblionumber,
618 barcode => 'barcode_6',
619 itemcallnumber => 'callnumber6',
620 homebranch => $branchcode_1,
621 holdingbranch => $branchcode_1,
626 )->store->itemnumber;
628 t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} );
629 AddIssue( $patron_2, 'barcode_6', dt_from_string );
630 $item = Koha::Items->find( $itemnumber4 );
631 ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' );
633 t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', '-1: 0' );
634 AddReturn( 'barcode_6', $branchcode_1 );
635 my $test = AddIssue( $patron_2, 'barcode_6', dt_from_string );
636 $item = Koha::Items->find( $itemnumber4 );
637 ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "-1: 0"} );
639 AddIssue( $patron_2, 'barcode_6', dt_from_string );
640 AddReturn( 'barcode_6', $branchcode_1 );
641 $item = Koha::Items->find( $itemnumber4 );
642 ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} );
645 $schema->storage->txn_rollback;