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 'چکی'
|
2026-11-15 11:25:05 +03:30
|
|
|
if (method === 'cash_check') return 'نصف نقد، نصف چکی'
|
2026-10-01 20:50:23 +03:30
|
|
|
return 'نقدی'
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-15 11:25:05 +03:30
|
|
|
export function settlementPlanLabel(
|
|
|
|
|
method?: string | null,
|
|
|
|
|
checkTermMonths?: number | null,
|
|
|
|
|
): string {
|
|
|
|
|
const base = settlementMethodLabel(method)
|
|
|
|
|
if ((method === 'check' || method === 'cash_check') && checkTermMonths) {
|
|
|
|
|
return `${base} · چک ${checkTermMonths} ماهه`
|
|
|
|
|
}
|
|
|
|
|
return base
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-01 20:50:23 +03:30
|
|
|
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
|
|
|
|
|
}
|