From 683460a3a8fef3fad430c1822edeb0349adb8aa2 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 This patch implements the logic to show guarantee's fines with guarantor user. To test: 1) Apply (if not already done) steps 1 to 5 of previous patch 2) Apply this patch 3) Set OPACFinesTab and AllowStaffToSetFinesVisibilityForGuarantor preference to "Allow" 4) Find a guarantee and in accounting create a manual invoice 5) Enter OPAC with guarantor user CHECK => In summary there is no "Relatives fines" tab 6) On intranet edit guarantee and set "Show fines to guarantors" to "Yes" and save 7) Reload guarantor's OPAC SUCCESS => You see a "Relatives fines" tab with guarantee's fines information 8) Sign off --- .../bootstrap/en/includes/account-table.inc | 40 +++++++++++++++++++ .../bootstrap/en/modules/opac-user.tt | 23 ++++++++++- opac/opac-account.pl | 28 +++++++++++++ opac/opac-user.pl | 13 ++++++ 4 files changed, 103 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 7dbf9ad18e..d43ddfe2ae 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,46 @@

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 %] + [% PROCESS account_type_description account=a %] + [%- 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_type_description -%] [%- SWITCH account.accounttype -%] [%- CASE 'Pay' -%]Payment 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 09f7031a3f..4f6d257948 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 d5677fc1b3..8ba2ba33f8 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -45,6 +45,34 @@ my $accountlines = $account->lines->search({ amountoutstanding => { '>=' => 0 }} my $total_outstanding = $accountlines->total_outstanding; my $outstanding_credits = $account->outstanding_credits; +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_outstanding, 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.17.1