Lines 18-34
Link Here
|
18 |
|
18 |
|
19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
20 |
|
20 |
|
21 |
use Test::More tests => 23; |
21 |
use Test::More tests => 24; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
26 |
use t::lib::Mocks; |
26 |
use t::lib::Mocks; |
27 |
|
27 |
|
|
|
28 |
use C4::Members; |
28 |
use Koha::Account; |
29 |
use Koha::Account; |
29 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Lines; |
30 |
use Koha::Account::Line; |
|
|
31 |
use Koha::Account::Offsets; |
31 |
use Koha::Account::Offsets; |
|
|
32 |
use Koha::DateUtils qw( dt_from_string ); |
32 |
|
33 |
|
33 |
BEGIN { |
34 |
BEGIN { |
34 |
use_ok('C4::Accounts'); |
35 |
use_ok('C4::Accounts'); |
Lines 627-630
subtest "Koha::Account::chargelostitem tests" => sub {
Link Here
|
627 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
628 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
628 |
}; |
629 |
}; |
629 |
|
630 |
|
|
|
631 |
subtest "Koha::Account::non_issues_charges tests" => sub { |
632 |
plan tests => 21; |
633 |
|
634 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
635 |
|
636 |
my $today = dt_from_string; |
637 |
my $res = 3; |
638 |
my $rent = 5; |
639 |
my $manual = 7; |
640 |
Koha::Account::Line->new( |
641 |
{ |
642 |
borrowernumber => $patron->borrowernumber, |
643 |
accountno => 1, |
644 |
date => $today, |
645 |
description => 'a Res fee', |
646 |
accounttype => 'Res', |
647 |
amountoutstanding => $res, |
648 |
} |
649 |
)->store; |
650 |
Koha::Account::Line->new( |
651 |
{ |
652 |
borrowernumber => $patron->borrowernumber, |
653 |
accountno => 2, |
654 |
date => $today, |
655 |
description => 'a Rental fee', |
656 |
accounttype => 'Rent', |
657 |
amountoutstanding => $rent, |
658 |
} |
659 |
)->store; |
660 |
Koha::Account::Line->new( |
661 |
{ |
662 |
borrowernumber => $patron->borrowernumber, |
663 |
accountno => 3, |
664 |
date => $today, |
665 |
description => 'a Manual invoice fee', |
666 |
accounttype => 'Copie', |
667 |
amountoutstanding => $manual, |
668 |
} |
669 |
)->store; |
670 |
Koha::AuthorisedValue->new( |
671 |
{ |
672 |
category => 'MANUAL_INV', |
673 |
authorised_value => 'Copie', |
674 |
lib => 'Fee for copie', |
675 |
} |
676 |
)->store; |
677 |
|
678 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
679 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
680 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
681 |
my ( $total, $non_issues_charges, $other_charges ) = |
682 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
683 |
is( |
684 |
$total, |
685 |
$res + $rent + $manual, |
686 |
'Total charges should be Res + Rent + Manual' |
687 |
); |
688 |
is( $non_issues_charges, 0, |
689 |
'If 0|0|0 there should not have non issues charges' ); |
690 |
is( $other_charges, 15, 'If 0|0|0 there should only have other charges' ); |
691 |
|
692 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
693 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
694 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
695 |
( $total, $non_issues_charges, $other_charges ) = |
696 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
697 |
is( |
698 |
$total, |
699 |
$res + $rent + $manual, |
700 |
'Total charges should be Res + Rent + Manual' |
701 |
); |
702 |
is( $non_issues_charges, $manual, |
703 |
'If 0|0|1 Only Manual should be a non issue charge' ); |
704 |
is( |
705 |
$other_charges, |
706 |
$res + $rent, |
707 |
'If 0|0|1 Res + Rent should be other charges' |
708 |
); |
709 |
|
710 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
711 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
712 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
713 |
( $total, $non_issues_charges, $other_charges ) = |
714 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
715 |
is( |
716 |
$total, |
717 |
$res + $rent + $manual, |
718 |
'Total charges should be Res + Rent + Manual' |
719 |
); |
720 |
is( $non_issues_charges, $rent, |
721 |
'If 0|1|0 Only Rental should be a non issue charge' ); |
722 |
is( |
723 |
$other_charges, |
724 |
$res + $manual, |
725 |
'If 0|1|0 Rent + Manual should be other charges' |
726 |
); |
727 |
|
728 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
729 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
730 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
731 |
( $total, $non_issues_charges, $other_charges ) = |
732 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
733 |
is( |
734 |
$total, |
735 |
$res + $rent + $manual, |
736 |
'Total charges should be Res + Rent + Manual' |
737 |
); |
738 |
is( |
739 |
$non_issues_charges, |
740 |
$rent + $manual, |
741 |
'If 0|1|1 Rent + Manual should be non issues charges' |
742 |
); |
743 |
is( $other_charges, $res, 'If 0|1|1 there should only have other charges' ); |
744 |
|
745 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
746 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
747 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
748 |
( $total, $non_issues_charges, $other_charges ) = |
749 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
750 |
is( |
751 |
$total, |
752 |
$res + $rent + $manual, |
753 |
'Total charges should be Res + Rent + Manual' |
754 |
); |
755 |
is( $non_issues_charges, $res, |
756 |
'If 1|0|0 Only Res should be non issues charges' ); |
757 |
is( |
758 |
$other_charges, |
759 |
$rent + $manual, |
760 |
'If 1|0|0 Rent + Manual should be other charges' |
761 |
); |
762 |
|
763 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
764 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
765 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
766 |
( $total, $non_issues_charges, $other_charges ) = |
767 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
768 |
is( |
769 |
$total, |
770 |
$res + $rent + $manual, |
771 |
'Total charges should be Res + Rent + Manual' |
772 |
); |
773 |
is( |
774 |
$non_issues_charges, |
775 |
$res + $rent, |
776 |
'If 1|1|0 Res + Rent should be non issues charges' |
777 |
); |
778 |
is( $other_charges, $manual, |
779 |
'If 1|1|0 Only Manual should be other charges' ); |
780 |
|
781 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
782 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
783 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
784 |
( $total, $non_issues_charges, $other_charges ) = |
785 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
786 |
is( |
787 |
$total, |
788 |
$res + $rent + $manual, |
789 |
'Total charges should be Res + Rent + Manual' |
790 |
); |
791 |
is( |
792 |
$non_issues_charges, |
793 |
$res + $rent + $manual, |
794 |
'If 1|1|1 Res + Rent + Manual should be non issues charges' |
795 |
); |
796 |
is( $other_charges, 0, 'If 1|1|1 there should not have any other charges' ); |
797 |
}; |
798 |
|
630 |
1; |
799 |
1; |
631 |
- |
|
|