Bugzilla – Attachment 138462 Details for
Bug 30612
Add account_lines method to Koha::[Old::]Checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30612: Add accountlines method to Koha::Checkout and Koha::Old::Checkout
Bug-30612-Add-accountlines-method-to-KohaCheckout-.patch (text/plain), 4.49 KB, created by
Jonathan Druart
on 2022-08-01 12:45:39 UTC
(
hide
)
Description:
Bug 30612: Add accountlines method to Koha::Checkout and Koha::Old::Checkout
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-01 12:45:39 UTC
Size:
4.49 KB
patch
obsolete
>From 9f9f685d0dcfc9c4029e8eeafd77c2dae5a96ef2 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 8 Jun 2022 13:41:56 -0400 >Subject: [PATCH] Bug 30612: Add accountlines method to Koha::Checkout and > Koha::Old::Checkout > >It would be very useful to have an accountlines method on checkouts objects. In particular it would make fees related to a checkout available from the checkout objects in overdue notices. > >Test Plan: >1) Apply this patch >2) prove t/db_dependent/Koha/Account/Line.t >3) prove t/db_dependent/Koha/Checkouts.t > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Checkout.pm | 14 ++++++++++++ > Koha/Old/Checkout.pm | 14 ++++++++++++ > t/db_dependent/Koha/Account/Line.t | 5 ++++- > t/db_dependent/Koha/Checkouts.t | 35 +++++++++++++++++++++++++++++- > 4 files changed, 66 insertions(+), 2 deletions(-) > >diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm >index 82cdfe4095b..61dc30d7789 100644 >--- a/Koha/Checkout.pm >+++ b/Koha/Checkout.pm >@@ -79,6 +79,20 @@ sub item { > return Koha::Item->_new_from_dbic( $item_rs ); > } > >+=head3 accountlines >+ >+my $accountlines = $checkout->accountlines; >+ >+Return the checked out accountlines >+ >+=cut >+ >+sub accountlines { >+ my ( $self ) = @_; >+ my $accountlines_rs = $self->_result->accountlines; >+ return Koha::Account::Lines->_new_from_dbic( $accountlines_rs ); >+} >+ > =head3 library > > my $library = $checkout->library; >diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm >index ab958985e79..91f70728315 100644 >--- a/Koha/Old/Checkout.pm >+++ b/Koha/Old/Checkout.pm >@@ -45,6 +45,20 @@ sub item { > return Koha::Item->_new_from_dbic( $item_rs ); > } > >+=head3 accountlines >+ >+my $accountlines = $checkout->accountlines; >+ >+Return the checked out accountlines >+ >+=cut >+ >+sub accountlines { >+ my ( $self ) = @_; >+ my $accountlines_rs = $self->_result->accountlines; >+ return Koha::Account::Lines->_new_from_dbic( $accountlines_rs ); >+} >+ > =head3 library > > my $library = $checkout->library; >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index 098d8e8becf..c2436b75168 100755 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -203,7 +203,7 @@ subtest 'is_credit() and is_debit() tests' => sub { > > subtest 'apply() tests' => sub { > >- plan tests => 31; >+ plan tests => 32; > > $schema->storage->txn_begin; > >@@ -346,6 +346,9 @@ subtest 'apply() tests' => sub { > } > )->store(); > >+ my $a = $checkout->accountlines->next; >+ is( $a->id, $accountline->id, "Koha::Checkout::accountlines returns the related acountline" ); >+ > # Enable renewing upon fine payment > t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 1 ); > my $called = 0; >diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t >index 9c4b0dbfeae..8ca855d27c3 100755 >--- a/t/db_dependent/Koha/Checkouts.t >+++ b/t/db_dependent/Koha/Checkouts.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 11; > > use C4::Circulation qw( MarkIssueReturned AddReturn ); > use Koha::Checkouts; >@@ -110,6 +110,39 @@ subtest 'item' => sub { > 'Koha::Checkout->item should return the correct item' ); > }; > >+subtest 'accountlines' => sub { >+ plan tests => 3; >+ >+ my $accountline = Koha::Account::Line->new( >+ { >+ issue_id => $retrieved_checkout_1->id, >+ borrowernumber => $retrieved_checkout_1->borrowernumber, >+ itemnumber => $retrieved_checkout_1->itemnumber, >+ branchcode => $retrieved_checkout_1->branchcode, >+ date => \'NOW()', >+ debit_type_code => 'OVERDUE', >+ status => 'UNRETURNED', >+ interface => 'cli', >+ amount => '1', >+ amountoutstanding => '1', >+ } >+ )->store(); >+ >+ my $accountlines = $retrieved_checkout_1->accountlines; >+ is( ref($accountlines), 'Koha::Account::Lines', >+ 'Koha::Checkout->accountlines should return a Koha::Item' ); >+ >+ my $line = $accountlines->next; >+ is( ref($line), 'Koha::Account::Line', >+ 'next returns a Koha::Account::Line' ); >+ >+ is( >+ $accountline->id, >+ $line->id, >+ 'Koha::Checkout->accountlines should return the correct accountlines' >+ ); >+}; >+ > subtest 'patron' => sub { > plan tests => 3; > my $patron = $builder->build_object( >-- >2.25.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 30612
:
133841
|
134567
|
135827
|
135828
|
135829
|
138461
| 138462 |
138463
|
138464
|
138465