fix(protocol): save DJ pay details without blocking on due-sum mismatch
Persist payment before samples to avoid consuming sample codes on validation failure, soft-delete samples on create rollback, and surface DJ due-amount mismatch as a hint only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f661d40f3a
commit
57487fd0dc
18 files changed
+13425
-12458
No files matched your search
@@ -54,6 +54,20 @@ export function calcRemainingAmount(contractAmount: number | null, details: Deta
|
||||
return Math.round(remaining * 100) / 100
|
||||
}
|
||||
|
||||
/** 趸交:应缴合计与合同金额不一致时返回提醒文案(不阻断保存) */
|
||||
export function djDueAmountMismatchHint(
|
||||
contractAmount: number | null | undefined,
|
||||
details: DetailLike[]
|
||||
): string | null {
|
||||
if (contractAmount == null || Number(contractAmount) === 0) return null
|
||||
const totalDue = details.reduce((sum, d) => sum + (Number(d.dueAmount) || 0), 0)
|
||||
const contract = Number(contractAmount)
|
||||
if (Math.abs(totalDue - contract) > 0.015) {
|
||||
return `趸交各明细应缴金额之和应为 ${contract.toFixed(2)},当前为 ${totalDue.toFixed(2)},请核对`
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function formatMoneySummary(v: number): string {
|
||||
return `¥${v.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user