@@ -, +, @@ --- Koha/Patron.pm | 9 ++++----- t/db_dependent/Koha/Patrons.t | 20 ++++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -519,16 +519,15 @@ sub get_overdues { return $issues; } -=head3 get_account_lines +=head3 account -my $fines = $patron->get_account_lines +my $account = $patron->account =cut -sub get_account_lines { +sub account { my ($self) = @_; - my $account_lines = $self->_result->accountlines; - return Koha::Account::Lines->_new_from_dbic($account_lines); + return Koha::Account->new( { patron_id => $self->borrowernumber } ); } =head3 type --- a/t/db_dependent/Koha/Patrons.t +++ a/t/db_dependent/Koha/Patrons.t @@ -471,26 +471,14 @@ subtest 'get_overdues' => sub { $patron->delete; }; -subtest 'get_account_lines' => sub { - plan tests => 2; +subtest 'account' => sub { + plan tests => 1; my $patron = $builder->build({source => 'Borrower'}); - my $accountline_1 = $builder->build({ source => 'Accountline', - value => { borrowernumber => $patron->{borrowernumber}, - amount => 42, - amountoutstanding => 42 } - }); - my $accountline_2 = $builder->build({ source => 'Accountline', - value => { borrowernumber => $patron->{borrowernumber}, - amount => -13, - amountoutstanding => -13 } - }); - $patron = Koha::Patrons->find( $patron->{borrowernumber} ); - my $account_lines = $patron->get_account_lines; - is( $account_lines->count, 2, 'There should have 2 account lines for that patron' ); - is( ref($account_lines), 'Koha::Account::Lines', 'get_account_lines should return a Koha::Account::Lines object' ); + my $account = $patron->account; + is( ref($account), 'Koha::Account', 'account should return a Koha::Account object' ); $patron->delete; }; --