fix(accounting): validate serial invoice templates
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 43s
Build and Push Docker Images / build-frontend (push) Successful in 1m13s
Build and Push Docker Images / build-website (push) Successful in 24s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 43s
Build and Push Docker Images / build-frontend (push) Successful in 1m13s
Build and Push Docker Images / build-website (push) Successful in 24s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
This commit is contained in:
@@ -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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user