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