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

(-)a/Koha/Account.pm (+20 lines)
Lines 524-529 sub non_issues_charges { Link Here
524
      : 0;
524
      : 0;
525
}
525
}
526
526
527
=head3 lines
528
529
my $lines = $self->lines;
530
531
Return all credits and debits for the user, outstanding or otherwise
532
533
=cut
534
535
sub lines {
536
    my ($self) = @_;
537
538
    my $lines = Koha::Account::Lines->search(
539
        {
540
            borrowernumber    => $self->{patron_id},
541
        }
542
    );
543
544
    return $lines;
545
}
546
527
1;
547
1;
528
548
529
=head2 Name mappings
549
=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