import { numeric, pgTable, serial, uuid } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { forklifts } from "./forklifts.js";
import { leaseInvoices } from "./leaseInvoices.js";

export const leaseInvoiceForklifts = pgTable("lease_invoice_forklifts", {
	id: uuid("id").defaultRandom().primaryKey(),
	invoiceId: uuid("invoice_id")
		.notNull()
		.references(() => leaseInvoices.id, { onDelete: "cascade" }),
	forkliftId: uuid("forklift_id")
		.notNull()
		.references(() => forklifts.forklift_id, { onDelete: "cascade" }),
	amount: numeric("amount"), // optional: amount of invoice allocated to this lift
});

export const newForkliftInvoiceSchema = createInsertSchema(
	leaseInvoiceForklifts,
);
