From cdc6063405ebaa6178cd00ef7dcd174242ed8f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 30 Jul 2026 17:35:24 +0200 Subject: [PATCH] fix delete in paymentvat.class.php (#39323) Co-authored-by: Laurent Destailleur --- htdocs/compta/tva/class/paymentvat.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 3ac9fca53f4..59d4f9823cf 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -458,11 +458,13 @@ class PaymentVAT extends CommonObject if ($this->bank_line > 0) { $accline = new AccountLine($this->db); - $accline->fetch($this->bank_line); - $result = $accline->delete($user); - if ($result < 0) { - $this->errors[] = $accline->error; - $error++; + $result = $accline->fetch($this->bank_line); + if ($result > 0) { + $result = $accline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + if ($result < 0) { + $this->errors[] = $accline->error; + $error++; + } } }