|
Lines 17-25
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 48; |
20 |
use Test::More tests => 59; |
| 21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
| 22 |
|
|
|
| 23 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
| 24 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
| 25 |
|
24 |
|
|
Lines 75-83
$dbh->do(q|DELETE FROM statistics|);
Link Here
|
| 75 |
# Generate sample datas |
74 |
# Generate sample datas |
| 76 |
my $itemtype = $builder->build( |
75 |
my $itemtype = $builder->build( |
| 77 |
{ source => 'Itemtype', |
76 |
{ source => 'Itemtype', |
| 78 |
value => { notforloan => undef, rentalcharge => 0 } |
77 |
value => { notforloan => undef, rentalcharge => 0, updatenotforloan => 1 } |
|
|
78 |
} |
| 79 |
)->{itemtype}; |
| 80 |
my $itemtype2 = $builder->build( |
| 81 |
{ source => 'Itemtype', |
| 82 |
value => { notforloan => undef, updatenotforloan => 0 } |
| 79 |
} |
83 |
} |
| 80 |
)->{itemtype}; |
84 |
)->{itemtype}; |
|
|
85 |
|
| 81 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
86 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 82 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
87 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 83 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
88 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
|
Lines 124-133
my $daysago10 = output_pref(
Link Here
|
| 124 |
|
129 |
|
| 125 |
# Add biblio and item |
130 |
# Add biblio and item |
| 126 |
my $record = MARC::Record->new(); |
131 |
my $record = MARC::Record->new(); |
|
|
132 |
my $record2 = MARC::Record->new(); |
| 127 |
$record->append_fields( |
133 |
$record->append_fields( |
|
|
134 |
MARC::Field->new( '942', '0', '0', c => $itemtype ), |
| 135 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
| 136 |
|
| 137 |
$record2->append_fields( |
| 138 |
MARC::Field->new( '942', '0', '0', c => $itemtype2 ), |
| 128 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
139 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
| 129 |
|
140 |
|
| 130 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
141 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
|
|
142 |
my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' ); |
| 131 |
|
143 |
|
| 132 |
my $barcode_1 = 'barcode_1'; |
144 |
my $barcode_1 = 'barcode_1'; |
| 133 |
my $barcode_2 = 'barcode_2'; |
145 |
my $barcode_2 = 'barcode_2'; |
|
Lines 391-397
my $itemnumber = Koha::Item->new(
Link Here
|
| 391 |
homebranch => $branchcode_1, |
403 |
homebranch => $branchcode_1, |
| 392 |
holdingbranch => $branchcode_1, |
404 |
holdingbranch => $branchcode_1, |
| 393 |
notforloan => 1, |
405 |
notforloan => 1, |
| 394 |
itype => $itemtype |
406 |
itype => $itemtype, |
|
|
407 |
biblioitemnumber => $biblioitemnumber |
| 395 |
}, |
408 |
}, |
| 396 |
)->store->itemnumber; |
409 |
)->store->itemnumber; |
| 397 |
|
410 |
|
|
Lines 409-414
AddReturn( 'barcode_3', $branchcode_1 );
Link Here
|
| 409 |
$item = Koha::Items->find( $itemnumber ); |
422 |
$item = Koha::Items->find( $itemnumber ); |
| 410 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
423 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
| 411 |
|
424 |
|
|
|
425 |
# Bug 25560: Exclude itemtypes from UpdateNotForLoanStatusOnCheckin syspref |
| 426 |
|
| 427 |
# item-level_itypes syspref is set to 'Specific item' |
| 428 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '1' ); |
| 429 |
|
| 430 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 |
| 431 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; |
| 432 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0} ); |
| 433 |
|
| 434 |
# Keep items.itype on an itemtype with updatenotforloan = 1 |
| 435 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itemtype has a updatenotforloan set to 1}); |
| 436 |
|
| 437 |
# items.notforloan status should change as the effective itemtype (item-level itype) |
| 438 |
# does allow notforloan status to be updated on checkin |
| 439 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); |
| 440 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 441 |
$item = Koha::Items->find( $itemnumber ); |
| 442 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does update the notforloan value when ithe effective itemtype (specific item) has an enabled updatenotforloan flag} ); |
| 443 |
|
| 444 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 1 |
| 445 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber)->store; |
| 446 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber })->itemtype)->updatenotforloan eq 1, q{Biblio-level itemtype has a updatenotforloan set to 1 }); |
| 447 |
|
| 448 |
# Set items.itype to an itemtype with updatenotforloanstatus = 0 |
| 449 |
Koha::Items->find( $itemnumber )->itype($itemtype2)->store; |
| 450 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itemtype has an updatenotforloan set to 0 }); |
| 451 |
|
| 452 |
# items.notforloan status shouldn't change as the effective itemtype (item-level itype) |
| 453 |
# does not allow notforloan status to be updated on checkin |
| 454 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9'); |
| 455 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 456 |
$item = Koha::Items->find( $itemnumber ); |
| 457 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value when th effective item type (specific item) has a disabled updatenotforloan flag} ); |
| 458 |
|
| 459 |
# item-level_itypes syspref is set to 'bibliographic record' |
| 460 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '0' ); |
| 461 |
|
| 462 |
# Check items.itype is still an itemtype with updatenotforloan = 0 |
| 463 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itype has a updatenotforloanstatuscheckin set to 0}); |
| 464 |
|
| 465 |
# items.notforloan status should change as the effective itemtype (biblio-level itemtype) |
| 466 |
# does allow notforloan status to be updated on checkin |
| 467 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 468 |
$item = Koha::Items->find( $itemnumber ); |
| 469 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value when the effective item type (bibliographic record) has an enabled updatenotforloan flag} ); |
| 470 |
|
| 471 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 |
| 472 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; |
| 473 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0 }); |
| 474 |
|
| 475 |
# Set items.itype to an itemtype with updatenotforloan = 1 |
| 476 |
Koha::Items->find( $itemnumber )->itype($itemtype)->store; |
| 477 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itype has an updatenotforloan set to 1}); |
| 478 |
|
| 479 |
# items.notforloan status shouldn't change as the effective itemtype (biblio-level itemtype) |
| 480 |
# doesn't allow notforloan status to be updated at checkin |
| 481 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); |
| 482 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 483 |
$item = Koha::Items->find( $itemnumber ); |
| 484 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloanvalue when the effective itemtype (bibliographic record) has a disabled updatenotforloan flag} ); |
| 485 |
|
| 412 |
my $itemnumber2 = Koha::Item->new( |
486 |
my $itemnumber2 = Koha::Item->new( |
| 413 |
{ |
487 |
{ |
| 414 |
biblionumber => $biblionumber, |
488 |
biblionumber => $biblionumber, |
|
Lines 488-493
is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val
Link Here
|
| 488 |
|
562 |
|
| 489 |
|
563 |
|
| 490 |
# Bug 14640 - Cancel the hold on checking out if asked |
564 |
# Bug 14640 - Cancel the hold on checking out if asked |
|
|
565 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
| 491 |
my $reserve_id = AddReserve( |
566 |
my $reserve_id = AddReserve( |
| 492 |
{ |
567 |
{ |
| 493 |
branchcode => $branchcode_1, |
568 |
branchcode => $branchcode_1, |