fix: resolve copper unit kilogram display and asset valuation calculations

This commit is contained in:
2026-11-07 12:24:19 +03:30
parent 7dd5304638
commit 808c272e0c
3 changed files with 83 additions and 25 deletions
+15 -1
View File
@@ -317,10 +317,24 @@ class WalletBalanceService
->orderBy('id')
->first();
return max(1, (int) ($product?->metal_id ?? 1));
if ($product && (int) ($product->metal_id ?? 0) > 0) {
return (int) $product->metal_id;
}
}
// در بورس مس، مس فلز اصلی پلتفرم است
$hasCopperProduct = Product::query()
->where('active', 1)
->where('metal_id', 3)
->exists();
if ($hasCopperProduct) {
return 3;
}
$metalIds = $this->catalogMetalIds();
if (in_array(3, $metalIds, true)) {
return 3;
}
return count($metalIds) === 1 ? (int) $metalIds[0] : 1;
}