From 55fe1d2a07f905b473ae08a5d9724fa12291b89f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 2 Feb 2026 17:22:24 +0000 Subject: [PATCH] Bug 37671: Add new 'PAYOUT' notice template When a refund is processed through Point of Sale, the system creates: 1. A credit account line (the refund) 2. A debit account line (the payout) The receipt printing logic currently only accounts for RECEIPTs against credits. This patch adds a new 'PAYOUT' template for dealing with the negative debits that make up a payout so we can construct a proper receipt for this action. --- .../data/mysql/atomicupdate/bug_37671.pl | 105 ++++++++++++++++++ .../mysql/en/mandatory/sample_notices.yml | 94 +++++++++++++++- 2 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_37671.pl diff --git a/installer/data/mysql/atomicupdate/bug_37671.pl b/installer/data/mysql/atomicupdate/bug_37671.pl new file mode 100644 index 00000000000..a2b4d5ea71d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37671.pl @@ -0,0 +1,105 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "37671", + description => "Add PAYOUT notice template for POS refund receipts", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Add new PAYOUT letter template for POS + $dbh->do( + q{ + INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang, updated_on) + VALUES ( + 'pos', 'PAYOUT', '', 'Point of sale payout receipt', 1, 'Payout receipt', + '[% USE KohaDates %] +[% USE Branches %] +[% USE Price %] +[% USE AuthorisedValues %] +[% PROCESS "accounts.inc" %] + +[% IF ( LibraryName ) %] + + + +[% END %] + + + + + + + + + + + + + + + + + + + + + + + [% IF debit.patron %] + + + + + [% END %] + + + + + + + + + [% FOREACH credit IN debit.credits %] + [% FOREACH offset IN credit.credit_offsets %] + [% IF offset.debit && offset.debit.debit_type_code != 'PAYOUT' %] + + + + + [% END %] + [% END %] + [% END %] + + + + + + + +
+

[% LibraryName | html %]

+
+

[% Branches.GetName( debit.branchcode ) | html %]

+
+

[% debit.date | $KohaDates %]

+
Transaction ID: [% debit.accountlines_id %]
Operator ID: [% debit.manager_id %]
Payout type: [% AuthorisedValues.GetByCode( "PAYMENT_TYPE", debit.payment_type ) | html %]
+

Refund Payout Receipt

+
+ Paid to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %]
+ Card number: [% debit.patron.cardnumber | html %] +
Refund details
Item / Original chargeRefund amount
+ [% PROCESS account_type_description account=offset.debit %] + [% IF offset.debit.description %] - [% offset.debit.description | html %][% END %] + [% IF offset.debit.itemnumber %]
[% offset.debit.item.biblio.title | html %][% END %] +
Original charge: [% offset.debit.amount | $Price %] +
[% credit.amount * -1 | $Price %]
Total payout: [% debit.amount | $Price %]
', + 'print', 'default', NOW() + ) + } + ); + + say_success( $out, "Added new PAYOUT letter template for POS refunds" ); + }, +}; diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 69ff86f532b..938fbd2d249 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -1808,6 +1808,7 @@ tables: - "[% USE KohaDates %]" - "[% USE Branches %]" - "[% USE Price %]" + - "[% USE AuthorisedValues %]" - "[% PROCESS \"accounts.inc\" %]" - "" - "[% IF ( LibraryName ) %]" @@ -1836,7 +1837,7 @@ tables: - "" - "" - " " - - " " + - " " - "" - " " - " " @@ -1949,6 +1950,97 @@ tables: - " " - "
Payment type: [% credit.payment_type %][% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', credit.payment_type ) | html %]
" + - module: pos + code: PAYOUT + branchcode: "" + name: "Point of sale payout receipt" + is_html: 1 + title: "Payout receipt" + message_transport_type: print + lang: default + content: + - "[% USE KohaDates %]" + - "[% USE Branches %]" + - "[% USE Price %]" + - "[% USE AuthorisedValues %]" + - "[% PROCESS \"accounts.inc\" %]" + - "" + - "[% IF ( LibraryName ) %]" + - " " + - " " + - " " + - "[% END %]" + - " " + - " " + - " " + - "" + - " " + - "" + - " " + - " " + - "" + - "" + - " " + - " " + - "" + - "" + - " " + - " " + - "" + - " " + - " " + - " " + - " " + - " " + - " [% IF debit.patron %]" + - " " + - " " + - " " + - " " + - " [% END %]" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "" + - " [% FOREACH credit IN debit.credits %]" + - " [% FOREACH offset IN credit.credit_offsets %]" + - " [% IF offset.debit && offset.debit.debit_type_code != 'PAYOUT' %]" + - " " + - " " + - " " + - " " + - " [% END %]" + - " [% END %]" + - " [% END %]" + - "" + - "" + - " " + - " " + - " " + - " " + - "" + - "
" + - "

[% LibraryName | html %]

" + - "
" + - "

[% Branches.GetName( debit.branchcode ) | html %]

" + - "
" + - "

[% debit.date | $KohaDates %]

" + - "
Transaction ID: [% debit.accountlines_id %]
Operator ID: [% debit.manager_id %]
Payout type: [% AuthorisedValues.GetByCode( \"PAYMENT_TYPE\", debit.payment_type ) | html %]
" + - "

Refund Payout Receipt

" + - "
" + - " Paid to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %]
" + - " Card number: [% debit.patron.cardnumber | html %]" + - "
Refund details
Item / Original chargeRefund amount
" + - " [% PROCESS account_type_description account=offset.debit %]" + - " [% IF offset.debit.description %] - [% offset.debit.description | html %][% END %]" + - " [% IF offset.debit.itemnumber %]
[% offset.debit.item.biblio.title | html %][% END %]" + - "
Original charge: [% offset.debit.amount | $Price %]" + - "
[% credit.amount * -1 | $Price %]
Total payout: [% debit.amount | $Price %]
" + - module: reserves code: CANCEL_HOLD_ON_LOST branchcode: "" -- 2.53.0