|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 15; |
22 |
use Test::More tests => 16; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
|
24 |
|
| 25 |
use C4::Circulation qw/AddIssue AddReturn/; |
25 |
use C4::Circulation qw/AddIssue AddReturn/; |
|
Lines 824-829
subtest "void() tests" => sub {
Link Here
|
| 824 |
$borrower->branchcode( $branchcode ); |
824 |
$borrower->branchcode( $branchcode ); |
| 825 |
$borrower->store; |
825 |
$borrower->store; |
| 826 |
|
826 |
|
|
|
827 |
t::lib::Mocks::mock_userenv({ branchcode => $branchcode, borrowernumber => $borrower->borrowernumber }); |
| 828 |
|
| 827 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
829 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
| 828 |
|
830 |
|
| 829 |
my $line1 = Koha::Account::Line->new( |
831 |
my $line1 = Koha::Account::Line->new( |
|
Lines 893-898
subtest "void() tests" => sub {
Link Here
|
| 893 |
$schema->storage->txn_rollback; |
895 |
$schema->storage->txn_rollback; |
| 894 |
}; |
896 |
}; |
| 895 |
|
897 |
|
|
|
898 |
subtest "cancel() tests" => sub { |
| 899 |
plan tests => 9; |
| 900 |
|
| 901 |
$schema->storage->txn_begin; |
| 902 |
|
| 903 |
# Create a borrower |
| 904 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
| 905 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 906 |
|
| 907 |
my $borrower = Koha::Patron->new( { |
| 908 |
cardnumber => 'dariahall', |
| 909 |
surname => 'Hall', |
| 910 |
firstname => 'Daria', |
| 911 |
} ); |
| 912 |
$borrower->categorycode( $categorycode ); |
| 913 |
$borrower->branchcode( $branchcode ); |
| 914 |
$borrower->store; |
| 915 |
|
| 916 |
t::lib::Mocks::mock_userenv({ branchcode => $branchcode, borrowernumber => $borrower->borrowernumber }); |
| 917 |
|
| 918 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
| 919 |
|
| 920 |
my $line1 = Koha::Account::Line->new( |
| 921 |
{ |
| 922 |
borrowernumber => $borrower->borrowernumber, |
| 923 |
amount => 10, |
| 924 |
amountoutstanding => 10, |
| 925 |
interface => 'commandline', |
| 926 |
debit_type_code => 'OVERDUE', |
| 927 |
} |
| 928 |
)->store(); |
| 929 |
my $line2 = Koha::Account::Line->new( |
| 930 |
{ |
| 931 |
borrowernumber => $borrower->borrowernumber, |
| 932 |
amount => 20, |
| 933 |
amountoutstanding => 20, |
| 934 |
interface => 'commandline', |
| 935 |
debit_type_code => 'OVERDUE', |
| 936 |
} |
| 937 |
)->store(); |
| 938 |
|
| 939 |
my $id = $account->pay({ |
| 940 |
lines => [$line2], |
| 941 |
amount => 5, |
| 942 |
}); |
| 943 |
|
| 944 |
is( $account->balance(), 25, "Account balance is 25" ); |
| 945 |
is( $line1->amountoutstanding+0, 10, 'First fee has amount outstanding of 10' ); |
| 946 |
is( $line2->amountoutstanding+0, 15, 'Second fee has amount outstanding of 15' ); |
| 947 |
|
| 948 |
my $ret = $line1->cancel(); |
| 949 |
is( ref($ret), 'Koha::Account::Line', 'Cancel returns the account line' ); |
| 950 |
is( $account->balance(), 15, "Account balance is 15" ); |
| 951 |
is( $line1->amount+0, 0, 'First fee has amount of 0' ); |
| 952 |
is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' ); |
| 953 |
|
| 954 |
$ret = $line2->cancel(); |
| 955 |
is ($ret, undef, 'cancel returns undef when line cannot be cancelled'); |
| 956 |
|
| 957 |
my $account_payment = Koha::Account::Lines->find($id); |
| 958 |
$ret = $account_payment->cancel(); |
| 959 |
is ($ret, undef, 'payment cannot be cancelled'); |
| 960 |
|
| 961 |
$schema->storage->txn_rollback; |
| 962 |
}; |
| 963 |
|
| 896 |
subtest "payout() tests" => sub { |
964 |
subtest "payout() tests" => sub { |
| 897 |
|
965 |
|
| 898 |
plan tests => 18; |
966 |
plan tests => 18; |
| 899 |
- |
|
|