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) ---
|
// --- Logik Helper (Unverändert zur Business Logik) ---
|
||||||
|
|
||||||
function calculateDateRange(config: any, executionDate: dayjs.Dayjs) {
|
function calculateDateRange(config: any, executionDate: dayjs.Dayjs) {
|
||||||
let firstDate = executionDate;
|
// Basis nehmen
|
||||||
let lastDate = executionDate;
|
let baseDate = executionDate;
|
||||||
// Logik 1:1 übernommen
|
|
||||||
|
let firstDate = baseDate;
|
||||||
|
let lastDate = baseDate;
|
||||||
|
|
||||||
if (config.intervall === "monatlich" && config.dateDirection === "Rückwirkend") {
|
if (config.intervall === "monatlich" && config.dateDirection === "Rückwirkend") {
|
||||||
firstDate = executionDate.subtract(1, "month").date(1);
|
// 1. Monat abziehen
|
||||||
lastDate = executionDate.subtract(1, "month").endOf("month");
|
// 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") {
|
} 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) {
|
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> = {};
|
let titleSums: Record<string, number> = {};
|
||||||
|
|
||||||
// Aktueller Titel für Gruppierung
|
// Aktueller Titel für Gruppierung
|
||||||
let currentTitle = "Ohne Titel";
|
let currentTitle = "";
|
||||||
|
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
if (row.mode === 'title') {
|
if (row.mode === 'title') {
|
||||||
@@ -467,8 +483,8 @@ function calculateDocumentTotals(rows: any[], taxType: string) {
|
|||||||
totalNet += amount;
|
totalNet += amount;
|
||||||
|
|
||||||
// Summen pro Titel addieren
|
// Summen pro Titel addieren
|
||||||
if (!titleSums[currentTitle]) titleSums[currentTitle] = 0;
|
//if (!titleSums[currentTitle]) titleSums[currentTitle] = 0;
|
||||||
titleSums[currentTitle] += amount;
|
if(currentTitle.length > 0) titleSums[currentTitle] += amount;
|
||||||
|
|
||||||
// Steuer-Logik
|
// Steuer-Logik
|
||||||
const tax = taxType === "19 UStG" || taxType === "13b UStG" ? 0 : Number(row.taxPercent);
|
const tax = taxType === "19 UStG" || taxType === "13b UStG" ? 0 : Number(row.taxPercent);
|
||||||
|
|||||||
Reference in New Issue
Block a user