fix(web-admin): align schedule paid/arrears with yjf-only rule
Period 已缴费 now counts only 付款完成 transfers, matching backend summarize_period. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d2bb1e0fa1
commit
c71bb5a11c
2 files changed
+16
-19
No files matched your search
@@ -98,9 +98,6 @@ export function sampleScheduleDuesMismatchHint(pay: SamplePaymentLike): string |
|
||||
return null
|
||||
}
|
||||
|
||||
/** 展示口径已缴:与后端 chase_period_money / 缴费信息期次一致 */
|
||||
const DISPLAY_PAID_STATUSES = new Set(['dfj', 'jfqrz', 'yjf'])
|
||||
|
||||
function sumTransferAmountByStatuses(
|
||||
transfers: TransferLike[] | undefined,
|
||||
statuses: Set<string>
|
||||
@@ -110,18 +107,6 @@ function sumTransferAmountByStatuses(
|
||||
.reduce((s, t) => s + (Number(t.transferAmount) || 0), 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* 期次已缴/欠缴(展示):已缴 = dfj + jfqrz + yjf;欠缴 = max(应缴 − 已缴, 0)
|
||||
*/
|
||||
export function schedulePaidArrears(
|
||||
dueAmount: number,
|
||||
transfers: TransferLike[]
|
||||
): { paid: number; arrears: number } {
|
||||
const paid = Math.round(sumTransferAmountByStatuses(transfers, DISPLAY_PAID_STATUSES) * 100) / 100
|
||||
const arrears = Math.round((dueAmount - paid) * 100) / 100
|
||||
return { paid, arrears: arrears > 0 ? arrears : 0 }
|
||||
}
|
||||
|
||||
/** 财务已确认口径(仅 yjf):用于分改趸并期等与后端 plan_fq_to_fgd_merge 对齐 */
|
||||
export function scheduleFinanceConfirmedPaidArrears(
|
||||
dueAmount: number,
|
||||
@@ -132,6 +117,18 @@ export function scheduleFinanceConfirmedPaidArrears(
|
||||
return { paid, arrears: Math.round((dueAmount - paid) * 100) / 100 }
|
||||
}
|
||||
|
||||
/**
|
||||
* 期次已缴/欠缴(展示):已缴 = 仅 yjf;欠缴 = max(应缴 − 已缴, 0)
|
||||
* 与后端 summarize_period / chase_period_money 一致
|
||||
*/
|
||||
export function schedulePaidArrears(
|
||||
dueAmount: number,
|
||||
transfers: TransferLike[]
|
||||
): { paid: number; arrears: number } {
|
||||
const { paid, arrears } = scheduleFinanceConfirmedPaidArrears(dueAmount, transfers)
|
||||
return { paid, arrears: arrears > 0 ? arrears : 0 }
|
||||
}
|
||||
|
||||
/** 单样本合同金额 = 优惠价格;未填优惠价则 null */
|
||||
export function resolveSampleContractAmount(
|
||||
sample: SamplePriceLike | null | undefined
|
||||
@@ -346,7 +343,7 @@ export function applyExpandRemainingToInstallment<T extends Record<string, any>>
|
||||
|
||||
for (const s of schList) {
|
||||
if ((s.transfers || []).some((t) => t.payStatus === 'jfqrz')) {
|
||||
throw new Error('存在缴费确认中的转账,请先完成财务确认')
|
||||
throw new Error('存在付款确认中的转账,请先完成财务确认')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user