Bugzilla – Attachment 183787 Details for
Bug 40305
Collected and change variables are inconsistent in controllers and notice templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40305: Fix 'tendered' vs 'collected' variable name inconsistency
Bug-40305-Fix-tendered-vs-collected-variable-name-.patch (text/plain), 13.94 KB, created by
Martin Renvoize (ashimema)
on 2025-07-04 09:08:39 UTC
(
hide
)
Description:
Bug 40305: Fix 'tendered' vs 'collected' variable name inconsistency
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-04 09:08:39 UTC
Size:
13.94 KB
patch
obsolete
>From 9889691e4eafb4da826305b21186f7b200600f32 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >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: > - " </tr>" > - " <tr>" > - " <td>Tendered: </td>" >- - " <td>[% collected | $Price %]</td>" >+ - " <td>[% tendered | $Price %]</td>" > - " </tr>" > - " <tr>" > - " <td>Change: </td>" >@@ -1941,7 +1941,7 @@ tables: > - " </tr>" > - " <tr>" > - " <td>Tendered: </td>" >- - " <td>[% collected | $Price %]</td>" >+ - " <td>[% tendered | $Price %]</td>" > - " </tr>" > - " <tr>" > - " <td>Change given:</td>" >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 @@ > <input name="paid" id="paid" type="text" step="0.01" min="0" value="[% amountoutstanding | $Price on_editing => 1 %]" /> > </li> > <li> >- <label for="collected">Amount tendered: </label> >- <input name="collected" id="collected" type="text" step="0.01" min="0" value="[% amountoutstanding | $Price on_editing => 1 %]" /> >+ <label for="tendered">Amount tendered: </label> >+ <input name="tendered" id="tendered" type="text" step="0.01" min="0" value="[% amountoutstanding | $Price on_editing => 1 %]" /> > </li> > <li> > <label>Change to give: </label> >@@ -364,8 +364,8 @@ > </li> > [% IF type != 'WRITEOFF' %] > <li> >- <label for="collected">Amount tendered: </label> >- <input name="collected" id="collected" type="text" step="0.01" min="0" value="[% total | $Price on_editing => 1 %]" /> >+ <label for="tendered">Amount tendered: </label> >+ <input name="tendered" id="tendered" type="text" step="0.01" min="0" value="[% total | $Price on_editing => 1 %]" /> > </li> > <li> > <label>Change to give: </label> >@@ -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 @@ > <div class="alert alert-info audio-alert-action"> > <p>Payment received</p> > <p> >- <a target="_blank" href="/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]" class="btn btn-default" >+ <a target="_blank" href="/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&tendered=[% tendered | uri %]&change=[% change | uri %]" class="btn btn-default" > ><i class="fa fa-print"></i> Print receipt</a > > > <a href="#" data-bs-toggle="modal" data-bs-target="#emailReceiptModal" class="btn btn-default"><i class="fa-solid fa-envelope"></i> Email receipt</a> >@@ -138,8 +138,8 @@ > <input type="text" inputmode="none" pattern="[0-9]*" name="paid" id="paid" value="" readonly /> > </li> > <li> >- <label for="collected" class="required">Amount tendered: </label> >- <input type="text" inputmode="numeric" pattern="[0-9]*" name="collected" id="collected" value="" class="required" required="required" /> >+ <label for="tendered" class="required">Amount tendered: </label> >+ <input type="text" inputmode="numeric" pattern="[0-9]*" name="tendered" id="tendered" value="" class="required" required="required" /> > <span class="required">Required</span> > </li> > <li> >@@ -181,7 +181,7 @@ > <form id="email_form" action="/cgi-bin/koha/pos/pay.pl" method="post" enctype="multipart/form-data" class="validated"> > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="payment_id" value="[% payment_id | uri %]" /> >- <input type="hidden" name="collected" value="[% collected | uri %]" /> >+ <input type="hidden" name="tendered" value="[% tendered | uri %]" /> > <input type="hidden" name="change" value="[% change | uri %]" />" > <div class="modal-dialog"> > <div class="modal-content"> >@@ -316,11 +316,11 @@ > function updateChangeValues() { > var change = $('#change')[0]; > var zero_formatted = "[% 0 | $Price %]"; >- 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) }); > change.innerHTML = zero_formatted; > $(':input[name="change"]').val(zero_formatted); > } else { >@@ -456,7 +456,7 @@ > > // Change calculation and modal > var change = $('#change')[0]; >- $("#paid, #collected").on("change",function() { >+ $("#paid, #tendered").on("change",function() { > moneyFormat( this ); > if (change != undefined) { > updateChangeValues(); >@@ -474,7 +474,7 @@ > paid: { > required: true > }, >- collected: { >+ tendered: { > required: true > }, > payment_type: { >@@ -518,7 +518,7 @@ > > [% 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'); >+ var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&tendered=[% tendered | uri %]&change=[% change | uri %]', '_blank'); > win.focus(); > }); > $("#printReceipt").click(); >diff --git a/members/paycollect.pl b/members/paycollect.pl >index 6b93d1cff42..f73477b4ffa 100755 >--- a/members/paycollect.pl >+++ b/members/paycollect.pl >@@ -72,8 +72,8 @@ my $user = $input->remote_user; > my $library_id = C4::Context->userenv->{'branch'}; > my $total_due = $account->outstanding_debits->total_outstanding; > >-my $total_paid = $input->param('paid'); >-my $total_collected = $input->param('collected'); >+my $total_paid = $input->param('paid'); >+my $total_tendered = $input->param('tendered'); > > my $selected_lines = $input->param('selected'); # comes from pay.pl > my $pay_individual = $input->param('pay_individual'); >@@ -151,7 +151,10 @@ if ( $total_paid and $total_paid ne '0.00' ) { > error_over => 1, > total_due => $total_due > ); >- } elsif ( $total_collected < $total_paid && !( $op eq 'cud-writeoff_individual' || $type eq 'WRITEOFF' ) ) { >+ } elsif ( defined $total_tendered >+ && $total_tendered < $total_paid >+ && !( $op eq 'cud-writeoff_individual' || $type eq 'WRITEOFF' ) ) >+ { > $template->param( > error_under => 1, > total_paid => $total_paid >diff --git a/pos/pay.pl b/pos/pay.pl >index 390b48696b8..193c51af1b9 100755 >--- a/pos/pay.pl >+++ b/pos/pay.pl >@@ -80,7 +80,7 @@ if ( $op eq 'cud-pay' ) { > > $template->param( > payment_id => $payment->accountlines_id, >- collected => scalar $input->param('collected'), >+ tendered => scalar $input->param('tendered'), > change => scalar $input->param('change') > ); > } >@@ -89,7 +89,7 @@ if ( $op eq 'cud-pay' ) { > if ( $op eq 'cud-send' ) { > my $payment_id = $input->param('payment_id'); > my $change = $input->param('change'); >- my $collected = $input->param('collected'); >+ my $tendered = $input->param('tendered'); > my $toaddr = $input->param('toaddr'); > > # Create our letter from the template >@@ -102,8 +102,8 @@ if ( $op eq 'cud-send' ) { > credits => $payment_id, > }, > substitute => { >- collected => $collected, >- change => $change >+ tendered => $tendered, >+ change => $change > } > ); > >@@ -123,7 +123,7 @@ if ( $op eq 'cud-send' ) { > # Set variables for template to allow printing still > $template->param( > payment_id => $payment_id, >- collected => $collected, >+ tendered => $tendered, > change => $change > ); > } >diff --git a/pos/printreceipt.pl b/pos/printreceipt.pl >index e615bfbd8ef..524754edf10 100755 >--- a/pos/printreceipt.pl >+++ b/pos/printreceipt.pl >@@ -62,8 +62,8 @@ my $letter = C4::Letters::GetPreparedLetter( > borrowers => $patron ? $patron->borrowernumber : undef > }, > substitute => { >- collected => scalar $input->param('collected'), >- change => scalar $input->param('change') >+ tendered => scalar $input->param('tendered'), >+ change => scalar $input->param('change') > } > ); > >-- >2.50.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40305
: 183787 |
183788