import {
	date,
	numeric,
	pgTable,
	text,
	timestamp,
	uuid,
} from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { leases } from "./forkliftLeases.js";

export const leaseInvoices = pgTable("lease_invoices", {
	id: uuid("id").defaultRandom().primaryKey(),
	leaseId: uuid("lease_id")
		.notNull()
		.references(() => leases.id, { onDelete: "cascade" }),
	invoiceNumber: text("invoice_number").unique().notNull(),
	invoiceDate: date("invoice_date").notNull(),
	totalAmount: numeric("total_amount"),
	add_date: timestamp("add_date"),
	uploadedBy: text("uploaded_by"),
});

export const newInvoiceSchema = createInsertSchema(leaseInvoices);
