feat(admin): signed profit/discount fields for special price packages

Let buy/sell extras be entered as profit or discount so negative values work in the editor and table.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 13:10:59 +03:30
co-authored by Cursor
parent 8636fd1aea
commit 7440a53c80
6 changed files with 180 additions and 13 deletions
@@ -2,6 +2,15 @@ import type { BaseTableColumn } from '@core/type/baseTable'
import { usePrice } from '@core/utils/usePrice'
import { toJalali } from '@core/utils/useDataTime'
function formatSignedProfit(raw: unknown) {
const n = Number(raw ?? 0)
if (!Number.isFinite(n) || n === 0) {
return usePrice(0, true, '')
}
const label = n < 0 ? 'تخفیف' : 'سود'
return `${label} ${usePrice(Math.abs(n), true, '')}`
}
export function getSpecialPricePackageColumns(): BaseTableColumn[] {
return [
{
@@ -37,14 +46,14 @@ export function getSpecialPricePackageColumns(): BaseTableColumn[] {
dataIndex: 'profit_buy',
key: 'profit_buy',
type: 'Text',
customRender: ({ record }) => usePrice(record.profit_buy ?? 0, true, '')
customRender: ({ record }) => formatSignedProfit(record.profit_buy)
},
{
title: 'سود فروش',
dataIndex: 'profit_sell',
key: 'profit_sell',
type: 'Text',
customRender: ({ record }) => usePrice(record.profit_sell ?? 0, true, '')
customRender: ({ record }) => formatSignedProfit(record.profit_sell)
},
{
title: 'نمایش محصول',