| 
      
            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 => 3;  | 
              584 | 
                  plan tests => 4;  | 
            
        
          | 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 683-688
          subtest "C4::Accounts::chargelostitem tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 683 | 
           | 
          683 | 
           | 
        
        
          | 684 | 
                  t::lib::Mocks::mock_preference( 'item-level_itypes',         '1' );  | 
          684 | 
                  t::lib::Mocks::mock_preference( 'item-level_itypes',         '1' );  | 
        
        
          | 685 | 
                  t::lib::Mocks::mock_preference( 'useDefaultReplacementCost', '0' );  | 
          685 | 
                  t::lib::Mocks::mock_preference( 'useDefaultReplacementCost', '0' );  | 
        
            
               | 
               | 
              686 | 
                      t::lib::Mocks::mock_preference( 'LostChargesControl',        'ItemHomeLibrary' );  | 
            
        
          | 686 | 
           | 
          687 | 
           | 
        
        
          | 687 | 
                  C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor" );  | 
          688 | 
                  C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber1, 0, "Perdedor" );  | 
        
        
          | 688 | 
                  $lostfine = Koha::Account::Lines->find(  | 
          689 | 
                  $lostfine = Koha::Account::Lines->find(  | 
        
  
    | 
      
            Lines 887-895
          subtest "C4::Accounts::chargelostitem tests" => sub {
      
      
        Link Here
      
     | 
  
        
          | 887 | 
                  $procfee->delete();  | 
          888 | 
                  $procfee->delete();  | 
        
        
          | 888 | 
              };  | 
          889 | 
              };  | 
        
        
          | 889 | 
           | 
          890 | 
           | 
        
            
               | 
               | 
              891 | 
                  subtest "further processing fee application tests" => sub { | 
            
            
              | 892 | 
                      plan tests => 8;  | 
            
            
              | 893 | 
               | 
            
            
              | 894 | 
                      my $branch_1 = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
            
              | 895 | 
                      my $branch_2 = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
            
              | 896 | 
                      my $branch_3 = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
            
              | 897 | 
                      my $branch_4 = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
            
              | 898 | 
               | 
            
            
              | 899 | 
                      my $one_rule = Koha::CirculationRules->set_rule(  | 
            
            
              | 900 | 
                          { | 
            
            
              | 901 | 
                              itemtype  => undef, branchcode => $branch_1->branchcode, rule_value => 1,  | 
            
            
              | 902 | 
                              rule_name => 'lost_item_processing_fee'  | 
            
            
              | 903 | 
                          }  | 
            
            
              | 904 | 
                      );  | 
            
            
              | 905 | 
                      my $two_rule = Koha::CirculationRules->set_rule(  | 
            
            
              | 906 | 
                          { | 
            
            
              | 907 | 
                              itemtype  => undef, branchcode => $branch_2->branchcode, rule_value => 2,  | 
            
            
              | 908 | 
                              rule_name => 'lost_item_processing_fee'  | 
            
            
              | 909 | 
                          }  | 
            
            
              | 910 | 
                      );  | 
            
            
              | 911 | 
                      my $three_rule = Koha::CirculationRules->set_rule(  | 
            
            
              | 912 | 
                          { | 
            
            
              | 913 | 
                              itemtype  => undef, branchcode => $branch_3->branchcode, rule_value => 3,  | 
            
            
              | 914 | 
                              rule_name => 'lost_item_processing_fee'  | 
            
            
              | 915 | 
                          }  | 
            
            
              | 916 | 
                      );  | 
            
            
              | 917 | 
                      my $four_rule = Koha::CirculationRules->set_rule(  | 
            
            
              | 918 | 
                          { | 
            
            
              | 919 | 
                              itemtype  => undef, branchcode => $branch_4->branchcode, rule_value => 4,  | 
            
            
              | 920 | 
                              rule_name => 'lost_item_processing_fee'  | 
            
            
              | 921 | 
                          }  | 
            
            
              | 922 | 
                      );  | 
            
            
              | 923 | 
               | 
            
            
              | 924 | 
                      t::lib::Mocks::mock_preference( 'LostChargesControl', 'PatronLibrary' );  | 
            
            
              | 925 | 
                      diag("Test LostChargesControl = PatronLibrary"); | 
            
            
              | 926 | 
               | 
            
            
              | 927 | 
                      my $borrower =  | 
            
            
              | 928 | 
                          $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $branch_1->branchcode } } ); | 
            
            
              | 929 | 
                      my $item = $builder->build_sample_item( { homebranch => $branch_4->branchcode } ); | 
            
            
              | 930 | 
                      C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '1', "Branch 1 used" );  | 
            
            
              | 931 | 
                      $procfee = Koha::Account::Lines->find(  | 
            
            
              | 932 | 
                          { | 
            
            
              | 933 | 
                              borrowernumber  => $borrower->borrowernumber, itemnumber => $item->itemnumber,  | 
            
            
              | 934 | 
                              debit_type_code => 'PROCESSING'  | 
            
            
              | 935 | 
                          }  | 
            
            
              | 936 | 
                      );  | 
            
            
              | 937 | 
                      ok( $procfee, "Processing fee created" );  | 
            
            
              | 938 | 
                      is( $procfee->amount + 0, 1, "Processing fee chosen correctly" );  | 
            
            
              | 939 | 
               | 
            
            
              | 940 | 
                      t::lib::Mocks::mock_preference( 'LostChargesControl', 'PickupLibrary' );  | 
            
            
              | 941 | 
                      diag("Test LostChargesControl = PickupLibrary"); | 
            
            
              | 942 | 
                      $context->mock(  | 
            
            
              | 943 | 
                          'userenv',  | 
            
            
              | 944 | 
                          sub { | 
            
            
              | 945 | 
                              return { | 
            
            
              | 946 | 
                                  number => $borrower->borrowernumber,  | 
            
            
              | 947 | 
                                  branch => $branch_2->branchcode,  | 
            
            
              | 948 | 
                              };  | 
            
            
              | 949 | 
                          }  | 
            
            
              | 950 | 
                      );  | 
            
            
              | 951 | 
               | 
            
            
              | 952 | 
                      # We can use same borrower - from branch 1  | 
            
            
              | 953 | 
                      $item = $builder->build_sample_item( { homebranch => $branch_4->branchcode } ) | 
            
            
              | 954 | 
                          ;    # new item to ensure we don't create a duplicate charge  | 
            
            
              | 955 | 
                      C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '2', "Branch 2 used" );  | 
            
            
              | 956 | 
                      $procfee = Koha::Account::Lines->find(  | 
            
            
              | 957 | 
                          { | 
            
            
              | 958 | 
                              borrowernumber  => $borrower->borrowernumber, itemnumber => $item->itemnumber,  | 
            
            
              | 959 | 
                              debit_type_code => 'PROCESSING'  | 
            
            
              | 960 | 
                          }  | 
            
            
              | 961 | 
                      );  | 
            
            
              | 962 | 
                      ok( $procfee, "Processing fee created" );  | 
            
            
              | 963 | 
                      is( $procfee->amount + 0, 2, "Processing fee chosen correctly" );  | 
            
            
              | 964 | 
               | 
            
            
              | 965 | 
                      t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' );  | 
            
            
              | 966 | 
                      diag("Test LostChargesControl = ItemhomeLibrary"); | 
            
            
              | 967 | 
               | 
            
            
              | 968 | 
                      t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );  | 
            
            
              | 969 | 
                      diag("    Test LostChargesControl = ItemhomeLibrary and HomeOrHoldingBranch = homebranch"); | 
            
            
              | 970 | 
               | 
            
            
              | 971 | 
                      # We can use same borrower - from branch 1  | 
            
            
              | 972 | 
                      $item = $builder->build_sample_item( { library => $branch_3->branchcode } ); | 
            
            
              | 973 | 
                      $item->holdingbranch( $branch_4->branchcode )  | 
            
            
              | 974 | 
                          ->store;    #build sample items makes them the same, ensure they are different  | 
            
            
              | 975 | 
                      C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '3', "Branch 3 used" );  | 
            
            
              | 976 | 
                      $procfee = Koha::Account::Lines->find(  | 
            
            
              | 977 | 
                          { | 
            
            
              | 978 | 
                              borrowernumber  => $borrower->borrowernumber, itemnumber => $item->itemnumber,  | 
            
            
              | 979 | 
                              debit_type_code => 'PROCESSING'  | 
            
            
              | 980 | 
                          }  | 
            
            
              | 981 | 
                      );  | 
            
            
              | 982 | 
                      ok( $procfee, "Processing fee created" );  | 
            
            
              | 983 | 
                      is( $procfee->amount + 0, 3, "Processing fee chosen correctly" );  | 
            
            
              | 984 | 
               | 
            
            
              | 985 | 
                      t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'holdingbranch' );  | 
            
            
              | 986 | 
                      diag("    Test LostChargesControl = ItemhomeLibrary and HomeOrHoldingBranch = holdingbranch"); | 
            
            
              | 987 | 
               | 
            
            
              | 988 | 
                      # We can use same borrower - from branch 1  | 
            
            
              | 989 | 
                      $item = $builder->build_sample_item( { library => $branch_4->branchcode } ); | 
            
            
              | 990 | 
                      $item->homebranch( $branch_3->branchcode )  | 
            
            
              | 991 | 
                          ->store;    #build sample items makes them the same, ensure they are different  | 
            
            
              | 992 | 
                      C4::Accounts::chargelostitem( $borrower->borrowernumber, $item->itemnumber, '4', "Branch 4 used" );  | 
            
            
              | 993 | 
                      $procfee = Koha::Account::Lines->find(  | 
            
            
              | 994 | 
                          { | 
            
            
              | 995 | 
                              borrowernumber  => $borrower->borrowernumber, itemnumber => $item->itemnumber,  | 
            
            
              | 996 | 
                              debit_type_code => 'PROCESSING'  | 
            
            
              | 997 | 
                          }  | 
            
            
              | 998 | 
                      );  | 
            
            
              | 999 | 
                      ok( $procfee, "Processing fee created" );  | 
            
            
              | 1000 | 
                      is( $procfee->amount + 0, 4, "Processing fee chosen correctly" );  | 
            
            
              | 1001 | 
               | 
            
            
              | 1002 | 
                  };  | 
            
            
              | 1003 | 
               | 
            
        
          | 890 | 
              subtest "basic fields tests" => sub { | 
          1004 | 
              subtest "basic fields tests" => sub { | 
        
        
          | 891 | 
                  plan tests => 12;  | 
          1005 | 
                  plan tests => 12;  | 
        
        
          | 892 | 
           | 
          1006 | 
           | 
        
            
               | 
               | 
              1007 | 
                      my $staff    = $builder->build( { source => 'Borrower' } ); | 
            
            
              | 1008 | 
                      my $staff_id = $staff->{borrowernumber}; | 
            
            
              | 1009 | 
                      $context->mock(  | 
            
            
              | 1010 | 
                          'userenv',  | 
            
            
              | 1011 | 
                          sub { | 
            
            
              | 1012 | 
                              return { | 
            
            
              | 1013 | 
                                  flags  => 1,  | 
            
            
              | 1014 | 
                                  number => $staff_id,  | 
            
            
              | 1015 | 
                                  branch => $branchcode,  | 
            
            
              | 1016 | 
                              };  | 
            
            
              | 1017 | 
                          }  | 
            
            
              | 1018 | 
                      );  | 
            
            
              | 1019 | 
               | 
            
        
          | 893 | 
                  t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' );  | 
          1020 | 
                  t::lib::Mocks::mock_preference( 'ProcessingFeeNote', 'Test Note' );  | 
        
        
          | 894 | 
                  C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor" );  | 
          1021 | 
                  C4::Accounts::chargelostitem( $cli_borrowernumber, $cli_itemnumber4, '1.99', "Perdedor" );  | 
        
        
          | 895 | 
           | 
          1022 | 
           | 
        
            
              | 896 | 
              -   | 
               | 
               |