fix price
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
<MobileDetailRow label="مشتری" :value="pargarCustomerLabel(row)" />
|
||||
<MobileDetailRow label="موبایل" :value="row.customer?.mobile || '-'" />
|
||||
<MobileDetailRow label="نوع" :value="pargarTypeLabel(row.type)" />
|
||||
<MobileDetailRow label="مقدار" :value="pargarAmountLabel(row)" />
|
||||
<MobileDetailRow label="مقدار" :value="pargarMetalAmountLabel(row)" />
|
||||
<MobileDetailRow label="مبلغ ریالی" :value="pargarRialAmountLabel(row)" />
|
||||
<MobileDetailRow label="شرح" full-width :value="pargarDescLabel(row)" />
|
||||
<MobileDetailRow label="وضعیت" :value="pargarStatusLabel(row.sync_status, row.pargar_ref, row.desc)" />
|
||||
<MobileDetailRow v-if="parsedPayload?.accountId" label="کد حساب پرگار" :value="parsedPayload.accountId" />
|
||||
@@ -79,9 +80,10 @@ import { canRetryPargar, pargarStatusLabel } from '@/pages/menuPages/accounting/
|
||||
import {
|
||||
formatTransactionAmount,
|
||||
parsePargarPayload,
|
||||
pargarAmountLabel,
|
||||
pargarCustomerLabel,
|
||||
pargarDescLabel,
|
||||
pargarMetalAmountLabel,
|
||||
pargarRialAmountLabel,
|
||||
pargarTypeLabel
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-gray-600">
|
||||
<span>نوع: <span class="font-600 text-gray-900">{{ pargarTypeLabel(item.type) }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ pargarAmountLabel(item) }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ metalLabel }}</span></span>
|
||||
<span>ریال: <span class="font-600 text-gray-900">{{ rialLabel }}</span></span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">{{ createdAtLabel }}</div>
|
||||
</div>
|
||||
@@ -22,8 +23,9 @@ import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { pargarStatusLabel } from '@/pages/menuPages/accounting/utils/pargarStatus'
|
||||
import {
|
||||
pargarAmountLabel,
|
||||
pargarCustomerLabel,
|
||||
pargarMetalAmountLabel,
|
||||
pargarRialAmountLabel,
|
||||
pargarTypeLabel
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
|
||||
@@ -39,6 +41,8 @@ const customerName = computed(() => pargarCustomerLabel(props.item))
|
||||
const createdAtLabel = computed(() =>
|
||||
props.item.created_at ? toJalali(props.item.created_at) : '-'
|
||||
)
|
||||
const metalLabel = computed(() => pargarMetalAmountLabel(props.item))
|
||||
const rialLabel = computed(() => pargarRialAmountLabel(props.item))
|
||||
const statusText = computed(() =>
|
||||
pargarStatusLabel(props.item.sync_status, props.item.pargar_ref, props.item.desc)
|
||||
)
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
<MobileDetailRow label="مشتری" :value="row.customer?.name || '-'" />
|
||||
<MobileDetailRow label="موبایل" :value="row.customer?.mobile || '-'" />
|
||||
<MobileDetailRow label="نوع" :value="row.type || '-'" />
|
||||
<MobileDetailRow label="مقدار" :value="row.amount ?? '-'" />
|
||||
<MobileDetailRow label="مقدار" :value="metalAmountLabel(row)" />
|
||||
<MobileDetailRow label="مبلغ ریالی" :value="rialAmountLabel(row)" />
|
||||
<MobileDetailRow label="شرح" full-width :value="row.desc || '-'" />
|
||||
<MobileDetailRow label="وضعیت" :value="tahesabStatusLabel(row.sync_status, row.tahesab_id)" />
|
||||
<MobileDetailRow label="کد تهحساب" :value="row.tahesab_id || '-'" />
|
||||
@@ -52,6 +53,10 @@ import MobileDetailSheet from '@/components/mobile/MobileDetailSheet.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import MobileInfoGrid from '@/components/mobile/MobileInfoGrid.vue'
|
||||
import MobileSheetHeader from '@/components/mobile/MobileSheetHeader.vue'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-gray-600">
|
||||
<span>نوع: <span class="font-600 text-gray-900">{{ item.type || '-' }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ item.amount ?? '-' }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ metalLabel }}</span></span>
|
||||
<span>ریال: <span class="font-600 text-gray-900">{{ rialLabel }}</span></span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">{{ createdAtLabel }}</div>
|
||||
</div>
|
||||
@@ -20,6 +21,10 @@
|
||||
import type { TahesabRecord } from '@/api/tahesab'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -34,6 +39,8 @@ const customerName = computed(() => props.item.customer?.name || '-')
|
||||
const createdAtLabel = computed(() =>
|
||||
props.item.created_at ? toJalali(props.item.created_at) : '-'
|
||||
)
|
||||
const metalLabel = computed(() => metalAmountLabel(props.item))
|
||||
const rialLabel = computed(() => rialAmountLabel(props.item))
|
||||
const statusText = computed(() =>
|
||||
tahesabStatusLabel(props.item.sync_status, props.item.tahesab_id)
|
||||
)
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
<MobileDetailRow label="مشتری" :value="row.customer?.name || '-'" />
|
||||
<MobileDetailRow label="موبایل" :value="row.customer?.mobile || '-'" />
|
||||
<MobileDetailRow label="نوع" :value="row.type || '-'" />
|
||||
<MobileDetailRow label="مقدار" :value="row.amount ?? '-'" />
|
||||
<MobileDetailRow label="مقدار" :value="metalAmountLabel(row)" />
|
||||
<MobileDetailRow label="مبلغ ریالی" :value="rialAmountLabel(row)" />
|
||||
<MobileDetailRow label="شرح" full-width :value="row.desc || '-'" />
|
||||
<MobileDetailRow label="وضعیت" :value="zarinStatusLabel(row.sync_status, row.zarin_id)" />
|
||||
<MobileDetailRow label="کد زرین" :value="row.zarin_id || '-'" />
|
||||
@@ -52,6 +53,10 @@ import MobileDetailSheet from '@/components/mobile/MobileDetailSheet.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import MobileInfoGrid from '@/components/mobile/MobileInfoGrid.vue'
|
||||
import MobileSheetHeader from '@/components/mobile/MobileSheetHeader.vue'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-gray-600">
|
||||
<span>نوع: <span class="font-600 text-gray-900">{{ item.type || '-' }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ item.amount ?? '-' }}</span></span>
|
||||
<span>مقدار: <span class="font-600 text-gray-900">{{ metalLabel }}</span></span>
|
||||
<span>ریال: <span class="font-600 text-gray-900">{{ rialLabel }}</span></span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-400">{{ createdAtLabel }}</div>
|
||||
</div>
|
||||
@@ -20,6 +21,10 @@
|
||||
import type { ZarinRecord } from '@/api/zarin'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -34,6 +39,8 @@ const customerName = computed(() => props.item.customer?.name || '-')
|
||||
const createdAtLabel = computed(() =>
|
||||
props.item.created_at ? toJalali(props.item.created_at) : '-'
|
||||
)
|
||||
const metalLabel = computed(() => metalAmountLabel(props.item))
|
||||
const rialLabel = computed(() => rialAmountLabel(props.item))
|
||||
const statusText = computed(() =>
|
||||
zarinStatusLabel(props.item.sync_status, props.item.zarin_id)
|
||||
)
|
||||
|
||||
@@ -130,9 +130,10 @@ import { canRetryPargar, pargarStatusLabel } from '@/pages/menuPages/accounting/
|
||||
import {
|
||||
formatTransactionAmount,
|
||||
parsePargarPayload,
|
||||
pargarAmountLabel,
|
||||
pargarCustomerLabel,
|
||||
pargarDescLabel,
|
||||
pargarMetalAmountLabel,
|
||||
pargarRialAmountLabel,
|
||||
pargarTypeLabel
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
@@ -155,7 +156,23 @@ const columns = [
|
||||
},
|
||||
{ title: 'مشتری', dataIndex: 'customer.name', key: 'customer.name', type: 'Text', customRender: (r: any) => pargarCustomerLabel(r.record) },
|
||||
{ title: 'نوع', dataIndex: 'type', key: 'type', type: 'Text', customRender: (r: any) => pargarTypeLabel(r.record.type) },
|
||||
{ title: 'مقدار', dataIndex: 'amount', key: 'amount', type: 'Number', customRender: (r: any) => pargarAmountLabel(r.record) },
|
||||
{
|
||||
title: 'مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => pargarMetalAmountLabel(r.record),
|
||||
},
|
||||
{
|
||||
title: 'مبلغ ریالی',
|
||||
dataIndex: 'rial_amount',
|
||||
key: 'rial_amount',
|
||||
type: 'Text',
|
||||
filterable: false,
|
||||
sortable: false,
|
||||
customRender: (r: any) => pargarRialAmountLabel(r.record),
|
||||
},
|
||||
{ title: 'شرح', dataIndex: 'desc', key: 'desc', type: 'Text', customRender: (r: any) => pargarDescLabel(r.record) },
|
||||
{
|
||||
title: 'وضعیت',
|
||||
@@ -197,7 +214,8 @@ const infoItems = computed(() => {
|
||||
{ label: 'موبایل', value: row.customer?.mobile || '-' },
|
||||
{ label: 'کد حساب پرگار', value: payload?.accountId || row.pargar_ref || '-' },
|
||||
{ label: 'نوع', value: pargarTypeLabel(row.type) },
|
||||
{ label: 'مقدار', value: pargarAmountLabel(row) },
|
||||
{ label: 'مقدار', value: pargarMetalAmountLabel(row) },
|
||||
{ label: 'مبلغ ریالی', value: pargarRialAmountLabel(row) },
|
||||
{ label: 'شرح', value: pargarDescLabel(row) },
|
||||
{ label: 'تعداد سطر سند', value: payload?.transactions.length ? String(payload.transactions.length) : '-' },
|
||||
{ label: 'زمان ثبت', value: row.created_at ? toJalali(row.created_at) : '-' },
|
||||
|
||||
@@ -92,6 +92,10 @@ import BasicModal from '@/components/BasicModal.vue'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
|
||||
import { tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
@@ -112,7 +116,23 @@ const columns = [
|
||||
},
|
||||
{ title: 'مشتری', dataIndex: 'customer.name', key: 'customer.name', type: 'Text' },
|
||||
{ title: 'نوع', dataIndex: 'type', key: 'type', type: 'Text' },
|
||||
{ title: 'مقدار', dataIndex: 'amount', key: 'amount', type: 'Number' },
|
||||
{
|
||||
title: 'مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => metalAmountLabel(r.record),
|
||||
},
|
||||
{
|
||||
title: 'مبلغ ریالی',
|
||||
dataIndex: 'rial_amount',
|
||||
key: 'rial_amount',
|
||||
type: 'Text',
|
||||
filterable: false,
|
||||
sortable: false,
|
||||
customRender: (r: any) => rialAmountLabel(r.record),
|
||||
},
|
||||
{ title: 'شرح', dataIndex: 'desc', key: 'desc', type: 'Text' },
|
||||
{
|
||||
title: 'وضعیت',
|
||||
@@ -152,7 +172,8 @@ const infoItems = computed(() => {
|
||||
{ label: 'مشتری', value: row.customer?.name },
|
||||
{ label: 'موبایل', value: row.customer?.mobile },
|
||||
{ label: 'نوع', value: row.type },
|
||||
{ label: 'مقدار', value: row.amount },
|
||||
{ label: 'مقدار', value: metalAmountLabel(row) },
|
||||
{ label: 'مبلغ ریالی', value: rialAmountLabel(row) },
|
||||
{ label: 'شرح', value: row.desc },
|
||||
{ label: 'زمان ثبت', value: row.created_at ? toJalali(row.created_at) : '-' },
|
||||
{ label: 'وضعیت', value: tahesabStatusLabel(row.sync_status, row.tahesab_id) },
|
||||
|
||||
@@ -92,6 +92,10 @@ import BasicModal from '@/components/BasicModal.vue'
|
||||
import ZarinRetryModal from '@/components/ZarinRetryModal.vue'
|
||||
import ZarinMobileCardList from '@/pages/menuPages/accounting/components/ZarinMobileCardList.vue'
|
||||
import { zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
import {
|
||||
metalAmountLabel,
|
||||
rialAmountLabel,
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
@@ -112,7 +116,23 @@ const columns = [
|
||||
},
|
||||
{ title: 'مشتری', dataIndex: 'customer.name', key: 'customer.name', type: 'Text' },
|
||||
{ title: 'نوع', dataIndex: 'type', key: 'type', type: 'Text' },
|
||||
{ title: 'مقدار', dataIndex: 'amount', key: 'amount', type: 'Number' },
|
||||
{
|
||||
title: 'مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => metalAmountLabel(r.record),
|
||||
},
|
||||
{
|
||||
title: 'مبلغ ریالی',
|
||||
dataIndex: 'rial_amount',
|
||||
key: 'rial_amount',
|
||||
type: 'Text',
|
||||
filterable: false,
|
||||
sortable: false,
|
||||
customRender: (r: any) => rialAmountLabel(r.record),
|
||||
},
|
||||
{ title: 'شرح', dataIndex: 'desc', key: 'desc', type: 'Text' },
|
||||
{
|
||||
title: 'وضعیت',
|
||||
@@ -152,7 +172,8 @@ const infoItems = computed(() => {
|
||||
{ label: 'مشتری', value: row.customer?.name },
|
||||
{ label: 'موبایل', value: row.customer?.mobile },
|
||||
{ label: 'نوع', value: row.type },
|
||||
{ label: 'مقدار', value: row.amount },
|
||||
{ label: 'مقدار', value: metalAmountLabel(row) },
|
||||
{ label: 'مبلغ ریالی', value: rialAmountLabel(row) },
|
||||
{ label: 'شرح', value: row.desc },
|
||||
{ label: 'زمان ثبت', value: row.created_at ? toJalali(row.created_at) : '-' },
|
||||
{ label: 'وضعیت', value: zarinStatusLabel(row.sync_status, row.zarin_id) },
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* استخراج مقدار فلز/تعداد و مبلغ ریالی از ردیف اسناد تهحساب / زرین.
|
||||
* منبع: ستون amount + JSON فیلد data (بدون ستون DB جدا).
|
||||
*/
|
||||
|
||||
export type AccountingSyncDocRecord = {
|
||||
amount?: number | string | null
|
||||
type?: string | null
|
||||
desc?: string | null
|
||||
data?: string | null
|
||||
}
|
||||
|
||||
function parseNum(value: unknown): number {
|
||||
if (value == null || value === '') return NaN
|
||||
const n = Number(String(value).replace(/,/g, '').replace('/', '.'))
|
||||
return Number.isFinite(n) ? n : NaN
|
||||
}
|
||||
|
||||
export function parseDocPayload(data?: string | null): Record<string, unknown> | null {
|
||||
if (!data?.trim()) return null
|
||||
try {
|
||||
const parsed = JSON.parse(data)
|
||||
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
||||
? (parsed as Record<string, unknown>)
|
||||
: null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeType(type?: string | null): string {
|
||||
return String(type ?? '')
|
||||
.trim()
|
||||
.replace(/ي/g, 'ی')
|
||||
.replace(/ك/g, 'ک')
|
||||
}
|
||||
|
||||
/** سند خالص ریالی (شارژ/برداشت کیف) */
|
||||
export function isRialOnlyDoc(record: AccountingSyncDocRecord): boolean {
|
||||
const type = normalizeType(record.type)
|
||||
if (type === 'ریال' || type === 'ريال') return true
|
||||
|
||||
const payload = parseDocPayload(record.data)
|
||||
const handler = String(payload?.handler ?? '')
|
||||
return handler === 'wallet'
|
||||
}
|
||||
|
||||
/**
|
||||
* مقدار فلز/تعداد برای نمایش در ستون «مقدار».
|
||||
* ردیف ریالی → null (نشان `-`).
|
||||
*/
|
||||
export function resolveMetalAmount(record: AccountingSyncDocRecord): number | null {
|
||||
if (isRialOnlyDoc(record)) return null
|
||||
|
||||
const n = parseNum(record.amount)
|
||||
if (!Number.isFinite(n)) return null
|
||||
return n
|
||||
}
|
||||
|
||||
/**
|
||||
* مبلغ ریالی برای ستون «مبلغ ریالی».
|
||||
* - wallet: همان amount
|
||||
* - storeTrade: total_price یا amount×price
|
||||
* - walletGold / goldReward: معمولاً نیست مگر در data
|
||||
*/
|
||||
export function resolveRialAmount(record: AccountingSyncDocRecord): number | null {
|
||||
if (isRialOnlyDoc(record)) {
|
||||
const n = parseNum(record.amount)
|
||||
return Number.isFinite(n) ? n : null
|
||||
}
|
||||
|
||||
const payload = parseDocPayload(record.data)
|
||||
if (!payload) return null
|
||||
|
||||
const handler = String(payload.handler ?? '')
|
||||
|
||||
const totalPrice = parseNum(payload.total_price)
|
||||
if (Number.isFinite(totalPrice) && Math.abs(totalPrice) >= 1) {
|
||||
return Math.round(totalPrice)
|
||||
}
|
||||
|
||||
// value فقط برای wallet ریالی معنا دارد؛ برای فلز نادیده
|
||||
if (handler === 'wallet') {
|
||||
const value = parseNum(payload.value)
|
||||
if (Number.isFinite(value)) return Math.round(value)
|
||||
}
|
||||
|
||||
if (handler === 'storeTrade' || handler === '') {
|
||||
const price = parseNum(payload.price)
|
||||
const qty = parseNum(payload.amount ?? record.amount)
|
||||
if (Number.isFinite(price) && Number.isFinite(qty) && price > 0 && Math.abs(qty) > 0) {
|
||||
return Math.round(price * qty)
|
||||
}
|
||||
}
|
||||
|
||||
const cash = parseNum(payload.cash ?? payload.mablagh ?? payload.mablagh_kol)
|
||||
if (Number.isFinite(cash) && Math.abs(cash) >= 1) {
|
||||
return Math.round(cash)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export function formatMetalAmountLabel(value: number | null | undefined): string {
|
||||
if (value == null || !Number.isFinite(value)) return '-'
|
||||
// تعداد صحیح (سکه و …) بدون اعشار اضافی؛ وزن با حداکثر ۶ رقم اعشار مفید
|
||||
if (Math.abs(value - Math.round(value)) < 1e-9) {
|
||||
return String(Math.round(value))
|
||||
}
|
||||
const trimmed = Number(value.toFixed(6))
|
||||
return String(trimmed)
|
||||
}
|
||||
|
||||
export function formatRialAmountLabel(value: number | null | undefined): string {
|
||||
if (value == null || !Number.isFinite(value)) return '-'
|
||||
return Math.round(value).toLocaleString('fa-IR')
|
||||
}
|
||||
|
||||
export function metalAmountLabel(record: AccountingSyncDocRecord): string {
|
||||
return formatMetalAmountLabel(resolveMetalAmount(record))
|
||||
}
|
||||
|
||||
export function rialAmountLabel(record: AccountingSyncDocRecord): string {
|
||||
return formatRialAmountLabel(resolveRialAmount(record))
|
||||
}
|
||||
@@ -70,40 +70,86 @@ export function pargarCustomerLabel(record: PargarRecord): string {
|
||||
}
|
||||
|
||||
export function pargarAmountLabel(record: PargarRecord): string {
|
||||
if (record.amount != null && record.amount !== 0) {
|
||||
return formatPargarAmount(record.amount, record)
|
||||
}
|
||||
|
||||
const payload = parsePargarPayload(record.data)
|
||||
if (!payload?.transactions.length) return '-'
|
||||
|
||||
let maxGold = 0
|
||||
let maxRial = 0
|
||||
for (const tx of payload.transactions) {
|
||||
maxGold = Math.max(maxGold, Math.abs(parseNum(tx.bedGold)), Math.abs(parseNum(tx.besGold)))
|
||||
maxRial = Math.max(maxRial, Math.abs(parseNum(tx.bedRial)), Math.abs(parseNum(tx.besRial)))
|
||||
}
|
||||
|
||||
if (maxGold >= 0.01) return `${maxGold} گرم`
|
||||
if (maxRial >= 1) return `${maxRial.toLocaleString('fa-IR')} ریال`
|
||||
const metal = pargarMetalAmountLabel(record)
|
||||
const rial = pargarRialAmountLabel(record)
|
||||
if (metal !== '-' && rial !== '-') return `${metal} / ${rial}`
|
||||
if (metal !== '-') return metal
|
||||
if (rial !== '-') return rial
|
||||
return '-'
|
||||
}
|
||||
|
||||
function formatPargarAmount(amount: number, record: PargarRecord): string {
|
||||
function resolvePargarSummaryUnit(record: PargarRecord): 'rial' | 'gold' | null {
|
||||
try {
|
||||
const raw = record.data ? (JSON.parse(record.data) as { _summary?: { amount_unit?: string } }) : null
|
||||
const unit = raw?._summary?.amount_unit
|
||||
if (unit === 'rial' || unit === 'gold') return unit
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
if (record.type === 'wallet_cash') return 'rial'
|
||||
if (record.type === 'wallet_gold' || record.type === 'mande') return 'gold'
|
||||
return null
|
||||
}
|
||||
|
||||
function maxGoldFromPayload(record: PargarRecord): number {
|
||||
const payload = parsePargarPayload(record.data)
|
||||
let summaryUnit: string | undefined
|
||||
if (payload && '_summary' in (JSON.parse(record.data || '{}') as Record<string, unknown>)) {
|
||||
const raw = JSON.parse(record.data || '{}') as { _summary?: { amount_unit?: string } }
|
||||
summaryUnit = raw._summary?.amount_unit
|
||||
if (!payload?.transactions.length) return 0
|
||||
let maxGold = 0
|
||||
for (const tx of payload.transactions) {
|
||||
maxGold = Math.max(maxGold, Math.abs(parseNum(tx.bedGold)), Math.abs(parseNum(tx.besGold)))
|
||||
}
|
||||
return maxGold
|
||||
}
|
||||
|
||||
function maxRialFromPayload(record: PargarRecord): number {
|
||||
const payload = parsePargarPayload(record.data)
|
||||
if (!payload?.transactions.length) return 0
|
||||
let maxRial = 0
|
||||
for (const tx of payload.transactions) {
|
||||
maxRial = Math.max(maxRial, Math.abs(parseNum(tx.bedRial)), Math.abs(parseNum(tx.besRial)))
|
||||
}
|
||||
return maxRial
|
||||
}
|
||||
|
||||
/** ستون مقدار — فلز/گرم (نه ریال) */
|
||||
export function pargarMetalAmountLabel(record: PargarRecord): string {
|
||||
if (record.type === 'wallet_cash') return '-'
|
||||
|
||||
const unit = resolvePargarSummaryUnit(record)
|
||||
if (record.amount != null && record.amount !== 0) {
|
||||
if (unit === 'rial') {
|
||||
// amount ریالی است؛ فلز را از تراکنشها بگیر
|
||||
} else if (unit === 'gold' || unit == null) {
|
||||
if (unit === 'gold' || record.type !== 'document') {
|
||||
const n = Number(record.amount)
|
||||
if (Number.isFinite(n) && Math.abs(n) >= 0.000001) {
|
||||
return Math.abs(n - Math.round(n)) < 1e-9 ? String(Math.round(n)) : String(Number(n.toFixed(6)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (summaryUnit === 'rial' || record.type === 'wallet_cash') {
|
||||
return `${amount.toLocaleString('fa-IR')} ریال`
|
||||
const maxGold = maxGoldFromPayload(record)
|
||||
if (maxGold >= 0.01) {
|
||||
return Math.abs(maxGold - Math.round(maxGold)) < 1e-9
|
||||
? String(Math.round(maxGold))
|
||||
: String(Number(maxGold.toFixed(6)))
|
||||
}
|
||||
if (summaryUnit === 'gold' || record.type === 'wallet_gold' || record.type === 'mande') {
|
||||
return `${amount} گرم`
|
||||
return '-'
|
||||
}
|
||||
|
||||
/** ستون مبلغ ریالی */
|
||||
export function pargarRialAmountLabel(record: PargarRecord): string {
|
||||
const unit = resolvePargarSummaryUnit(record)
|
||||
if (record.amount != null && record.amount !== 0) {
|
||||
if (unit === 'rial' || record.type === 'wallet_cash') {
|
||||
return Math.round(Number(record.amount)).toLocaleString('fa-IR')
|
||||
}
|
||||
}
|
||||
return String(amount)
|
||||
|
||||
const maxRial = maxRialFromPayload(record)
|
||||
if (maxRial >= 1) return Math.round(maxRial).toLocaleString('fa-IR')
|
||||
return '-'
|
||||
}
|
||||
|
||||
export function pargarDescLabel(record: PargarRecord): string {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
title: 'دسترسی مشتری به قابلیتها',
|
||||
icon: 'vuesax-linear:people',
|
||||
match: (k) =>
|
||||
/^(banner_enabled|tracking_systems_enabled|jibit_verification|register_jibit_verify|show_product_details)$/.test(k)
|
||||
/^(banner_enabled|tracking_systems_enabled|jibit_verification|register_jibit_verify|show_product_details|show_product_trade_status|show_product_card_meta)$/.test(k)
|
||||
},
|
||||
{
|
||||
id: 'trading_hours',
|
||||
|
||||
@@ -271,6 +271,8 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
show_home_price_when_closed: 'switch',
|
||||
show_gold_ounce_price: 'switch',
|
||||
show_product_details: 'switch',
|
||||
show_product_trade_status: 'switch',
|
||||
show_product_card_meta: 'switch',
|
||||
send_to_tahesab: 'switch',
|
||||
accounting_provider: 'select',
|
||||
profit_gold_api_enabled: 'switch',
|
||||
@@ -566,6 +568,10 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
'روشن: اگر آدرس API تابلو (zaarbox_api_url) تنظیم شده باشد، قیمت انس طلا در اپ مشتری نمایش داده میشود. خاموش: نمایش داده نمیشود.',
|
||||
show_product_details:
|
||||
'روشن: بعد از انتخاب محصول در صفحه خرید/فروش، متن توضیح محصول نمایش داده میشود. خاموش: توضیح نشان داده نمیشود.',
|
||||
show_product_trade_status:
|
||||
'روشن: روی کارت محصول برچسب خرید باز/بسته و فروش باز/بسته نمایش داده میشود. خاموش: مخفی است.',
|
||||
show_product_card_meta:
|
||||
'روشن: روی کارت محصول دستهبندی، وضعیت تحویل فیزیکی و مقدار/وزن نمایش داده میشود. خاموش: مخفی است.',
|
||||
fee_single:
|
||||
'منسوخ — دیگر استفاده نمیشود. اختلاف فقط از buy_fee / sell_fee (خالی = صفر).',
|
||||
buy_fee:
|
||||
@@ -825,6 +831,8 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
show_home_price_when_closed: 'نمایش قیمت صفحه اصلی خارج از ساعت کاری',
|
||||
show_gold_ounce_price: 'نمایش قیمت انس طلا',
|
||||
show_product_details: 'نمایش جزئیات اطلاعات محصول',
|
||||
show_product_trade_status: 'نمایش خرید/فروش باز روی کارت محصول',
|
||||
show_product_card_meta: 'نمایش دسته و تحویل و مقدار روی کارت محصول',
|
||||
fee_single: 'اختلاف پایه خرید/فروش',
|
||||
buy_fee: 'اضافه قیمت خرید',
|
||||
sell_fee: 'کسر قیمت فروش',
|
||||
@@ -983,7 +991,8 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
||||
'open_register',
|
||||
'referral_id', 'referral_limit', 'referral_gift_on_first_order',
|
||||
'register_jibit_verify', 'register_referral_bonus_message', 'register_referral_sms_to_referrer',
|
||||
'sell_fee', 'show_last_price', 'show_home_price_when_closed', 'show_gold_ounce_price', 'show_product_details', 'startDay',
|
||||
'sell_fee', 'show_last_price', 'show_home_price_when_closed', 'show_gold_ounce_price', 'show_product_details',
|
||||
'show_product_trade_status', 'show_product_card_meta', 'startDay',
|
||||
'support_messengers', 'support_messenger_text',
|
||||
'deposit_support_message_text', 'deposit_account_holder', 'deposit_card_number', 'deposit_sheba',
|
||||
'text_about', 'text_rule',
|
||||
|
||||
Reference in New Issue
Block a user