wallet handling

This commit is contained in:
2026-06-15 12:05:00 +03:30
parent 38e0cffe86
commit 23311cee01
5 changed files with 65 additions and 21 deletions
@@ -35,7 +35,7 @@
</template>
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
دارایی ریالی:
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(totalRialValue) }} ریال</div>
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(cashWallet) }} ریال</div>
<BasicIcon @click="$emit('openRialModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
</div>
</div>
@@ -59,7 +59,7 @@ defineEmits<{
const meta = computed(() => assetsSummary.value?.meta)
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
const primaryMetalTotal = computed(() => metalTotals.value[0])
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
const countBasedInventory = computed(() =>
(assetsSummary.value?.count_products ?? []).reduce((sum, item) => sum + Number(item.quantity ?? 0), 0)
@@ -31,9 +31,9 @@
<a-divider class="!my-1" />
<BasicInfoItem
class="flex justify-between"
title="معادل ریالی محصولات"
title="ارزش ریالی طلا (وزن × قیمت زنده)"
is-line
:value="usePrice(assetsRialValue)"
:value="usePrice(metalRialValue)"
/>
<a-divider class="!my-1" />
<BasicInfoItem
@@ -56,7 +56,8 @@ import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
import { usePrice } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { formatInventoryCardValue, assetSheetInventoryCards } from '@/utils/productAssets'
import { formatInventoryCardValue, assetSheetInventoryCards, resolveAssetsRialValue } from '@/utils/productAssets'
import { getTradeBuyPrice, lastPrice } from '@/utils/price'
const props = defineProps<{
show: boolean
@@ -78,8 +79,10 @@ const visible = computed({
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
const assetsRialValue = computed(() => assetsSummary.value?.assets_rial_value ?? 0)
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
const metalRialValue = computed(() =>
resolveAssetsRialValue(assetsSummary.value, getTradeBuyPrice(lastPrice.value))
)
const totalRialValue = computed(() => cashWallet.value + metalRialValue.value)
onMounted(() => {
void loadWalletAssets()