Bug 22359: Improvements to payment collection inputs
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 20 Nov 2019 16:01:56 +0000 (16:01 +0000)
committerJoy Nelson <joy@bywatersolutions.com>
Fri, 13 Mar 2020 01:19:48 +0000 (01:19 +0000)
This patch attempts to clarify the uses of the various input fields on
the paycollect screens.

It does this by adding validation to the form such that entering a
'collected' value that is lower than the 'paid' value is now forbidden.

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt

index fa35813..c996bc1 100644 (file)
 
     <li>
         <label for="paid">Amount being paid: </label>
-        <input name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
+        <input name="paid" id="paid" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
     </li>
     <li>
         <label for="collected">Collected from patron: </label>
-        <input id="collected" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
+        <input name="collected" id="collected" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
     </li>
     <li>
         <label>Change to give: </label>
         </li>
     <li>
         [% IF type == 'WRITEOFF' %]
-            <label for="paid">Writeoff amount:</label>
+            <label for="paid">Writeoff amount: </label>
         [% ELSE %]
-            <label for="paid">Amount paid: </label>
+            <label for="paid">Amount being paid: </label>
         [% END %]
-        <input name="paid" id="paid" value="[% total | $Price on_editing => 1 %]"/>
+        <input name="paid" id="paid" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
     </li>
-
     [% IF type != 'WRITEOFF' %]
         <li>
             <label for="collected">Collected from patron: </label>
-            <input id="collected" value="[% total | $Price on_editing => 1 %]"/>
+            <input name="collected" id="collected" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
         </li>
         <li>
             <label>Change to give: </label>
             $('#modal_submit').click(function() {
                 forms[0].submit();
             });
+
+            $( "#payindivfine, #payfine" ).validate({
+                rules: {
+                    paid: { required: true },
+                    collected: {
+                        required: true
+                    }
+                }
+            });
         });
 
         prevent_default = 1;
             var change = $('#change')[0];
             change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
             if (change.innerHTML <= 0) {
+                var paid = $('#paid')[0];
+                moneyFormat(paid);
+                $('#collected').rules( "add", { min: Number(paid.value) });
+                $( "#payindivfine, #payfine" ).valid();
                 change.innerHTML = "0.00";
                 $('input[name="change_given"]').val('0.00');
             } else {