From bad8cf1da8243efa41eedcfc6e704ca27798cc86 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 --- koha-tmpl/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 e0a68b1436..afdbb1519c 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 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) }); + $("#payForm").valid() change.innerHTML = "0.00"; + $(':input[name="change"]').val('0.00'); } 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); } @@ -358,6 +363,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.11.0