From ddd5fa021b9908d68bbf767742eeeca0b19ab2e6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 2 Mar 2020 16:45:58 +0000 Subject: [PATCH] Bug 24519: Match paycollect form validation for change collection This patch adds form validation to the Point Of Sale payment page such that one cannot submit the form with a 'collected' value that is less than the 'owed' amount. Signed-off-by: Sally Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart (cherry picked from commit 080288bce48cf4fa94b19d35a117dd3e1967a4c9) Signed-off-by: Fridolin Somers (cherry picked from commit f5d1436a1d5ee8299841cdab54bb35c437e33700) Signed-off-by: Andrew Fuerste-Henry --- .../intranet-tmpl/prog/en/modules/pos/pay.tt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt index 027f39f71a..02f159cfc9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt @@ -245,14 +245,19 @@ var zero_formatted = "[% 0 | $Price %]"; 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) }); + $("#payForm").valid() change.innerHTML = zero_formatted; + $(':input[name="change"]').val(zero_formatted); } else { change.value = change.innerHTML; moneyFormat(change); change.innerHTML = change.value; + $(':input[name="change"]').val(change.value); } - $(':input[name="change"]').val(change.value); $('#modal_change').html(change.innerHTML); } @@ -357,6 +362,15 @@ $('#payForm').submit(); }); + $( "#payForm" ).validate({ + rules: { + paid: { required: true }, + collected: { + required: true + } + } + }); + $('#payForm').submit(function(e){ if (change != undefined && change.innerHTML > 0.00 && !checked) { e.preventDefault(); -- 2.39.5