Bugzilla – Attachment 81357 Details for
Bug 21694
Add the Koha::Account->lines method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21694: Add the Koha::Account->lines method
Bug-21694-Add-the-KohaAccount-lines-method.patch (text/plain), 2.93 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-10-27 11:48:03 UTC
(
hide
)
Description:
Bug 21694: Add the Koha::Account->lines method
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-10-27 11:48:03 UTC
Size:
2.93 KB
patch
obsolete
>From df08b4c6fa8eac61b618e3771c666005b51e84cb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 26 Oct 2018 18:34:35 +0100 >Subject: [PATCH] Bug 21694: Add the Koha::Account->lines method > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Account.pm | 20 ++++++++++++++++++++ > t/db_dependent/Koha/Account.t | 35 ++++++++++++++++++++++++++++++++++- > 2 files changed, 54 insertions(+), 1 deletion(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index ef5cd478ec..ff286a5027 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -509,6 +509,26 @@ sub non_issues_charges { > )->total_outstanding; > } > >+=head3 lines >+ >+my $lines = $self->lines; >+ >+Return all credits and debits for the user, outstanding or otherwise >+ >+=cut >+ >+sub lines { >+ my ($self) = @_; >+ >+ my $lines = Koha::Account::Lines->search( >+ { >+ borrowernumber => $self->{patron_id}, >+ } >+ ); >+ >+ return $lines; >+} >+ > 1; > > =head2 Name mappings >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 21f0e62191..ff400c7552 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > > use Koha::Account; > use Koha::Account::Lines; >@@ -192,3 +192,36 @@ subtest 'add_credit() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'lines() tests' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $account = $patron->account; >+ >+ my @generated_lines; >+ >+ # Add Credits >+ push @generated_lines, $account->add_credit({ amount => 1 }); >+ push @generated_lines, $account->add_credit({ amount => 2 }); >+ push @generated_lines, $account->add_credit({ amount => 3 }); >+ push @generated_lines, $account->add_credit({ amount => 4 }); >+ >+ # Add Debits >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 1 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 2 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 3 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 4 })->store; >+ >+ # Paid Off >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store; >+ push @generated_lines, Koha::Account::Line->new({ borrowernumber => $patron->id, amountoutstanding => 0 })->store; >+ >+ my $lines = $account->lines; >+ is( $lines->_resultset->count, 10, "All accountlines (debits, credits and paid off) were fetched"); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.19.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21694
:
81323
|
81324
|
81357
|
81358
|
81637
|
81638