From 1f0df38f1f7d8193c5e671c69d80ece3f8da98cc Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 13 Apr 2023 17:52:58 +0000 Subject: [PATCH] Bug 33176: Enforce RequirePaymentType with API Signed-off-by: David Nind --- Koha/REST/V1/Patrons/Account.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm index cf9bc9a416..bb740724b0 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -109,6 +109,10 @@ sub add_credit { my $note = $body->{note}; my $library_id = $body->{library_id}; + if ( C4::Context->preference("RequirePaymentType") && !defined($payment_type) ) { + Koha::Exceptions::Account::PaymentTypeRequired->throw(); + } + my $credit = $account->add_credit( { amount => $amount, type => $credit_type, -- 2.30.2