提交
This commit is contained in:
1 parent
a2125374a8
commit
3950b5c334
157 files changed
+57538
-22359
No files matched your search
@@ -70,8 +70,7 @@ export function normalizeInstallmentAmounts(
|
||||
return defaultInstallmentAmounts(contractAmount, count)
|
||||
}
|
||||
if (isLegacyInstallmentRatios(values, contractAmount)) {
|
||||
const sized =
|
||||
values.length === count ? values : resizeInstallmentRatios(values, count)
|
||||
const sized = values.length === count ? values : resizeInstallmentRatios(values, count)
|
||||
return calcInstallmentDueAmountsByRatios(contractAmount, finalizeInstallmentRatios(sized))
|
||||
}
|
||||
const amounts = values.map((v) => Number(v || 0))
|
||||
@@ -283,6 +282,36 @@ export function calcUnpaidAmountsByRatios(
|
||||
type PaymentLike = Record<string, unknown> | null | undefined
|
||||
type DetailLike = Record<string, any>
|
||||
|
||||
function integerOrUndefined(value: unknown): number | undefined {
|
||||
if (value === null || value === undefined || value === '') return undefined
|
||||
const parsed = Number(value)
|
||||
return Number.isFinite(parsed) ? Math.trunc(parsed) : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通协议保存只提交草稿字段。财务确认、退款状态及其附件必须走专用接口。
|
||||
*/
|
||||
export function buildProtocolPaymentDetailPayload(detail: DetailLike): DetailLike {
|
||||
return {
|
||||
id: detail.id,
|
||||
transferType: detail.transferType,
|
||||
dueAmount: detail.dueAmount,
|
||||
transferAmount: detail.transferAmount,
|
||||
transferTime: detail.transferTime,
|
||||
installmentNo: integerOrUndefined(detail.installmentNo),
|
||||
installmentDueDate: detail.installmentDueDate,
|
||||
remark: detail.remark,
|
||||
attachments: (detail.attachments || []).map((attachment: DetailLike) => ({
|
||||
id: attachment.id,
|
||||
fileName: attachment.fileName,
|
||||
fileUrl: attachment.fileUrl,
|
||||
fileSize: attachment.fileSize,
|
||||
fileSizeDisplay: attachment.fileSizeDisplay,
|
||||
fileType: attachment.fileType
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function resolveFqAmounts(payment: PaymentLike, count: number, details?: DetailLike[]): number[] {
|
||||
const contract = payment?.contractAmount != null ? Number(payment.contractAmount) : null
|
||||
const stored = Array.isArray(payment?.installmentRatios)
|
||||
|
||||
Reference in new issue
Block a user