Initial admin edits
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user