|
Lines 581-587
subtest 'balance' => sub {
Link Here
|
| 581 |
}; |
581 |
}; |
| 582 |
|
582 |
|
| 583 |
subtest "C4::Accounts::chargelostitem tests" => sub { |
583 |
subtest "C4::Accounts::chargelostitem tests" => sub { |
| 584 |
plan tests => 4; |
584 |
plan tests => 5; |
| 585 |
|
585 |
|
| 586 |
my $branch = $builder->build( { source => 'Branch' } ); |
586 |
my $branch = $builder->build( { source => 'Branch' } ); |
| 587 |
my $branchcode = $branch->{branchcode}; |
587 |
my $branchcode = $branch->{branchcode}; |
|
Lines 678-683
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
| 678 |
my $lostfine; |
678 |
my $lostfine; |
| 679 |
my $procfee; |
679 |
my $procfee; |
| 680 |
|
680 |
|
|
|
681 |
subtest "Bug 35612: chargelostitem records branch context in accountlines.branchcode" => sub { |
| 682 |
plan tests => 7; |
| 683 |
|
| 684 |
t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); |
| 685 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); |
| 686 |
|
| 687 |
my $lib_home = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 688 |
my $lib_hold = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 689 |
my $lib_issue = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 690 |
my $lib_patron = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 691 |
|
| 692 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $lib_patron } } ); |
| 693 |
|
| 694 |
my $item = $builder->build_sample_item(); |
| 695 |
$item->homebranch($lib_home)->holdingbranch($lib_hold)->store; |
| 696 |
|
| 697 |
my $issue_id = $builder->build( |
| 698 |
{ |
| 699 |
source => 'Issue', |
| 700 |
value => { |
| 701 |
borrowernumber => $patron->borrowernumber, |
| 702 |
itemnumber => $item->itemnumber, |
| 703 |
branchcode => $lib_issue, |
| 704 |
} |
| 705 |
} |
| 706 |
)->{issue_id}; |
| 707 |
|
| 708 |
my $fake_user_branch = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 709 |
my $module = Test::MockModule->new('C4::Context'); |
| 710 |
$module->mock( |
| 711 |
'userenv', |
| 712 |
sub { |
| 713 |
return { |
| 714 |
flags => 1, |
| 715 |
number => $patron->borrowernumber, |
| 716 |
branch => $fake_user_branch, |
| 717 |
}; |
| 718 |
} |
| 719 |
); |
| 720 |
|
| 721 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); |
| 722 |
t::lib::Mocks::mock_preference( 'useDefaultReplacementCost', 0 ); |
| 723 |
|
| 724 |
t::lib::Mocks::mock_preference( 'LostChargesControl', 'PatronLibrary' ); |
| 725 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' ); |
| 726 |
|
| 727 |
C4::Accounts::chargelostitem( |
| 728 |
$patron->borrowernumber, |
| 729 |
$item->itemnumber, |
| 730 |
6.12, |
| 731 |
"Lost test", |
| 732 |
{ issue_id => $issue_id } |
| 733 |
); |
| 734 |
|
| 735 |
my $lost = Koha::Account::Lines->find( |
| 736 |
{ |
| 737 |
borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', |
| 738 |
issue_id => $issue_id |
| 739 |
} |
| 740 |
); |
| 741 |
ok( $lost, "LOST line created" ); |
| 742 |
is( $lost->branchcode, $lib_patron, "LOST uses PatronLibrary context branchcode" ); |
| 743 |
|
| 744 |
$lost->delete; |
| 745 |
|
| 746 |
t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' ); |
| 747 |
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' ); |
| 748 |
|
| 749 |
C4::Accounts::chargelostitem( |
| 750 |
$patron->borrowernumber, |
| 751 |
$item->itemnumber, |
| 752 |
6.12, |
| 753 |
"Lost test 2", |
| 754 |
{ issue_id => $issue_id } |
| 755 |
); |
| 756 |
|
| 757 |
$lost = Koha::Account::Lines->find( |
| 758 |
{ |
| 759 |
borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', |
| 760 |
issue_id => $issue_id |
| 761 |
} |
| 762 |
); |
| 763 |
ok( $lost, "LOST line created (case 2)" ); |
| 764 |
is( $lost->branchcode, $lib_hold, "LOST uses item holdingbranch when HomeOrHoldingBranch=holdingbranch" ); |
| 765 |
$lost->delete; |
| 766 |
|
| 767 |
C4::Accounts::chargelostitem( |
| 768 |
$patron->borrowernumber, |
| 769 |
$item->itemnumber, |
| 770 |
6.12, |
| 771 |
"Lost test 3", |
| 772 |
{ issue_id => $issue_id, library_id => $lib_issue } |
| 773 |
); |
| 774 |
|
| 775 |
$lost = Koha::Account::Lines->find( |
| 776 |
{ |
| 777 |
borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST', |
| 778 |
issue_id => $issue_id |
| 779 |
} |
| 780 |
); |
| 781 |
|
| 782 |
ok( $lost, "LOST line created (override)" ); |
| 783 |
is( $lost->branchcode, $lib_issue, "Explicit library_id is recorded as branchcode" ); |
| 784 |
$lost->delete; |
| 785 |
|
| 786 |
C4::Accounts::chargelostitem( |
| 787 |
$patron->borrowernumber, |
| 788 |
$item->itemnumber, |
| 789 |
6.12, |
| 790 |
"Lost test dedupe", |
| 791 |
{ issue_id => $issue_id, library_id => $lib_issue } |
| 792 |
); |
| 793 |
|
| 794 |
C4::Accounts::chargelostitem( |
| 795 |
$patron->borrowernumber, |
| 796 |
$item->itemnumber, |
| 797 |
6.12, |
| 798 |
"Lost test dedupe", |
| 799 |
{ issue_id => $issue_id, library_id => $lib_issue } |
| 800 |
); |
| 801 |
|
| 802 |
is( |
| 803 |
Koha::Account::Lines->search( |
| 804 |
{ |
| 805 |
borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, |
| 806 |
debit_type_code => 'LOST', issue_id => $issue_id |
| 807 |
} |
| 808 |
)->count, |
| 809 |
1, |
| 810 |
"Dedupes LOST charges for same itemnumber + issue_id (no item_id regression)" |
| 811 |
); |
| 812 |
}; |
| 813 |
|
| 681 |
subtest "fee application tests" => sub { |
814 |
subtest "fee application tests" => sub { |
| 682 |
plan tests => 48; |
815 |
plan tests => 48; |
| 683 |
|
816 |
|
|
Lines 1046-1052
subtest "C4::Accounts::chargelostitem tests" => sub {
Link Here
|
| 1046 |
); |
1179 |
); |
| 1047 |
|
1180 |
|
| 1048 |
t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' ); |
1181 |
t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' ); |
| 1049 |
C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor" ); |
1182 |
C4::Accounts::chargelostitem( |
|
|
1183 |
$cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor", |
| 1184 |
{ library_id => $branchcode, issue_id => $cli_issue_id_4X } |
| 1185 |
); |
| 1050 |
|
1186 |
|
| 1051 |
# Lost Item Fee |
1187 |
# Lost Item Fee |
| 1052 |
$lostfine = Koha::Account::Lines->find( |
1188 |
$lostfine = Koha::Account::Lines->find( |
| 1053 |
- |
|
|