From 243cab0f1841c83ac5ad45450796e8a0ba2f34c5 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 21 Dec 2017 14:15:52 +0000 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 Signed-off-by: Lee Jamison Running updatedatabase.pl after patch application makes dependencies happy. Passes QA Tools and works as intended. Rebased (2017-12-21): Alex Arnaud --- Koha/Account/Offset.pm | 23 +++++++++++++++++++ .../prog/en/modules/members/boraccount.tt | 26 ++-------------------- t/db_dependent/Accounts.t | 8 ++++++- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Koha/Account/Offset.pm b/Koha/Account/Offset.pm index b411653..3110d6a 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/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index ceb503e..d719e1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -55,30 +55,7 @@ [% 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 'PF' %]Processing fee - [% 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 %] @@ -91,6 +68,7 @@ [% ELSE %] Print [% END %] + Details [% IF ( reverse_col) %] [% IF ( account.payment ) %] Reverse diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 2ce9474..29611cd 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -632,7 +632,7 @@ subtest "Koha::Account::chargelostitem tests" => sub { subtest "Koha::Account::Line::void tests" => sub { - plan tests => 12; + plan tests => 14; # Create a borrower my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; @@ -662,6 +662,12 @@ subtest "Koha::Account::Line::void tests" => sub { amount => 30, } ); + + # Test debit and credit methods fo Koha::Account::Offset + my $account_offset = Koha::Account::Offsets->find( { credit_id => $id, debit_id => $line1->id } ); + is( $account_offset->debit->id, $line1->id, "Koha::Account::Offset->debit gets correct accountline" ); + is( $account_offset->credit->id, $id, "Koha::Account::Offset->credit gets correct accountline" ); + my $account_payment = Koha::Account::Lines->find( $id ); is( $account->balance(), "0.000000", "Account balance is 0" ); -- 2.10.2