Fix Time Issue
This commit is contained in:
@@ -332,17 +332,33 @@ async function getFileTypeId(server: FastifyInstance,tenantId: number) {
|
||||
// --- Logik Helper (Unverändert zur Business Logik) ---
|
||||
|
||||
function calculateDateRange(config: any, executionDate: dayjs.Dayjs) {
|
||||
let firstDate = executionDate;
|
||||
let lastDate = executionDate;
|
||||
// Logik 1:1 übernommen
|
||||
// Basis nehmen
|
||||
let baseDate = executionDate;
|
||||
|
||||
let firstDate = baseDate;
|
||||
let lastDate = baseDate;
|
||||
|
||||
if (config.intervall === "monatlich" && config.dateDirection === "Rückwirkend") {
|
||||
firstDate = executionDate.subtract(1, "month").date(1);
|
||||
lastDate = executionDate.subtract(1, "month").endOf("month");
|
||||
// 1. Monat abziehen
|
||||
// 2. Start/Ende des Monats berechnen
|
||||
// 3. WICHTIG: Zeit hart auf 12:00:00 setzen, damit Zeitzonen das Datum nicht kippen
|
||||
firstDate = baseDate.subtract(1, "month").startOf("month").hour(12).minute(0).second(0).millisecond(0);
|
||||
lastDate = baseDate.subtract(1, "month").endOf("month").hour(12).minute(0).second(0).millisecond(0);
|
||||
|
||||
} else if (config.intervall === "vierteljährlich" && config.dateDirection === "Rückwirkend") {
|
||||
firstDate = executionDate.subtract(1, "quarter").startOf("quarter");
|
||||
lastDate = executionDate.subtract(1, "quarter").endOf("quarter");
|
||||
|
||||
firstDate = baseDate.subtract(1, "quarter").startOf("quarter").hour(12).minute(0).second(0).millisecond(0);
|
||||
lastDate = baseDate.subtract(1, "quarter").endOf("quarter").hour(12).minute(0).second(0).millisecond(0);
|
||||
}
|
||||
return { firstDate: firstDate.toISOString(), lastDate: lastDate.toISOString() };
|
||||
|
||||
// Das Ergebnis ist nun z.B.:
|
||||
// firstDate: '2025-12-01T12:00:00.000Z' (Eindeutig der 1. Dezember)
|
||||
// lastDate: '2025-12-31T12:00:00.000Z' (Eindeutig der 31. Dezember)
|
||||
|
||||
return {
|
||||
firstDate: firstDate.toISOString(),
|
||||
lastDate: lastDate.toISOString()
|
||||
};
|
||||
}
|
||||
|
||||
async function getSaveData(item: any, tenant: any, firstDate: string, lastDate: string, executionDate: string, executedBy: string) {
|
||||
@@ -453,7 +469,7 @@ function calculateDocumentTotals(rows: any[], taxType: string) {
|
||||
let titleSums: Record<string, number> = {};
|
||||
|
||||
// Aktueller Titel für Gruppierung
|
||||
let currentTitle = "Ohne Titel";
|
||||
let currentTitle = "";
|
||||
|
||||
rows.forEach(row => {
|
||||
if (row.mode === 'title') {
|
||||
@@ -467,8 +483,8 @@ function calculateDocumentTotals(rows: any[], taxType: string) {
|
||||
totalNet += amount;
|
||||
|
||||
// Summen pro Titel addieren
|
||||
if (!titleSums[currentTitle]) titleSums[currentTitle] = 0;
|
||||
titleSums[currentTitle] += amount;
|
||||
//if (!titleSums[currentTitle]) titleSums[currentTitle] = 0;
|
||||
if(currentTitle.length > 0) titleSums[currentTitle] += amount;
|
||||
|
||||
// Steuer-Logik
|
||||
const tax = taxType === "19 UStG" || taxType === "13b UStG" ? 0 : Number(row.taxPercent);
|
||||
|
||||
Reference in New Issue
Block a user