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');