fix amount 4

This commit is contained in:
2026-06-09 11:17:07 +03:30
parent ca7177d21b
commit a8dd0071e2
3 changed files with 49 additions and 7 deletions
+35 -3
View File
@@ -270,6 +270,31 @@ class Controller extends BaseController
return 'فروش ' . $productTitle;
}
public static function mainMetalBuyTitle(): string
{
return self::productBuyTitle(self::metalTypeLabel());
}
public static function mainMetalSellTitle(): string
{
return self::productSellTitle(self::metalTypeLabel());
}
/** واحد وزن معاملات فلز اصلی — مس: کیلوگرم، طلا: گرم */
public static function tradeWeightUnit(): string
{
$label = self::metalTypeLabel();
return str_contains($label, 'مس') ? 'کیلوگرم' : 'گرم';
}
public static function isWeightBasedProductUnit(?string $unit): bool
{
$unit = trim((string) $unit);
return in_array($unit, ['کیلوگرم', 'گرم'], true);
}
public static function meltedGoldBuyTitle(): string
{
return 'خرید ' . self::meltedGoldLabel();
@@ -296,6 +321,10 @@ class Controller extends BaseController
return false;
}
if (self::isWeightBasedProductUnit($product['unit'] ?? null)) {
return false;
}
if (isset($product['direct_price']) && (int) $product['direct_price'] !== 0) {
return true;
}
@@ -310,13 +339,16 @@ class Controller extends BaseController
public static function productQuantityUnit(?array $product): string
{
$unit = trim((string) ($product['unit'] ?? ''));
if ($unit !== '') {
return $unit;
}
if (self::isCountBasedProduct($product)) {
return 'عدد';
}
$unit = trim((string) ($product['unit'] ?? ''));
return $unit !== '' ? $unit : 'گرم';
return 'گرم';
}
/** مطابق ادمین: وزن «دارد» => amount != 1 ؛ «ندارد» => amount = 1 */