fixed kilo in metals 7
This commit is contained in:
@@ -35,7 +35,7 @@ class AssetSummaryService
|
||||
->where('owner_type', $ownerType)
|
||||
->get();
|
||||
|
||||
$mainWallet = $userWallets->first(fn (Wallet $w) => $w->product_id === null);
|
||||
$mainWallet = $this->resolveMainWallet($userWallets);
|
||||
$metalIds = $this->catalogMetalIds($catalog);
|
||||
$weightUnit = Controller::tradeWeightUnit();
|
||||
$hasCountBased = $this->catalogHasCountBased($catalog);
|
||||
@@ -52,7 +52,7 @@ class AssetSummaryService
|
||||
$this->buildInventoryCards($userWallets, $catalogById, $mainWalletProductIds)
|
||||
);
|
||||
$metalTotals = $this->buildMetalTotals($userWallets, $mainWallet, $metalIds, $weightUnit, $catalogById, $metalsWithProductWallet, $mainWalletProductIds);
|
||||
$cashWallet = (float) ($mainWallet->cash ?? 0);
|
||||
$cashWallet = (float) ($mainWallet?->cash ?? 0);
|
||||
$assetsRialValue = $this->sumAssetsRialValue(
|
||||
$metalTotals,
|
||||
$userWallets,
|
||||
@@ -112,7 +112,7 @@ class AssetSummaryService
|
||||
array $mainWalletProductIds = []
|
||||
): array {
|
||||
$cards = [];
|
||||
$mainWalletGrams = Controller::weightToGrams((float) ($mainWallet->gold ?? 0));
|
||||
$mainWalletGrams = Controller::weightToGrams((float) ($mainWallet?->gold ?? 0));
|
||||
$assignedMetalIds = [];
|
||||
$mainProductId = $this->configService->mainProductId();
|
||||
|
||||
@@ -123,7 +123,7 @@ class AssetSummaryService
|
||||
return [];
|
||||
}
|
||||
|
||||
$mainWalletWeight = (float) ($mainWallet->gold ?? 0);
|
||||
$mainWalletWeight = (float) ($mainWallet?->gold ?? 0);
|
||||
if ($mainWalletWeight <= 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -186,6 +186,13 @@ class AssetSummaryService
|
||||
return $cards;
|
||||
}
|
||||
|
||||
private function resolveMainWallet(Collection $userWallets): ?Wallet
|
||||
{
|
||||
return $userWallets->first(
|
||||
fn (Wallet $w) => $w->fund_id === null && $w->product_id === null
|
||||
);
|
||||
}
|
||||
|
||||
private function catalogProduct(Product $product, Collection $catalogById): Product
|
||||
{
|
||||
return $catalogById->get((int) $product->id) ?? $product;
|
||||
@@ -301,6 +308,10 @@ class AssetSummaryService
|
||||
$cards = [];
|
||||
|
||||
foreach ($userWallets as $walletLine) {
|
||||
if ($walletLine->fund_id !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($walletLine->product_id === null || (float) $walletLine->gold <= 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -349,7 +360,7 @@ class AssetSummaryService
|
||||
return [];
|
||||
}
|
||||
|
||||
$mainWalletGrams = Controller::weightToGrams((float) ($mainWallet->gold ?? 0));
|
||||
$mainWalletGrams = Controller::weightToGrams((float) ($mainWallet?->gold ?? 0));
|
||||
$totals = [];
|
||||
|
||||
// فلز نمایندهٔ کیف اصلی در حالت main_wallet_products
|
||||
|
||||
Reference in New Issue
Block a user