diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1b497120e54..48be736362c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7178,7 +7178,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * Function to use on each input amount before any numeric test or database insert. A better name for this function * should be roundtext2num(). * - * @param int|float|string $amount Amount to convert/clean or round + * @param int|float|string|null $amount Amount to convert/clean or round * @param ''|'MU'|'MT'|'MS'|'CU'|'CT'|int<0,max> $rounding ''=No rounding * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 2d0d838cabc..08385b342a4 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -122,7 +122,7 @@ if ($idprod > 0) { } } - $prices[] = array("id" => 'pmpprice', "price" => price2num((float) $price, 'MU'), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() + $prices[] = array("id" => 'pmpprice', "price" => price2num($price, 'MU'), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() } // Add price for costprice (at end) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f9834f88e51..cecda57430f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6111,7 +6111,7 @@ class Product extends CommonObject * @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove) * @param int<0,1> $movement 0 = add, 1 = remove * @param string $label Label of stock movement - * @param float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. + * @param int|float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed. * @param string $inventorycode Inventory code * @param string $origin_element Origin element type * @param ?int $origin_id Origin id of element diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 73f6fd0134f..a0835b81ffb 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1198,7 +1198,7 @@ if ($resql) { print ''; } else { if (getDolGlobalString('INVENTORY_MANAGE_REAL_PMP')) { - //PMP Expected + // PMP Expected if (!empty($obj->pmp_expected)) { $pmp_expected = $obj->pmp_expected; } else { @@ -1206,7 +1206,7 @@ if ($resql) { } $pmp_valuation = $pmp_expected * $valuetoshow; print ''; - print price($pmp_expected); + print is_null($pmp_expected) ? '' : price($pmp_expected); print ''; print ''; print price($pmp_valuation); @@ -1216,7 +1216,7 @@ if ($resql) { print $obj->qty_view; // qty found print ''; - //PMP Real + // PMP Real print ''; if (!empty($obj->pmp_real)) { $pmp_real = $obj->pmp_real; @@ -1224,7 +1224,7 @@ if ($resql) { $pmp_real = $product_static->pmp; } $pmp_valuation_real = $pmp_real * $obj->qty_view; - print price($pmp_real); + print is_null($pmp_real) ? '' : price($pmp_real); print ''; print ''; print price($pmp_valuation_real); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 362cd716b9b..9abd5d83716 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -216,7 +216,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer // Define value of products moved $pricesrc = 0; if (!empty($product->pmp)) { - $pricesrc = $product->pmp; + $pricesrc = (float) $product->pmp; } $pricedest = $pricesrc;