feat: add required kyc blocking modal and fix copper asset units to kilogram

This commit is contained in:
2026-11-05 17:17:29 +03:30
parent ae01f6c8d6
commit 0f50ec315c
18 changed files with 495 additions and 50 deletions
+21 -9
View File
@@ -186,6 +186,14 @@ function sumBoursecuHomeProductInventories(
return sum
}
export function resolveBoursecuCopperUnit(unit?: string | null): string {
const trimmed = (unit ?? '').trim()
if (!trimmed || trimmed === 'گرم' || trimmed === 'gram' || trimmed === 'g') {
return 'کیلوگرم'
}
return trimmed
}
function findMetalTotalById(metalTotals: WalletMetalTotal[], metalId: number) {
return metalTotals.find((metal) => metal.metal_id === metalId)
}
@@ -195,7 +203,8 @@ function formatBoursecuMetalRowValue(metal: WalletMetalTotal): string {
if (metal.metal_id === METAL_GOLD) {
return `${amount} عدد`
}
return `${amount}${metal.unit ?? ''}`
const unit = metal.metal_id === METAL_COPPER ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit ?? 'کیلوگرم')
return `${amount} ${unit}`
}
function formatRialNumber(value: number): string {
@@ -237,8 +246,11 @@ function buildBoursecuCopperPopupLines(summary: {
const metalTotals = summary.metal_totals ?? []
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
const shamshMetal = findMetalTotalById(metalTotals, METAL_GOLD)
const weightUnit = copperMetal?.unit || 'کیلوگرم'
const totalWeight = sumBoursecuHomeProductInventories(inventoryCards, countProducts)
const weightUnit = resolveBoursecuCopperUnit(copperMetal?.unit)
const totalWeight =
copperMetal != null && Number(copperMetal.total_weight ?? 0) > 0
? Number(copperMetal.total_weight)
: sumBoursecuHomeProductInventories(inventoryCards, countProducts)
const katodCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuKatodCard)
const maftolCard = findBoursecuProductCard(inventoryCards, countProducts, isBoursecuMaftolCard)
@@ -319,10 +331,10 @@ export function buildBoursecuHomeAssetRows(
const countProducts = summary.count_products ?? []
const metalTotals = summary.metal_totals ?? []
const copperMetal = findMetalTotalById(metalTotals, METAL_COPPER)
const weightUnit = copperMetal?.unit || 'کیلوگرم'
const weightUnit = resolveBoursecuCopperUnit(copperMetal?.unit)
const totalCopperWeight =
copperMetal != null
? Number(copperMetal.total_weight ?? 0)
copperMetal != null && Number(copperMetal.total_weight ?? 0) > 0
? Number(copperMetal.total_weight)
: sumBoursecuHomeProductInventories(inventoryCards, countProducts)
const cash = Number(summary.cash_wallet ?? 0)
@@ -387,7 +399,7 @@ export function resolveSummaryMetalWeight(
/** متن توضیح مودال دارایی فلزی — بر اساس metal_totals سرور، بدون هاردکد طلا */
export function formatMetalAssetsInfoText(metal: WalletMetalTotal): string {
const unit = metal.unit || 'گرم'
const unit = metal.metal_id === METAL_COPPER ? resolveBoursecuCopperUnit(metal.unit) : (metal.unit || 'کیلوگرم')
return `${metal.label}: مجموع کیف محصولات (${metal.product_weight} ${unit}) + موجودی کیف اصلی (${metal.melted_weight} ${unit})`
}
@@ -510,7 +522,7 @@ export function computeMetalRialValue(
const metalId = Number(metal.metal_id ?? 0)
const unitPrice =
livePricesByMetal?.[metalId] ??
(metalId === METAL_GOLD ? liveGoldPrice : 0)
(metalId === METAL_COPPER || metalId === METAL_GOLD ? liveGoldPrice : 0)
return sum + weight * unitPrice
}, 0)
@@ -534,7 +546,7 @@ export function formatInventoryCardValue(card: {
display_type?: string
}): string {
const quantity = Number(card.quantity ?? 0)
const unit = card.unit ?? (card.display_type === 'count' ? 'عدد' : 'گرم')
const unit = card.unit ?? (card.display_type === 'count' ? 'عدد' : 'کیلوگرم')
const formatted =
card.display_type === 'count'
? usePriceWithoutType(quantity, false)