|
Lines 18-24
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 |
|
|
Lines 630-633
subtest "Koha::Account::chargelostitem tests" => sub {
Link Here
|
| 630 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
630 |
is( $procfee->amount, "2.040000", "Processing fee if processing fee"); |
| 631 |
}; |
631 |
}; |
| 632 |
|
632 |
|
|
|
633 |
subtest "Koha::Account::Line::void tests" => sub { |
| 634 |
|
| 635 |
plan tests => 12; |
| 636 |
|
| 637 |
# Create a borrower |
| 638 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
| 639 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 640 |
|
| 641 |
my $borrower = Koha::Patron->new( { |
| 642 |
cardnumber => 'dariahall', |
| 643 |
surname => 'Hall', |
| 644 |
firstname => 'Daria', |
| 645 |
} ); |
| 646 |
$borrower->categorycode( $categorycode ); |
| 647 |
$borrower->branchcode( $branchcode ); |
| 648 |
$borrower->store; |
| 649 |
|
| 650 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
| 651 |
|
| 652 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store(); |
| 653 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store(); |
| 654 |
|
| 655 |
is( $account->balance(), "30.000000", "Account balance is 30" ); |
| 656 |
is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' ); |
| 657 |
is( $line2->amountoutstanding, 20, 'Second fee has amount outstanding of 20' ); |
| 658 |
|
| 659 |
my $id = $account->pay( |
| 660 |
{ |
| 661 |
lines => [$line1, $line2], |
| 662 |
amount => 30, |
| 663 |
} |
| 664 |
); |
| 665 |
my $account_payment = Koha::Account::Lines->find( $id ); |
| 666 |
|
| 667 |
is( $account->balance(), "0.000000", "Account balance is 0" ); |
| 668 |
|
| 669 |
$line1->_result->discard_changes(); |
| 670 |
$line2->_result->discard_changes(); |
| 671 |
is( $line1->amountoutstanding, '0.000000', 'First fee has amount outstanding of 0' ); |
| 672 |
is( $line2->amountoutstanding, '0.000000', 'Second fee has amount outstanding of 0' ); |
| 673 |
|
| 674 |
$account_payment->void(); |
| 675 |
|
| 676 |
is( $account->balance(), "30.000000", "Account balance is again 30" ); |
| 677 |
|
| 678 |
$account_payment->_result->discard_changes(); |
| 679 |
$line1->_result->discard_changes(); |
| 680 |
$line2->_result->discard_changes(); |
| 681 |
|
| 682 |
is( $account_payment->accounttype, 'VOID', 'Voided payment accounttype is VOID' ); |
| 683 |
is( $account_payment->amount, '0.000000', 'Voided payment amount is 0' ); |
| 684 |
is( $account_payment->amountoutstanding, '0.000000', 'Voided payment amount outstanding is 0' ); |
| 685 |
|
| 686 |
is( $line1->amountoutstanding, '10.000000', 'First fee again has amount outstanding of 10' ); |
| 687 |
is( $line2->amountoutstanding, '20.000000', 'Second fee again has amount outstanding of 20' ); |
| 688 |
}; |
| 689 |
|
| 633 |
1; |
690 |
1; |
| 634 |
- |
|
|