From 9b8b2650da798ade7c6bf8409edba469de91b30b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 14 Jun 2017 10:47:11 -0400 Subject: [PATCH] Bug 2696 - Fine Payments Should Show What Was Paid For Test Plan: 1) Apply this patch and its' dependencies 2) Create and pay some various fees and fines 3) View the payments for fees, and fees paid by payments by using the new 'Details' button available on boraccount.pl --- Koha/Account/Offset.pm | 23 ++++ .../prog/en/includes/account_offset_type.inc | 8 ++ .../intranet-tmpl/prog/en/includes/accounttype.inc | 23 ++++ .../prog/en/modules/members/accountline-details.tt | 137 +++++++++++++++++++++ .../prog/en/modules/members/boraccount.tt | 25 +--- members/accountline-details.pl | 66 ++++++++++ 6 files changed, 259 insertions(+), 23 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/accounttype.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt create mode 100755 members/accountline-details.pl diff --git a/Koha/Account/Offset.pm b/Koha/Account/Offset.pm index 8f5f463..49e6f8a 100644 --- a/Koha/Account/Offset.pm +++ b/Koha/Account/Offset.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Account::Line; use base qw(Koha::Object); @@ -35,6 +36,28 @@ Account offsets are used to track the changes in account lines =cut +=head3 debit + +=cut + +sub debit { + my ( $self ) = @_; + my $debit_rs = $self->_result->debit; + return unless $debit_rs; + return Koha::Account::Line->_new_from_dbic( $debit_rs ); +} + +=head3 credit + +=cut + +sub credit { + my ( $self ) = @_; + my $credit_rs = $self->_result->credit; + return unless $credit_rs; + return Koha::Account::Line->_new_from_dbic( $credit_rs ); +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc new file mode 100644 index 0000000..ee53087 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/account_offset_type.inc @@ -0,0 +1,8 @@ +[% SWITCH account_offset.type %] + [% CASE 'Payment' %]Payment + [% CASE 'Manual Debit' %]Manual invoice + [% CASE 'Lost Item Return' %]Lost item returned + [% CASE 'Writeoff' %]Writeoff + [% CASE 'Void Payment' %]Void payment + [% CASE %][% account_offset.type %] +[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/accounttype.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/accounttype.inc new file mode 100644 index 0000000..3619bb0 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounttype.inc @@ -0,0 +1,23 @@ +[% SWITCH accountline.accounttype %] + [% CASE 'Pay' %]Payment, thanks + [% CASE 'Pay00' %]Payment, thanks (cash via SIP2) + [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2) + [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2) + [% CASE 'VOID' %]Payment, Voided + [% CASE 'N' %]New card + [% CASE 'F' %]Fine + [% CASE 'A' %]Account management fee + [% CASE 'M' %]Sundry + [% CASE 'L' %]Lost item + [% CASE 'W' %]Writeoff + [% CASE 'FU' %]Accruing fine + [% CASE 'HE' %]Hold waiting too long + [% CASE 'Rent' %]Rental fee + [% CASE 'FOR' %]Forgiven + [% CASE 'LR' %]Lost item fee refund + [% CASE 'PAY' %]Payment + [% CASE 'WO' %]Writeoff + [% CASE 'C' %]Credit + [% CASE 'CR' %]Credit + [% CASE %][% accountline.accounttype %] +[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt new file mode 100644 index 0000000..5e5a504 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/accountline-details.tt @@ -0,0 +1,137 @@ +[%- USE Price -%] +[%- USE KohaDates -%] +[%- USE AuthorisedValues -%] + +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %] +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patron-search.inc' %] + + + +
+
+
+
+ [% IF accountline %] + [% IF type == 'credit' %] +

Details for payment

+ [% ELSIF type == 'debit' %] +

Details for fee

+ [% END %] + + + + + + + + + + + + + + + + + + + + + + + + +
DateDescription of chargesNoteAmountOutstanding
+ [% accountline.date |$KohaDates %] + + [% INCLUDE 'accounttype.inc' accountline => accountline %] + [%- IF accountline.payment_type -%] + , [% AuthorisedValues.GetByCode('PAYMENT_TYPE', accountline.payment_type) %] + [%- END =%] + [%- IF accountline.description -%] + , [% accountline.description %] + [%- END -%] + +   + [% IF ( accountline.itemnumber ) %] + [% accountline.title |html %] + [% END %] + + [% accountline.note | html_line_break %] + + [% accountline.amount | $Price %] + + [% accountline.amountoutstanding | $Price %] +
+ + [% IF type == 'credit' %] +

