Deploy via committed dist: local Nest build, server runs with .env
Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateCheckRass = calculateCheckRass;
|
||||
function startOfDay(date) {
|
||||
const d = new Date(date);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return d;
|
||||
}
|
||||
function calculateCheckRass(checks, baseDate = new Date()) {
|
||||
if (checks.length === 0) {
|
||||
return {
|
||||
checkCount: 0,
|
||||
totalAmount: 0,
|
||||
nearestDueDate: null,
|
||||
farthestDueDate: null,
|
||||
rassDays: 0,
|
||||
rassDate: null,
|
||||
};
|
||||
}
|
||||
const base = startOfDay(baseDate);
|
||||
let totalAmount = 0;
|
||||
let weightedDays = 0;
|
||||
const dueDates = [];
|
||||
for (const check of checks) {
|
||||
const due = startOfDay(new Date(check.dueDate));
|
||||
dueDates.push(due);
|
||||
const days = Math.max(0, Math.round((due.getTime() - base.getTime()) / (1000 * 60 * 60 * 24)));
|
||||
totalAmount += check.amount;
|
||||
weightedDays += check.amount * days;
|
||||
}
|
||||
const rassDays = totalAmount > 0 ? Math.round(weightedDays / totalAmount) : 0;
|
||||
const rassDate = new Date(base);
|
||||
rassDate.setDate(rassDate.getDate() + rassDays);
|
||||
dueDates.sort((a, b) => a.getTime() - b.getTime());
|
||||
return {
|
||||
checkCount: checks.length,
|
||||
totalAmount,
|
||||
nearestDueDate: dueDates[0]?.toISOString() ?? null,
|
||||
farthestDueDate: dueDates[dueDates.length - 1]?.toISOString() ?? null,
|
||||
rassDays,
|
||||
rassDate: rassDate.toISOString(),
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=check-rass.js.map
|
||||
Reference in New Issue
Block a user