|
Lines 18-24
Link Here
|
| 18 |
|
18 |
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 25; |
21 |
use Test::More tests => 26; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
|
Lines 847-850
subtest "Koha::Account::non_issues_charges tests" => sub {
Link Here
|
| 847 |
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists, the last 2 have been deleted ok" ); |
847 |
is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists, the last 2 have been deleted ok" ); |
| 848 |
}; |
848 |
}; |
| 849 |
|
849 |
|
|
|
850 |
subtest "Koha::Account::Line::void tests" => sub { |
| 851 |
|
| 852 |
plan tests => 12; |
| 853 |
|
| 854 |
# Create a borrower |
| 855 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
| 856 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 857 |
|
| 858 |
my $borrower = Koha::Patron->new( { |
| 859 |
cardnumber => 'dariahall', |
| 860 |
surname => 'Hall', |
| 861 |
firstname => 'Daria', |
| 862 |
} ); |
| 863 |
$borrower->categorycode( $categorycode ); |
| 864 |
$borrower->branchcode( $branchcode ); |
| 865 |
$borrower->store; |
| 866 |
|
| 867 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
| 868 |
|
| 869 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store(); |
| 870 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store(); |
| 871 |
|
| 872 |
is( $account->balance(), 30, "Account balance is 30" ); |
| 873 |
is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' ); |
| 874 |
is( $line2->amountoutstanding, 20, 'Second fee has amount outstanding of 20' ); |
| 875 |
|
| 876 |
my $id = $account->pay( |
| 877 |
{ |
| 878 |
lines => [$line1, $line2], |
| 879 |
amount => 30, |
| 880 |
} |
| 881 |
); |
| 882 |
my $account_payment = Koha::Account::Lines->find( $id ); |
| 883 |
|
| 884 |
is( $account->balance(), 0, "Account balance is 0" ); |
| 885 |
|
| 886 |
$line1->_result->discard_changes(); |
| 887 |
$line2->_result->discard_changes(); |
| 888 |
is( $line1->amountoutstanding, '0.000000', 'First fee has amount outstanding of 0' ); |
| 889 |
is( $line2->amountoutstanding, '0.000000', 'Second fee has amount outstanding of 0' ); |
| 890 |
|
| 891 |
$account_payment->void(); |
| 892 |
|
| 893 |
is( $account->balance(), 30, "Account balance is again 30" ); |
| 894 |
|
| 895 |
$account_payment->_result->discard_changes(); |
| 896 |
$line1->_result->discard_changes(); |
| 897 |
$line2->_result->discard_changes(); |
| 898 |
|
| 899 |
is( $account_payment->accounttype, 'VOID', 'Voided payment accounttype is VOID' ); |
| 900 |
is( $account_payment->amount, '0.000000', 'Voided payment amount is 0' ); |
| 901 |
is( $account_payment->amountoutstanding, '0.000000', 'Voided payment amount outstanding is 0' ); |
| 902 |
|
| 903 |
is( $line1->amountoutstanding, '10.000000', 'First fee again has amount outstanding of 10' ); |
| 904 |
is( $line2->amountoutstanding, '20.000000', 'Second fee again has amount outstanding of 20' ); |
| 905 |
}; |
| 906 |
|
| 850 |
1; |
907 |
1; |
| 851 |
- |
|
|