From 57212f76b3069f1699d3eb7632a7d82764184373 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 5 Feb 2021 15:11:37 +0000 Subject: [PATCH] Bug 24300: Add payout amount to boraccount page Test plan 1/ Add some debts and credits to a patrons account, resulting in an overall credit 2/ Note the appearance of a 'Payout amount' button next to the total due line. 3/ Try paying out an amount with the button 4/ Signoff Signed-off-by: Sally Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- .../prog/en/modules/members/boraccount.tt | 7 ++- members/boraccount.pl | 49 +++++++++++++------ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index 191e9d3731..7b0f34fd80 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -143,10 +143,15 @@ Total due [% IF ( totalcredit ) %] [% total | $Price %] + + [% IF CAN_user_updatecharges_payout %] + + [% END %] + [% ELSE %] [% total | $Price %] + [% END %] - diff --git a/members/boraccount.pl b/members/boraccount.pl index 7bd550940d..0fec75ed59 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -76,24 +76,41 @@ if ( $action eq 'void' ) { } if ( $action eq 'payout' ) { - my $payment_id = scalar $input->param('accountlines_id'); - my $payment = Koha::Account::Lines->find($payment_id); + my $payment_id = scalar $input->param('accountlines_id'); my $amount = scalar $input->param('amount'); my $payout_type = scalar $input->param('payout_type'); - $schema->txn_do( - sub { - my $payout = $payment->payout( - { - payout_type => $payout_type, - branch => $library_id, - staff_id => $logged_in_user->id, - cash_register => $registerid, - interface => 'intranet', - amount => $amount - } - ); - } - ); + if ( $payment_id eq "" ) { + $schema->txn_do( + sub { + $patron->account->payout_amount( + { + payout_type => $payout_type, + branch => $library_id, + staff_id => $logged_in_user->id, + cash_register => $registerid, + interface => 'intranet', + amount => $amount + } + ); + } + ); + } else { + my $payment = Koha::Account::Lines->find($payment_id); + $schema->txn_do( + sub { + my $payout = $payment->payout( + { + payout_type => $payout_type, + branch => $library_id, + staff_id => $logged_in_user->id, + cash_register => $registerid, + interface => 'intranet', + amount => $amount + } + ); + } + ); + } } if ( $action eq 'refund' ) { -- 2.39.5