From 0c8943e3486b73b3843f549c71b9fe13f28ced0d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 13 Dec 2016 13:23:18 +0000 Subject: [PATCH] Bug 15985 - Include transacting library in fines Some librarians would like to see the library an item was checked out from in the fines table on the fines payment page. Test Plan: 1) Apply this patch 2) Find a patron with overdue items that have fines 3) Browse to the pay fines page 4) Note the new "checked out from" column --- Koha/Checkout.pm | 14 +++++++++++--- koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt | 8 ++++++-- members/pay.pl | 2 ++ t/db_dependent/Koha/Checkouts.t | 6 +++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index 358f41c..eb8c144 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -19,9 +19,7 @@ package Koha::Checkout; use Modern::Perl; -use Carp; - -use Koha::Database; +use Koha::Libraries; use base qw(Koha::Object); @@ -35,6 +33,16 @@ Koha::Checkout - Koha Checkout object class =cut +=head library + +=cut + +sub library { + my ($self) = @_; + + return Koha::Libraries->find( $self->branchcode ); +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index b37ce3c..9451096 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -75,6 +75,7 @@ function enableCheckboxActions(){   Fines & charges + Checked out from Description Payment note Account type @@ -86,7 +87,7 @@ function enableCheckboxActions(){ - Total due: + Total due: [% total | format('%.2f') %] @@ -115,6 +116,9 @@ function enableCheckboxActions(){ + + [% line.checkout.library.branchname %] + [% SWITCH line.accounttype %] [% CASE 'Pay' %]Payment, thanks @@ -152,7 +156,7 @@ function enableCheckboxActions(){ [% IF ( account_grp.total ) %] - Sub total: + Sub total: [% account_grp.total | format('%.2f') %] [% END %] diff --git a/members/pay.pl b/members/pay.pl index bfca78b..6df625e 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -41,6 +41,7 @@ use C4::Koha; use C4::Overdues; use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Patron::Images; +use Koha::Checkouts; use Koha::Patron::Categories; use URI::Escape; @@ -127,6 +128,7 @@ sub add_accounts_to_template { GetBorNotifyAcctRecord( $borrowernumber, $notify_id ); if ( @{$accountlines} ) { my $totalnotify = AmountNotify( $notify_id, $borrowernumber ); + map { $_->{checkout} = Koha::Checkouts->find($_->{issue_id} ) } @$accountlines; push @{$accounts}, { accountlines => $accountlines, notify => $notify_id, diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t index e8b1341..ec565e6 100644 --- 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 => 4; +use Test::More tests => 6; use Koha::Checkout; use Koha::Checkouts; @@ -49,6 +49,9 @@ my $new_checkout_2 = Koha::Checkout->new( } )->store; +is( $new_checkout_1->library->branchcode, $library->{branchcode}, 'Got correct library for checkout1' ); +is( $new_checkout_2->library->branchcode, $library->{branchcode}, 'Got correct library for checkout2' ); + like( $new_checkout_1->issue_id, qr|^\d+$|, 'Adding a new checkout should have set the issue_id' ); is( Koha::Checkouts->search->count, $nb_of_checkouts + 2, 'The 2 checkouts should have been added' ); @@ -58,6 +61,7 @@ is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a chec $retrieved_checkout_1->delete; is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); + $schema->storage->txn_rollback; 1; -- 2.1.4