R62 Fix A1-A6:请假预览全非工作日处理

这个提交包含在:
2026-04-14 12:55:27 +08:00
父节点 f8d941ec64
当前提交 c90cb165be
共修改 7 个文件,包含 114 行新增和 6 行删除
+11 -3
查看文件
@@ -233,10 +233,13 @@ function buildNaturalWorkingDaysPreview(body) {
weekendDayCount: 0,
adjustedWorkdayCount: 0,
calendarApplied: false,
isNonWorkingRange: false,
};
}
async function resolveWorkingDaysPreview(fastify, employee, body) {
async function resolveWorkingDaysPreview(fastify, employee, body, options = {}) {
const allowNonWorkingRange = Boolean(options.allowNonWorkingRange);
if (!employee?.legal_entity_id) {
return buildNaturalWorkingDaysPreview(body);
}
@@ -288,11 +291,14 @@ async function resolveWorkingDaysPreview(fastify, employee, body) {
startSession: body.startSession,
endSession: body.endSession,
calendarDays: calendar.days,
allowNonWorkingRange,
});
}
async function resolveRequestedDaysForCreate(fastify, employee, body) {
const preview = await resolveWorkingDaysPreview(fastify, employee, body);
const preview = await resolveWorkingDaysPreview(fastify, employee, body, {
allowNonWorkingRange: false,
});
return preview.requestedDays;
}
@@ -579,7 +585,9 @@ async function leaveRoutes(fastify) {
},
async (request, reply) => {
const query = parseWorkingDaysPreviewQuery(request.query);
const preview = await resolveWorkingDaysPreview(fastify, request.employee, query);
const preview = await resolveWorkingDaysPreview(fastify, request.employee, query, {
allowNonWorkingRange: true,
});
return sendData(reply, request, preview);
},