From 76cf8ebe065f20be39f4ff9294b67f16abfa4bc5 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 23 Mar 2024 01:11:57 +0100 Subject: [PATCH] Fix PhanTypeInvalid{Left,Right}OperandOfNumericOp mostly by typing, casting, idate --- htdocs/compta/ajaxpayment.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 7a593ad368d..849e13a5ed8 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,7 +70,7 @@ if (is_array($amounts)) { if (is_array($remains)) { foreach ($remains as $key => $value) { $value = price2num($value); - $remains[$key] = (($invoice_type) == 2 ? -1 : 1) * $value; + $remains[$key] = ($invoice_type == 2 ? -1 : 1) * (float) $value; if (empty($value)) { unset($remains[$key]); } @@ -81,7 +82,7 @@ if (is_array($remains)) { } // Treatment -$result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment +$result = ($amountPayment != '') ? ((float) $amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment');