Lines 18-24
Link Here
|
18 |
|
18 |
|
19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
20 |
|
20 |
|
21 |
use Test::More tests => 22; |
21 |
use Test::More tests => 23; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 490-492
subtest 'balance' => sub {
Link Here
|
490 |
$patron->delete; |
490 |
$patron->delete; |
491 |
}; |
491 |
}; |
492 |
|
492 |
|
493 |
- |
493 |
subtest "Koha::Account::Line::void tests" => sub { |
|
|
494 |
|
495 |
plan tests => 12; |
496 |
|
497 |
# Create a borrower |
498 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
499 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
500 |
|
501 |
my $borrower = Koha::Patron->new( { |
502 |
cardnumber => 'dariahall', |
503 |
surname => 'Hall', |
504 |
firstname => 'Daria', |
505 |
} ); |
506 |
$borrower->categorycode( $categorycode ); |
507 |
$borrower->branchcode( $branchcode ); |
508 |
$borrower->store; |
509 |
|
510 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
511 |
|
512 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10 })->store(); |
513 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20 })->store(); |
514 |
|
515 |
is( $account->balance(), "30.000000", "Account balance is 30" ); |
516 |
is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' ); |
517 |
is( $line2->amountoutstanding, 20, 'Second fee has amount outstanding of 20' ); |
518 |
|
519 |
my $id = $account->pay( |
520 |
{ |
521 |
lines => [$line1, $line2], |
522 |
amount => 30, |
523 |
} |
524 |
); |
525 |
my $account_payment = Koha::Account::Lines->find( $id ); |
526 |
|
527 |
is( $account->balance(), "0.000000", "Account balance is 0" ); |
528 |
|
529 |
$line1->_result->discard_changes(); |
530 |
$line2->_result->discard_changes(); |
531 |
is( $line1->amountoutstanding, '0.000000', 'First fee has amount outstanding of 0' ); |
532 |
is( $line2->amountoutstanding, '0.000000', 'Second fee has amount outstanding of 0' ); |
533 |
|
534 |
$account_payment->void(); |
535 |
|
536 |
is( $account->balance(), "30.000000", "Account balance is again 30" ); |
537 |
|
538 |
$account_payment->_result->discard_changes(); |
539 |
$line1->_result->discard_changes(); |
540 |
$line2->_result->discard_changes(); |
541 |
|
542 |
is( $account_payment->accounttype, 'VOID', 'Voided payment accounttype is VOID' ); |
543 |
is( $account_payment->amount, '0.000000', 'Voided payment amount is 0' ); |
544 |
is( $account_payment->amountoutstanding, '0.000000', 'Voided payment amount outstanding is 0' ); |
545 |
|
546 |
is( $line1->amountoutstanding, '10.000000', 'First fee again has amount outstanding of 10' ); |
547 |
is( $line2->amountoutstanding, '20.000000', 'Second fee again has amount outstanding of 20' ); |
548 |
}; |
549 |
|
550 |
1; |