Bug 33176: Enforce RequirePaymentType with API

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit df4285adb2)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 68c725afee)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
This commit is contained in:
Lucas Gass 2023-04-13 17:52:58 +00:00 committed by Pedro Amorim
parent db6758b8c2
commit 7310866d36

View file

@ -109,6 +109,10 @@ sub add_credit {
my $note = $body->{note}; my $note = $body->{note};
my $library_id = $body->{library_id}; my $library_id = $body->{library_id};
if ( C4::Context->preference("RequirePaymentType") && !defined($payment_type) ) {
Koha::Exceptions::Account::PaymentTypeRequired->throw();
}
my $credit = $account->add_credit( my $credit = $account->add_credit(
{ amount => $amount, { amount => $amount,
type => $credit_type, type => $credit_type,