diff --git a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php index aa103161..16f5e029 100644 --- a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php +++ b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php @@ -281,7 +281,8 @@ class ComputeProductMonthlyWeightedAverage extends Command $openingAmount = $adjusted === null ? null : round($openingAmountRaw, 2); $denominator = $openingQuantity + $purchaseQuantity; if ($denominator === 0.0) { - $weighted = $adjusted === null ? null : round($adjusted, 4); + // 四项全 0:加权平均单价取"更改价格"(按两位舍入后的值)。 + $weighted = $adjusted === null ? null : round($adjusted, 2); } else { // 先除再舍入:用未舍入的期初金额与入库金额相除,最后统一保留两位。 $weighted = round(($openingAmountRaw + $purchaseAmountRaw) / $denominator, 4);