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

(-)a/Koha/Patron.pm (-5 / +4 lines)
Lines 519-534 sub get_overdues { Link Here
519
    return $issues;
519
    return $issues;
520
}
520
}
521
521
522
=head3 get_account_lines
522
=head3 account
523
523
524
my $fines = $patron->get_account_lines
524
my $account = $patron->account
525
525
526
=cut
526
=cut
527
527
528
sub get_account_lines {
528
sub account {
529
    my ($self) = @_;
529
    my ($self) = @_;
530
    my $account_lines = $self->_result->accountlines;
530
    return Koha::Account->new( { patron_id => $self->borrowernumber } );
531
    return Koha::Account::Lines->_new_from_dbic($account_lines);
532
}
531
}
533
532
534
=head3 type
533
=head3 type
(-)a/t/db_dependent/Koha/Patrons.t (-17 / +4 lines)
Lines 471-496 subtest 'get_overdues' => sub { Link Here
471
    $patron->delete;
471
    $patron->delete;
472
};
472
};
473
473
474
subtest 'get_account_lines' => sub {
474
subtest 'account' => sub {
475
    plan tests => 2;
475
    plan tests => 1;
476
476
477
    my $patron = $builder->build({source => 'Borrower'});
477
    my $patron = $builder->build({source => 'Borrower'});
478
478
479
    my $accountline_1 = $builder->build({ source => 'Accountline',
480
        value  => { borrowernumber => $patron->{borrowernumber},
481
                    amount => 42,
482
                    amountoutstanding => 42 }
483
    });
484
    my $accountline_2 = $builder->build({ source => 'Accountline',
485
        value  => { borrowernumber => $patron->{borrowernumber},
486
                    amount => -13,
487
                    amountoutstanding => -13 }
488
    });
489
490
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
479
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
491
    my $account_lines = $patron->get_account_lines;
480
    my $account = $patron->account;
492
    is( $account_lines->count, 2, 'There should have 2 account lines for that patron' );
481
    is( ref($account),   'Koha::Account', 'account should return a Koha::Account object' );
493
    is( ref($account_lines),   'Koha::Account::Lines', 'get_account_lines should return a Koha::Account::Lines object' );
494
482
495
    $patron->delete;
483
    $patron->delete;
496
};
484
};
497
- 

Return to bug 17585