|
Lines 25-31
use Test::Warn;
Link Here
|
| 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; |
|
|
| 29 |
use Koha::Account; |
28 |
use Koha::Account; |
| 30 |
use Koha::Account::Lines; |
29 |
use Koha::Account::Lines; |
| 31 |
use Koha::Account::Offsets; |
30 |
use Koha::Account::Offsets; |
|
Lines 284-290
subtest "Koha::Account::pay particular line tests" => sub {
Link Here
|
| 284 |
my $line3 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 3 })->store(); |
283 |
my $line3 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 3 })->store(); |
| 285 |
my $line4 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 4 })->store(); |
284 |
my $line4 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 4 })->store(); |
| 286 |
|
285 |
|
| 287 |
is( $account->balance(), "10.000000", "Account balance is 10" ); |
286 |
is( $account->balance(), 10, "Account balance is 10" ); |
| 288 |
|
287 |
|
| 289 |
$account->pay( |
288 |
$account->pay( |
| 290 |
{ |
289 |
{ |
|
Lines 326-332
subtest "Koha::Account::pay writeoff tests" => sub {
Link Here
|
| 326 |
|
325 |
|
| 327 |
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42 })->store(); |
326 |
my $line = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42 })->store(); |
| 328 |
|
327 |
|
| 329 |
is( $account->balance(), "42.000000", "Account balance is 42" ); |
328 |
is( $account->balance(), 42, "Account balance is 42" ); |
| 330 |
|
329 |
|
| 331 |
my $id = $account->pay( |
330 |
my $id = $account->pay( |
| 332 |
{ |
331 |
{ |
|
Lines 675-687
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 675 |
} |
674 |
} |
| 676 |
)->store; |
675 |
)->store; |
| 677 |
|
676 |
|
|
|
677 |
my $account = $patron->account; |
| 678 |
|
| 678 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
679 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
| 679 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
680 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
| 680 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
681 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
| 681 |
my ( $total, $non_issues_charges, $other_charges ) = |
682 |
my ( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 682 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
683 |
my $other_charges = $total - $non_issues_charges; |
| 683 |
is( |
684 |
is( |
| 684 |
$total, |
685 |
$account->balance, |
| 685 |
$res + $rent + $manual, |
686 |
$res + $rent + $manual, |
| 686 |
'Total charges should be Res + Rent + Manual' |
687 |
'Total charges should be Res + Rent + Manual' |
| 687 |
); |
688 |
); |
|
Lines 692-699
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 692 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
693 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
| 693 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
694 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
| 694 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
695 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
| 695 |
( $total, $non_issues_charges, $other_charges ) = |
696 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 696 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
697 |
$other_charges = $total - $non_issues_charges; |
| 697 |
is( |
698 |
is( |
| 698 |
$total, |
699 |
$total, |
| 699 |
$res + $rent + $manual, |
700 |
$res + $rent + $manual, |
|
Lines 710-717
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 710 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
711 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
| 711 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
712 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
| 712 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
713 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
| 713 |
( $total, $non_issues_charges, $other_charges ) = |
714 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 714 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
715 |
$other_charges = $total - $non_issues_charges; |
| 715 |
is( |
716 |
is( |
| 716 |
$total, |
717 |
$total, |
| 717 |
$res + $rent + $manual, |
718 |
$res + $rent + $manual, |
|
Lines 728-735
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 728 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
729 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); |
| 729 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
730 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
| 730 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
731 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
| 731 |
( $total, $non_issues_charges, $other_charges ) = |
732 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 732 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
733 |
$other_charges = $total - $non_issues_charges; |
| 733 |
is( |
734 |
is( |
| 734 |
$total, |
735 |
$total, |
| 735 |
$res + $rent + $manual, |
736 |
$res + $rent + $manual, |
|
Lines 745-752
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 745 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
746 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
| 746 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
747 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 0 ); |
| 747 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
748 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
| 748 |
( $total, $non_issues_charges, $other_charges ) = |
749 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 749 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
750 |
$other_charges = $total - $non_issues_charges; |
| 750 |
is( |
751 |
is( |
| 751 |
$total, |
752 |
$total, |
| 752 |
$res + $rent + $manual, |
753 |
$res + $rent + $manual, |
|
Lines 763-770
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 763 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
764 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
| 764 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
765 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
| 765 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
766 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 0 ); |
| 766 |
( $total, $non_issues_charges, $other_charges ) = |
767 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 767 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
768 |
$other_charges = $total - $non_issues_charges; |
| 768 |
is( |
769 |
is( |
| 769 |
$total, |
770 |
$total, |
| 770 |
$res + $rent + $manual, |
771 |
$res + $rent + $manual, |
|
Lines 781-788
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 781 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
782 |
t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 1 ); |
| 782 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
783 |
t::lib::Mocks::mock_preference( 'RentalsInNoissuesCharge', 1 ); |
| 783 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
784 |
t::lib::Mocks::mock_preference( 'ManInvInNoissuesCharge', 1 ); |
| 784 |
( $total, $non_issues_charges, $other_charges ) = |
785 |
( $total, $non_issues_charges ) = ( $account->balance, $account->non_issues_charges ); |
| 785 |
C4::Members::GetMemberAccountBalance( $patron->borrowernumber ); |
786 |
$other_charges = $total - $non_issues_charges; |
| 786 |
is( |
787 |
is( |
| 787 |
$total, |
788 |
$total, |
| 788 |
$res + $rent + $manual, |
789 |
$res + $rent + $manual, |
| 789 |
- |
|
|