From 023382a4e74e347c642e062dc36c9377c11dc8f0 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 12 Jan 2026 12:18:33 +0000 Subject: [PATCH] Bug 41592: Refactor register page to use shared refund modal This patch refactors the register report page (register.tt) to use the new shared refund modal component created in previous commits, removing duplicate code and providing a consistent refund experience across both the Point of Sale and register pages. Changes: - Replace inline refund modal with shared refund_modal.inc component - Update modal population JavaScript to work with new modal structure: * Parse amount and amountoutstanding as floats for proper formatting * Populate transaction details fields (description, original charge, amount paid) * Hide payment method and original register rows (not applicable in this context) * Update form field IDs to match new modal structure - Fix focus to use #refund_amount instead of deprecated #returned field - Update cash register validation to use #refund_registerid_select - Add html_helpers.inc for proper formatting support The shared modal intelligently adapts to different contexts, showing only relevant information based on available data. For patron account refunds, payment method and original register information are hidden since debits can be paid by multiple credits with different payment methods. Test plan: 1. Apply patch and rebuild: yarn build 2. Navigate to a register page with some paid charges 3. Click "Issue refund" on a debit that has been paid 4. Verify refund modal displays: - Transaction description (properly formatted) - Original charge amount (properly formatted with currency) - Amount paid (properly formatted) - No original register row (hidden in this context) 5. Enter a refund amount and complete the refund 6. Verify the refund is processed successfully --- .../prog/en/modules/pos/register.tt | 71 +++---------------- 1 file changed, 10 insertions(+), 61 deletions(-) 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 ceb3777e975..26feadd336a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -4,6 +4,8 @@ [% USE KohaDates %] [% USE AuthorisedValues %] [% USE Price %] +[% USE Registers %] +[% SET registers = Registers.all( filters => { current_branch => 1 } ) %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% PROCESS 'accounts.inc' %] @@ -150,6 +152,7 @@ data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" + data-payment-type="[% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %]" data-member="[% credit.debit.borrowernumber | html %]" > Issue refund @@ -163,6 +166,7 @@ data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" + data-payment-type="[% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %]" data-member="[% credit.debit.borrowernumber | html %]" > Issue refund @@ -285,6 +289,7 @@ data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" + data-payment-type="[% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %]" data-member="[% credit.debit.borrowernumber | html %]" > Issue refund @@ -298,6 +303,7 @@ data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" + data-payment-type="[% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %]" data-member="[% credit.debit.borrowernumber | html %]" > Issue refund @@ -397,48 +403,7 @@ - - - +[% INCLUDE 'modals/refund_modal.inc' refund_form_action = '/cgi-bin/koha/pos/register.pl' register_id = register.id registers = registers %] [% INCLUDE 'modals/cashup_summary.inc' %] @@ -448,6 +413,7 @@ [% INCLUDE 'js-date-format.inc' %] [% Asset.js("js/cashup_modal.js") | $raw %] [% Asset.js("js/modal_printer.js") | $raw %] + [% Asset.js("js/refund_modal.js") | $raw %] [% INCLUDE 'calendar.inc' %]