Fees paid

+ [% ELSIF type == 'debit' %] +

Payments

+ [% END %] + + [% IF account_offsets %] + + + + + + + + + + + + + + + + + + + [% FOREACH ao IN account_offsets.sort('created_on') %] + [% IF type == 'credit' %] + [% SET offset_accountline = ao.debit %] + [% ELSIF type == 'debit' %] + [% SET offset_accountline = ao.credit %] + [% END %] + + [% IF offset_accountline %] + + + + + + + + + + + + + + [% END %] + [% END %] + +
Date createdDate updatedAmountAmount outstandingTypeNoteTransacting
librarian id
Date/Time of changeAmount of changeType of change 
[% offset_accountline.date | $KohaDates %][% offset_accountline.timestamp | $KohaDates with_hours => 1 %][% offset_accountline.amount | $Price %][% offset_accountline.amountoutstanding | $Price %][% INCLUDE 'accounttype.inc' accountline => offset_accountline %][% offset_accountline.note %][% IF offset_accountline.manager_id %][% offset_accountline.manager_id %][% END %][% ao.created_on | $KohaDates with_hours => 1 %][% ao.amount | $Price %][% INCLUDE 'account_offset_type.inc' account_offset => ao %] Details
+ [% ELSE %] + No details available for this payment. + [% END %] + [% ELSE %] +
+

Account line not found.

+
+ [% END %] +
+
+ +
+ [% INCLUDE 'circ-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index ba06227..4fe190a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -85,29 +85,7 @@ $(document).ready(function() { [% account.date |$KohaDates %] - [% SWITCH account.accounttype %] - [% CASE 'Pay' %]Payment, thanks - [% CASE 'Pay00' %]Payment, thanks (cash via SIP2) - [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2) - [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2) - [% CASE 'VOID' %]Payment, Voided - [% CASE 'N' %]New card - [% CASE 'F' %]Fine - [% CASE 'A' %]Account management fee - [% CASE 'M' %]Sundry - [% CASE 'L' %]Lost item - [% CASE 'W' %]Writeoff - [% CASE 'FU' %]Accruing fine - [% CASE 'HE' %]Hold waiting too long - [% CASE 'Rent' %]Rental fee - [% CASE 'FOR' %]Forgiven - [% CASE 'LR' %]Lost item fee refund - [% CASE 'PAY' %]Payment - [% CASE 'WO' %]Writeoff - [% CASE 'C' %]Credit - [% CASE 'CR' %]Credit - [% CASE %][% account.accounttype %] - [%- END -%] + [% INCLUDE 'accounttype.inc' accountline => account %] [%- IF account.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', account.payment_type) %][% END %] [%- IF account.description %], [% account.description %][% END %]  [% IF ( account.itemnumber ) %][% account.title |html %][% END %] @@ -120,6 +98,7 @@ $(document).ready(function() { [% ELSE %] Print [% END %] + Details [% IF ( reverse_col) %] [% IF ( account.payment ) %] Reverse diff --git a/members/accountline-details.pl b/members/accountline-details.pl new file mode 100755 index 0000000..e4b405e --- /dev/null +++ b/members/accountline-details.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright 2017 ByWater Solutions +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI; +use C4::Auth; +use C4::Output; +use C4::Context; +use C4::Members qw( GetMember ); +use Koha::Account::Lines; + +my $input = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/accountline-details.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { + borrowers => 1, + updatecharges => 'remaining_permissions' + }, + } +); + +my $accountlines_id = $input->param('accountlines_id'); + +my $accountline = Koha::Account::Lines->find($accountlines_id); + +if ($accountline) { + my $type = $accountline->accounttype =~ /^Pay/ ? 'credit' : 'debit'; + my $column = $type eq 'credit' ? 'credit_id' : 'debit_id'; + + my @account_offsets = Koha::Account::Offsets->search( { $column => $accountlines_id } ); + + $template->param( + type => $type, + accountline => $accountline, + account_offsets => \@account_offsets, + + finesview => 1, + ); + + my $data = GetMember( 'borrowernumber' => $accountline->borrowernumber ); + $template->param(%$data); +} + +output_html_with_http_headers $input, $cookie, $template->output; -- 2.10.2