|
Lines 90-96
subtest 'outstanding_credits() tests' => sub {
Link Here
|
| 90 |
$schema->storage->txn_begin; |
90 |
$schema->storage->txn_begin; |
| 91 |
|
91 |
|
| 92 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
92 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 93 |
my $account = Koha::Account->new({ patron_id => $patron->id }); |
93 |
my $account = $patron->account; |
| 94 |
|
94 |
|
| 95 |
my @generated_lines; |
95 |
my @generated_lines; |
| 96 |
push @generated_lines, $account->add_credit({ amount => 1 }); |
96 |
push @generated_lines, $account->add_credit({ amount => 1 }); |
|
Lines 98-106
subtest 'outstanding_credits() tests' => sub {
Link Here
|
| 98 |
push @generated_lines, $account->add_credit({ amount => 3 }); |
98 |
push @generated_lines, $account->add_credit({ amount => 3 }); |
| 99 |
push @generated_lines, $account->add_credit({ amount => 4 }); |
99 |
push @generated_lines, $account->add_credit({ amount => 4 }); |
| 100 |
|
100 |
|
| 101 |
my ( $total, $lines ) = $account->outstanding_credits(); |
101 |
my $lines = $account->outstanding_credits(); |
| 102 |
|
102 |
|
| 103 |
is( $total, -10, 'Outstandig credits total is correctly calculated' ); |
103 |
is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' ); |
| 104 |
|
104 |
|
| 105 |
my $i = 0; |
105 |
my $i = 0; |
| 106 |
foreach my $line ( @{ $lines->as_list } ) { |
106 |
foreach my $line ( @{ $lines->as_list } ) { |
|
Lines 109-116
subtest 'outstanding_credits() tests' => sub {
Link Here
|
| 109 |
$i++; |
109 |
$i++; |
| 110 |
} |
110 |
} |
| 111 |
|
111 |
|
| 112 |
( $total, $lines ) = Koha::Account->new({ patron_id => 'InvalidBorrowernumber' })->outstanding_credits(); |
112 |
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); |
| 113 |
is( $total, 0, "Total if no outstanding credits is 0" ); |
113 |
$lines = $patron_2->account->outstanding_credits(); |
|
|
114 |
is( $lines->total_outstanding, 0, "Total if no outstanding credits is 0" ); |
| 114 |
is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" ); |
115 |
is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" ); |
| 115 |
|
116 |
|
| 116 |
$schema->storage->txn_rollback; |
117 |
$schema->storage->txn_rollback; |
| 117 |
- |
|
|