From 74a80a35c72995311c7a76a9efe3853db1fb166c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 2 May 2018 13:12:02 +0000 Subject: [PATCH] Bug 20691: Implement fines view --- .../opac-tmpl/bootstrap/en/modules/opac-account.tt | 62 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 22 ++++++++ opac/opac-account.pl | 27 ++++++++++ opac/opac-user.pl | 12 +++++ 4 files changed, 123 insertions(+) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt index d5b5e346ec..072e4d87c8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -177,6 +177,68 @@ [% ELSE %]

You have no fines or charges

[% END %] + + [% FOREACH r IN relatives %] +

[% r.patron.firstname %] [% r.patron.surname %]'s fines and charges

+ + + + + + + + + + + + + [% SET account_sum = 0 %] + [% FOREACH a IN r.accountlines %] + [% SET account_sum = account_sum + a.amountoutstanding %] + + + + [% IF ( a.amount < 0 ) %] + [% IF ( a.amountoutstanding < 0 ) %] + + [% END %] + + + + + + + + +
DateDescriptionFine amountAmount outstanding
[% a.date | $KohaDates %] + [% SWITCH a.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 '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 %][% a.accounttype %] + [%- END -%] + [%- IF a.payment_type %], [% AuthorisedValues.GetByCode('PAYMENT_TYPE', a.payment_type, 1) %][% END %] + [%- IF a.description %], [% a.description %][% END %] + [% IF a.itemnumber %]([% a.item.biblio.title %])[% END %] + [% ELSE %][% END %][% a.amount | $Price %][% ELSE %][% END %][% a.amountoutstanding | $Price %]
Total due[% account_sum | $Price %]
+ [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 4c87896b50..453d1aabfd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -133,6 +133,8 @@ [% IF ( BORROWER_INFO.amountoverfive ) %]
  • Fines ([% amountoutstanding | $Price %])
  • [% END %] [% IF ( BORROWER_INFO.amountoverzero ) %]
  • Fines ([% amountoutstanding | $Price %])
  • [% END %] [% IF ( BORROWER_INFO.amountlessthanzero ) %]
  • Credits ([% amountoutstanding | $Price %])
  • [% END %] + + [% IF relatives %]
  • Relatives' fines
  • [% END %] [% END %] [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] @@ -396,6 +398,26 @@ [% END %] + + [% IF relatives_with_fines %] +

    Fines and charges

    + + + + + + + + [% FOREACH r IN relatives_with_fines %] + + + + + [% END %] + +
    Amount
    [% r.firstname %] [% r.surname %] currently owes fines and charges amounting to:[% r.account.balance | $Price %]
    +
    + [% END %] [% END # / OPACFinesTab %] [% IF relatives %] diff --git a/opac/opac-account.pl b/opac/opac-account.pl index 9611554b58..6d9c222fe6 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -67,6 +67,33 @@ while ( my $line = $accts->next ) { push @accountlines, $accountline; } +if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') + || C4::Context->preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') + ) +{ + my @relatives; + + # Filter out guarantees that don't want guarantor to see checkouts + foreach my $gr ( $patron->guarantee_relationships() ) { + my $g = $gr->guarantee; + if ( $g->privacy_guarantor_checkouts ) { + + my $relatives_accountlines = Koha::Account::Lines->search( + { borrowernumber => $g->borrowernumber }, + { order_by => { -desc => 'accountlines_id' } } + ); + push( + @relatives, + { + patron => $g, + accountlines => $relatives_accountlines, + } + ); + } + } + $template->param( relatives => \@relatives ); +} + $template->param( ACCOUNT_LINES => \@accountlines, total => sprintf( "%.2f", $total ), # FIXME Use TT plugin Price diff --git a/opac/opac-user.pl b/opac/opac-user.pl index a40cb60c5a..b4acebbec2 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -350,6 +350,18 @@ if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor' $template->param( relatives => \@relatives ); } +if ( C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor') + || C4::Context->preference('AllowStaffToSetFinesVisibilityForGuarantor') ) +{ + my @relatives_with_fines; + # Filter out guarantees that don't want guarantor to see checkouts + foreach my $gr ( $patron->guarantee_relationships() ) { + my $g = $gr->guarantee; + push( @relatives_with_fines, $g ) if $g->privacy_guarantor_fines; + } + $template->param( relatives_with_fines => \@relatives_with_fines ); +} + $template->param( borrower => scalar Koha::Patrons->find($borrowernumber), patron_messages => $patron_messages, -- 2.15.1 (Apple Git-101)