feat(forklifts): added backend forklift stuff and frontend companies
This commit is contained in:
0
app/src/pkg/db/schema/forkliftComments.ts
Normal file
0
app/src/pkg/db/schema/forkliftComments.ts
Normal file
0
app/src/pkg/db/schema/forkliftHours.ts
Normal file
0
app/src/pkg/db/schema/forkliftHours.ts
Normal file
26
app/src/pkg/db/schema/forkliftLeaseCompanys.ts
Normal file
26
app/src/pkg/db/schema/forkliftLeaseCompanys.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { boolean, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import z from "zod";
|
||||
|
||||
export const forkliftCompanies = pgTable("forklift_companies", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
name: text("name").notNull().unique(),
|
||||
active: boolean("active").default(true),
|
||||
add_date: timestamp("add_date").defaultNow(),
|
||||
add_user: text("add_user").default("LST"),
|
||||
upd_date: timestamp("upd_date").defaultNow(),
|
||||
upd_user: text("upd_user").default("LST"),
|
||||
});
|
||||
|
||||
export const selectForkliftCompanySchema =
|
||||
createSelectSchema(forkliftCompanies);
|
||||
|
||||
export const insertForkliftCompanySchema = createInsertSchema(
|
||||
forkliftCompanies,
|
||||
).extend({
|
||||
name: z.string().min(3),
|
||||
// zipcode: z
|
||||
// .string()
|
||||
// .regex(/^\d{5}$/)
|
||||
// .optional(),
|
||||
});
|
||||
13
app/src/pkg/db/schema/forkliftLeases.ts
Normal file
13
app/src/pkg/db/schema/forkliftLeases.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { date, pgTable, text, uuid } from "drizzle-orm/pg-core";
|
||||
import { createSelectSchema } from "drizzle-zod";
|
||||
import { forkliftCompanies } from "./forkliftLeaseCompanys.js";
|
||||
|
||||
export const leases = pgTable("leases", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
leaseNumber: text("lease_number").notNull(),
|
||||
companyId: uuid("company_id").references(() => forkliftCompanies.id),
|
||||
startDate: date("start_date"),
|
||||
endDate: date("end_date"),
|
||||
leaseLink: text("lease_link"),
|
||||
});
|
||||
export const selectLeasesDataSchema = createSelectSchema(leases);
|
||||
14
app/src/pkg/db/schema/forkliftLeasesInvoice.ts
Normal file
14
app/src/pkg/db/schema/forkliftLeasesInvoice.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { numeric, pgTable, serial, uuid } from "drizzle-orm/pg-core";
|
||||
import { forklifts } from "./forklifts.js";
|
||||
import { leaseInvoices } from "./leaseInvoices.js";
|
||||
|
||||
export const leaseInvoiceForklifts = pgTable("lease_invoice_forklifts", {
|
||||
id: serial("id").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
|
||||
});
|
||||
0
app/src/pkg/db/schema/forkliftRepairs.ts
Normal file
0
app/src/pkg/db/schema/forkliftRepairs.ts
Normal file
52
app/src/pkg/db/schema/forklifts.ts
Normal file
52
app/src/pkg/db/schema/forklifts.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
integer,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
serial,
|
||||
text,
|
||||
timestamp,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
import { leases } from "./forkliftLeases.js";
|
||||
import { serverData } from "./servers.js";
|
||||
|
||||
const status = pgEnum("forklift_status", [
|
||||
"active",
|
||||
"inactive",
|
||||
"sold",
|
||||
"retired",
|
||||
"transferred",
|
||||
]);
|
||||
|
||||
export const forklifts = pgTable("forklifts", {
|
||||
forklift_id: uuid("forklift_id").defaultRandom().primaryKey(),
|
||||
forkliftNumber: serial("forklift_number").notNull(),
|
||||
serialNumber: text("serial_number").notNull(),
|
||||
model: text("model").notNull(),
|
||||
plant: text("plant")
|
||||
.notNull()
|
||||
.references(() => serverData.name, { onDelete: "set null" }), // what plant the forklift is in.
|
||||
forkliftStatus: text("forklift_status").default("active"), //["active","inactive","sold","retired","transferred",]
|
||||
glCode: integer("gl_code").notNull(), // this will be updated on the onconflift update so we dont do anything funny.
|
||||
profitCenter: integer("profit_center").notNull(), // should be updated if its changing profit centers per request by the plant
|
||||
manufacturer: text("manufacturer").notNull(),
|
||||
manufacturerYear: text("manufacturer_year").notNull(),
|
||||
engine: text("engine").notNull(),
|
||||
batteryType: text("battery_type").notNull(),
|
||||
leaseId: uuid("lease_id").references(() => leases.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
dataPlate: text("data_plate"),
|
||||
add_date: timestamp("add_date").defaultNow(),
|
||||
add_user: text("add_user").default("LST"),
|
||||
upd_date: timestamp("add_date").defaultNow(),
|
||||
upd_user: text("add_user").default("LST"),
|
||||
});
|
||||
|
||||
export const forkliftsSchema = createSelectSchema(forklifts);
|
||||
export const newForkliftsSchema = createInsertSchema(forklifts);
|
||||
|
||||
export type Forklift = z.infer<typeof forkliftsSchema>;
|
||||
export type NewNewForklift = z.infer<typeof newForkliftsSchema>;
|
||||
19
app/src/pkg/db/schema/leaseInvoices.ts
Normal file
19
app/src/pkg/db/schema/leaseInvoices.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { date, numeric, pgTable, text, uuid } from "drizzle-orm/pg-core";
|
||||
import { forkliftCompanies } from "./forkliftLeaseCompanys.js";
|
||||
import { leases } from "./forkliftLeases.js";
|
||||
import { forklifts } from "./forklifts.js";
|
||||
|
||||
export const leaseInvoices = pgTable("lease_invoices", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
leaseId: uuid("lease_id")
|
||||
.notNull()
|
||||
.references(() => leases.id, { onDelete: "cascade" }),
|
||||
companyId: uuid("company_id").references(() => forkliftCompanies.id),
|
||||
invoiceNumber: text("invoice_number").notNull(),
|
||||
invoiceDate: date("invoice_date").notNull(),
|
||||
forkliftId: uuid("forklift_id")
|
||||
.notNull()
|
||||
.references(() => forklifts.forklift_id, { onDelete: "cascade" }),
|
||||
totalAmount: numeric("total_amount"),
|
||||
uploadedBy: text("uploaded_by"),
|
||||
});
|
||||
Reference in New Issue
Block a user