Bug 40305

Summary: Collected and change variables are inconsistent in controllers and notice templates
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: NoticesAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jacob.omara, lisette, lucas, martin.renvoize, pedro.amorim, sally.healey, samalau, testopia
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 24381    
Bug Blocks: 36846    
Attachments: Bug 40305: Fix 'tendered' vs 'collected' variable name inconsistency
Bug 40305: Add database update to fix existing notice templates

Description Martin Renvoize (ashimema) 2025-07-04 09:07:23 UTC
We've tried fixing this a few times but never fully achieved it.

We need to get these consistent across the board to ensure the feature is working correctly out of the box everywhere.

collected => tendered
change_given => change
Comment 1 Martin Renvoize (ashimema) 2025-07-04 09:08:39 UTC
Created attachment 183787 [details] [review]
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
Comment 2 Martin Renvoize (ashimema) 2025-07-04 09:08:42 UTC
Created attachment 183788 [details] [review]
Bug 40305: Add database update to fix existing notice templates

This database update fixes existing RECEIPT and ACCOUNT_CREDIT notice
templates that may still use the old 'collected' variable instead of
'tendered'. It handles various formatting patterns and provides
verification that the conversion was successful.