Bug 27290: Clean up validation

It seems we had the validator instantiated twice and we used a mix of
validation of required at form element level and in JS instantiator.

This patch moves the rules to consistently apply at the instantiation
and removes the duplicate lines.

To test:
1 - Enable 'useCashRegisters' and 'EnablePointofSale'
2 - Add a cash register
3 - Add a debit type that can be sold
4 - Go to point of sale and sell the item multiple times
5 - Enter 'Amount tendered' less than amount being paid
6 - Click confirm
7 - Transaction is processed as if full funds received
8 - Try with a negative number - goes through again

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2020-12-21 16:25:47 +00:00 committed by Jonathan Druart
parent 4904abf1c3
commit 01fc41ca59
1 changed files with 11 additions and 15 deletions

View File

@ -112,7 +112,7 @@
<ol>
<li>
<label for="paid">Amount being paid: </label>
<input type="text" inputmode="numeric" pattern="[0-9]*" name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]" readonly/>
<input type="text" inputmode="none" pattern="[0-9]*" name="paid" id="paid" value="" readonly/>
</li>
<li>
<label for="collected" class="required">Amount tendered: </label>
@ -258,7 +258,6 @@
var paid = $('#paid')[0];
moneyFormat(paid);
$('#collected').rules( "add", { min: Number(paid.value) });
$("#payForm").valid()
change.innerHTML = zero_formatted;
$(':input[name="change"]').val(zero_formatted);
} else {
@ -372,11 +371,19 @@
$('#payForm').submit();
});
$( "#payForm" ).validate({
$('#payForm').validate({
rules: {
paid: { required: true },
paid: {
required: true
},
collected: {
required: true
},
payment_type: {
required: true
},
registerid: {
required: true
}
}
});
@ -403,17 +410,6 @@
}
});
$('#payForm').validate({
rules: {
collected: {
required: true
},
registerid: {
required: true
}
}
});
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
$("#printReceipt").click(function() {
var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');