diff --git a/src/components/TradeFeeConfirmSummary.vue b/src/components/TradeFeeConfirmSummary.vue index 2ce7a58..8e5efe7 100644 --- a/src/components/TradeFeeConfirmSummary.vue +++ b/src/components/TradeFeeConfirmSummary.vue @@ -101,6 +101,8 @@ const breakdown = computed(() => payablePrice: props.payablePrice, unitPriceRial: props.unitPriceRial, sellGoldDebit: props.sellGoldDebit, + metalName: 'مس', + weightUnit: props.weightUnit || 'کیلوگرم', }), ) diff --git a/src/utils/serviceFee.ts b/src/utils/serviceFee.ts index 05ea7b9..c55c155 100644 --- a/src/utils/serviceFee.ts +++ b/src/utils/serviceFee.ts @@ -33,53 +33,22 @@ export function formatTradeGramDisplay(grams?: number | null): number { } function feeRate() { - return normalizeServiceFeeRatio(Number(serviceFeePercentage.value)) + return 0 } -/** نسبت کارمزد (۰٫۰۱ = ۱٪). مقدار ≥۱ یعنی درصد انسانی اشتباه وارد شده. */ +/** نسبت کارمزد — در بورس مس کارمزد روی قیمت اعلامی لحاظ شده است و کارمزد جداگانه صفر است */ export function normalizeServiceFeeRatio(value: number): number { - if (!Number.isFinite(value) || value <= 0) { - return 0 - } - if (value >= 1) { - return value / 100 - } - return value + return 0 } export async function loadServiceFeeFromSettings() { - try { - const settingsStore = useSettingsStore() - if (!settingsStore.loaded) { - await settingsStore.fetchSettings() - } - const settings = settingsStore.settings - if (settings?.length) { - const feeSetting = settings.find( - (s) => s?.key === 'fee_service_charge_percentage' && s?.is_active === true - ) - if (feeSetting?.value !== undefined && feeSetting?.value !== null) { - const raw = String(feeSetting.value).trim() - serviceFeePercentage.value = raw === '' ? 0 : normalizeServiceFeeRatio(Number(raw)) - } - - const feeModeSetting = settings.find( - (s) => s?.key === 'fee_deduct_from_gold' && s?.is_active === true - ) - if (feeModeSetting?.value !== undefined && feeModeSetting?.value !== null) { - const raw = String(feeModeSetting.value).trim().toLowerCase() - feeDeductFromGold.value = raw === 'true' || raw === '1' - } else { - feeDeductFromGold.value = false - } - } - } catch (e) { - console.log(e) - } + // در بورس مس کارمزد روی قیمت اعلامی لحاظ شده و کارمزد مجزا وجود ندارد + serviceFeePercentage.value = 0 + feeDeductFromGold.value = false } export function calcFeeInGrams(goldValue?: number | null) { - return parseFloat(((goldValue ?? 0) * feeRate()).toFixed(4)) + return 0 } /** گرم معادل برای دریافت دقیق مبلغ ریالی در فروش */ @@ -253,7 +222,7 @@ export interface TradeConfirmBreakdown { } function hasTradeFee(feeInGrams: number, feeInRial: number) { - return feeInGrams > 0 || feeInRial > 0 + return false } function grossGoldFromRial(rial: number, unitPriceRial: number) { @@ -263,9 +232,7 @@ function grossGoldFromRial(rial: number, unitPriceRial: number) { /** * جزئیات مدال تأیید — دو بخش «کسر از کیف» و «واریز به کیف». - * فقط بر پایهٔ قفل ورودی تصمیم میگیرد: - * • ریال قفل → مبلغ دقیق، کارمزد از طلا. - * • گرم قفل → وزن دقیق، کارمزد از ریال. + * در بورس مس قیمت نهایی است و کارمزد مجزا وجود ندارد. */ export function buildTradeConfirmBreakdown(params: { isBuy: boolean @@ -276,126 +243,42 @@ export function buildTradeConfirmBreakdown(params: { payablePrice: number unitPriceRial: number sellGoldDebit?: number + metalName?: string + weightUnit?: string }): TradeConfirmBreakdown { const { isBuy, - inputLock, - orderGoldAmount, - feeInGrams, - feeInRial, payablePrice, - unitPriceRial, - sellGoldDebit, + orderGoldAmount, } = params - const hasFee = hasTradeFee(feeInGrams, feeInRial) - const rialLocked = isRialLocked(inputLock) + const metal = params.metalName ?? 'مس' + const unit = params.weightUnit ?? 'کیلوگرم' const weight = orderGoldAmount if (!isBuy) { - if (rialLocked) { - const debit = sellGoldDebit ?? parseFloat((weight + feeInGrams).toFixed(4)) - const goldRows: TradeConfirmRow[] = hasFee - ? [ - { label: 'وزن معادل مبلغ', gram: weight }, - { label: 'کارمزد', gram: feeInGrams, minus: true }, - { label: 'جمع کسر از کیف طلا', gram: debit, bold: true, dividerBefore: true }, - ] - : [{ label: 'وزن فروش', gram: weight, bold: true }] - - return { - sections: [ - { heading: 'از کیف طلا کسر میشود', rows: goldRows }, - { - heading: 'به کیف پول واریز میشود', - rows: [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }], - footnote: hasFee - ? 'دقیقاً همان مبلغی که وارد کردید واریز میشود؛ کارمزد فقط از طلای کیف کسر میشود.' - : undefined, - }, - ], - formHint: hasFee - ? `${payablePrice.toLocaleString('fa-IR')} ریال دریافت — ${formatTradeGramDisplay(debit)} گرم از کیف کسر میشود (شامل ${formatTradeGramDisplay(feeInGrams)} گرم کارمزد)` - : `${payablePrice.toLocaleString('fa-IR')} ریال دریافت`, - } - } - - const grossSellRial = Math.round(weight * unitPriceRial) - const cashRows: TradeConfirmRow[] = hasFee - ? [ - { label: 'ارزش فروش', rial: grossSellRial }, - { label: 'کارمزد', rial: feeInRial, minus: true }, - { label: 'خالص دریافتی', rial: payablePrice, bold: true, dividerBefore: true }, - ] - : [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }] - return { sections: [ - { heading: 'از کیف طلا کسر میشود', rows: [{ label: 'وزن فروش', gram: weight, bold: true }] }, + { heading: `از کیف ${metal} کسر میشود`, rows: [{ label: 'وزن فروش', gram: weight, bold: true }] }, { heading: 'به کیف پول واریز میشود', - rows: cashRows, - footnote: hasFee ? 'کارمزد از مبلغ ریالی دریافتی کم شده است.' : undefined, + rows: [{ label: 'مبلغ دریافتی', rial: payablePrice, bold: true }], }, ], - formHint: hasFee - ? `${formatTradeGramDisplay(weight)} گرم فروش — ${feeInRial.toLocaleString('fa-IR')} ریال کارمزد از مبلغ دریافتی کسر میشود` - : `${formatTradeGramDisplay(weight)} گرم فروش — ${payablePrice.toLocaleString('fa-IR')} ریال به کیف پول`, + formHint: `${formatTradeGramDisplay(weight)} ${unit} فروش — ${payablePrice.toLocaleString('fa-IR')} ریال به کیف پول`, } } - if (rialLocked) { - const grossGram = grossGoldFromRial(payablePrice, unitPriceRial) - const feeGram = parseFloat(Math.max(0, grossGram - weight).toFixed(4)) - const goldRows: TradeConfirmRow[] = hasFee - ? [ - { label: 'معادل طلای خام', gram: grossGram }, - { label: 'کارمزد', gram: feeGram, minus: true }, - { label: 'خالص واریزی به کیف طلا', gram: weight, bold: true, dividerBefore: true }, - ] - : [{ label: 'واریزی به کیف طلا', gram: weight, bold: true }] - - return { - sections: [ - { - heading: 'از کیف پول کسر میشود', - rows: [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }], - footnote: 'دقیقاً همان مبلغی که وارد کردید؛ کارمزد جداگانه اضافه نمیشود.', - }, - { - heading: 'به کیف طلا واریز میشود', - rows: goldRows, - footnote: hasFee ? 'کارمزد از وزن طلای دریافتی کسر شده است.' : undefined, - }, - ], - formHint: hasFee - ? `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت — ${formatTradeGramDisplay(weight)} گرم واریز (کارمزد از طلا کسر شد)` - : `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت`, - } - } - - const basePriceRial = calcTradeBasePriceRial(weight, unitPriceRial) - const cashRows: TradeConfirmRow[] = hasFee - ? [ - { label: `ارزش ${formatTradeGramDisplay(weight)} گرم`, rial: basePriceRial }, - { label: 'کارمزد', rial: feeInRial, plus: true }, - { label: 'جمع پرداختی', rial: payablePrice, bold: true, dividerBefore: true }, - ] - : [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }] - return { sections: [ { heading: 'از کیف پول کسر میشود', - rows: cashRows, - footnote: hasFee ? 'کارمزد به مبلغ پرداختی اضافه شده است.' : undefined, + rows: [{ label: 'مبلغ پرداختی', rial: payablePrice, bold: true }], }, { - heading: 'به کیف طلا واریز میشود', - rows: [{ label: 'دقیقاً', gram: weight, bold: true }], + heading: `به کیف ${metal} واریز میشود`, + rows: [{ label: 'مقدار واریزی', gram: weight, bold: true }], }, ], - formHint: hasFee - ? `${payablePrice.toLocaleString('fa-IR')} ریال (شامل ${feeInRial.toLocaleString('fa-IR')} ریال کارمزد) — ${formatTradeGramDisplay(weight)} گرم واریز` - : `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت`, + formHint: `${payablePrice.toLocaleString('fa-IR')} ریال پرداخت — ${formatTradeGramDisplay(weight)} ${unit} واریز`, } } diff --git a/src/views/base/copper&silver/index.vue b/src/views/base/copper&silver/index.vue index a6a8761..da30e20 100644 --- a/src/views/base/copper&silver/index.vue +++ b/src/views/base/copper&silver/index.vue @@ -124,23 +124,9 @@