提交
This commit is contained in:
1 parent
2e66e03792
commit
09afdb1d65
93 files changed
+22307
-15075
No files matched your search
@@ -13,6 +13,34 @@ export function addMonthsYmd(dateStr: string, months: number): string {
|
||||
return `${yy}${mm}${dd}`
|
||||
}
|
||||
|
||||
/** 日期加 N 天,返回 YYYYMMDD(入参支持 YYYYMMDD 或 YYYY-MM-DD) */
|
||||
export function addDaysYmd(dateStr: string, days: number): string {
|
||||
const compact = String(dateStr || '').replace(/-/g, '')
|
||||
if (compact.length !== 8) return ''
|
||||
const y = parseInt(compact.slice(0, 4), 10)
|
||||
const m = parseInt(compact.slice(4, 6), 10) - 1
|
||||
const d = parseInt(compact.slice(6, 8), 10)
|
||||
const date = new Date(y, m, d)
|
||||
date.setDate(date.getDate() + days)
|
||||
const yy = date.getFullYear()
|
||||
const mm = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const dd = String(date.getDate()).padStart(2, '0')
|
||||
return `${yy}${mm}${dd}`
|
||||
}
|
||||
|
||||
/** 分期应缴费时间:第 1 期=开始时间,第 2 期起在按月递增基础上提前 10 天 */
|
||||
export function calcFqInstallmentDueDate(
|
||||
startDate: string,
|
||||
index: number,
|
||||
intervalMonths: number
|
||||
): string {
|
||||
const base = addMonthsYmd(startDate, index * intervalMonths)
|
||||
if (index >= 1) {
|
||||
return addDaysYmd(base, -10)
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
export function calcInstallmentDueAmounts(
|
||||
contractAmount: number | null | undefined,
|
||||
count: number
|
||||
@@ -87,14 +115,15 @@ export function alignFqPaymentDetailsForDisplay(
|
||||
if (i < unnumbered.length) {
|
||||
const raw = { ...unnumbered[i], installmentNo: no }
|
||||
if (!raw.installmentDueDate && startDate && interval) {
|
||||
raw.installmentDueDate = addMonthsYmd(startDate, i * interval)
|
||||
raw.installmentDueDate = calcFqInstallmentDueDate(startDate, i, interval)
|
||||
}
|
||||
result.push(raw)
|
||||
continue
|
||||
}
|
||||
result.push({
|
||||
installmentNo: no,
|
||||
installmentDueDate: startDate && interval ? addMonthsYmd(startDate, i * interval) : '',
|
||||
installmentDueDate:
|
||||
startDate && interval ? calcFqInstallmentDueDate(startDate, i, interval) : '',
|
||||
dueAmount: amounts[i] ?? null,
|
||||
payStatus: 'dfj',
|
||||
transferType: '',
|
||||
|
||||
Reference in new issue
Block a user