From 1b603bc63ef56720631032edc49303e21a193a11 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 Sponsored-by: OpenFifth Signed-off-by: Jackie Usher --- .../data/mysql/atomicupdate/bug_40445.pl | 20 ++++++++++++ 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, 75 insertions(+), 6 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_40445.pl b/installer/data/mysql/atomicupdate/bug_40445.pl index dce18a8c979..e73db60c26f 100755 --- a/installer/data/mysql/atomicupdate/bug_40445.pl +++ b/installer/data/mysql/atomicupdate/bug_40445.pl @@ -53,5 +53,25 @@ return { $out, "CashupReconciliationNoteRequired: Controls whether reconciliation notes are required during cashup with discrepancies" ); + + # 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 513faabdf98..40fd0cddcf5 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -149,6 +149,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CardnumberLength', '', NULL, 'Set a length for card numbers with a maximum of 32 characters.', 'Free'), ('CardnumberLog','1',NULL,'If ON, log edit actions on patron cardnumbers','YesNo'), ('casAuthentication','0',NULL,'Enable or disable CAS authentication','YesNo'), +('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'), ('casLogout','0',NULL,'Does a logout from Koha should also log the user out of CAS?','YesNo'), ('casServerUrl','https://localhost:8443/cas',NULL,'URL of the cas server','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 fafd5b6a02e..8ec7061ad54 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 85ad4fe8c45..5891e5c4c5a 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.53.0