2026-08-11 19:35:28 +08:00
|
|
|
export type FinanceStatusTone = 'success' | 'warning' | 'info' | 'danger' | 'primary'
|
|
|
|
|
|
|
|
|
|
interface FinanceStatusDefinition {
|
|
|
|
|
label: string
|
|
|
|
|
tone: FinanceStatusTone
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const financeStatuses: Record<string, FinanceStatusDefinition> = {
|
|
|
|
|
ACTIVE: { label: '正常', tone: 'success' },
|
|
|
|
|
DISABLED: { label: '停用', tone: 'info' },
|
|
|
|
|
INACTIVE: { label: '停用', tone: 'info' },
|
|
|
|
|
DRAFT: { label: '草稿', tone: 'info' },
|
|
|
|
|
PENDING: { label: '待审核', tone: 'warning' },
|
|
|
|
|
PENDING_REVIEW: { label: '待审核', tone: 'warning' },
|
|
|
|
|
APPROVED: { label: '已审核', tone: 'success' },
|
|
|
|
|
ISSUED: { label: '已出账', tone: 'primary' },
|
|
|
|
|
REJECTED: { label: '已驳回', tone: 'danger' },
|
|
|
|
|
UNPAID: { label: '未支付', tone: 'warning' },
|
|
|
|
|
PARTIALLY_PAID: { label: '部分结清', tone: 'warning' },
|
|
|
|
|
PAID: { label: '已结清', tone: 'success' },
|
|
|
|
|
VOIDED: { label: '已作废', tone: 'info' },
|
|
|
|
|
AVAILABLE: { label: '待结算', tone: 'warning' },
|
|
|
|
|
LOCKED: { label: '结算锁定', tone: 'warning' },
|
|
|
|
|
BILLED: { label: '已入账', tone: 'success' },
|
|
|
|
|
RECORDED: { label: '已登记', tone: 'primary' },
|
|
|
|
|
CONFIRMED: { label: '已确认', tone: 'success' },
|
2026-08-19 09:14:35 +08:00
|
|
|
PENDING_CONFIRMATION: { label: '待客户确认', tone: 'warning' },
|
|
|
|
|
NOT_REQUIRED: { label: '无需确认', tone: 'info' },
|
2026-08-11 19:35:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const financeBillStatusOptions = [
|
|
|
|
|
{ label: '草稿', value: 'DRAFT' },
|
|
|
|
|
{ label: '待审核', value: 'PENDING_REVIEW' },
|
|
|
|
|
{ label: '已出账', value: 'ISSUED' },
|
|
|
|
|
{ label: '已驳回', value: 'REJECTED' },
|
|
|
|
|
{ label: '部分结清', value: 'PARTIALLY_PAID' },
|
|
|
|
|
{ label: '已结清', value: 'PAID' },
|
|
|
|
|
{ label: '已作废', value: 'VOIDED' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const financeArapStatusOptions = [
|
|
|
|
|
...financeBillStatusOptions,
|
|
|
|
|
{ label: '待结算', value: 'AVAILABLE' },
|
|
|
|
|
{ label: '结算锁定', value: 'LOCKED' },
|
|
|
|
|
{ label: '已入账', value: 'BILLED' },
|
|
|
|
|
{ label: '已登记', value: 'RECORDED' },
|
|
|
|
|
{ label: '已确认', value: 'CONFIRMED' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
function normalizeStatus(status: unknown) {
|
|
|
|
|
return typeof status === 'string' ? status.trim().toUpperCase() : ''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function financeStatusLabel(status: unknown) {
|
|
|
|
|
return financeStatuses[normalizeStatus(status)]?.label || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function financeStatusTone(status: unknown): FinanceStatusTone {
|
|
|
|
|
return financeStatuses[normalizeStatus(status)]?.tone || 'info'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const financeSourceTypeLabels: Record<string, string> = {
|
2026-08-17 13:24:55 +08:00
|
|
|
INBOUND_FEE: '入库费用', ORDER_FEE: '订单费用', CONTAINER_FEE: '装柜费用', CONTAINER_COST: '整柜成本', MANUAL_COST: '人工成本', STORAGE_FEE: '仓储费用',
|
2026-08-11 19:35:28 +08:00
|
|
|
}
|
|
|
|
|
const financeBusinessTypeLabels: Record<string, string> = {
|
2026-08-17 16:45:46 +08:00
|
|
|
RECONCILIATION_CREATED: '生成对账单',
|
|
|
|
|
SETTLEMENT_ISSUED: '结算单生效',
|
|
|
|
|
RECEIPT: '收款',
|
|
|
|
|
PAYMENT: '付款',
|
|
|
|
|
ADJUSTMENT: '账务调整',
|
|
|
|
|
VOID: '作废',
|
2026-08-19 09:42:12 +08:00
|
|
|
// The following values are returned by current Finance read models.
|
2026-08-17 16:45:46 +08:00
|
|
|
BILL: '对账单',
|
|
|
|
|
COST: '成本',
|
|
|
|
|
SETTLEMENT: '结算',
|
2026-08-11 19:35:28 +08:00
|
|
|
}
|
|
|
|
|
const financeDocumentTypeLabels: Record<string, string> = {
|
|
|
|
|
BILL: '对账单', RECEIPT: '收款单', COST: '成本单', SETTLEMENT: '结算单', REVISION: '调整记录',
|
|
|
|
|
}
|
|
|
|
|
const financeOperationActionLabels: Record<string, string> = {
|
2026-08-19 09:14:35 +08:00
|
|
|
CREATE: '创建', APPROVE: '审核通过', REJECT: '审核驳回', UPDATE: '更新',
|
|
|
|
|
FEE_SOURCE_EDIT: '编辑费用', FEE_SOURCE_SUBMIT: '提交审核', FEE_SOURCE_REVIEW_APPROVE: '审核通过',
|
|
|
|
|
FEE_SOURCE_REVIEW_REJECT: '审核驳回', FEE_SOURCE_ADJUST: '调整费用', FEE_SOURCE_VOID: '作废费用',
|
2026-08-17 16:45:46 +08:00
|
|
|
RECONCILIATION_CREATE: '生成对账单', RECONCILIATION_CREATED: '生成对账单', RECONCILIATION_ADJUST: '调整对账单',
|
|
|
|
|
BILL_CREATE: '创建账单', BILL_ISSUE: '出账', BILL_ADJUST: '调整账单', BILL_VOID: '作废账单',
|
|
|
|
|
SETTLEMENT_AR_CREATE: '生成应收结算单', SETTLEMENT_AP_CREATE: '生成应付结算单', SETTLEMENT_PAYMENT_CREATE: '登记收付款',
|
|
|
|
|
RECEIPT_CREATE: '登记收款', COST_CREATE: '登记成本', VOID: '作废', REOPEN: '重开',
|
2026-08-11 19:35:28 +08:00
|
|
|
}
|
|
|
|
|
const financeOperationResultLabels: Record<string, string> = {
|
|
|
|
|
SUCCESS: '操作成功', FAILED: '操作失败', PENDING: '待处理', PROCESSING: '处理中',
|
|
|
|
|
}
|
2026-08-11 19:59:15 +08:00
|
|
|
const financeDirectionLabels: Record<string, string> = {
|
|
|
|
|
RECEIVABLE: '应收', PAYABLE: '应付',
|
|
|
|
|
}
|
2026-08-11 19:35:28 +08:00
|
|
|
|
|
|
|
|
function codeLabel(value: unknown, labels: Record<string, string>, unknownLabel: string) {
|
|
|
|
|
const code = normalizeStatus(value)
|
|
|
|
|
if (!code) return '—'
|
|
|
|
|
return labels[code] || unknownLabel
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-17 16:45:46 +08:00
|
|
|
export const financeSourceTypeLabel = (value: unknown) => codeLabel(value, financeSourceTypeLabels, '未知来源类型')
|
|
|
|
|
export const financeBusinessTypeLabel = (value: unknown) => codeLabel(value, financeBusinessTypeLabels, '未知业务类型')
|
|
|
|
|
export const financeDocumentTypeLabel = (value: unknown) => codeLabel(value, financeDocumentTypeLabels, '未知单据类型')
|
|
|
|
|
export const financeOperationActionLabel = (value: unknown) => codeLabel(value, financeOperationActionLabels, '未知操作')
|
2026-08-11 19:35:28 +08:00
|
|
|
export const financeOperationResultLabel = (value: unknown) => codeLabel(value, financeOperationResultLabels, '结果未知')
|
2026-08-11 19:59:15 +08:00
|
|
|
export const financeDirectionLabel = (value: unknown) => codeLabel(value, financeDirectionLabels, '未知方向')
|