From 0e8d4461c4fafe5dba2646963f3440cc1ae09eba Mon Sep 17 00:00:00 2001 From: iLLixM <162678117+iLLixM@users.noreply.github.com> Date: Fri, 21 Nov 2025 18:34:24 +0100 Subject: [PATCH] Fix: Prevent negative payment amount in EPC-QR Code (#36364) --- htdocs/core/class/commoninvoice.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index d1adb0d9fce..50c56f07f99 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1669,6 +1669,9 @@ abstract class CommonInvoice extends CommonObject $amount_to_pay = $this->total_ttc; } + // Prevent negative values (e.g. overpayments) + $amount_to_pay = max(0, $amount_to_pay); + // Ensure numeric formatting for EPC QR code $amount_to_pay = price2num($amount_to_pay, 'MT');