ui changes
This commit is contained in:
@@ -426,6 +426,48 @@ export function formatPortfolioProfitPercent(percent?: number | null): string {
|
||||
return `${sign}${value.toFixed(2)}٪`
|
||||
}
|
||||
|
||||
/** متن توضیح مودال سود/زیان تحققنیافته طلا */
|
||||
export function formatPortfolioProfitInfoText(
|
||||
portfolio: {
|
||||
average_buy_price?: number | null
|
||||
live_gold_price?: number | null
|
||||
cost_basis_rial?: number | null
|
||||
gold_weight?: number | null
|
||||
gold_rial_value?: number | null
|
||||
unrealized_profit_rial?: number | null
|
||||
unrealized_profit_percent?: number | null
|
||||
},
|
||||
weightUnit = 'گرم'
|
||||
): string {
|
||||
const lines: string[] = []
|
||||
|
||||
if (portfolio.average_buy_price != null && portfolio.average_buy_price > 0) {
|
||||
lines.push(`میانگین قیمت خرید: ${formatRialNumber(portfolio.average_buy_price)} ریال`)
|
||||
}
|
||||
if (portfolio.live_gold_price != null && portfolio.live_gold_price > 0) {
|
||||
lines.push(`قیمت فعلی طلا: ${formatRialNumber(portfolio.live_gold_price)} ریال`)
|
||||
}
|
||||
if (portfolio.gold_weight != null && portfolio.gold_weight > 0) {
|
||||
lines.push(`وزن طلای شما: ${formatWeightAmount(portfolio.gold_weight)} ${weightUnit}`)
|
||||
}
|
||||
if (portfolio.cost_basis_rial != null && portfolio.cost_basis_rial > 0) {
|
||||
lines.push(`بهای تمامشده طلا: ${formatRialNumber(portfolio.cost_basis_rial)} ریال`)
|
||||
}
|
||||
if (portfolio.gold_rial_value != null && portfolio.gold_rial_value > 0) {
|
||||
lines.push(`ارزش فعلی طلا: ${formatRialNumber(portfolio.gold_rial_value)} ریال`)
|
||||
}
|
||||
if (portfolio.unrealized_profit_rial != null) {
|
||||
const pct = formatPortfolioProfitPercent(portfolio.unrealized_profit_percent)
|
||||
lines.push(
|
||||
`سود/زیان تحققنیافته: ${formatPortfolioProfitText(portfolio.unrealized_profit_rial)}${pct ? ` (${pct})` : ''}`
|
||||
)
|
||||
}
|
||||
|
||||
lines.push('محاسبه بر اساس میانگین وزنی قیمت خرید و قیمت لحظهای بازار است.')
|
||||
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
/** متن توضیح مودال دارایی ریالی */
|
||||
export function formatRialAssetsInfoText(
|
||||
cashWallet: number,
|
||||
|
||||
Reference in New Issue
Block a user