From 6b7b43c558874a3f39b556b7fff3f6897202ce03 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 29 Mar 2019 14:31:22 +0000
Subject: [PATCH] Bug 22521: Update UI to use accountlines.status

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
---
 .../prog/en/includes/accounts.inc             | 52 +++++++++++--------
 .../prog/en/modules/members/maninvoice.tt     |  2 +-
 .../en/modules/members/moremember-print.tt    |  2 +-
 .../prog/en/modules/members/pay.tt            | 27 ++--------
 .../bootstrap/en/includes/account-table.inc   | 14 +++--
 .../bootstrap/en/modules/opac-account.tt      |  1 +
 opac/opac-user.pl                             |  2 +-
 7 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
index cf388239fb..fd306c77b4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
@@ -1,27 +1,26 @@
 [%- BLOCK account_type_description -%]
     [%- SWITCH account.accounttype -%]
-        [%- CASE 'Pay'   -%]<span>Payment, thanks</span>
-        [%- CASE 'Pay00' -%]<span>Payment, thanks (cash via SIP2)</span>
-        [%- CASE 'Pay01' -%]<span>Payment, thanks (VISA via SIP2)</span>
-        [%- CASE 'Pay02' -%]<span>Payment, thanks (credit card via SIP2)</span>
-        [%- CASE 'VOID'  -%]<span>Voided</span>
-        [%- CASE 'N'     -%]<span>New card</span>
-        [%- CASE 'F'     -%]<span>Fine</span>
-        [%- CASE 'A'     -%]<span>Account management fee</span>
-        [%- CASE 'M'     -%]<span>Sundry</span>
-        [%- CASE 'L'     -%]<span>Lost item</span>
-        [%- CASE 'W'     -%]<span>Writeoff</span>
-        [%- CASE 'FU'    -%]<span>Accruing fine</span>
-        [%- CASE 'HE'    -%]<span>Hold waiting too long</span>
-        [%- CASE 'Rent'  -%]<span>Rental fee</span>
-        [%- CASE 'FOR'   -%]<span>Forgiven</span>
-        [%- CASE 'LR'    -%]<span>Lost item fee refund</span>
-        [%- CASE 'PF'    -%]<span>Processing fee</span>
-        [%- CASE 'PAY'   -%]<span>Payment</span>
-        [%- CASE 'WO'    -%]<span>Writeoff</span>
-        [%- CASE 'C'     -%]<span>Credit</span>
-        [%- CASE 'CR'    -%]<span>Credit</span>
-        [%- CASE         -%][% account.accounttype | html %]
+        [%- CASE 'Pay'     -%]<span>Payment, thanks</span>
+        [%- CASE 'Pay00'   -%]<span>Payment, thanks (cash via SIP2)</span>
+        [%- CASE 'Pay01'   -%]<span>Payment, thanks (VISA via SIP2)</span>
+        [%- CASE 'Pay02'   -%]<span>Payment, thanks (credit card via SIP2)</span>
+        [%- CASE 'VOID'    -%]<span>Voided</span>
+        [%- CASE 'N'       -%]<span>New card</span>
+        [%- CASE 'OVERDUE' -%]<span>Fine[%- PROCESS account_status_description account=account -%]</span>
+        [%- CASE 'A'       -%]<span>Account management fee</span>
+        [%- CASE 'M'       -%]<span>Sundry</span>
+        [%- CASE 'L'       -%]<span>Lost item</span>
+        [%- CASE 'W'       -%]<span>Writeoff</span>
+        [%- CASE 'HE'      -%]<span>Hold waiting too long</span>
+        [%- CASE 'Rent'    -%]<span>Rental fee</span>
+        [%- CASE 'FOR'     -%]<span>Forgiven</span>
+        [%- CASE 'LR'      -%]<span>Lost item fee refund</span>
+        [%- CASE 'PF'      -%]<span>Processing fee</span>
+        [%- CASE 'PAY'     -%]<span>Payment</span>
+        [%- CASE 'WO'      -%]<span>Writeoff</span>
+        [%- CASE 'C'       -%]<span>Credit</span>
+        [%- CASE 'CR'      -%]<span>Credit</span>
+        [%- CASE           -%][% account.accounttype | html %]
     [%- END -%]
 [%- END -%]
 
