Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
|
23 |
|
24 |
use Koha::Account; |
24 |
use Koha::Account; |
25 |
use Koha::Account::Lines; |
25 |
use Koha::Account::Lines; |
Lines 65-70
subtest 'outstanding_debits() tests' => sub {
Link Here
|
65 |
$schema->storage->txn_rollback; |
65 |
$schema->storage->txn_rollback; |
66 |
}; |
66 |
}; |
67 |
|
67 |
|
|
|
68 |
subtest 'outstanding_credits() tests' => sub { |
69 |
|
70 |
plan tests => 5; |
71 |
|
72 |
$schema->storage->txn_begin; |
73 |
|
74 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
75 |
my $account = Koha::Account->new({ patron_id => $patron->id }); |
76 |
|
77 |
my @generated_lines; |
78 |
push @generated_lines, $account->add_credit({ amount => 1 }); |
79 |
push @generated_lines, $account->add_credit({ amount => 2 }); |
80 |
push @generated_lines, $account->add_credit({ amount => 3 }); |
81 |
push @generated_lines, $account->add_credit({ amount => 4 }); |
82 |
|
83 |
my ( $total, $lines ) = $account->outstanding_credits(); |
84 |
|
85 |
is( $total, -10, 'Outstandig debits total is correctly calculated' ); |
86 |
|
87 |
my $i = 0; |
88 |
foreach my $line ( @{ $lines->as_list } ) { |
89 |
my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); |
90 |
is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); |
91 |
$i++; |
92 |
} |
93 |
|
94 |
$schema->storage->txn_rollback; |
95 |
}; |
96 |
|
68 |
subtest 'add_credit() tests' => sub { |
97 |
subtest 'add_credit() tests' => sub { |
69 |
|
98 |
|
70 |
plan tests => 15; |
99 |
plan tests => 15; |
71 |
- |
|
|