Lines 19-26
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 1; |
22 |
use Test::More tests => 2; |
23 |
use Test::Exception; |
|
|
24 |
|
23 |
|
25 |
use Koha::Account::Offsets; |
24 |
use Koha::Account::Offsets; |
26 |
|
25 |
|
Lines 73-75
subtest 'total() tests' => sub {
Link Here
|
73 |
|
72 |
|
74 |
$schema->storage->txn_rollback; |
73 |
$schema->storage->txn_rollback; |
75 |
}; |
74 |
}; |
76 |
- |
75 |
|
|
|
76 |
subtest 'filter_by_non_reversable() and filter_by_reversable() tests' => sub { |
77 |
|
78 |
plan tests => 4; |
79 |
|
80 |
$schema->storage->txn_begin; |
81 |
|
82 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
83 |
my $account = $patron->account; |
84 |
|
85 |
my $manual_fee = $account->add_debit({ amount => 11, interface => 'intranet', type => 'MANUAL' }); |
86 |
|
87 |
$account->pay( { amount => 1, type => 'WRITEOFF' } ); |
88 |
$account->pay( { amount => 2, type => 'DISCOUNT' } ); |
89 |
$account->pay( { amount => 3, type => 'CANCELLATION' } ); |
90 |
$account->pay( { amount => 4, type => 'PAYMENT' } ); |
91 |
$account->pay( { amount => 5, type => 'CREDIT' } ); |
92 |
|
93 |
# non-reversable offsets |
94 |
is( $manual_fee->debit_offsets->filter_by_non_reversable->count, |
95 |
3, '3 non-reversable offsets' ); |
96 |
is( $manual_fee->debit_offsets->filter_by_non_reversable->total, |
97 |
-6, '-6 the total amount of the non-reversable offsets' ); |
98 |
# reversable offsets |
99 |
is( $manual_fee->debit_offsets->filter_by_reversable->count, |
100 |
2, 'The right reversable offsets count' ); |
101 |
is( $manual_fee->debit_offsets->filter_by_reversable->total, |
102 |
-5, 'The right total amount of the reversable offsets' ); |
103 |
|
104 |
$schema->storage->txn_rollback; |
105 |
}; |