diff --git a/src/components/customer/CustomerWalletBalancePanel.vue b/src/components/customer/CustomerWalletBalancePanel.vue index 857b529..d2c17d1 100644 --- a/src/components/customer/CustomerWalletBalancePanel.vue +++ b/src/components/customer/CustomerWalletBalancePanel.vue @@ -239,6 +239,13 @@ function inventoryCards() { return [...(summary.value.inventory_cards ?? []), ...(summary.value.count_products ?? [])] } +function isCountChargeTarget(target: ChargeTarget) { + if (target.kind === 'money') return false + if (target.allows_decimal === false) return true + if (target.unit === 'عدد') return true + return target.trade_by_quantity === false && !isMeltedTradeGroup(target.group_type) +} + function balanceForTarget(target: ChargeTarget) { if (!summary.value) return '—' if (target.kind === 'money') { @@ -246,18 +253,15 @@ function balanceForTarget(target: ChargeTarget) { } const card = inventoryCards().find((row) => Number(row.product_id) === Number(target.product_id)) - if (card) return formatCard(card) - // تعدادی: همیشه «عدد» — نه گرم (وزن هر قطعه در فیلد unit محصول است) - const isCount = - target.allows_decimal === false || - target.unit === 'عدد' || - (target.trade_by_quantity === false && !isMeltedTradeGroup(target.group_type)) - - if (isCount) { - return '۰ عدد' + // اولویت با نوع شارژ (تعدادی) — حتی اگر کارت دارایی اشتباه «گرم» برچسب زده باشد + if (isCountChargeTarget(target)) { + const qty = Number(card?.quantity ?? 0) + return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 0 })} عدد` } + if (card) return formatCard(card) + return formatMetalDisplayValue(0, target.metal_id ?? 1) } diff --git a/src/pages/menuPages/customers/base/components/WalletChargeForm.vue b/src/pages/menuPages/customers/base/components/WalletChargeForm.vue index 62a4e57..28b7483 100644 --- a/src/pages/menuPages/customers/base/components/WalletChargeForm.vue +++ b/src/pages/menuPages/customers/base/components/WalletChargeForm.vue @@ -37,11 +37,12 @@ v-model:value="modelValue.amountAbs" :addon-before="resolvedUnit" :type="resolvedInputType" - :step="integerOnly ? 1 : undefined" + :step="requiresInteger ? 1 : undefined" :place-holder="amountPlaceholder" + @onchange="onAmountChange" /> -