3.0.0 #220

Merged
flfeders merged 676 commits from dev into main 2026-09-20 16:10:48 +00:00
Showing only changes of commit a50ff256ee - Show all commits

View File

@@ -37,7 +37,8 @@ export const executeManualGeneration = async (
if (!tenant) throw new Error(`Tenant mit ID ${tenantId} nicht gefunden.`); if (!tenant) throw new Error(`Tenant mit ID ${tenantId} nicht gefunden.`);
// 2. Templates laden // 2. Templates laden
const templates = await server.db const uniqueTemplateIds = [...new Set(templateIds)]
const templates = (await server.db
.select() .select()
.from(schema.createddocuments) .from(schema.createddocuments)
.where( .where(
@@ -45,13 +46,13 @@ export const executeManualGeneration = async (
eq(schema.createddocuments.tenant, tenantId), eq(schema.createddocuments.tenant, tenantId),
eq(schema.createddocuments.type, "serialInvoices"), eq(schema.createddocuments.type, "serialInvoices"),
eq(schema.createddocuments.archived, false), eq(schema.createddocuments.archived, false),
inArray(schema.createddocuments.id, templateIds) inArray(schema.createddocuments.id, uniqueTemplateIds)
) )
); ))
.filter((template) => Boolean((template.serialConfig as any)?.active));
if (templates.length === 0) { if (templates.length !== uniqueTemplateIds.length) {
console.warn("Keine passenden Vorlagen gefunden."); throw new Error("Mindestens eine Serienrechnungsvorlage wurde nicht gefunden, ist archiviert oder inaktiv.");
throw new Error("Keine passenden Serienrechnungsvorlagen gefunden.");
} }
// 3. Folder & FileType IDs holen (Hilfsfunktionen unten) // 3. Folder & FileType IDs holen (Hilfsfunktionen unten)
@@ -67,7 +68,7 @@ export const executeManualGeneration = async (
executionDate: executionDayjs.toDate(), executionDate: executionDayjs.toDate(),
status: "draft", status: "draft",
createdBy: executedBy, createdBy: executedBy,
summary: `${templateIds.length} Vorlagen verarbeitet` summary: `${uniqueTemplateIds.length} Vorlagen verarbeitet`
}) })
.returning(); .returning();