feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base
This commit is contained in:
1 parent
453bece72c
commit
7204dd6b60
108 files changed
+10400
-105
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import {
|
||||
boolean,
|
||||
check,
|
||||
customType,
|
||||
integer,
|
||||
@@ -43,6 +44,15 @@ export const billingReports = pgTable(
|
||||
status: reportStatus("status").notNull().default("draft"),
|
||||
pdf: bytea("pdf"),
|
||||
pdfSha256: varchar("pdf_sha256", { length: 64 }),
|
||||
// The actual VAT invoice is uploaded by the admin AFTER finalization.
|
||||
// Uploading it triggers the bundled email (invoice + Nutzungsnachweis).
|
||||
invoicePdf: bytea("invoice_pdf"),
|
||||
invoicePdfSha256: varchar("invoice_pdf_sha256", { length: 64 }),
|
||||
invoicePdfFilename: text("invoice_pdf_filename"),
|
||||
invoiceUploadedAt: timestamp("invoice_uploaded_at", { withTimezone: true }),
|
||||
invoiceEmailStatus: text("invoice_email_status").notNull().default("not_sent"),
|
||||
invoiceEmailSentAt: timestamp("invoice_email_sent_at", { withTimezone: true }),
|
||||
invoiceEmailError: text("invoice_email_error"),
|
||||
createdByUserId: uuid("created_by_user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "restrict" }),
|
||||
@@ -58,6 +68,14 @@ export const billingReports = pgTable(
|
||||
uniqueIndex("billing_reports_report_number_unique").on(table.reportNumber),
|
||||
uniqueIndex("billing_reports_invoice_number_unique").on(table.invoiceNumber),
|
||||
check("billing_reports_pdf_sha256_hex_check", sql`${table.pdfSha256} ~ '^[0-9a-f]{64}$'`),
|
||||
check(
|
||||
"billing_reports_invoice_pdf_sha256_hex_check",
|
||||
sql`${table.invoicePdfSha256} IS NULL OR ${table.invoicePdfSha256} ~ '^[0-9a-f]{64}$'`,
|
||||
),
|
||||
check(
|
||||
"billing_reports_invoice_email_status_check",
|
||||
sql`${table.invoiceEmailStatus} in ('not_sent', 'sent', 'failed')`,
|
||||
),
|
||||
check(
|
||||
"billing_reports_final_pdf_check",
|
||||
sql`${table.status} <> 'final' OR (${table.pdf} IS NOT NULL AND ${table.pdfSha256} IS NOT NULL)`,
|
||||
@@ -81,6 +99,7 @@ export const billingReportItems = pgTable(
|
||||
purposeSnapshot: text("purpose_snapshot").notNull(),
|
||||
internalReferenceSnapshot: text("internal_reference_snapshot"),
|
||||
priceCents: integer("price_cents").notNull(),
|
||||
collab: boolean("collab").notNull().default(false),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
|
||||
Reference in new issue
Block a user