fix bug ۲

This commit is contained in:
2026-07-10 00:19:30 +03:30
parent e0c4897111
commit abc58c4180
2 changed files with 27 additions and 5 deletions
+6 -2
View File
@@ -265,13 +265,17 @@ class Product extends Model
$min = $this->min_order_cash;
$max = $this->max_order_cash;
if ($min !== null && $totalPriceRial < (float) $min) {
// یک ریال تلرانس — وقتی target_cash به گرم تبدیل و دوباره ضرب می‌شود ممکن است
// total_price موقت چند ریال از حداقل کمتر شود (مثلاً دقیقاً ۲۰۰,۰۰۰,۰۰۰).
$toleranceRial = 1.0;
if ($min !== null && $totalPriceRial + $toleranceRial < (float) $min) {
throw new \Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException(
'حداقل مبلغ این محصول ' . number_format((float) $min) . ' ریال می‌باشد'
);
}
if ($max !== null && $totalPriceRial > (float) $max) {
if ($max !== null && $totalPriceRial > (float) $max + $toleranceRial) {
throw new \Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException(
'حداکثر مبلغ این محصول ' . number_format((float) $max) . ' ریال می‌باشد'
);