Bugzilla – Attachment 72612 Details for
Bug 15985
Include checkout library in fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15985: Add new method Koha::Account::Line::checkout
Bug-15985-Add-new-method-KohaAccountLinecheckout.patch (text/plain), 5.29 KB, created by
Kyle M Hall (khall)
on 2018-03-09 15:44:10 UTC
(
hide
)
Description:
Bug 15985: Add new method Koha::Account::Line::checkout
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-03-09 15:44:10 UTC
Size:
5.29 KB
patch
obsolete
>From 5e9b3be147a76f599f58b9808a6ebb44c6638f15 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Fri, 9 Mar 2018 10:43:41 -0500 >Subject: [PATCH] Bug 15985: Add new method Koha::Account::Line::checkout > >--- > Koha/Account/Line.pm | 12 ++++++++++++ > Koha/Old/Checkout.pm | 2 +- > Koha/Old/Checkouts.pm | 2 +- > Koha/Schema/Result/OldIssue.pm | 10 ++++++++++ > members/pay.pl | 6 +++--- > t/db_dependent/Koha/Account/Lines.t | 37 ++++++++++++++++++++++++++++++++++++- > 6 files changed, 63 insertions(+), 6 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 2065de7..ddc59fe 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -21,6 +21,7 @@ use Carp; > > use Koha::Database; > use Koha::Items; >+use Koha::Checkouts; > > use base qw(Koha::Object); > >@@ -46,6 +47,17 @@ sub item { > return Koha::Item->_new_from_dbic( $rs ); > } > >+=head3 checkout >+ >+Return the checkout linked to this account line if exists >+ >+=cut >+ >+sub checkout { >+ my ($self) = @_; >+ return Koha::Checkouts->find( $self->issue_id ) || Koha::Old::Checkouts->find( $self->issue_id ); >+} >+ > =head3 _type > > =cut >diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm >index 3a7c1eb..df861d7 100644 >--- a/Koha/Old/Checkout.pm >+++ b/Koha/Old/Checkout.pm >@@ -19,7 +19,7 @@ use Modern::Perl; > > use Koha::Database; > >-use base qw(Koha::Object); >+use base qw(Koha::Checkout); > > sub _type { > return 'OldIssue'; >diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm >index c7f1a6a..1b5e218 100644 >--- a/Koha/Old/Checkouts.pm >+++ b/Koha/Old/Checkouts.pm >@@ -20,7 +20,7 @@ use Modern::Perl; > use Koha::Database; > use Koha::Old::Checkout; > >-use base qw(Koha::Objects); >+use base qw(Koha::Checkouts); > > sub _type { > return 'OldIssue'; >diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm >index b9c5b23..0998a08 100644 >--- a/Koha/Schema/Result/OldIssue.pm >+++ b/Koha/Schema/Result/OldIssue.pm >@@ -225,6 +225,16 @@ __PACKAGE__->belongs_to( > }, > ); > >+__PACKAGE__->belongs_to( >+ "branch", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branchcode" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ }, >+); >+ > > # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKLeDDEz22G5BU/ZAl7QLA >diff --git a/members/pay.pl b/members/pay.pl >index bb6573c..7fed067 100755 >--- a/members/pay.pl >+++ b/members/pay.pl >@@ -129,14 +129,14 @@ sub add_accounts_to_template { > my $total = $patron->account->balance; > my $account_lines = Koha::Account::Lines->search({ borrowernumber => $borrowernumber, amountoutstanding => { '!=' => 0 } }, { order_by => ['accounttype'] }); > my @accounts; >- while ( my $account_line = $account_lines->next ) { >- $account_line = $account_line->unblessed; >+ while ( my $a = $account_lines->next ) { >+ my $account_line = $a->unblessed; > if ( $account_line->{itemnumber} ) { > my $item = Koha::Items->find( $account_line->{itemnumber} ); > my $biblio = $item->biblio; > $account_line->{biblionumber} = $biblio->biblionumber; > $account_line->{title} = $biblio->title; >- $account_line->{checkout} = Koha::Checkouts->find($accountline->{issue_id}); >+ $account_line->{checkout} = $a->checkout; > } > push @accounts, $account_line; > } >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index 0c3287d..6db3ecd 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use Koha::Account::Lines; > use Koha::Items; >@@ -60,6 +60,41 @@ subtest 'item' => sub { > is( $line->itemnumber, $account_line_item->itemnumber, 'Koha::Account::Line->item should return the correct item' ); > }; > >+subtest 'checkout' => sub { >+ plan tests => 1; >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ my $item = Koha::Item->new( >+ { >+ biblionumber => $biblioitem->{biblionumber}, >+ biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ barcode => 'some_barcode_13', >+ itype => 'BK', >+ })->store; >+ >+ my $checkout = Koha::Checkout->new( >+ { borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->itemnumber, >+ branchcode => $library->{branchcode}, >+ } >+ )->store; >+ >+ my $line = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->itemnumber, >+ issue_id => $checkout->id, >+ accounttype => "F", >+ amount => 10, >+ })->store; >+ >+ is( $line->checkout->id, $checkout->id, 'Koha::Account::Line->checkout should return the correct checkout' ); >+}; >+ > $schema->storage->txn_rollback; > > 1; >-- >2.10.2
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 15985
:
58157
|
58163
|
71165
|
72611
|
72612
|
90317
|
90318
|
90364
|
90478
|
97177
|
97178
|
97179
|
97180
|
99821
|
99822
|
99823
|
99824
|
99825
|
103152
|
103153
|
103154
|
103155
|
103156
|
103157
|
104491
|
104492
|
105144
|
105398