From 3553f6fb15f7f0953cd25eb65e246bab519c3d60 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 --- .../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 3824133902..c6907fcca0 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 35930810be..ebe69db39c 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 $transaction_type = scalar $input->param('transaction_type'); - $schema->txn_do( - sub { - my $payout = $payment->payout( - { - payout_type => $transaction_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 => $transaction_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 => $transaction_type, + branch => $library_id, + staff_id => $logged_in_user->id, + cash_register => $registerid, + interface => 'intranet', + amount => $amount + } + ); + } + ); + } } if ( $action eq 'refund' ) { -- 2.20.1