Files
nademitex_admin/src/utils/settlement.ts
T

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-10-01 20:50:23 +03:30
import type { SettlementMethod } from '@/types'
const CASH_PHASE_RAW_STATUSES = new Set([
'awaiting_cash_payment',
'cash_invoice_issued',
'cash_in_progress',
'cash_payment_submitted',
'awaiting_cash_confirmation',
])
export function settlementMethodLabel(method?: string | null): string {
if (!method) return 'انتخاب‌نشده'
if (method === 'check') return 'چکی'
if (method === 'cash_check') return 'نقدی-چکی'
return 'نقدی'
}
export function orderShowsCashActions(
order: { settlementMethod?: SettlementMethod | null; rawStatus?: string },
): boolean {
const method = order.settlementMethod
if (!method) return false
if (method === 'cash') {
return order.rawStatus !== 'cash_confirmed'
}
if (method === 'cash_check') {
return !!order.rawStatus && CASH_PHASE_RAW_STATUSES.has(order.rawStatus)
}
return false
}
export function orderShowsCheckActions(
order: { settlementMethod?: SettlementMethod | null; rawStatus?: string },
): boolean {
const method = order.settlementMethod
if (method === 'check') return true
if (method === 'cash_check') {
return !!order.rawStatus && !CASH_PHASE_RAW_STATUSES.has(order.rawStatus)
}
return false
}