View | Details | Raw Unified | Return to bug 32450
Collapse All | Expand All

(-)a/t/db_dependent/Accounts.t (-110 / +30 lines)
Lines 764-770 subtest "C4::Accounts::chargelostitem tests" => sub { Link Here
764
};
764
};
765
765
766
subtest "Koha::Account::non_issues_charges tests" => sub {
766
subtest "Koha::Account::non_issues_charges tests" => sub {
767
    plan tests => 21;
767
    plan tests => 6;
768
768
769
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
769
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
770
    my $account = $patron->account;
770
    my $account = $patron->account;
Lines 772-777 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
772
    my $res    = 3;
772
    my $res    = 3;
773
    my $rent   = 5;
773
    my $rent   = 5;
774
    my $manual = 7;
774
    my $manual = 7;
775
    my $print = 4;
775
    $account->add_debit(
776
    $account->add_debit(
776
        {
777
        {
777
            description => 'a Res fee',
778
            description => 'a Res fee',
Lines 805-814 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
805
        }
806
        }
806
    )->store;
807
    )->store;
807
808
808
809
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
810
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 );
811
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  0 );
812
    my ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
809
    my ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
813
    my $other_charges = $total - $non_issues_charges;
810
    my $other_charges = $total - $non_issues_charges;
814
    is(
811
    is(
Lines 816-930 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
816
        $res + $rent + $manual,
813
        $res + $rent + $manual,
817
        'Total charges should be Res + Rent + Manual'
814
        'Total charges should be Res + Rent + Manual'
818
    );
815
    );
819
    is( $non_issues_charges, 0,
816
    is( $non_issues_charges, 15,
820
        'If 0|0|0 there should not have non issues charges' );
817
        'All types should count towards the non issue charge' );
821
    is( $other_charges, 15, 'If 0|0|0 there should only have other charges' );
818
    is( $other_charges, 0, 'There shouldn\'t be any non-included charges' );
822
823
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
824
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 );
825
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  1 );
826
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
827
    $other_charges = $total - $non_issues_charges;
828
    is(
829
        $total,
830
        $res + $rent + $manual,
831
        'Total charges should be Res + Rent + Manual'
832
    );
833
    is( $non_issues_charges, $manual,
834
        'If 0|0|1 Only Manual should be a non issue charge' );
835
    is(
836
        $other_charges,
837
        $res + $rent,
838
        'If 0|0|1 Res + Rent should be other charges'
839
    );
840
819
841
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
820
    Koha::Account::DebitTypes->find_or_create(
842
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 );
821
        {
843
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  0 );
822
            code        => 'Print',
844
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
823
            description => 'Charge for using the printer',
845
    $other_charges = $total - $non_issues_charges;
824
            is_system   => 0,
846
    is(
825
            restricts_checkouts => 0
847
        $total,
826
        }
848
        $res + $rent + $manual,
827
    )->store;
849
        'Total charges should be Res + Rent + Manual'
828
    Koha::Account::Line->new(
850
    );
829
        {
851
    is( $non_issues_charges, $rent,
830
            borrowernumber    => $patron->borrowernumber,
852
        'If 0|1|0 Only Rental should be a non issue charge' );
831
            description       => 'Non-restricting fee',
853
    is(
832
            debit_type_code   => 'Print',
854
        $other_charges,
833
            amountoutstanding => $print,
855
        $res + $manual,
834
            interface         => 'commandline'
856
        'If 0|1|0 Rent + Manual should be other charges'
835
        }
857
    );
836
    )->store;
858
859
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   0 );
860
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 );
861
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  1 );
862
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
863
    $other_charges = $total - $non_issues_charges;
864
    is(
865
        $total,
866
        $res + $rent + $manual,
867
        'Total charges should be Res + Rent + Manual'
868
    );
869
    is(
870
        $non_issues_charges,
871
        $rent + $manual,
872
        'If 0|1|1 Rent + Manual should be non issues charges'
873
    );
874
    is( $other_charges, $res, 'If 0|1|1 there should only have other charges' );
875
837
876
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   1 );
838
    my ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
877
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 );
839
    my $other_charges = $total - $non_issues_charges;
878
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  0 );
879
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
880
    $other_charges = $total - $non_issues_charges;
881
    is(
882
        $total,
883
        $res + $rent + $manual,
884
        'Total charges should be Res + Rent + Manual'
885
    );
886
    is( $non_issues_charges, $res,
887
        'If 1|0|0 Only Res should be non issues charges' );
888
    is(
840
    is(
889
        $other_charges,
841
        $account->balance,
890
        $rent + $manual,
842
        $res + $rent + $manual + $print,
891
        'If 1|0|0 Rent + Manual should be other charges'
843
        'Total charges should be Res + Rent + Manual + Print'
892
    );
844
    );
845
    is( $non_issues_charges, 15,
846
        'All types except Print should count towards the non issue charge' );
847
    is( $other_charges, 4, 'There should be non-included charges for Print' );
893
848
894
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   1 );
895
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 );
896
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  0 );
897
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
898
    $other_charges = $total - $non_issues_charges;
899
    is(
900
        $total,
901
        $res + $rent + $manual,
902
        'Total charges should be Res + Rent + Manual'
903
    );
904
    is(
905
        $non_issues_charges,
906
        $res + $rent,
907
        'If 1|1|0 Res + Rent should be non issues charges'
908
    );
909
    is( $other_charges, $manual,
910
        'If 1|1|0 Only Manual should be other charges' );
911
912
    t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge',   1 );
913
    t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 );
914
    t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge',  1 );
915
    ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges );
916
    $other_charges = $total - $non_issues_charges;
917
    is(
918
        $total,
919
        $res + $rent + $manual,
920
        'Total charges should be Res + Rent + Manual'
921
    );
922
    is(
923
        $non_issues_charges,
924
        $res + $rent + $manual,
925
        'If 1|1|1 Res + Rent + Manual should be non issues charges'
926
    );
927
    is( $other_charges, 0, 'If 1|1|1 there should not have any other charges' );
928
};
849
};
929
850
930
subtest "Koha::Account::non_issues_charges tests" => sub {
851
subtest "Koha::Account::non_issues_charges tests" => sub {
931
- 

Return to bug 32450