From 9889691e4eafb4da826305b21186f7b200600f32 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 4 Jul 2025 09:20:30 +0100 Subject: [PATCH] Bug 40305: Fix 'tendered' vs 'collected' variable name inconsistency "One Ring to rule them all, one Ring to find them, One Ring to bring them all and in the darkness bind them" We've been battling against this for years, with a mixed use of terminology and thus confusion in templates vs controllers and notice templates. I've decided to just try and make sure all the terminology matches throughout, and use the more popular 'tendered' term over the 'collected' term. This patch standardizes the terminology used throughout the payment system to consistently use 'tendered' instead of the mixed usage of 'collected' and 'tendered' that has caused confusion over the years. Changes include: - Update all payment form templates to use 'tendered' input names - Update JavaScript validation and change calculation logic - Update controller parameter handling in pos/pay.pl, pos/printreceipt.pl, and members/paycollect.pl - Update sample notice templates (RECEIPT) to use 'tendered' variable - Add null check for $total_tendered to prevent perl warnings Test plan: 1. Test Point of Sale payments with tendered amounts and change calculation 2. Test member account payments with tendered amounts 3. Test receipt generation (both print and email) 4. Verify JavaScript validation works correctly 5. Confirm no perl warnings when tendered amount is undefined --- .../data/mysql/en/mandatory/sample_notices.yml | 4 ++-- .../prog/en/modules/members/paycollect.tt | 16 ++++++++-------- .../intranet-tmpl/prog/en/modules/pos/pay.tt | 18 +++++++++--------- members/paycollect.pl | 9 ++++++--- pos/pay.pl | 10 +++++----- pos/printreceipt.pl | 4 ++-- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 3a102653101..68a93981775 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1865,7 +1865,7 @@ tables: - " " - " " - " Tendered: " - - " [% collected | $Price %]" + - " [% tendered | $Price %]" - " " - " " - " Change: " @@ -1941,7 +1941,7 @@ tables: - " " - " " - " Tendered: " - - " [% collected | $Price %]" + - " [% tendered | $Price %]" - " " - " " - " Change given:" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index 8c4c8758c08..9b403eb62cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -183,8 +183,8 @@
  • - - + +
  • @@ -364,8 +364,8 @@
  • [% IF type != 'WRITEOFF' %]
  • - - + +
  • @@ -453,7 +453,7 @@ var change = $('#change')[0]; $('#payindivfine, #payfine').preventDoubleFormSubmit(); - $("#paid, #collected").on("change",function() { + $("#paid, #tendered").on("change",function() { moneyFormat( this ); if (change != undefined) { updateChangeValues(); @@ -483,7 +483,7 @@ $( "#payindivfine, #payfine" ).validate({ rules: { paid: { required: true }, - collected: { + tendered: { required: true }, [% IF Koha.Preference('UseCashRegisters') %] @@ -577,11 +577,11 @@ function updateChangeValues() { var change = $('#change')[0]; - change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100; + change.innerHTML = Math.round(($('#tendered')[0].value - $('#paid')[0].value) * 100) / 100; if (change.innerHTML <= 0) { var paid = $('#paid')[0]; moneyFormat(paid); - $('#collected').rules( "add", { min: Number(paid.value) }); + $('#tendered').rules( "add", { min: Number(paid.value) }); $( "#payindivfine, #payfine" ).valid(); change.innerHTML = "0.00"; $('input[name="change_given"]').val('0.00'); 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 a1eca52972b..ee7251f9c6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt @@ -51,7 +51,7 @@

    Payment received

    - Print receipt Email receipt @@ -138,8 +138,8 @@

  • - - + + Required
  • @@ -181,7 +181,7 @@
    [% INCLUDE 'csrf-token.inc' %] - + "