From f307c48b9d2d657d041a7800d045366fdb95583b Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 22 May 2019 03:20:13 -0300 Subject: [PATCH] Bug 20691: Implement fines view --- .../bootstrap/en/includes/account-table.inc | 62 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 23 +++++++- opac/opac-account.pl | 28 ++++++++++ opac/opac-user.pl | 13 +++++ 4 files changed, 125 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc index e2bb1a1b36..506a621703 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc @@ -116,6 +116,68 @@

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 %] + [%- BLOCK account_status_description -%] [%- SWITCH account.status -%] [%- CASE 'UNRETURNED' -%] (Accruing) 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 60c7039f45..b8e580789c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -149,8 +149,9 @@ [% IF relatives %]
  • Relatives' checkouts
  • [% END %] [% IF ( overdues_count ) %]
  • Overdue ([% overdues_count | html %])
  • [% END %] [% IF ( OPACFinesTab ) %] - [% IF ( amountoutstanding > 0 ) %]
  • Fines ([% amountoutstanding | $Price %])
  • [% END %] + [% IF ( amountoutstanding > 0 ) %]
  • Fines ([% amountoutstanding | $Price %])
  • [% END %] [% IF ( amountoutstanding < 0 ) %]
  • Credits ([% amountoutstanding * -1 | $Price %])
  • [% END %] + [% IF relatives_with_fines %]
  • Relatives' fines
  • [% END %] [% END %] [% IF borrower_club_enrollments.count || borrower_enrollable_clubs.count %] @@ -411,6 +412,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 9c47e35755..d00b290bca 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -44,6 +44,34 @@ my $account = $patron->account; my $total = $account->balance; my $accountlines = $account->lines; +if ( C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor') + || C4::Context->preference('AllowStaffToSetFinesVisibilityForGuarantor') + ) +{ + 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_fines ) { + + 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 => $total, diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 177bed321c..b26dc99ba6 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -340,6 +340,19 @@ 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( patron_messages => $patron_messages, opacnote => $borr->{opacnote}, -- 2.11.0