|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 49; |
20 |
use Test::More tests => 50; |
| 21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 77-82
my $itemtype = $builder->build(
Link Here
|
| 77 |
value => { notforloan => undef, rentalcharge => 0 } |
77 |
value => { notforloan => undef, rentalcharge => 0 } |
| 78 |
} |
78 |
} |
| 79 |
)->{itemtype}; |
79 |
)->{itemtype}; |
|
|
80 |
my $itemtype2 = $builder->build( |
| 81 |
{ source => 'Itemtype', |
| 82 |
value => { notforloan => undef } |
| 83 |
} |
| 84 |
)->{itemtype}; |
| 80 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
85 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 81 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
86 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 82 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
87 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
|
Lines 123-132
my $daysago10 = output_pref(
Link Here
|
| 123 |
|
128 |
|
| 124 |
# Add biblio and item |
129 |
# Add biblio and item |
| 125 |
my $record = MARC::Record->new(); |
130 |
my $record = MARC::Record->new(); |
|
|
131 |
my $record2 = MARC::Record->new(); |
| 126 |
$record->append_fields( |
132 |
$record->append_fields( |
|
|
133 |
MARC::Field->new( '942', '0', '0', c => $itemtype ), |
| 134 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
| 135 |
|
| 136 |
$record2->append_fields( |
| 137 |
MARC::Field->new( '942', '0', '0', c => $itemtype2 ), |
| 127 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
138 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
| 128 |
|
139 |
|
| 129 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
140 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
|
|
141 |
my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' ); |
| 130 |
|
142 |
|
| 131 |
my $barcode_1 = 'barcode_1'; |
143 |
my $barcode_1 = 'barcode_1'; |
| 132 |
my $barcode_2 = 'barcode_2'; |
144 |
my $barcode_2 = 'barcode_2'; |
|
Lines 385-391
my $itemnumber = Koha::Item->new(
Link Here
|
| 385 |
homebranch => $branchcode_1, |
397 |
homebranch => $branchcode_1, |
| 386 |
holdingbranch => $branchcode_1, |
398 |
holdingbranch => $branchcode_1, |
| 387 |
notforloan => 1, |
399 |
notforloan => 1, |
| 388 |
itype => $itemtype |
400 |
itype => $itemtype, |
|
|
401 |
biblioitemnumber => $biblioitemnumber |
| 389 |
}, |
402 |
}, |
| 390 |
)->store->itemnumber; |
403 |
)->store->itemnumber; |
| 391 |
|
404 |
|
|
Lines 397-412
AddReturn( 'barcode_3', $branchcode_1 );
Link Here
|
| 397 |
my $item = Koha::Items->find( $itemnumber ); |
410 |
my $item = Koha::Items->find( $itemnumber ); |
| 398 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
411 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
| 399 |
|
412 |
|
| 400 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); |
413 |
my $updatenotforloanstatusoncheckin = " |
|
|
414 |
_ALL_:\n |
| 415 |
1: 0\n |
| 416 |
9: 1\n\n |
| 417 |
$itemtype:\n |
| 418 |
1: 9 |
| 419 |
"; |
| 420 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
| 401 |
AddReturn( 'barcode_3', $branchcode_1 ); |
421 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 402 |
$item = Koha::Items->find( $itemnumber ); |
422 |
$item = Koha::Items->find( $itemnumber ); |
| 403 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); |
423 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} ); |
| 404 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
424 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
| 405 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
425 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
| 406 |
|
426 |
|
| 407 |
AddReturn( 'barcode_3', $branchcode_1 ); |
427 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 408 |
$item = Koha::Items->find( $itemnumber ); |
428 |
$item = Koha::Items->find( $itemnumber ); |
| 409 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
429 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} ); |
|
|
430 |
|
| 431 |
# Change the returning item to an item type without a rule |
| 432 |
Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store; |
| 433 |
Koha::Items->find( $itemnumber )->notforloan( 1 )->store; |
| 434 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 435 |
$item = Koha::Items->find( $itemnumber ); |
| 436 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} ); |
| 410 |
|
437 |
|
| 411 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' ); |
438 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' ); |
| 412 |
$item->notforloan(1)->store; |
439 |
$item->notforloan(1)->store; |
|
Lines 496-501
is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val
Link Here
|
| 496 |
|
523 |
|
| 497 |
|
524 |
|
| 498 |
# Bug 14640 - Cancel the hold on checking out if asked |
525 |
# Bug 14640 - Cancel the hold on checking out if asked |
|
|
526 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
| 499 |
my $reserve_id = AddReserve( |
527 |
my $reserve_id = AddReserve( |
| 500 |
{ |
528 |
{ |
| 501 |
branchcode => $branchcode_1, |
529 |
branchcode => $branchcode_1, |
| 502 |
- |
|
|