feat: align fee summary, special pricing and support chat with modular

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 17:57:22 +03:30
co-authored by Cursor
parent e9c5830d4e
commit e01192fb5e
11 changed files with 292 additions and 49 deletions
+29 -3
View File
@@ -5,7 +5,7 @@ export type ProductCashFeeSource = {
cash_fee_sell_is_percent?: boolean | null
}
/** 0.5 => 0.5% ، 5 => 5% */
/** 0.5 => 0.5% ، 5 => 5% — همیشه عدد درصد */
export function resolveCashFeePercentRatio(percentValue?: number | null) {
const offset = Number(percentValue ?? 0)
if (!offset || !Number.isFinite(offset)) {
@@ -15,6 +15,11 @@ export function resolveCashFeePercentRatio(percentValue?: number | null) {
return offset / 100
}
/** @deprecated از resolveCashFeePercentRatio استفاده کنید */
export function resolveFeePercentRatio(percentValue?: number | null) {
return resolveCashFeePercentRatio(percentValue)
}
export function resolveProductCashFeeRial(
feeValue: number | null | undefined,
isPercent: boolean | null | undefined,
@@ -38,17 +43,38 @@ export function resolveProductCashFeeRial(
}
export function resolveProductCashFeeBuyRial(product: ProductCashFeeSource, basePriceRial: number) {
return resolveProductCashFeeRial(
const baseFee = resolveProductCashFeeRial(
product.cash_fee_buy,
product.cash_fee_buy_is_percent,
basePriceRial,
)
const special = Number((product as any).special_profit_buy ?? 0)
return baseFee + (Number.isFinite(special) ? Math.round(special) : 0)
}
export function resolveProductCashFeeSellRial(product: ProductCashFeeSource, basePriceRial: number) {
return resolveProductCashFeeRial(
const baseFee = resolveProductCashFeeRial(
product.cash_fee_sell,
product.cash_fee_sell_is_percent,
basePriceRial,
)
const special = Number((product as any).special_profit_sell ?? 0)
return baseFee + (Number.isFinite(special) ? Math.round(special) : 0)
}
export function formatProductCashFeeLabel(
feeValue: number | null | undefined,
isPercent?: boolean | null,
) {
const raw = Number(feeValue ?? 0)
if (!raw) {
return '۰'
}
if (isPercent) {
const text = Number.isInteger(raw) ? String(raw) : String(parseFloat(raw.toFixed(4)))
return `${text}%`
}
return `${raw} ریال`
}