fix(drafts): exclude drafts from VAT/revenue/created aggregations + koncept audit labels

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-09 19:04:10 +02:00
parent 52ff0a6ffa
commit 9e9aacdf0b
6 changed files with 133 additions and 5 deletions

View File

@@ -127,13 +127,15 @@ export default async function invoicesRoutes(
const invoice = await createInvoice(body);
// A draft has no number yet — show "koncept" instead of "null".
const isDraft = invoice.status === "draft";
await logAudit({
request,
authData: request.authData,
action: "create",
entityType: "invoice",
entityId: invoice.id,
description: `Vytvořena faktura ${invoice.invoice_number}`,
description: `Vytvořena faktura ${invoice.invoice_number ?? "koncept"}`,
});
// Return both invoice_id and id for frontend compatibility
return success(
@@ -144,7 +146,9 @@ export default async function invoicesRoutes(
invoice_number: invoice.invoice_number,
},
201,
"Faktura byla vystavena",
isDraft
? "Faktura byla uložena jako koncept"
: "Faktura byla vystavena",
);
},
);