LP1981628 follow-up to the follow-up
authorJason Etheridge <jason@EquinoxOLI.org>
Mon, 18 Jul 2022 19:02:54 +0000 (15:02 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 11 Oct 2022 21:01:56 +0000 (17:01 -0400)
Consolidate some of the logic to make it more clear what is happening,
leverage the existing myopac_cc_allowed boolean, and catch the
Pay All Charges button in the TPAC.  This also clears up some display
oddities and makes sure the non-payment labeling is being used.

Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/templates-bootstrap/opac/myopac/charges.tt2
Open-ILS/src/templates/opac/myopac/main.tt2
Open-ILS/src/templates/opac/parts/myopac/main_base.tt2

index 1a4a671..31e5b10 100755 (executable)
@@ -7,7 +7,15 @@
     myopac_cc_allowed = 0;
     IF (ctx.fines.grocery.size OR ctx.fines.circulation.size) AND ctx.get_org_setting(ctx.user.home_ou, 'credit.payments.allow') == 1;
         myopac_cc_allowed = 1;
-    END
+    END;
+    neg_or_zero = 0;
+    FOR f IN ctx.fines.circulation;
+        IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+    END;
+    FOR f IN ctx.fines.grocery;
+        IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+    END;
+    IF neg_or_zero > 0; myopac_cc_allowed = 0; END;
 %]
 [%  IF myopac_cc_allowed; %]
 <form action="[% ctx.opac_root %]/myopac/main_payment_form#payment" method="get" id="selected_fines">
@@ -54,7 +62,7 @@
                 </tr>
             </thead>
             <tbody id='myopac_circ_trans_tbody'>
-                           [% c = 0; neg_or_zero = 0; %]
+                [% c = 0; %]
                 [% FOR f IN ctx.fines.circulation;
                     attrs = {marc_xml => f.marc_xml};
                     IF f.marc_xml;
@@ -76,7 +84,6 @@
                             [% money(f.xact.balance_owed) %]
                         </strong>
                         <input class="fineAmount" value="[% f.xact.balance_owed %]" hidden />
-                                               [% IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END %]
                     </td>
                     
                     <td>
                             [% money(f.xact.balance_owed) %]
                         </strong>
                          <input type="hidden" class="fineAmount" value="[% f.xact.balance_owed %]" hidden />
-                        [% IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END %]
                     </td>
                     
                     <td>
 <script >
 $( document ).ready(function() {
    $("input[type=checkbox]").click(function () {
-       var amount = 0;
+    var amount = 0;
     $("td input:checked").each(function () {
-               var item = jQuery( this ).parent().parent().children("td").children(".fineAmount").attr("value");
+    var item = jQuery( this ).parent().parent().children("td").children(".fineAmount").attr("value");
         item = parseFloat(item);
         amount += item;
     });
index 30e00ae..b7e3b5a 100644 (file)
@@ -6,7 +6,15 @@
     myopac_cc_allowed = 0;
     IF (ctx.fines.grocery.size OR ctx.fines.circulation.size) AND ctx.get_org_setting(ctx.user.home_ou, 'credit.payments.allow') == 1;
         myopac_cc_allowed = 1;
-    END
+    END;
+    neg_or_zero = 0;
+    FOR f IN ctx.fines.circulation;
+        IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+    END;
+    FOR f IN ctx.fines.grocery;
+        IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+    END;
+    IF neg_or_zero > 0; myopac_cc_allowed = 0; END
 %]
 <h3 class="sr-only">[% l('My Account Summary') %]</h3>
 [%  IF myopac_cc_allowed;
@@ -55,7 +63,6 @@
                 </tr>
             </thead>
             <tbody id='myopac_circ_trans_tbody'>
-                [% neg_or_zero = 0; %]
                 [% FOR f IN ctx.fines.circulation;
                     attrs = {marc_xml => f.marc_xml};
                     IF f.marc_xml;
                     <td>
                         <strong class="alert">
                             [% money(f.xact.balance_owed)%]
-                            [% IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END %]
                         </strong>
                     </td>
                     
                     <td class="mobile_hide">
                        [% f.xact.last_billing_type %]
                     </td>
-                                  
+
                     <td>
                         [% recid = f.xact.circulation.target_copy.call_number.record.id || f.xact.reservation.target_resource_type.record.id;
                         IF recid; %]
                         <strong>
                             [% money(f.xact.balance_owed) %]
                         </strong>
-                        [% IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END %]
                     </td>
                     
                     <td>[% f.xact.last_billing_type %]</td>
index ea434ec..3c1271b 100644 (file)
         <span class='[% ctx.user_stats.fines.balance_owed ? "alert" : ""%]'>
             [% money(ctx.user_stats.fines.balance_owed) %]
         </span><br />
-        [% IF (ctx.fines.grocery.size OR ctx.fines.circulation.size) AND ctx.get_org_setting(ctx.user.home_ou, 'credit.payments.allow') == 1 %]
+        [%
+            allow_pay_all_charges = 0;
+            IF (ctx.fines.grocery.size OR ctx.fines.circulation.size) AND ctx.get_org_setting(ctx.user.home_ou, 'credit.payments.allow') == 1;
+                allow_pay_all_charges = 1;
+            END;
+            neg_or_zero = 0;
+            FOR f IN ctx.fines.circulation;
+                IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+            END;
+            FOR f IN ctx.fines.grocery;
+                IF f.xact.balance_owed <= 0; neg_or_zero = neg_or_zero + 1; END;
+            END;
+            IF neg_or_zero > 0; allow_pay_all_charges = 0; END
+        %]
+        [% IF allow_pay_all_charges %]
        <form action="[% ctx.opac_root %]/myopac/main_payment_form" method="get"><input
             type="submit" title="[% l('Pay All Charges') %]"
             value="[% l('Pay All Charges') %]" class="pos-rel-top-5 opac-button" /></form>