View | Details | Raw Unified | Return to bug 21694
Collapse All | Expand All

(-)a/Koha/Account.pm (+20 lines)
Lines 509-514 sub non_issues_charges { Link Here
509
    )->total_outstanding;
509
    )->total_outstanding;
510
}
510
}
511
511
512
=head3 lines
513
514
my $lines = $self->lines;
515
516
Return all credits and debits for the user, outstanding or otherwise
517
518
=cut
519
520
sub lines {
521
    my ($self) = @_;
522
523
    my $lines = Koha::Account::Lines->search(
524
        {
525
            borrowernumber    => $self->{patron_id},
526
        }
527
    );
528
529
    return $lines;
530
}
531
512
1;
532
1;
513
533
514
=head2 Name mappings
534
=head2 Name mappings
(-)a/t/db_dependent/Koha/Account.t (-2 / +34 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use Koha::Account;
24
use Koha::Account;
25
use Koha::Account::Lines;
25
use Koha::Account::Lines;
Lines 192-194 subtest 'add_credit() tests' => sub { Link Here
192
192
193
    $schema->storage->txn_rollback;
193
    $schema->storage->txn_rollback;
194
};
194
};
195
- 
195
196
subtest 'lines() tests' => sub {
197
198
    plan tests => 1;
199
200
    $schema->storage->txn_begin;
201
202
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
203
    my $account = $patron->account;
204
205
    my @generated_lines;
206
207
    # Add Credits
208
    push @generated_lines, $account->add_credit({ amount => 1 });
209
    push @generated_lines, $account->add_credit({ amount => 2 });
210
    push @generated_lines, $account->add_credit({ amount => 3 });
211
    push @generated_lines, $account->add_credit({ amount => 4 });
212
213
    # Add Debits
214
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store;
215
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 2 })->store;
216
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store;
217
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store;
218
219
    # Paid Off
220
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store;
221
    push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store;
222
223
    my $lines = $account->lines;
224
    is( $lines->_resultset->count, 10, "All accountlines (debits, credits and paid off) were fetched");
225
226
    $schema->storage->txn_rollback;
227
};

Return to bug 21694