Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: crud for gauge calibration records

Brad Barbinaa28a4d26f4b
diff --git a/apps/erp/app/modules/quality/quality.models.ts b/apps/erp/app/modules/quality/quality.models.ts
index 763832abaa..7f6bd24421 100644
--- a/apps/erp/app/modules/quality/quality.models.ts
+++ b/apps/erp/app/modules/quality/quality.models.ts
@@ -85,6 +85,16 @@ export const gaugeValidator = z.object({
),
});
+export const gaugeCalibrationRecordValidator = z.object({
+ id: zfd.text(z.string().optional()),
+ gaugeId: z.string().min(1, { message: "Gauge is required" }),
+ dateCalibrated: z.string().min(1, { message: "Date is required" }),
+ requiresAction: zfd.checkbox(),
+ requiresAdjustment: zfd.checkbox(),
+ requiresRepair: zfd.checkbox(),
+ notes: zfd.text(z.string().optional()),
+});
+
export const gaugeTypeValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }),
diff --git a/apps/erp/app/modules/quality/quality.service.ts b/apps/erp/app/modules/quality/quality.service.ts
index 53f77ea7d6..0eb1e1b581 100644
--- a/apps/erp/app/modules/quality/quality.service.ts
+++ b/apps/erp/app/modules/quality/quality.service.ts
@@ -1,10 +1,14 @@
import type { Database, Json } from "@carbon/database";
+import { parseDate } from "@internationalized/date";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
+import type { inspectionStatus } from "../shared";
import type {
+ gaugeCalibrationRecordValidator,
+ gaugeCalibrationStatus,
gaugeTypeValidator,
gaugeValidator,
nonConformanceReviewerValidator,
@@ -21,6 +25,16 @@ export async function deleteGauge(
return client.from("gauges").delete().eq("id", gaugeId);
}
+export async function deleteGaugeCalibrationRecord(
+ client: SupabaseClient<Database>,
+ gaugeCalibrationRecordId: string
+) {
+ return client
+ .from("gaugeCalibrationRecord")
+ .delete()
+ .eq("id", gaugeCalibrationRecordId);
+}
+
export async function deleteGaugeType(
client: SupabaseClient<Database>,
gaugeTypeId: string
@@ -138,6 +152,53 @@ export async function getGauges(
return query;
}
+export async function getGaugesList(
+ client: SupabaseClient<Database>,
+ companyId: string
+) {
+ return client
+ .from("gauge")
+ .select("id, name:gaugeId, description")
+ .eq("companyId", companyId);
+}
+
+export async function getGaugeCalibrationRecord(
+ client: SupabaseClient<Database>,
+ id: string
+) {
+ return client
+ .from("gaugeCalibrationRecords")
+ .select("*")
+ .eq("id", id)
+ .single();
+}
+
+export async function getGaugeCalibrationRecords(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ args?: GenericQueryFilters & { search: string | null }
+) {
+ let query = client
+ .from("gaugeCalibrationRecords")
+ .select("*", { count: "exact" })
+ .eq("companyId", companyId);
+
+ if (args?.search) {
+ query = query.or(
+ `gaugeId.ilike.%${args.search}%,description.ilike.%${args.search}%,modelNumber.ilike.%${args.search}%,serialNumber.ilike.%${args.search}%`
+ );
+ }
+
+ if (args) {
+ query = setGenericQueryFilters(query, args, [
+ { column: "createdAt", ascending: false },
+ { column: "dateCalibrated", ascending: false },
+ ]);
+ }
+
+ return query;
+}
+
export async function getGaugeTypesList(
client: SupabaseClient<Database>,
companyId: string
@@ -640,12 +701,14 @@ export async function upsertGauge(
| (Omit<z.infer<typeof gaugeValidator>, "id" | "gaugeId"> & {
gaugeId: string;
companyId: string;
+ gaugeCalibrationStatus: (typeof gaugeCalibrationStatus)[number];
createdBy: string;
customFields?: Json;
})
| (Omit<z.infer<typeof gaugeValidator>, "id" | "gaugeId"> & {
id: string;
gaugeId: string;
+ gaugeCalibrationStatus: (typeof gaugeCalibrationStatus)[number];
updatedBy: string;
customFields?: Json;
})
@@ -657,6 +720,69 @@ export async function upsertGauge(
}
}
+export async function upsertGaugeCalibrationRecord(
+ client: SupabaseClient<Database>,
+ gaugeCalibrationRecord:
+ | (Omit<z.infer<typeof gaugeCalibrationRecordValidator>, "id"> & {
+ companyId: string;
+ inspectionStatus: (typeof inspectionStatus)[number];
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof gaugeCalibrationRecordValidator>, "id"> & {
+ id: string;
+ inspectionStatus: (typeof inspectionStatus)[number];
+ updatedBy: string;
+ customFields?: Json;
+ })
+) {
+ const gauge = await client
+ .from("gauge")
+ .select("*")
+ .eq("id", gaugeCalibrationRecord.gaugeId)
+ .single();
+
+ if (gauge.error) return gauge;
+
+ if (
+ !gauge.data?.lastCalibrationDate ||
+ parseDate(gauge.data.lastCalibrationDate) <
+ parseDate(gaugeCalibrationRecord.dateCalibrated)
+ ) {
+ const nextCalibrationDate = parseDate(gaugeCalibrationRecord.dateCalibrated)
+ .add({
+ months: gauge.data.calibrationIntervalInMonths,
+ })
+ .toString();
+
+ const update = await client
+ .from("gauge")
+ .update({
+ gaugeCalibrationStatus:
+ gaugeCalibrationRecord.inspectionStatus === "Pass"
+ ? "In-Calibration"
+ : "Out-of-Calibration",
+ lastCalibrationDate: gaugeCalibrationRecord.dateCalibrated,
+ nextCalibrationDate: nextCalibrationDate,
+ })
+ .eq("id", gaugeCalibrationRecord.gaugeId);
+
+ if (update.error) return update;
+ }
+
+ if ("createdBy" in gaugeCalibrationRecord) {
+ return client
+ .from("gaugeCalibrationRecord")
+ .insert([gaugeCalibrationRecord])
+ .select("id")
+ .single();
+ }
+ return client
+ .from("gaugeCalibrationRecord")
+ .update(sanitize(gaugeCalibrationRecord))
+ .eq("id", gaugeCalibrationRecord.id);
+}
+
export async function upsertGaugeType(
client: SupabaseClient<Database>,
gaugeType:
diff --git a/apps/erp/app/modules/quality/types.ts b/apps/erp/app/modules/quality/types.ts
index 3511fd67be..4d1725ef91 100644
--- a/apps/erp/app/modules/quality/types.ts
+++ b/apps/erp/app/modules/quality/types.ts
@@ -1,6 +1,7 @@
import type { Database } from "@carbon/database";
import type { nonConformanceAssociationType } from "./quality.models";
import type {
+ getGaugeCalibrationRecords,
getGauges,
getGaugeTypes,
getNonConformance,
@@ -16,6 +17,10 @@ export type Gauge = NonNullable<
Awaited<ReturnType<typeof getGauges>>["data"]
>[number];
+export type GaugeCalibrationRecord = NonNullable<
+ Awaited<ReturnType<typeof getGaugeCalibrationRecords>>["data"]
+>[number];
+
export type GaugeType = NonNullable<
Awaited<ReturnType<typeof getGaugeTypes>>["data"]
>[number];
diff --git a/apps/erp/app/modules/quality/ui/Gauge/GaugesTable.tsx b/apps/erp/app/modules/quality/ui/Gauge/GaugesTable.tsx
index 363cf300b1..114bbfdca8 100644
--- a/apps/erp/app/modules/quality/ui/Gauge/GaugesTable.tsx
+++ b/apps/erp/app/modules/quality/ui/Gauge/GaugesTable.tsx
@@ -7,13 +7,23 @@ import {
LuCalendar,
LuCircleGauge,
LuContainer,
+ LuFileText,
LuHash,
LuMap,
LuPencil,
LuShapes,
+ LuShield,
LuTrash,
+ LuUser,
+ LuUsers,
} from "react-icons/lu";
-import { Hyperlink, New, SupplierAvatar, Table } from "~/components";
+import {
+ EmployeeAvatar,
+ Hyperlink,
+ New,
+ SupplierAvatar,
+ Table,
+} from "~/components";
import { flushSync } from "react-dom";
import { ConfirmDelete } from "~/components/Modals";
@@ -26,9 +36,14 @@ import { formatDate } from "@carbon/utils";
import { Enumerable } from "~/components/Enumerable";
import { useLocations } from "~/components/Form/Location";
import { useCustomColumns } from "~/hooks/useCustomColumns";
+import { usePeople } from "~/stores/people";
import { useSuppliers } from "~/stores/suppliers";
-import { gaugeRole, gaugeStatus } from "../../quality.models";
-import { GaugeRole, GaugeStatus } from "./GaugeStatus";
+import {
+ gaugeCalibrationStatus,
+ gaugeRole,
+ gaugeStatus,
+} from "../../quality.models";
+import { GaugeCalibrationStatus, GaugeRole, GaugeStatus } from "./GaugeStatus";
type GaugesTableProps = {
data: Gauge[];
@@ -36,12 +51,22 @@ type GaugesTableProps = {
count: number;
};
+const defaultColumnVisibility = {
+ type: false,
+ extension: false,
+ createdAt: false,
+ updatedAt: false,
+ updatedBy: false,
+ description: false,
+};
+
const GaugesTable = memo(({ data, types, count }: GaugesTableProps) => {
const [params] = useUrlParams();
const navigate = useNavigate();
const permissions = usePermissions();
const deleteDisclosure = useDisclosure();
const [selectedGauge, setSelectedGauge] = useState<Gauge | null>(null);
+ const [people] = usePeople();
const customColumns = useCustomColumns<Gauge>("gauge");
const [suppliers] = useSuppliers();
@@ -123,12 +148,31 @@ const GaugesTable = memo(({ data, types, count }: GaugesTableProps) => {
},
},
},
+ {
+ accessorKey: "gaugeCalibrationStatus",
+ header: "Calibration Status",
+ cell: ({ row }) => (
+ <GaugeCalibrationStatus
+ status={row.original.gaugeCalibrationStatus}
+ />
+ ),
+ meta: {
+ icon: <LuCircleGauge />,
+ filter: {
+ type: "static",
+ options: gaugeCalibrationStatus.map((status) => ({
+ label: <GaugeCalibrationStatus status={status} />,
+ value: status,
+ })),
+ },
+ },
+ },
{
accessorKey: "gaugeRole",
header: "Role",
cell: ({ row }) => <GaugeRole role={row.original.gaugeRole} />,
meta: {
- icon: <LuHash />,
+ icon: <LuShield />,
filter: {
type: "static",
options: gaugeRole.map((role) => ({
@@ -193,9 +237,59 @@ const GaugesTable = memo(({ data, types, count }: GaugesTableProps) => {
},
},
},
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ icon: <LuUser />,
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuFileText />,
+ },
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ icon: <LuUsers />,
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Updated At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ meta: {
+ icon: <LuFileText />,
+ },
+ },
];
return [...defaultColumns, ...customColumns];
- }, [customColumns, locations, suppliers, types]);
+ }, [customColumns, locations, people, suppliers, types]);
const renderContextMenu = useCallback(
(row: Gauge) => {
@@ -235,6 +329,7 @@ const GaugesTable = memo(({ data, types, count }: GaugesTableProps) => {
data={data}
columns={columns}
count={count}
+ defaultColumnVisibility={defaultColumnVisibility}
primaryAction={
permissions.can("create", "quality") && (
<New
diff --git a/apps/erp/app/modules/shared/shared.models.ts b/apps/erp/app/modules/shared/shared.models.ts
index 767b4df166..d74617e498 100644
--- a/apps/erp/app/modules/shared/shared.models.ts
+++ b/apps/erp/app/modules/shared/shared.models.ts
@@ -23,6 +23,8 @@ export const documentTypes = [
"Other",
] as const;
+export const inspectionStatus = ["Pass", "Fail"] as const;
+
export const tablesWithTags = [
"consumable",
"fixture",
diff --git a/apps/erp/app/routes/x+/quality+/gauges.$id.tsx b/apps/erp/app/routes/x+/quality+/gauges.$id.tsx
index 4243a614c4..c5080d7ce0 100644
--- a/apps/erp/app/routes/x+/quality+/gauges.$id.tsx
+++ b/apps/erp/app/routes/x+/quality+/gauges.$id.tsx
@@ -7,6 +7,7 @@ import {
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { defer, redirect } from "@vercel/remix";
@@ -21,7 +22,7 @@ import {
import GaugeForm from "~/modules/quality/ui/Gauge/GaugeForm";
import { getCustomFields, setCustomFields } from "~/utils/form";
import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
+import { getParams, path } from "~/utils/path";
export const handle: Handle = {
breadcrumb: "Gauges",
to: path.to.gauges,
@@ -65,7 +66,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
update: "quality",
});
- const { orderId: id } = params;
+ const { id } = params;
if (!id) throw new Error("Could not find id");
const formData = await request.formData();
@@ -78,9 +79,18 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { gaugeId, ...data } = validation.data;
if (!gaugeId) throw new Error("Could not find gaugeId");
+ const gaugeCalibrationStatus = data.nextCalibrationDate
+ ? parseDate(data.nextCalibrationDate) < today(getLocalTimeZone())
+ ? "Out-of-Calibration"
+ : data.lastCalibrationDate
+ ? "In-Calibration"
+ : "Pending"
+ : "Pending";
+
const update = await upsertGauge(client, {
id,
gaugeId,
+ gaugeCalibrationStatus,
...data,
customFields: setCustomFields(formData),
updatedBy: userId,
@@ -93,7 +103,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
throw redirect(
- path.to.gauge(id),
+ `${path.to.gauges}?${getParams(request)}`,
await flash(request, success("Updated gauge"))
);
}
diff --git a/apps/erp/app/routes/x+/quality+/gauges.new.tsx b/apps/erp/app/routes/x+/quality+/gauges.new.tsx
index cf1080aab7..63bdc7ed5a 100644
--- a/apps/erp/app/routes/x+/quality+/gauges.new.tsx
+++ b/apps/erp/app/routes/x+/quality+/gauges.new.tsx
@@ -7,7 +7,7 @@ import {
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { getLocalTimeZone, today } from "@internationalized/date";
+import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
import { useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
@@ -18,13 +18,7 @@ import GaugeForm from "~/modules/quality/ui/Gauge/GaugeForm";
import { getNextSequence } from "~/modules/settings";
import { setCustomFields } from "~/utils/form";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const handle: Handle = {
- breadcrumb: "Gauges",
- to: path.to.gauges,
-};
+import { getParams, path } from "~/utils/path";
export async function loader({ request }: LoaderFunctionArgs) {
await requirePermissions(request, {
@@ -70,9 +64,18 @@ export async function action({ request }: ActionFunctionArgs) {
if (!gaugeId) throw new Error("gaugeId is not defined");
const { id: _id, ...data } = validation.data;
+ const gaugeCalibrationStatus = data.nextCalibrationDate
+ ? parseDate(data.nextCalibrationDate) < today(getLocalTimeZone())
+ ? "Out-of-Calibration"
+ : data.lastCalibrationDate
+ ? "In-Calibration"
+ : "Pending"
+ : "Pending";
+
const createGauge = await upsertGauge(client, {
...data,
gaugeId,
+ gaugeCalibrationStatus,
companyId,
createdBy: userId,
customFields: setCustomFields(formData),
@@ -94,7 +97,7 @@ export async function action({ request }: ActionFunctionArgs) {
}
throw redirect(
- path.to.gauges,
+ `${path.to.gauges}?${getParams(request)}`,
await flash(request, success(`Gauge ${readableId} created`))
);
}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 56b6bb6141..3532cdc7b1 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -35,6 +35,7 @@ export const path = {
docs: `${api}/docs`,
employeeTypes: `${api}/users/employee-types`,
emptyPermissions: `${api}/users/empty-permissions`,
+ gauges: `${api}/quality/gauges`,
generateCsvColumns: (table: string) =>
generatePath(`${api}/ai/csv/${table}/columns`),
groupsByType: (type?: string) =>
@@ -422,6 +423,8 @@ export const path = {
generatePath(`${x}/users/employee-types/delete/${id}`),
deleteGauge: (id: string) =>
generatePath(`${x}/quality/gauges/delete/${id}`),
+ deleteGaugeCalibrationRecord: (id: string) =>
+ generatePath(`${x}/quality/calibrations/delete/${id}`),
deleteGaugeType: (id: string) =>
generatePath(`${x}/quality/gauge-types/delete/${id}`),
deleteGroup: (id: string) => generatePath(`${x}/users/groups/delete/${id}`),
@@ -569,8 +572,10 @@ export const path = {
fiscalYears: `${x}/accounting/years`,
forgotPassword: "/forgot-password",
gauge: (id: string) => generatePath(`${x}/quality/gauges/${id}`),
-
gauges: `${x}/quality/gauges`,
+ gaugeCalibrationRecord: (id: string) =>
+ generatePath(`${x}/quality/calibrations/${id}`),
+ gaugeCalibrationRecords: `${x}/quality/calibrations`,
gaugeTypes: `${x}/quality/gauge-types`,
gaugeType: (id: string) => generatePath(`${x}/quality/gauge-types/${id}`),
group: (id: string) => generatePath(`${x}/users/groups/${id}`),
@@ -730,6 +735,7 @@ export const path = {
newFixtureSupplier: (id: string) =>
generatePath(`${x}/fixture/${id}/purchasing/new`),
newGauge: `${x}/quality/gauges/new`,
+ newGaugeCalibrationRecord: `${x}/quality/calibrations/new`,
newGaugeType: `${x}/quality/gauge-types/new`,
newGroup: `${x}/users/groups/new`,
newHoliday: `${x}/people/holidays/new`,
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 4f930b94cb..452473d72a 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -7854,6 +7854,96 @@ export default {
tags: ["currencyCode"],
},
},
+ "/gaugeCalibrationRecords": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.dateCalibrated",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.inspectionStatus",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.requiresAction",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.requiresAdjustment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.requiresRepair",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.updatedBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.gaugeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.gaugeTypeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.description",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/gaugeCalibrationRecords",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["gaugeCalibrationRecords"],
+ },
+ },
"/methodMaterial": {
get: {
parameters: [
@@ -41307,6 +41397,222 @@ export default {
tags: ["nonConformance"],
},
},
+ "/gaugeCalibrationRecord": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.gaugeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.dateCalibrated",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.inspectionStatus",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAction",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAdjustment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresRepair",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/gaugeCalibrationRecord",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["gaugeCalibrationRecord"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.gaugeCalibrationRecord",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["gaugeCalibrationRecord"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.gaugeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.dateCalibrated",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.inspectionStatus",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAction",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAdjustment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresRepair",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["gaugeCalibrationRecord"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.gaugeId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.dateCalibrated",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.inspectionStatus",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAction",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresAdjustment",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.requiresRepair",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.customFields",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.gaugeCalibrationRecord",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["gaugeCalibrationRecord"],
+ },
+ },
"/purchaseInvoicePaymentRelation": {
get: {
parameters: [
@@ -56240,7 +56546,7 @@ export default {
properties: {
id: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -56289,7 +56595,7 @@ export default {
},
supplierLocationId: {
description:
- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -56586,6 +56892,83 @@ export default {
},
type: "object",
},
+ gaugeCalibrationRecords: {
+ properties: {
+ id: {
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ dateCalibrated: {
+ format: "date",
+ type: "string",
+ },
+ inspectionStatus: {
+ enum: ["Pass", "Fail"],
+ format: 'public."inspectionStatus"',
+ type: "string",
+ },
+ requiresAction: {
+ format: "boolean",
+ type: "boolean",
+ },
+ requiresAdjustment: {
+ format: "boolean",
+ type: "boolean",
+ },
+ requiresRepair: {
+ format: "boolean",
+ type: "boolean",
+ },
+ notes: {
+ format: "json",
+ },
+ customFields: {
+ format: "json",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ gaugeId: {
+ format: "text",
+ type: "string",
+ },
+ gaugeTypeId: {
+ description:
+ "Note:\nThis is a Foreign Key to `gaugeType.id`.<fk table='gaugeType' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ description: {
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
methodMaterial: {
required: [
"id",
@@ -72056,6 +72439,93 @@ export default {
},
type: "object",
},
+ gaugeCalibrationRecord: {
+ required: [
+ "id",
+ "gaugeId",
+ "dateCalibrated",
+ "inspectionStatus",
+ "requiresAction",
+ "requiresAdjustment",
+ "requiresRepair",
+ "notes",
+ "customFields",
+ "createdAt",
+ "createdBy",
+ ],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ gaugeId: {
+ description:
+ "Note:\nThis is a Foreign Key to `gauge.id`.<fk table='gauge' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ dateCalibrated: {
+ format: "date",
+ type: "string",
+ },
+ inspectionStatus: {
+ enum: ["Pass", "Fail"],
+ format: 'public."inspectionStatus"',
+ type: "string",
+ },
+ requiresAction: {
+ default: false,
+ format: "boolean",
+ type: "boolean",
+ },
+ requiresAdjustment: {
+ default: false,
+ format: "boolean",
+ type: "boolean",
+ },
+ requiresRepair: {
+ default: false,
+ format: "boolean",
+ type: "boolean",
+ },
+ notes: {
+ format: "json",
+ },
+ customFields: {
+ format: "json",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
purchaseInvoicePaymentRelation: {
required: ["id", "invoiceId", "paymentId"],
properties: {
@@ -79642,6 +80112,111 @@ export default {
in: "query",
type: "string",
},
+ "body.gaugeCalibrationRecords": {
+ name: "gaugeCalibrationRecords",
+ description: "gaugeCalibrationRecords",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/gaugeCalibrationRecords",
+ },
+ },
+ "rowFilter.gaugeCalibrationRecords.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.dateCalibrated": {
+ name: "dateCalibrated",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.inspectionStatus": {
+ name: "inspectionStatus",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.requiresAction": {
+ name: "requiresAction",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.requiresAdjustment": {
+ name: "requiresAdjustment",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.requiresRepair": {
+ name: "requiresRepair",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.gaugeId": {
+ name: "gaugeId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.gaugeTypeId": {
+ name: "gaugeTypeId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.description": {
+ name: "description",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.methodMaterial": {
name: "methodMaterial",
description: "methodMaterial",
@@ -97030,6 +97605,99 @@ export default {
in: "query",
type: "string",
},
+ "body.gaugeCalibrationRecord": {
+ name: "gaugeCalibrationRecord",
+ description: "gaugeCalibrationRecord",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/gaugeCalibrationRecord",
+ },
+ },
+ "rowFilter.gaugeCalibrationRecord.id": {
+ name: "id",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.gaugeId": {
+ name: "gaugeId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.dateCalibrated": {
+ name: "dateCalibrated",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.inspectionStatus": {
+ name: "inspectionStatus",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.requiresAction": {
+ name: "requiresAction",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.requiresAdjustment": {
+ name: "requiresAdjustment",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.requiresRepair": {
+ name: "requiresRepair",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.customFields": {
+ name: "customFields",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.purchaseInvoicePaymentRelation": {
name: "purchaseInvoicePaymentRelation",
description: "purchaseInvoicePaymentRelation",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 9f04e1f07d..fb530c9c94 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6403,6 +6403,170 @@ export type Database = {
},
]
}
+ gaugeCalibrationRecord: {
+ Row: {
+ companyId: string | null
+ createdAt: string
+ createdBy: string
+ customFields: Json
+ dateCalibrated: string
+ gaugeId: string
+ id: string
+ inspectionStatus: Database["public"]["Enums"]["inspectionStatus"]
+ notes: Json
+ requiresAction: boolean
+ requiresAdjustment: boolean
+ requiresRepair: boolean
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy: string
+ customFields?: Json
+ dateCalibrated: string
+ gaugeId: string
+ id?: string
+ inspectionStatus: Database["public"]["Enums"]["inspectionStatus"]
+ notes?: Json
+ requiresAction?: boolean
+ requiresAdjustment?: boolean
+ requiresRepair?: boolean
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json
+ dateCalibrated?: string
+ gaugeId?: string
+ id?: string
+ inspectionStatus?: Database["public"]["Enums"]["inspectionStatus"]
+ notes?: Json
+ requiresAction?: boolean
+ requiresAdjustment?: boolean
+ requiresRepair?: boolean
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_gaugeId_fkey"
+ columns: ["gaugeId"]
+ isOneToOne: false
+ referencedRelation: "gauge"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_gaugeId_fkey"
+ columns: ["gaugeId"]
+ isOneToOne: false
+ referencedRelation: "gauges"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
gaugeType: {
Row: {
companyId: string | null
@@ -32763,6 +32927,135 @@ export type Database = {
},
]
}
+ gaugeCalibrationRecords: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ dateCalibrated: string | null
+ description: string | null
+ gaugeId: string | null
+ gaugeTypeId: string | null
+ id: string | null
+ inspectionStatus:
+ | Database["public"]["Enums"]["inspectionStatus"]
+ | null
+ notes: Json | null
+ requiresAction: boolean | null
+ requiresAdjustment: boolean | null
+ requiresRepair: boolean | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gauge_gaugeTypeId_fkey"
+ columns: ["gaugeTypeId"]
+ isOneToOne: false
+ referencedRelation: "gaugeType"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
gauges: {
Row: {
calibrationIntervalInMonths: number | null
@@ -35928,14 +36221,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -38023,14 +38316,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -41152,6 +41445,7 @@ export type Database = {
glAccountType: "Posting" | "Total" | "Begin Total" | "End Total"
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
+ inspectionStatus: "Pass" | "Fail"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
itemLedgerDocumentType:
| "Sales Shipment"
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 9f04e1f07d..fb530c9c94 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6403,6 +6403,170 @@ export type Database = {
},
]
}
+ gaugeCalibrationRecord: {
+ Row: {
+ companyId: string | null
+ createdAt: string
+ createdBy: string
+ customFields: Json
+ dateCalibrated: string
+ gaugeId: string
+ id: string
+ inspectionStatus: Database["public"]["Enums"]["inspectionStatus"]
+ notes: Json
+ requiresAction: boolean
+ requiresAdjustment: boolean
+ requiresRepair: boolean
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy: string
+ customFields?: Json
+ dateCalibrated: string
+ gaugeId: string
+ id?: string
+ inspectionStatus: Database["public"]["Enums"]["inspectionStatus"]
+ notes?: Json
+ requiresAction?: boolean
+ requiresAdjustment?: boolean
+ requiresRepair?: boolean
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string | null
+ createdAt?: string
+ createdBy?: string
+ customFields?: Json
+ dateCalibrated?: string
+ gaugeId?: string
+ id?: string
+ inspectionStatus?: Database["public"]["Enums"]["inspectionStatus"]
+ notes?: Json
+ requiresAction?: boolean
+ requiresAdjustment?: boolean
+ requiresRepair?: boolean
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_gaugeId_fkey"
+ columns: ["gaugeId"]
+ isOneToOne: false
+ referencedRelation: "gauge"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_gaugeId_fkey"
+ columns: ["gaugeId"]
+ isOneToOne: false
+ referencedRelation: "gauges"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
gaugeType: {
Row: {
companyId: string | null
@@ -32763,6 +32927,135 @@ export type Database = {
},
]
}
+ gaugeCalibrationRecords: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ customFields: Json | null
+ dateCalibrated: string | null
+ description: string | null
+ gaugeId: string | null
+ gaugeTypeId: string | null
+ id: string | null
+ inspectionStatus:
+ | Database["public"]["Enums"]["inspectionStatus"]
+ | null
+ notes: Json | null
+ requiresAction: boolean | null
+ requiresAdjustment: boolean | null
+ requiresRepair: boolean | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "gauge_gaugeTypeId_fkey"
+ columns: ["gaugeTypeId"]
+ isOneToOne: false
+ referencedRelation: "gaugeType"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "gaugeCalibrationRecord_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
gauges: {
Row: {
calibrationIntervalInMonths: number | null
@@ -35928,14 +36221,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -38023,14 +38316,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -41152,6 +41445,7 @@ export type Database = {
glAccountType: "Posting" | "Total" | "Begin Total" | "End Total"
glConsolidatedRate: "Average" | "Current" | "Historical"
glIncomeBalance: "Balance Sheet" | "Income Statement"
+ inspectionStatus: "Pass" | "Fail"
itemCostingMethod: "Standard" | "Average" | "LIFO" | "FIFO"
itemLedgerDocumentType:
| "Sales Shipment"
diff --git a/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql b/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql
index 7aa4b7b803..9243925ed8 100644
--- a/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql
+++ b/packages/database/supabase/migrations/20250502132738_gauge-calibration.sql
@@ -4,6 +4,9 @@ VALUES ('nonConformanceType', 'Non-Conformance Type', 'Quality');
INSERT INTO "customFieldTable" ("table", "name", "module")
VALUES ('gaugeType', 'Gauge Type', 'Quality');
+INSERT INTO "customFieldTable" ("table", "name", "module")
+VALUES ('gaugeCalibrationRecord', 'Gauge Calibration Record', 'Quality');
+
ALTER TABLE "nonConformanceType"
ADD COLUMN "customFields" JSON NOT NULL DEFAULT '{}';
@@ -117,7 +120,6 @@ CREATE TYPE "gaugeCalibrationStatus" AS ENUM (
'Out-of-Calibration'
);
-
CREATE TABLE "gauge" (
"id" TEXT NOT NULL DEFAULT xid(),
"gaugeId" TEXT NOT NULL,
@@ -179,4 +181,58 @@ SELECT
6,
1,
"id"
-FROM "company";
\ No newline at end of file
+FROM "company";
+
+
+CREATE TYPE "inspectionStatus" AS ENUM (
+ 'Pass',
+ 'Fail'
+);
+
+CREATE TABLE "gaugeCalibrationRecord" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "gaugeId" TEXT NOT NULL,
+ "dateCalibrated" DATE NOT NULL,
+ "inspectionStatus" "inspectionStatus" NOT NULL,
+ "requiresAction" BOOLEAN NOT NULL DEFAULT FALSE,
+ "requiresAdjustment" BOOLEAN NOT NULL DEFAULT FALSE,
+ "requiresRepair" BOOLEAN NOT NULL DEFAULT FALSE,
+ "notes" JSON NOT NULL DEFAULT '{}',
+ "customFields" JSON NOT NULL DEFAULT '{}',
+ "companyId" TEXT,
+ "createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "gaugeCalibrationRecord_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "gaugeCalibrationRecord_gaugeId_fkey" FOREIGN KEY ("gaugeId") REFERENCES "gauge"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "gaugeCalibrationRecord_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "gaugeCalibrationRecord_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE,
+ CONSTRAINT "gaugeCalibrationRecord_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE
+);
+
+CREATE INDEX "gaugeCalibrationRecord_companyId_idx" ON "gaugeCalibrationRecord" ("companyId");
+CREATE INDEX "gaugeCalibrationRecord_gaugeId_idx" ON "gaugeCalibrationRecord" ("gaugeId");
+
+CREATE OR REPLACE VIEW "gaugeCalibrationRecords" WITH(SECURITY_INVOKER=true) AS
+SELECT
+ gcr.id,
+ gcr."gaugeId",
+ gcr."dateCalibrated",
+ gcr."inspectionStatus",
+ gcr."requiresAction",
+ gcr."requiresAdjustment",
+ gcr."requiresRepair",
+ gcr."notes",
+ gcr."customFields",
+ gcr."companyId",
+ gcr."createdAt",
+ gcr."createdBy",
+ gcr."updatedAt",
+ gcr."updatedBy",
+ g."gaugeId" as "gaugeReadableId",
+ g."gaugeTypeId",
+ g."description"
+FROM "gaugeCalibrationRecord" gcr
+JOIN "gauge" g ON gcr."gaugeId" = g."id";