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.`);
// 2. Templates laden
const templates = await server.db
const uniqueTemplateIds = [...new Set(templateIds)]
const templates = (await server.db
.select()
.from(schema.createddocuments)
.where(
@@ -45,13 +46,13 @@ export const executeManualGeneration = async (
eq(schema.createddocuments.tenant, tenantId),
eq(schema.createddocuments.type, "serialInvoices"),
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) {
console.warn("Keine passenden Vorlagen gefunden.");
throw new Error("Keine passenden Serienrechnungsvorlagen gefunden.");
if (templates.length !== uniqueTemplateIds.length) {
throw new Error("Mindestens eine Serienrechnungsvorlage wurde nicht gefunden, ist archiviert oder inaktiv.");
}
// 3. Folder & FileType IDs holen (Hilfsfunktionen unten)
@@ -67,7 +68,7 @@ export const executeManualGeneration = async (
executionDate: executionDayjs.toDate(),
status: "draft",
createdBy: executedBy,
summary: `${templateIds.length} Vorlagen verarbeitet`
summary: `${uniqueTemplateIds.length} Vorlagen verarbeitet`
})
.returning();