@@ -37,3 +36,12 @@
         [%- CASE                  -%][% account_offset.type | html %]
     [%- END -%]
 [%- END -%]
+
+[%- BLOCK account_status_description -%]
+    [%- SWITCH account.status -%]
+        [%- CASE 'UNRETURNED' -%]<span> (Accruing)</span>
+        [%- CASE 'RETURNED'   -%]<span> (Returned)</span>
+        [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
+        [%- CASE              -%]
+    [%- END -%]
+[%- END -%]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
index 672c4cbd76..213641047a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
@@ -79,7 +79,7 @@
     [% INCLUDE 'str/members-menu.inc' %]
     [% Asset.js("js/members-menu.js") | $raw %]
     <script>
-        var type_fees = {'L':'','F':'','A':'','N':'','M':''};
+        var type_fees = {'L':'','OVERDUE':'','A':'','N':'','M':''};
         [% FOREACH invoice_types_loo IN invoice_types_loop %]
             type_fees['[% invoice_types_loo.authorised_value | html %]'] = "[% invoice_types_loo.lib | html %]";
         [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt
index 10ee5574e0..2bb327c13f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-print.tt
@@ -120,7 +120,7 @@
                           , [% account.description | html %]
                       [% END %]
                       &nbsp;
-                      [% IF ( account.itemnumber AND account.accounttype != 'F' AND account.accounttype != 'FU' ) %]
+                      [% IF ( account.itemnumber AND account.accounttype != 'OVERDUE' ) %]
                           <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% account.item.biblionumber | uri %]&amp;itemnumber=[% account.itemnumber | uri %]">[% account.item.biblio.title | html %]</a>
                       [% END %]
                   </td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
index 7afd743acc..e5cfad05cb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt
@@ -7,6 +7,9 @@
 [% USE ColumnsSettings %]
 [% USE KohaDates %]
 [% SET footerjs = 1 %]
+
+[% PROCESS 'accounts.inc' %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Make a payment for  [% patron.firstname | html %] [% patron.surname | html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -80,29 +83,7 @@
     <input type="hidden" name="borrowernumber[% line.accountlines_id | html %]" value="[% line.borrowernumber | html %]" />
     </td>
     <td>
-        [% SWITCH line.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 %][% line.accounttype | html %]
-        [%- END -%]
+        [% PROCESS account_type_description account=line %]
         [%- IF line.description %], [% line.description | html %][% END %]
         [% IF line.itemnumber %]([% line.item.biblio.title | html %])[% END %]
     </td>
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 a73da77196..2896adadf0 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc
@@ -33,12 +33,11 @@
                         [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2)
                         [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2)
                         [% CASE 'N' %]New card
-                        [% CASE 'F' %]Fine
+                        [% CASE 'OVERDUE' %]Fine[%- PROCESS account_status_description account=account -%]
                         [% 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
@@ -109,4 +108,13 @@
     </form>
 [% ELSE %]
     <h4>You have no fines or charges</h4>
-[% END %]
\ No newline at end of file
+[% END %]
+
+[%- BLOCK account_status_description -%]
+    [%- SWITCH account.status -%]
+        [%- CASE 'UNRETURNED' -%]<span> (Accruing)</span>
+        [%- CASE 'RETURNED'   -%]<span> (Returned)</span>
+        [%- CASE 'FORGIVEN'   -%]<span> (Forgiven)</span>
+        [%- CASE              -%]
+    [%- END -%]
+[%- END -%]
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 265136d715..c6f6cc7efc 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt
@@ -68,6 +68,7 @@
 
                     [% PROCESS 'account-table.inc' ACCOUNT_LINES = ACCOUNT_LINES, ENABLE_OPAC_PAYMENTS = ENABLE_OPAC_PAYMENTS, plugins = plugins %]
 
+
                 </div> <!-- / #useraccount -->
             </div> <!-- / .span10 -->
         </div> <!-- / .row-fluid -->
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index 7ed262f6a2..7dee44c744 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -196,7 +196,7 @@ if ( $pending_checkouts->count ) { # Useless test
             {
                 borrowernumber    => $patron->borrowernumber,
                 amountoutstanding => { '>' => 0 },
-                accounttype       => [ 'F', 'L' ],
+                accounttype       => [ 'OVERDUE', 'L' ],
                 itemnumber        => $issue->{itemnumber}
             },
         );
-- 
2.20.1