fix showing amount of wallet

This commit is contained in:
2026-06-23 23:31:08 +03:30
parent 69a39ff371
commit 6c89375370
4 changed files with 18 additions and 9 deletions
+9 -5
View File
@@ -1,5 +1,5 @@
import type { Product } from '@/models/products'
import { usePriceWithoutType } from '@/utils/usePrice'
import { formatWeightAmount, usePriceWithoutType } from '@/utils/usePrice'
import type { UserWalletLine } from '@/models/wallet'
import type { ProductFile } from '@/utils/file'
import type { WalletInventoryCard, WalletMetalTotal } from '@/models/walletAssets'
@@ -198,7 +198,7 @@ function findMetalTotalById(metalTotals: WalletMetalTotal[], metalId: number) {
}
function formatBoursecuMetalRowValue(metal: WalletMetalTotal): string {
const amount = usePriceWithoutType(Number(metal.total_weight ?? 0), false)
const amount = formatWeightAmount(Number(metal.total_weight ?? 0))
if (metal.metal_id === METAL_GOLD) {
return `${amount} عدد`
}
@@ -266,7 +266,7 @@ function buildBoursecuCopperPopupLines(summary: {
},
{
label: 'مجموع کل دارایی مس',
value: `${usePriceWithoutType(totalWeight, false)} ${weightUnit}`,
value: `${formatWeightAmount(totalWeight)} ${weightUnit}`,
},
]
}
@@ -343,7 +343,7 @@ export function buildBoursecuHomeAssetRows(
{
id: 'copper-total',
label: 'کل دارایی مسی',
value: `${usePriceWithoutType(totalCopperWeight, false)} ${weightUnit}`,
value: `${formatWeightAmount(totalCopperWeight)} ${weightUnit}`,
popupLines: buildBoursecuCopperPopupLines(summary),
},
{
@@ -448,7 +448,11 @@ export function formatInventoryCardValue(card: {
}): string {
const quantity = Number(card.quantity ?? 0)
const unit = card.unit ?? (card.display_type === 'count' ? 'عدد' : 'گرم')
return `${usePriceWithoutType(quantity, false)} ${unit}`
const formatted =
card.display_type === 'count'
? usePriceWithoutType(quantity, false)
: formatWeightAmount(quantity)
return `${formatted} ${unit}`
}
export function findProductInventoryCard(
+5
View File
@@ -101,3 +101,8 @@ export function formatGoldAmount(amount?: number | null): string {
if (!Number.isFinite(num)) return '0'
return formatGroupedPrice(Number(num.toFixed(3)), false)
}
/** وزن فلز (گرم/کیلو) — بدون گرد کردن به بالا (برخلاف usePriceWithoutType) */
export function formatWeightAmount(amount?: number | null): string {
return formatGoldAmount(amount)
}
@@ -75,7 +75,7 @@
import { computed } from 'vue'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import BoursecuAssetsSummary from './BoursecuAssetsSummary.vue'
import { usePriceWithoutType } from '@/utils/usePrice'
import { formatWeightAmount, usePriceWithoutType } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { resolveSummaryMetalWeight } from '@/utils/productAssets'
@@ -118,7 +118,7 @@ const countBasedInventory = computed(() =>
)
function formatMetalTotal(metal: WalletMetalTotal) {
return `${usePriceWithoutType(resolveSummaryMetalWeight(metal, inventoryCards.value), false)}${metal.unit}`
return `${formatWeightAmount(resolveSummaryMetalWeight(metal, inventoryCards.value))}${metal.unit}`
}
</script>
@@ -2,7 +2,7 @@
import { computed } from 'vue'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import BoursecuAssetsSummary from '../../components/BoursecuAssetsSummary.vue'
import { usePriceWithoutType } from '@/utils/usePrice'
import { formatWeightAmount, usePriceWithoutType } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { resolveSummaryMetalWeight } from '@/utils/productAssets'
@@ -80,7 +80,7 @@ const metrics = computed<MetricItem[]>(() => {
})
function formatMetalTotal(metal: WalletMetalTotal) {
return `${usePriceWithoutType(resolveSummaryMetalWeight(metal, inventoryCards.value), false)}${metal.unit}`
return `${formatWeightAmount(resolveSummaryMetalWeight(metal, inventoryCards.value))}${metal.unit}`
}
function handleInfo(metric: MetricItem) {