提交
This commit is contained in:
1 parent
afd517ce10
commit
eec61cb5dd
82 files changed
+16585
-9026
No files matched your search
@@ -1,5 +1,7 @@
|
||||
/** 分期缴费:期数对齐、应缴日/金额计算(与 ProtocolFormDialog 逻辑一致) */
|
||||
|
||||
const DAYS_PER_MONTH = 30
|
||||
|
||||
export function addMonthsYmd(dateStr: string, months: number): string {
|
||||
const compact = String(dateStr || '').replace(/-/g, '')
|
||||
if (compact.length !== 8) return ''
|
||||
@@ -28,13 +30,34 @@ export function addDaysYmd(dateStr: string, days: number): string {
|
||||
return `${yy}${mm}${dd}`
|
||||
}
|
||||
|
||||
/** 分期应缴费时间:第 1 期=开始时间,第 2 期起在按月递增基础上提前 10 天 */
|
||||
/** 整数部分按日历加月,小数部分按 30 天/月换算为天数 */
|
||||
export function addIntervalMonthsYmd(dateStr: string, totalMonths: number): string {
|
||||
const compact = String(dateStr || '').replace(/-/g, '')
|
||||
if (compact.length !== 8 || !Number.isFinite(totalMonths) || totalMonths === 0) {
|
||||
return compact.length === 8 ? compact : ''
|
||||
}
|
||||
const wholeMonths = Math.trunc(totalMonths)
|
||||
const fracMonths = totalMonths - wholeMonths
|
||||
let result = compact
|
||||
if (wholeMonths !== 0) {
|
||||
result = addMonthsYmd(result, wholeMonths)
|
||||
}
|
||||
if (fracMonths !== 0) {
|
||||
const days = Math.round(fracMonths * DAYS_PER_MONTH)
|
||||
if (days !== 0) {
|
||||
result = addDaysYmd(result, days)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 分期应缴费时间:第 1 期=开始时间,第 2 期起在间隔递增基础上提前 10 天 */
|
||||
export function calcFqInstallmentDueDate(
|
||||
startDate: string,
|
||||
index: number,
|
||||
intervalMonths: number
|
||||
): string {
|
||||
const base = addMonthsYmd(startDate, index * intervalMonths)
|
||||
const base = addIntervalMonthsYmd(startDate, index * intervalMonths)
|
||||
if (index >= 1) {
|
||||
return addDaysYmd(base, -10)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user