From b7eaf82972e7d4e38bb93c4d4417b445fc2c361d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 Apr 2025 21:00:25 +0200 Subject: [PATCH] Bug 38010: Fix vendor deletion tests Signed-off-by: Jonathan Druart --- Koha/REST/V1/Acquisitions/Vendors.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Vendors.pm b/Koha/REST/V1/Acquisitions/Vendors.pm index 07b8554fc3b..d17f6e19527 100644 --- a/Koha/REST/V1/Acquisitions/Vendors.pm +++ b/Koha/REST/V1/Acquisitions/Vendors.pm @@ -171,7 +171,11 @@ sub delete { my $c = shift->openapi->valid_input or return; return try { - my $vendor = Koha::Acquisition::Booksellers->find( $c->param('vendor_id') ); + my $vendor = Koha::Acquisition::Booksellers->find( $c->param('vendor_id') ); + + return $c->render_resource_not_found("Vendor") + unless $vendor; + my $basket_count = $vendor->baskets->count; my $subscription_count = $vendor->subscriptions->count; my $invoice_count = $vendor->invoices->count; @@ -182,9 +186,6 @@ sub delete { openapi => { error => "Vendor cannot be deleted with existing baskets, subscriptions or invoices" } ) unless $safe_to_delete; - return $c->render_resource_not_found("Vendor") - unless $vendor; - $vendor->delete; return $c->render_resource_deleted; } catch { -- 2.34.1