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 settlementPlanLabel( method?: string | null, checkTermMonths?: number | null, ): string { const base = settlementMethodLabel(method) if ((method === 'check' || method === 'cash_check') && checkTermMonths) { return `${base} · چک ${checkTermMonths} ماهه` } return base } 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 }