fix: 修复多处边界条件问题
- rooms: parseRoomNumber 未知格式返回默认 capacity=4,防止 undefined 绕过入住容量检查 - rooms: 修复 parseInt() || undefined 导致楼层 0 被吞掉 - rooms: batchImport 中 capacity 使用 ?? 代替 ||,显式 0 不被覆盖 - occupancies: 所有 capacity 比较加 ?? 0 防守兜底,fail closed - schedules: assertValidScheduleRange 增加 startTime > endTime 校验 - attendance: 时段重叠检查改为按 startTime 排序后再比较,消除漏检 - attendance: 移除 getScheduleOptionsForAttendance 中不可靠的 raw[index] fallback - expenses: 个人附加费批量导入增加 assertPositiveAmount 校验 - expenses: 水电费导入增加 periodEnd >= periodStart 校验
This commit is contained in:
@@ -291,6 +291,11 @@ export class ExpensesService {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
if (!this.isValidDate(periodStart) || !this.isValidDate(periodEnd) || periodEnd < periodStart) {
|
||||
errors.push(`第${rowNum}行: ${row.roomNumber} 账期无效(${periodStart} ~ ${periodEnd}),已跳过`);
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 关键校验:电费 + 水费 都为 0 时,多半是 Excel 公式未正确计算或字段缺失,
|
||||
// 必须给出明确错误,避免出现"提示成功但无数据"的迷之现象。
|
||||
@@ -439,6 +444,15 @@ export class ExpensesService {
|
||||
}
|
||||
}
|
||||
|
||||
// 校验金额
|
||||
try {
|
||||
this.assertPositiveAmount(row.amount);
|
||||
} catch (e: any) {
|
||||
errors.push(`第${rowNum}行: ${row.studentName} ${e.message}`);
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.personalExpRepo.save(
|
||||
this.personalExpRepo.create({
|
||||
studentId: student.id,
|
||||
|
||||
Reference in New Issue
Block a user