fix(wallet): use dynamic metal label in wallet balance subject

This commit is contained in:
2026-11-18 10:13:15 +03:30
parent 97d1077db6
commit 3e053b65c9
+4 -3
View File
@@ -593,6 +593,8 @@ class WalletBalanceService
$product = $this->lineProduct($row); $product = $this->lineProduct($row);
$fund = $this->lineFund($row); $fund = $this->lineFund($row);
$cash = (float) ($this->lineValue($row, 'cash') ?? 0); $cash = (float) ($this->lineValue($row, 'cash') ?? 0);
$metalId = $this->resolveWalletLineMetalId($row, $mainWalletMetalId);
$metalLabel = $this->balanceReportService->metalLabel($metalId);
if ($fundId !== null) { if ($fundId !== null) {
$kind = 'fund'; $kind = 'fund';
@@ -602,7 +604,7 @@ class WalletBalanceService
} elseif ($productId === null) { } elseif ($productId === null) {
$kind = 'main'; $kind = 'main';
$kindLabel = 'کیف اصلی'; $kindLabel = 'کیف اصلی';
$subject = 'کیف اصلی — ریال و طلای آبشده'; $subject = 'کیف اصلی — ریال و ' . ($metalLabel !== '' ? $metalLabel : 'مس');
} else { } else {
$kind = 'product'; $kind = 'product';
$kindLabel = 'کیف محصول'; $kindLabel = 'کیف محصول';
@@ -610,7 +612,6 @@ class WalletBalanceService
$subject = $title !== '' ? "محصول «{$title}»" : "محصول کد {$productId}"; $subject = $title !== '' ? "محصول «{$title}»" : "محصول کد {$productId}";
} }
$metalId = $this->resolveWalletLineMetalId($row, $mainWalletMetalId);
$goldGrams = $this->walletLineGoldGrams($row); $goldGrams = $this->walletLineGoldGrams($row);
$goldToCash = $goldGrams > 0 ? (int) round($goldGrams * $this->livePricePerGram($metalId)) : 0; $goldToCash = $goldGrams > 0 ? (int) round($goldGrams * $this->livePricePerGram($metalId)) : 0;
@@ -624,7 +625,7 @@ class WalletBalanceService
'product_amount' => $product?->amount ?? null, 'product_amount' => $product?->amount ?? null,
'fund_title' => $fund?->title ?? null, 'fund_title' => $fund?->title ?? null,
'wallet_metal_id' => $metalId, 'wallet_metal_id' => $metalId,
'wallet_metal_label' => $this->balanceReportService->metalLabel($metalId), 'wallet_metal_label' => $metalLabel,
'gold_to_cash' => $goldToCash, 'gold_to_cash' => $goldToCash,
'gold_grams' => round($goldGrams, 3), 'gold_grams' => round($goldGrams, 3),
'total_rial_value' => (int) round($cash + $goldToCash), 'total_rial_value' => (int) round($cash + $goldToCash),