From e3c38990083cb5240973f30197d12aabfd888c8d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 11 Nov 2025 07:03:18 +0000 Subject: [PATCH] Bug 40445: Add authorized value support for reconciliation notes This patch adds the ability to restrict reconciliation notes to a predefined list of authorized values for standardization and consistency. A new system preference `CashupReconciliationNoteAuthorisedValue` allows administrators to specify an authorized value category for the note dropdown. If not configured, a free text textarea is used instead. Test plan: 1. Create authorized value category (e.g., CASHUP_NOTE) with values like "Till count error", "Cash removed", "Foreign currency", etc. 2. Set CashupReconciliationNoteAuthorisedValue to CASHUP_NOTE 3. Perform cashup - note field should be dropdown with AV options 4. Clear preference - note field should revert to textarea 5. Verify notes are saved correctly in both modes --- ...45_reconciliation_note_authorized_value.pl | 31 ++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/accounting.pref | 4 +++ .../prog/en/modules/pos/register.tt | 32 ++++++++++++++++--- .../intranet-tmpl/prog/js/cashup_modal.js | 12 ++++++- pos/register.pl | 12 +++++++ 6 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_40445_reconciliation_note_authorized_value.pl diff --git a/installer/data/mysql/atomicupdate/bug_40445_reconciliation_note_authorized_value.pl b/installer/data/mysql/atomicupdate/bug_40445_reconciliation_note_authorized_value.pl new file mode 100644 index 00000000000..06519b00388 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_40445_reconciliation_note_authorized_value.pl @@ -0,0 +1,31 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "40445", + description => "Add system preference for cashup reconciliation note authorized values", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Add CashupReconciliationNoteAuthorisedValue preference + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES ( + 'CashupReconciliationNoteAuthorisedValue', + '', + '', + 'Authorized value category to use for cashup reconciliation notes (leave empty for free text)', + 'Free' + ) + } + ); + + say_success( $out, "Added CashupReconciliationNoteAuthorisedValue system preference" ); + say_info( + $out, + "CashupReconciliationNoteAuthorisedValue: Optionally restrict reconciliation notes to authorized values" + ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 0d4abc85c55..5576abf5a69 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -150,6 +150,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('casLogout','0','','Does a logout from Koha should also log the user out of CAS?','YesNo'), ('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'), ('casServerVersion','2', '2|3','Version of the CAS server Koha will connect to.','Choice'), +('CashupReconciliationNoteAuthorisedValue', '', NULL, 'Authorized value category to use for cashup reconciliation notes (leave empty for free text)', 'Free'), ('CashupReconciliationNoteRequired', '0', NULL, 'Require a reconciliation note when completing cashup with discrepancies between expected and actual amounts', 'YesNo'), ('CatalogConcerns', '0', NULL, 'Allow users to report catalog concerns', 'YesNo'), ('CatalogerEmails', '', '', 'Notify these catalogers by email when a catalog concern is submitted', 'free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref index 37046e4aa75..627ca5a800f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref @@ -63,3 +63,7 @@ Accounting: 1: "Require" 0: "Don't require" - a reconciliation note when completing cashup with discrepancies between expected and actual amounts. + - + - "Use authorized value category " + - pref: CashupReconciliationNoteAuthorisedValue + - " for reconciliation notes during cashup. Leave empty to allow free text entry." diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt index 00392774f33..c7b29b96845 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -469,12 +469,24 @@ @@ -584,6 +596,16 @@ [% INCLUDE 'datatables.inc' %] [% INCLUDE 'format_price.inc' %] [% INCLUDE 'js-date-format.inc' %] + [% Asset.js("js/cashup_modal.js") | $raw %] [% Asset.js("js/modal_printer.js") | $raw %] [% INCLUDE 'calendar.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js index 9f57c77e1a7..11d00e034ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js @@ -198,13 +198,23 @@ $(document).ready(function () { // Add note if present if (reconciliationNote) { + // Check if note is an authorized value code and use description if available + var noteDisplay = reconciliationNote; + if ( + typeof reconciliation_note_avs !== "undefined" && + reconciliation_note_avs[reconciliationNote] + ) { + noteDisplay = + reconciliation_note_avs[reconciliationNote]; + } + tfoot.append( "" + __("Note:") + " " + - escape_str(reconciliationNote) + + escape_str(noteDisplay) + "" ); } diff --git a/pos/register.pl b/pos/register.pl index 183d9b27d52..a0752689c37 100755 --- a/pos/register.pl +++ b/pos/register.pl @@ -67,10 +67,22 @@ if ( !$registers->count ) { my $accountlines = $cash_register->outstanding_accountlines(); my $cashup_in_progress = $cash_register->cashup_in_progress(); + # Get authorized values for reconciliation notes if configured + my $note_av_category = C4::Context->preference('CashupReconciliationNoteAuthorisedValue'); + my $reconciliation_note_avs; + if ($note_av_category) { + require Koha::AuthorisedValues; + $reconciliation_note_avs = Koha::AuthorisedValues->search( + { category => $note_av_category }, + { order_by => { '-asc' => 'lib' } } + ); + } + $template->param( register => $cash_register, accountlines => $accountlines, cashup_in_progress => $cashup_in_progress, + reconciliation_note_avs => $reconciliation_note_avs, reconciliation_note_required => C4::Context->preference('CashupReconciliationNoteRequired'), ); -- 2.51.1