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

@@ -268,6 +268,9 @@ export async function getInvoiceStats(queryMonth?: number, queryYear?: number) {
const [monthInvoices, awaitingInvoices, overdueInvoices] = await Promise.all([
prisma.invoices.findMany({
where: {
// Drafts are not real financial documents — exclude them so their
// VAT/amounts never inflate the monthly stats (vat_month etc.).
status: { not: "draft" },
issue_date: { gte: monthStart, lte: monthEnd },
},
include: { invoice_items: true },