|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 67; |
20 |
use Test::More tests => 39; |
| 21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 490-578
is(
Link Here
|
| 490 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
490 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
| 491 |
); |
491 |
); |
| 492 |
|
492 |
|
| 493 |
my $itemnumber2 = Koha::Item->new( |
|
|
| 494 |
{ |
| 495 |
biblionumber => $biblionumber, |
| 496 |
barcode => 'barcode_4', |
| 497 |
itemcallnumber => 'callnumber4', |
| 498 |
homebranch => $branchcode_1, |
| 499 |
holdingbranch => $branchcode_1, |
| 500 |
location => 'FIC', |
| 501 |
itype => $itemtype |
| 502 |
} |
| 503 |
)->store->itemnumber; |
| 504 |
|
| 505 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', q{} ); |
| 506 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} ); |
| 507 |
|
| 508 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 509 |
my $item2 = Koha::Items->find( $itemnumber2 ); |
| 510 |
ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); |
| 511 |
|
| 512 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); |
| 513 |
$log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
| 514 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 515 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 516 |
is( $item2->location, 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
| 517 |
is( $item2->permanent_location, 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
| 518 |
$log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
| 519 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
| 520 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 521 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 522 |
ok( $item2->location eq 'GEN', q{UpdateItemLocationOnCheckin does not update location value from 'GEN' with setting "FIC: GEN"} ); |
| 523 |
|
| 524 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' ); |
| 525 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 526 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 527 |
ok( $item2->location eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART"} ); |
| 528 |
Koha::Item::Transfer->new({ |
| 529 |
itemnumber => $itemnumber2, |
| 530 |
frombranch => $branchcode_2, |
| 531 |
tobranch => $branchcode_1, |
| 532 |
datesent => '2020-01-01' |
| 533 |
})->store; |
| 534 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 535 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 536 |
ok( $item2->location eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART" when transfer filled} ); |
| 537 |
|
| 538 |
ok( $item2->permanent_location eq 'GEN', q{UpdateItemLocationOnCheckin does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} ); |
| 539 |
AddIssue( $patron_1, 'barcode_4', $daysago10,0, $today, '' ); |
| 540 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 541 |
ok( $item2->location eq 'GEN', q{Location updates from 'CART' to permanent location on issue} ); |
| 542 |
|
| 543 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" ); |
| 544 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 545 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 546 |
ok( $item2->location eq '', q{UpdateItemLocationOnCheckin updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} ); |
| 547 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 548 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 549 |
ok( $item2->location eq 'PROC' , q{UpdateItemLocationOnCheckin updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
| 550 |
ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
| 551 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 552 |
$item2 = Koha::Items->find( $itemnumber2 ); |
| 553 |
ok( $item2->location eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } ); |
| 554 |
ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } ); |
| 555 |
|
| 556 |
# Bug 28472 |
| 557 |
my $itemnumber3 = Koha::Item->new( |
| 558 |
{ |
| 559 |
biblionumber => $biblionumber, |
| 560 |
barcode => 'barcode_5', |
| 561 |
itemcallnumber => 'callnumber5', |
| 562 |
homebranch => $branchcode_1, |
| 563 |
holdingbranch => $branchcode_1, |
| 564 |
location => undef, |
| 565 |
itype => $itemtype |
| 566 |
} |
| 567 |
)->store->itemnumber; |
| 568 |
|
| 569 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' ); |
| 570 |
AddReturn( 'barcode_5', $branchcode_1 ); |
| 571 |
my $item3 = Koha::Items->find( $itemnumber3 ); |
| 572 |
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"} ); |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
# Bug 14640 - Cancel the hold on checking out if asked |
493 |
# Bug 14640 - Cancel the hold on checking out if asked |
| 577 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
494 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
| 578 |
my $reserve_id = AddReserve( |
495 |
my $reserve_id = AddReserve( |
|
Lines 665-778
AddReturn( 'barcode_6', $branchcode_1 );
Link Here
|
| 665 |
$item = Koha::Items->find( $itemnumber4 ); |
582 |
$item = Koha::Items->find( $itemnumber4 ); |
| 666 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
583 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
| 667 |
|
584 |
|
| 668 |
# Bug 21159 - Update item shelving location on checkout |
|
|
| 669 |
my $itemnumber5 = Koha::Item->new( |
| 670 |
{ |
| 671 |
biblionumber => $biblionumber, |
| 672 |
barcode => 'barcode_7', |
| 673 |
itemcallnumber => 'callnumber3', |
| 674 |
homebranch => $branchcode_1, |
| 675 |
holdingbranch => $branchcode_1, |
| 676 |
location => 'FIC', |
| 677 |
itype => $itemtype |
| 678 |
}, |
| 679 |
)->store->itemnumber; |
| 680 |
|
| 681 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', q{} ); |
| 682 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} ); |
| 683 |
AddIssue( $patron_1, 'barcode_7' ); |
| 684 |
my $item5 = Koha::Items->find($itemnumber5); |
| 685 |
ok( $item5->location eq 'FIC', 'UpdateItemLocationOnCheckout does not modify value when not enabled' ); |
| 686 |
|
| 687 |
#--- |
| 688 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 689 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', 'FIC: GEN' ); |
| 690 |
$log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 691 |
AddIssue( $patron_1, 'barcode_7' ); |
| 692 |
$item5 = Koha::Items->find($itemnumber5); |
| 693 |
is( |
| 694 |
$item5->location, 'GEN', |
| 695 |
q{UpdateItemLocationOnCheckout updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} |
| 696 |
); |
| 697 |
is( |
| 698 |
$item5->permanent_location, 'GEN', |
| 699 |
q{UpdateItemLocationOnCheckout updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} |
| 700 |
); |
| 701 |
$log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 702 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckout is not logged" ); |
| 703 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 704 |
AddIssue( $patron_1, 'barcode_7' ); |
| 705 |
$item5 = Koha::Items->find($itemnumber5); |
| 706 |
ok( |
| 707 |
$item5->location eq 'GEN', |
| 708 |
q{UpdateItemLocationOnCheckout does not update location value from 'GEN' with setting "FIC: GEN"} |
| 709 |
); |
| 710 |
|
| 711 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
| 712 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 713 |
AddIssue( $patron_1, 'barcode_7' ); |
| 714 |
$item5 = Koha::Items->find($itemnumber5); |
| 715 |
ok( |
| 716 |
$item5->location eq 'CART', |
| 717 |
q{UpdateItemLocationOnCheckout updates location value from 'GEN' with setting "_ALL_: CART"} |
| 718 |
); |
| 719 |
ok( |
| 720 |
$item5->permanent_location eq 'GEN', |
| 721 |
q{UpdateItemLocationOnCheckout does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} |
| 722 |
); |
| 723 |
|
| 724 |
$item5->location('GEN')->store; |
| 725 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" ); |
| 726 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 727 |
AddIssue( $patron_1, 'barcode_7' ); |
| 728 |
$item5 = Koha::Items->find($itemnumber5); |
| 729 |
ok( |
| 730 |
$item5->location eq '', |
| 731 |
q{UpdateItemLocationOnCheckout updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} |
| 732 |
); |
| 733 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 734 |
AddIssue( $patron_1, 'barcode_7' ); |
| 735 |
$item5 = Koha::Items->find($itemnumber5); |
| 736 |
ok( |
| 737 |
$item5->location eq 'PROC', |
| 738 |
q{UpdateItemLocationOnCheckout updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} |
| 739 |
); |
| 740 |
ok( |
| 741 |
$item5->permanent_location eq '', |
| 742 |
q{UpdateItemLocationOnCheckout does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} |
| 743 |
); |
| 744 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 745 |
AddIssue( $patron_1, 'barcode_7' ); |
| 746 |
$item5 = Koha::Items->find($itemnumber5); |
| 747 |
ok( |
| 748 |
$item5->location eq '', |
| 749 |
q{UpdateItemLocationOnCheckout updates location value from 'PROC' to '' with setting "PROC: _PERM_" } |
| 750 |
); |
| 751 |
ok( |
| 752 |
$item5->permanent_location eq '', |
| 753 |
q{UpdateItemLocationOnCheckout does not update permanent_location from '' with setting "PROC: _PERM_" } |
| 754 |
); |
| 755 |
|
| 756 |
# Bug 28472 |
| 757 |
my $itemnumber6 = Koha::Item->new( |
| 758 |
{ |
| 759 |
biblionumber => $biblionumber, |
| 760 |
barcode => 'barcode_8', |
| 761 |
itemcallnumber => 'callnumber5', |
| 762 |
homebranch => $branchcode_1, |
| 763 |
holdingbranch => $branchcode_1, |
| 764 |
location => undef, |
| 765 |
itype => $itemtype |
| 766 |
} |
| 767 |
)->store->itemnumber; |
| 768 |
|
| 769 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
| 770 |
AddIssue( $patron_1, 'barcode_8' ); |
| 771 |
my $item6 = Koha::Items->find($itemnumber6); |
| 772 |
is( |
| 773 |
$item6->location, 'CART', |
| 774 |
q{UpdateItemLocationOnCheckout updates location value from NULL (i.e. the item has no shelving location set) to 'CART' with setting "_ALL_: CART"} |
| 775 |
); |
| 776 |
|
| 777 |
#End transaction |
585 |
#End transaction |
| 778 |
$schema->storage->txn_rollback; |
586 |
$schema->storage->txn_rollback; |
| 779 |
- |
|
|