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

@@ -198,7 +198,11 @@ export default async function dashboardRoutes(
prisma.quotations.count({ where: { status: "ordered" } }),
prisma.quotations.count({ where: { status: "invalidated" } }),
prisma.quotations.count({
where: { created_at: { gte: monthStart, lt: monthEnd } },
where: {
// Drafts aren't real offers — keep them out of the count.
status: { not: "draft" },
created_at: { gte: monthStart, lt: monthEnd },
},
}),
]);
result.offers = {
@@ -246,6 +250,7 @@ export default async function dashboardRoutes(
FROM invoices i
JOIN invoice_items ii ON i.id = ii.invoice_id
WHERE i.issue_date >= ${monthStartStr} AND i.issue_date < ${monthEndStr}
AND i.status <> 'draft'
GROUP BY i.currency
`,
]);