fix(procurement): preserve correction drafts separately from pending commands

This commit is contained in:
2026-10-10 14:01:11 +08:00
parent 0ca12de2f4
commit 2bf561bafe
3 changed files with 117 additions and 16 deletions
@@ -0,0 +1,16 @@
export interface ProcurementCorrectionDraft {
feeId: string
targetOriginalAmount: string
reason: string
voucherFileId: string
orderVersion: number
}
export function readCorrectionDraft(raw: string | null): ProcurementCorrectionDraft | null {
if (!raw) return null
const value: unknown = JSON.parse(raw)
if (!value || typeof value !== 'object') throw new Error('费用更正草稿无法读取')
const draft = value as Record<string, unknown>
if (!['feeId', 'targetOriginalAmount', 'reason', 'voucherFileId'].every(key => typeof draft[key] === 'string') || !Number.isSafeInteger(draft.orderVersion)) throw new Error('费用更正草稿无法读取')
return { feeId: draft.feeId as string, targetOriginalAmount: draft.targetOriginalAmount as string, reason: draft.reason as string, voucherFileId: draft.voucherFileId as string, orderVersion: draft.orderVersion as number }
}