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.

refactor: move work instructions to operation to make copying easier

Brad Barbinf02997143564
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index 5ae40dfeab..92f5743430 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -612,7 +612,7 @@ export async function getMethodOperations(
) {
return client
.from("methodOperation")
- .select("*, methodOperationWorkInstruction(content)")
+ .select("*")
.eq("makeMethodId", makeMethodId)
.order("order", { ascending: true });
}
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index 3f1524f6e3..9450aef98c 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -54,9 +54,7 @@ import { path } from "~/utils/path";
import { methodOperationValidator } from "../../items.models";
type Operation = z.infer<typeof methodOperationValidator> & {
- methodOperationWorkInstruction: {
- content: JSONContent | null;
- };
+ workInstruction: JSONContent | null;
};
type ItemWithData = Item & {
@@ -117,9 +115,7 @@ const initialOperation: Omit<Operation, "makeMethodId" | "order"> = {
setupTime: 0,
setupUnit: "Total Minutes",
workCenterId: "",
- methodOperationWorkInstruction: {
- content: {},
- },
+ workInstruction: {},
};
const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
@@ -244,9 +240,7 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
...item,
data: {
...item.data,
- methodOperationWorkInstruction: {
- content,
- },
+ workInstruction: content,
},
}
: item
@@ -255,13 +249,13 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
if (selectedItemId !== null && !isTemporaryId(selectedItemId))
await supabase
- ?.from("methodOperationWorkInstruction")
+ ?.from("methodOperation")
.update({
- content,
+ workInstruction: content,
updatedAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
- .eq("methodOperationId", selectedItemId!);
+ .eq("id", selectedItemId!);
}, 2000);
const onUploadImage = async (file: File) => {
@@ -285,6 +279,8 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
return `/file/preview/private/${result.data.path}`;
};
+ console.log({ items });
+
const [tabChangeRerender, setTabChangeRerender] = useState<number>(1);
const renderListItem = ({
item,
@@ -338,8 +334,7 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
{permissions.can("update", "parts") ? (
<Editor
initialValue={
- item.data.methodOperationWorkInstruction?.content ??
- ({} as JSONContent)
+ item.data.workInstruction ?? ({} as JSONContent)
}
onUpload={onUploadImage}
onChange={onUpdateWorkInstruction}
@@ -349,8 +344,7 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
className="prose dark:prose-invert"
dangerouslySetInnerHTML={{
__html: generateHTML(
- item.data.methodOperationWorkInstruction?.content ??
- ({} as JSONContent)
+ item.data.workInstruction ?? ({} as JSONContent)
),
}}
/>
@@ -547,13 +541,13 @@ function OperationForm({
// save the work instructions
if (isTemporaryId(item.id) && supabase) {
supabase
- .from("quoteOperationWorkInstruction")
+ .from("methodOperation")
.update({
- content: item.data.methodOperationWorkInstruction.content,
+ workInstruction: item.data.workInstruction,
createdAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
- .eq("quoteOperationId", methodOperationFetcher.data.id)
+ .eq("id", methodOperationFetcher.data.id)
.then(() => {
setSelectedItemId(null);
});
@@ -562,7 +556,7 @@ function OperationForm({
}
}
}, [
- item.data.methodOperationWorkInstruction.content,
+ item.data.workInstruction,
item.id,
methodOperationFetcher.data,
setItems,
@@ -668,9 +662,7 @@ function OperationForm({
? {
...makeItem({
...values,
- methodOperationWorkInstruction: {
- content: i.data.methodOperationWorkInstruction?.content,
- },
+ workInstruction: i.data.workInstruction,
}),
id: item.id,
}
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
index 8a8add3c6e..bb864ebf1a 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobsTable.tsx
@@ -290,8 +290,8 @@ const JobsTable = memo(({ data, count, locations }: JobsTableProps) => {
{selectedJob && selectedJob.id && (
<ConfirmDelete
action={path.to.deleteJob(selectedJob.id)}
- name={selectedJob?.name ?? ""}
- text={`Are you sure you want to deactivate the ${selectedJob?.name} work center?`}
+ name={selectedJob?.jobId ?? ""}
+ text={`Are you sure you want to delete the job: ${selectedJob?.jobId}?`}
isOpen={deleteModal.isOpen}
onCancel={onDeleteCancel}
onSubmit={onDeleteCancel}
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 1228ac937d..5bba193c9b 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -701,7 +701,7 @@ export async function getQuoteOperation(
) {
return client
.from("quoteOperation")
- .select("*, quoteOperationWorkInstruction(content)")
+ .select("*")
.eq("id", quoteOperationId)
.single();
}
@@ -722,7 +722,7 @@ export async function getQuoteOperationsByMethodId(
) {
return client
.from("quoteOperation")
- .select("*, quoteOperationWorkInstruction(content)")
+ .select("*")
.eq("quoteMakeMethodId", quoteMakeMethodId)
.order("order", { ascending: true });
}
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index f2cab93f05..3608d1bd22 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -55,9 +55,7 @@ import { quoteOperationValidator } from "../../sales.models";
import type { Quotation } from "../../types";
type Operation = z.infer<typeof quoteOperationValidator> & {
- quoteOperationWorkInstruction: {
- content: JSONContent | null;
- };
+ workInstruction: JSONContent | null;
};
type ItemWithData = Item & {
@@ -123,9 +121,7 @@ const initialOperation: Omit<Operation, "quoteMakeMethodId" | "order"> = {
setupTime: 0,
setupUnit: "Total Minutes",
workCenterId: "",
- quoteOperationWorkInstruction: {
- content: {},
- },
+ workInstruction: {},
};
const QuoteBillOfProcess = ({
@@ -260,9 +256,7 @@ const QuoteBillOfProcess = ({
...item,
data: {
...item.data,
- quoteOperationWorkInstruction: {
- content,
- },
+ workInstruction: content,
},
}
: item
@@ -270,13 +264,13 @@ const QuoteBillOfProcess = ({
);
if (selectedItemId !== null && !isTemporaryId(selectedItemId))
await supabase
- ?.from("quoteOperationWorkInstruction")
+ ?.from("quoteOperation")
.update({
- content,
+ workInstruction: content,
updatedAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
- .eq("quoteOperationId", selectedItemId!);
+ .eq("id", selectedItemId!);
}, 2500);
const onUploadImage = async (file: File) => {
@@ -350,8 +344,7 @@ const QuoteBillOfProcess = ({
{permissions.can("update", "parts") ? (
<Editor
initialValue={
- item.data.quoteOperationWorkInstruction?.content ??
- ({} as JSONContent)
+ item.data.workInstruction ?? ({} as JSONContent)
}
onUpload={onUploadImage}
onChange={onUpdateWorkInstruction}
@@ -361,8 +354,7 @@ const QuoteBillOfProcess = ({
className="prose dark:prose-invert"
dangerouslySetInnerHTML={{
__html: generateHTML(
- item.data.quoteOperationWorkInstruction?.content ??
- ({} as JSONContent)
+ item.data.workInstruction ?? ({} as JSONContent)
),
}}
/>
@@ -567,9 +559,9 @@ function OperationForm({
// save the work instructions
if (isTemporaryId(item.id) && supabase) {
supabase
- .from("quoteOperationWorkInstruction")
+ .from("quoteOperation")
.update({
- content: item.data.quoteOperationWorkInstruction.content,
+ workInstruction: item.data.workInstruction,
createdAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
@@ -586,7 +578,7 @@ function OperationForm({
fetcher.data,
setItems,
setSelectedItemId,
- item.data.quoteOperationWorkInstruction.content,
+ item.data.workInstruction,
supabase,
userId,
]);
@@ -775,9 +767,7 @@ function OperationForm({
? {
...makeItem({
...values,
- quoteOperationWorkInstruction: {
- content: i.data.quoteOperationWorkInstruction?.content,
- },
+ workInstruction: i.data.workInstruction,
}),
id: item.id,
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index 1d293f1df5..4da5297eee 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -90,10 +90,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
workCenterId: operation.workCenterId ?? undefined,
operationSupplierProcessId:
operation.operationSupplierProcessId ?? undefined,
- methodOperationWorkInstruction:
- operation.methodOperationWorkInstruction as {
- content: JSONContent | null;
- },
+ workInstruction: operation.workInstruction as JSONContent | null,
})) ?? [],
});
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx
index f0dfc334df..49ae050047 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.tsx
@@ -98,10 +98,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
methodOperations.data?.map((operation) => ({
...operation,
workCenterId: operation.workCenterId ?? undefined,
- methodOperationWorkInstruction:
- operation.methodOperationWorkInstruction as {
- content: JSONContent | null;
- },
+ workInstruction: operation.workInstruction as JSONContent,
})) ?? [],
methods: (methodTree.data.length > 0
? flattenTree(methodTree.data[0])
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index 256cfc336d..58f1cda35a 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -90,10 +90,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
workCenterId: operation.workCenterId ?? undefined,
operationSupplierProcessId:
operation.operationSupplierProcessId ?? undefined,
- methodOperationWorkInstruction:
- operation.methodOperationWorkInstruction as {
- content: JSONContent | null;
- },
+ workInstruction: operation.workInstruction as JSONContent | null,
})) ?? [],
});
}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
index 9684e5ca82..9ef0d56b1f 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
@@ -97,10 +97,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
methodOperations:
methodOperations.data?.map((operation) => ({
...operation,
- methodOperationWorkInstruction:
- operation.methodOperationWorkInstruction as {
- content: JSONContent | null;
- },
+ workCenterId: operation.workCenterId ?? undefined,
+ operationSupplierProcessId:
+ operation.operationSupplierProcessId ?? undefined,
+ workInstruction: operation.workInstruction as JSONContent | null,
})) ?? [],
methods: (methodTree.data.length > 0
? flattenTree(methodTree.data[0])
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
index c16cfd6b07..b5ed742558 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
@@ -96,10 +96,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
machineRate: o.machineRate ?? 0,
operationSupplierProcessId: o.operationSupplierProcessId ?? undefined,
quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,
- quoteOperationWorkInstruction: {
- content: (o.quoteOperationWorkInstruction?.content ??
- {}) as JSONContent,
- },
+ workInstruction: o.workInstruction as JSONContent | null,
})) ?? [],
});
}
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
index bc544d1938..21982cad89 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
@@ -67,10 +67,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
machineRate: o.machineRate ?? 0,
operationSupplierProcessId: o.operationSupplierProcessId ?? undefined,
quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,
- quoteOperationWorkInstruction: {
- content: (o.quoteOperationWorkInstruction?.content ??
- {}) as JSONContent,
- },
+ workInstruction: o.workInstruction as JSONContent,
})) ?? [],
});
}
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 7ed64983c0..d474d532ec 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -4440,6 +4440,9 @@ export default {
{
$ref: "#/parameters/rowFilter.jobOperation.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.jobOperation.workInstruction",
+ },
{
$ref: "#/parameters/select",
},
@@ -4567,6 +4570,9 @@ export default {
{
$ref: "#/parameters/rowFilter.jobOperation.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.jobOperation.workInstruction",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -4647,6 +4653,9 @@ export default {
{
$ref: "#/parameters/rowFilter.jobOperation.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.jobOperation.workInstruction",
+ },
{
$ref: "#/parameters/body.jobOperation",
},
@@ -5029,159 +5038,6 @@ export default {
tags: ["purchaseOrderLines"],
},
},
- "/quoteOperationWorkInstruction": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.quoteOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.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/quoteOperationWorkInstruction",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["quoteOperationWorkInstruction"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.quoteOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["quoteOperationWorkInstruction"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.quoteOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["quoteOperationWorkInstruction"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.quoteOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.quoteOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/body.quoteOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["quoteOperationWorkInstruction"],
- },
- },
"/materialForm": {
get: {
parameters: [
@@ -5587,159 +5443,6 @@ export default {
tags: ["item"],
},
},
- "/methodOperationWorkInstruction": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.methodOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.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/methodOperationWorkInstruction",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["methodOperationWorkInstruction"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.methodOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["methodOperationWorkInstruction"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.methodOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["methodOperationWorkInstruction"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.methodOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.methodOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/body.methodOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["methodOperationWorkInstruction"],
- },
- },
"/receipt": {
get: {
parameters: [
@@ -11759,6 +11462,9 @@ export default {
{
$ref: "#/parameters/rowFilter.job.customerId",
},
+ {
+ $ref: "#/parameters/rowFilter.job.locationId",
+ },
{
$ref: "#/parameters/rowFilter.job.status",
},
@@ -11899,6 +11605,9 @@ export default {
{
$ref: "#/parameters/rowFilter.job.customerId",
},
+ {
+ $ref: "#/parameters/rowFilter.job.locationId",
+ },
{
$ref: "#/parameters/rowFilter.job.status",
},
@@ -11993,6 +11702,9 @@ export default {
{
$ref: "#/parameters/rowFilter.job.customerId",
},
+ {
+ $ref: "#/parameters/rowFilter.job.locationId",
+ },
{
$ref: "#/parameters/rowFilter.job.status",
},
@@ -14831,6 +14543,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.methodOperation.workInstruction",
+ },
{
$ref: "#/parameters/select",
},
@@ -14953,6 +14668,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.methodOperation.workInstruction",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -15029,6 +14747,9 @@ export default {
{
$ref: "#/parameters/rowFilter.methodOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.methodOperation.workInstruction",
+ },
{
$ref: "#/parameters/body.methodOperation",
},
@@ -16778,159 +16499,6 @@ export default {
tags: ["employees"],
},
},
- "/jobOperationWorkInstruction": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.jobOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.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/jobOperationWorkInstruction",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["jobOperationWorkInstruction"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.jobOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["jobOperationWorkInstruction"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.jobOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["jobOperationWorkInstruction"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.jobOperationId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.content",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.jobOperationWorkInstruction.updatedBy",
- },
- {
- $ref: "#/parameters/body.jobOperationWorkInstruction",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["jobOperationWorkInstruction"],
- },
- },
"/quoteOperationsWithMakeMethods": {
get: {
parameters: [
@@ -17027,6 +16595,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteOperationsWithMakeMethods.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteOperationsWithMakeMethods.workInstruction",
+ },
{
$ref: "#/parameters/select",
},
@@ -18842,6 +18413,9 @@ export default {
{
$ref: "#/parameters/rowFilter.jobs.customerId",
},
+ {
+ $ref: "#/parameters/rowFilter.jobs.locationId",
+ },
{
$ref: "#/parameters/rowFilter.jobs.status",
},
@@ -24398,6 +23972,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteOperation.workInstruction",
+ },
{
$ref: "#/parameters/select",
},
@@ -24547,6 +24124,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteOperation.workInstruction",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -24650,6 +24230,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteOperation.operationSupplierProcessId",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteOperation.workInstruction",
+ },
{
$ref: "#/parameters/body.quoteOperation",
},
@@ -36339,6 +35922,7 @@ export default {
"companyId",
"createdAt",
"createdBy",
+ "workInstruction",
],
properties: {
id: {
@@ -36494,6 +36078,9 @@ export default {
customFields: {
format: "jsonb",
},
+ workInstruction: {
+ format: "json",
+ },
},
type: "object",
},
@@ -36744,45 +36331,6 @@ export default {
},
type: "object",
},
- quoteOperationWorkInstruction: {
- required: ["quoteOperationId", "companyId", "createdAt", "createdBy"],
- properties: {
- quoteOperationId: {
- description: "Note:\nThis is a Primary Key.<pk/>",
- format: "text",
- type: "string",
- },
- content: {
- format: "json",
- },
- companyId: {
- 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",
- },
materialForm: {
required: ["id", "name", "createdBy", "createdAt"],
properties: {
@@ -36938,45 +36486,6 @@ export default {
},
type: "object",
},
- methodOperationWorkInstruction: {
- required: ["methodOperationId", "companyId", "createdAt", "createdBy"],
- properties: {
- methodOperationId: {
- description: "Note:\nThis is a Primary Key.<pk/>",
- format: "text",
- type: "string",
- },
- content: {
- format: "json",
- },
- companyId: {
- 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",
- },
receipt: {
required: [
"id",
@@ -39590,6 +39099,7 @@ export default {
"jobId",
"itemId",
"unitOfMeasureCode",
+ "locationId",
"status",
"deadlineType",
"orderQuantity",
@@ -39630,6 +39140,12 @@ export default {
format: "text",
type: "string",
},
+ locationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
status: {
default: "Draft",
enum: [
@@ -41086,6 +40602,7 @@ export default {
"machineTime",
"machineUnit",
"operationType",
+ "workInstruction",
],
properties: {
id: {
@@ -41238,6 +40755,9 @@ export default {
format: "text",
type: "string",
},
+ workInstruction: {
+ format: "json",
+ },
},
type: "object",
},
@@ -41916,45 +41436,6 @@ export default {
},
type: "object",
},
- jobOperationWorkInstruction: {
- required: ["jobOperationId", "companyId", "createdAt", "createdBy"],
- properties: {
- jobOperationId: {
- description: "Note:\nThis is a Primary Key.<pk/>",
- format: "text",
- type: "string",
- },
- content: {
- format: "json",
- },
- companyId: {
- 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",
- },
quoteOperationsWithMakeMethods: {
properties: {
makeMethodId: {
@@ -42141,6 +41622,9 @@ export default {
format: "text",
type: "string",
},
+ workInstruction: {
+ format: "json",
+ },
},
type: "object",
},
@@ -42767,6 +42251,12 @@ export default {
format: "text",
type: "string",
},
+ locationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
status: {
enum: [
"Draft",
@@ -45058,7 +44548,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",
},
@@ -45107,7 +44597,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",
},
@@ -45349,6 +44839,7 @@ export default {
"operationMinimumCost",
"operationLeadTime",
"operationUnitCost",
+ "workInstruction",
],
properties: {
id: {
@@ -45547,6 +45038,9 @@ export default {
format: "text",
type: "string",
},
+ workInstruction: {
+ format: "json",
+ },
},
type: "object",
},
@@ -51884,6 +51378,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.jobOperation.workInstruction": {
+ name: "workInstruction",
+ required: false,
+ format: "json",
+ in: "query",
+ type: "string",
+ },
"body.journalLine": {
name: "journalLine",
description: "journalLine",
@@ -52238,64 +51739,6 @@ export default {
in: "query",
type: "string",
},
- "body.quoteOperationWorkInstruction": {
- name: "quoteOperationWorkInstruction",
- description: "quoteOperationWorkInstruction",
- required: false,
- in: "body",
- schema: {
- $ref: "#/definitions/quoteOperationWorkInstruction",
- },
- },
- "rowFilter.quoteOperationWorkInstruction.quoteOperationId": {
- name: "quoteOperationId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.content": {
- name: "content",
- required: false,
- format: "json",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.companyId": {
- name: "companyId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.createdAt": {
- name: "createdAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.createdBy": {
- name: "createdBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.updatedAt": {
- name: "updatedAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.quoteOperationWorkInstruction.updatedBy": {
- name: "updatedBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
"body.materialForm": {
name: "materialForm",
description: "materialForm",
@@ -52489,64 +51932,6 @@ export default {
in: "query",
type: "string",
},
- "body.methodOperationWorkInstruction": {
- name: "methodOperationWorkInstruction",
- description: "methodOperationWorkInstruction",
- required: false,
- in: "body",
- schema: {
- $ref: "#/definitions/methodOperationWorkInstruction",
- },
- },
- "rowFilter.methodOperationWorkInstruction.methodOperationId": {
- name: "methodOperationId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.content": {
- name: "content",
- required: false,
- format: "json",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.companyId": {
- name: "companyId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.createdAt": {
- name: "createdAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.createdBy": {
- name: "createdBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.updatedAt": {
- name: "updatedAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.methodOperationWorkInstruction.updatedBy": {
- name: "updatedBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
"body.receipt": {
name: "receipt",
description: "receipt",
@@ -55941,6 +55326,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.job.locationId": {
+ name: "locationId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"rowFilter.job.status": {
name: "status",
required: false,
@@ -58091,6 +57483,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.methodOperation.workInstruction": {
+ name: "workInstruction",
+ required: false,
+ format: "json",
+ in: "query",
+ type: "string",
+ },
"body.salesOrderPayment": {
name: "salesOrderPayment",
description: "salesOrderPayment",
@@ -58970,64 +58369,6 @@ export default {
in: "query",
type: "string",
},
- "body.jobOperationWorkInstruction": {
- name: "jobOperationWorkInstruction",
- description: "jobOperationWorkInstruction",
- required: false,
- in: "body",
- schema: {
- $ref: "#/definitions/jobOperationWorkInstruction",
- },
- },
- "rowFilter.jobOperationWorkInstruction.jobOperationId": {
- name: "jobOperationId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.content": {
- name: "content",
- required: false,
- format: "json",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.companyId": {
- name: "companyId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.createdAt": {
- name: "createdAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.createdBy": {
- name: "createdBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.updatedAt": {
- name: "updatedAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.jobOperationWorkInstruction.updatedBy": {
- name: "updatedBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
"body.quoteOperationsWithMakeMethods": {
name: "quoteOperationsWithMakeMethods",
description: "quoteOperationsWithMakeMethods",
@@ -59254,6 +58595,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.quoteOperationsWithMakeMethods.workInstruction": {
+ name: "workInstruction",
+ required: false,
+ format: "json",
+ in: "query",
+ type: "string",
+ },
"body.oauthToken": {
name: "oauthToken",
description: "oauthToken",
@@ -60083,6 +59431,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.jobs.locationId": {
+ name: "locationId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"rowFilter.jobs.status": {
name: "status",
required: false,
@@ -63758,6 +63113,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.quoteOperation.workInstruction": {
+ name: "workInstruction",
+ required: false,
+ format: "json",
+ in: "query",
+ type: "string",
+ },
"body.salesRfq": {
name: "salesRfq",
description: "salesRfq",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 2e50741919..f81b9c6ad6 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6865,6 +6865,7 @@ export type Database = {
inventoryQuantity: number
itemId: string
jobId: string
+ locationId: string
notes: Json | null
orderQuantity: number
productionQuantity: number
@@ -6894,6 +6895,7 @@ export type Database = {
inventoryQuantity?: number
itemId: string
jobId: string
+ locationId: string
notes?: Json | null
orderQuantity?: number
productionQuantity?: number
@@ -6923,6 +6925,7 @@ export type Database = {
inventoryQuantity?: number
itemId?: string
jobId?: string
+ locationId?: string
notes?: Json | null
orderQuantity?: number
productionQuantity?: number
@@ -7073,6 +7076,34 @@ export type Database = {
referencedRelation: "itemQuantities"
referencedColumns: ["itemId"]
},
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -7415,6 +7446,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -7439,6 +7471,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -7463,6 +7496,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -7607,114 +7641,6 @@ export type Database = {
},
]
}
- jobOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- jobOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- jobOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- jobOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_jobOperationId_fkey"
- columns: ["jobOperationId"]
- isOneToOne: true
- referencedRelation: "jobOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
journal: {
Row: {
accountingPeriodId: string | null
@@ -8873,6 +8799,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -8896,6 +8823,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -8919,6 +8847,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -9077,114 +9006,6 @@ export type Database = {
},
]
}
- methodOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- methodOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- methodOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- methodOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_methodOperationId_fkey"
- columns: ["methodOperationId"]
- isOneToOne: true
- referencedRelation: "methodOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
modelUpload: {
Row: {
autodeskUrn: string | null
@@ -14706,6 +14527,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -14738,6 +14560,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -14770,6 +14593,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -14963,121 +14787,6 @@ export type Database = {
},
]
}
- quoteOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- quoteOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- quoteOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- quoteOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_quoteOperationId_fkey"
- columns: ["quoteOperationId"]
- isOneToOne: true
- referencedRelation: "quoteOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_quoteOperationId_fkey"
- columns: ["quoteOperationId"]
- isOneToOne: true
- referencedRelation: "quoteOperationsWithMakeMethods"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
quotePayment: {
Row: {
companyId: string
@@ -23347,6 +23056,7 @@ export type Database = {
| Database["public"]["Enums"]["itemTrackingType"]
| null
jobId: string | null
+ locationId: string | null
modelId: string | null
modelName: string | null
modelPath: string | null
@@ -23509,6 +23219,34 @@ export type Database = {
referencedRelation: "itemQuantities"
referencedColumns: ["itemId"]
},
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -25611,6 +25349,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json | null
}
Relationships: [
{
@@ -26602,14 +26341,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 9f303713ea..4b31815357 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -234,6 +234,7 @@ serve(async (req: Request) => {
op.processId,
op.operationSupplierProcessId
),
+ workInstruction: op.workInstruction,
companyId,
createdBy: userId,
customFields: {},
@@ -431,6 +432,7 @@ serve(async (req: Request) => {
op.processId,
op.operationSupplierProcessId
),
+ workInstruction: op.workInstruction,
companyId,
createdBy: userId,
customFields: {},
@@ -680,6 +682,7 @@ serve(async (req: Request) => {
operationOrder: op.operationOrder ?? "After Previous",
operationType: op.operationType ?? "Inside",
operationSupplierProcessId: op.operationSupplierProcessId,
+ workInstruction: op.workInstruction,
companyId,
createdBy: userId,
customFields: {},
@@ -876,7 +879,7 @@ serve(async (req: Request) => {
order: op.order ?? 1,
operationOrder: op.operationOrder ?? "After Previous",
operationType: op.operationType ?? "Inside",
-
+ workInstruction: op.workInstruction,
companyId,
createdBy: userId,
customFields: {},
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 2e50741919..f81b9c6ad6 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6865,6 +6865,7 @@ export type Database = {
inventoryQuantity: number
itemId: string
jobId: string
+ locationId: string
notes: Json | null
orderQuantity: number
productionQuantity: number
@@ -6894,6 +6895,7 @@ export type Database = {
inventoryQuantity?: number
itemId: string
jobId: string
+ locationId: string
notes?: Json | null
orderQuantity?: number
productionQuantity?: number
@@ -6923,6 +6925,7 @@ export type Database = {
inventoryQuantity?: number
itemId?: string
jobId?: string
+ locationId?: string
notes?: Json | null
orderQuantity?: number
productionQuantity?: number
@@ -7073,6 +7076,34 @@ export type Database = {
referencedRelation: "itemQuantities"
referencedColumns: ["itemId"]
},
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -7415,6 +7446,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -7439,6 +7471,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -7463,6 +7496,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -7607,114 +7641,6 @@ export type Database = {
},
]
}
- jobOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- jobOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- jobOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- jobOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_jobOperationId_fkey"
- columns: ["jobOperationId"]
- isOneToOne: true
- referencedRelation: "jobOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "jobOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
journal: {
Row: {
accountingPeriodId: string | null
@@ -8873,6 +8799,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -8896,6 +8823,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -8919,6 +8847,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -9077,114 +9006,6 @@ export type Database = {
},
]
}
- methodOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- methodOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- methodOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- methodOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_methodOperationId_fkey"
- columns: ["methodOperationId"]
- isOneToOne: true
- referencedRelation: "methodOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "methodOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
modelUpload: {
Row: {
autodeskUrn: string | null
@@ -14706,6 +14527,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json
}
Insert: {
companyId: string
@@ -14738,6 +14560,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Update: {
companyId?: string
@@ -14770,6 +14593,7 @@ export type Database = {
updatedAt?: string | null
updatedBy?: string | null
workCenterId?: string | null
+ workInstruction?: Json
}
Relationships: [
{
@@ -14963,121 +14787,6 @@ export type Database = {
},
]
}
- quoteOperationWorkInstruction: {
- Row: {
- companyId: string
- content: Json | null
- createdAt: string
- createdBy: string
- quoteOperationId: string
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- content?: Json | null
- createdAt?: string
- createdBy: string
- quoteOperationId: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- content?: Json | null
- createdAt?: string
- createdBy?: string
- quoteOperationId?: string
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_createdBy_fkey"
- columns: ["createdBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_quoteOperationId_fkey"
- columns: ["quoteOperationId"]
- isOneToOne: true
- referencedRelation: "quoteOperation"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_quoteOperationId_fkey"
- columns: ["quoteOperationId"]
- isOneToOne: true
- referencedRelation: "quoteOperationsWithMakeMethods"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employees"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeesAcrossCompanies"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "employeeSummary"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "user"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteOperationWorkInstruction_updatedBy_fkey"
- columns: ["updatedBy"]
- isOneToOne: false
- referencedRelation: "userDefaults"
- referencedColumns: ["userId"]
- },
- ]
- }
quotePayment: {
Row: {
companyId: string
@@ -23347,6 +23056,7 @@ export type Database = {
| Database["public"]["Enums"]["itemTrackingType"]
| null
jobId: string | null
+ locationId: string | null
modelId: string | null
modelName: string | null
modelPath: string | null
@@ -23509,6 +23219,34 @@ export type Database = {
referencedRelation: "itemQuantities"
referencedColumns: ["itemId"]
},
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "job_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "job_quoteId_fkey"
columns: ["quoteId"]
@@ -25611,6 +25349,7 @@ export type Database = {
updatedAt: string | null
updatedBy: string | null
workCenterId: string | null
+ workInstruction: Json | null
}
Relationships: [
{
@@ -26602,14 +26341,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
diff --git a/packages/database/supabase/migrations/20240909194622_jobs.sql b/packages/database/supabase/migrations/20240909194622_jobs.sql
index 0116642a8f..4358f89fab 100644
--- a/packages/database/supabase/migrations/20240909194622_jobs.sql
+++ b/packages/database/supabase/migrations/20240909194622_jobs.sql
@@ -88,6 +88,7 @@ CREATE TABLE "public"."job" (
"itemId" TEXT NOT NULL,
"unitOfMeasureCode" TEXT NOT NULL,
"customerId" TEXT,
+ "locationId" TEXT NOT NULL,
"status" "jobStatus" NOT NULL DEFAULT 'Draft',
"dueDate" DATE,
"deadlineType" "deadlineType" NOT NULL DEFAULT 'No Deadline',
@@ -115,6 +116,7 @@ CREATE TABLE "public"."job" (
CONSTRAINT "job_jobId_key" UNIQUE ("jobId", "companyId"),
CONSTRAINT "job_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "job_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customer" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "job_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "job_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "job_salesOrderId_fkey" FOREIGN KEY ("salesOrderId") REFERENCES "salesOrder" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "job_salesOrderLineId_fkey" FOREIGN KEY ("salesOrderLineId") REFERENCES "salesOrderLine" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
diff --git a/packages/database/supabase/migrations/20240910110352_jobs-rls.sql b/packages/database/supabase/migrations/20240910110352_jobs-rls.sql
new file mode 100644
index 0000000000..5c2c50caf8
--- /dev/null
+++ b/packages/database/supabase/migrations/20240910110352_jobs-rls.sql
@@ -0,0 +1,82 @@
+ALTER TABLE "job" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Requests with an API key can access jobs" ON "job"
+FOR ALL USING (
+ has_valid_api_key_for_company("companyId")
+);
+
+CREATE POLICY "Requests with an API key can select users from their company" ON "user"
+FOR SELECT USING (
+ EXISTS (
+ SELECT 1
+ FROM "userToCompany"
+ WHERE "userToCompany"."userId" = "user"."id"::text
+ AND "userToCompany"."companyId" IN (
+ SELECT "companyId"
+ FROM "apiKey"
+ WHERE "apiKey"."key" = current_setting('request.header.carbon-key', true)
+ )
+ )
+);
+
+-- Add workInstruction column to quoteOperation table
+ALTER TABLE "quoteOperation" ADD COLUMN "workInstruction" JSON NOT NULL DEFAULT '{}';
+
+-- Migrate data from quoteOperationWorkInstruction to quoteOperation
+UPDATE "quoteOperation" qo
+SET "workInstruction" = qowi.content
+FROM "quoteOperationWorkInstruction" qowi
+WHERE qo.id = qowi."quoteOperationId";
+
+-- Add workInstruction column to jobOperation table
+ALTER TABLE "jobOperation" ADD COLUMN "workInstruction" JSON NOT NULL DEFAULT '{}';
+
+-- Migrate data from jobOperationWorkInstruction to jobOperation
+UPDATE "jobOperation" jo
+SET "workInstruction" = jowi.content
+FROM "jobOperationWorkInstruction" jowi
+WHERE jo.id = jowi."jobOperationId";
+
+-- Add workInstruction column to methodOperation table
+ALTER TABLE "methodOperation" ADD COLUMN "workInstruction" JSON NOT NULL DEFAULT '{}';
+
+-- Migrate data from methodOperationWorkInstruction to methodOperation
+UPDATE "methodOperation" mo
+SET "workInstruction" = mowi.content
+FROM "methodOperationWorkInstruction" mowi
+WHERE mo.id = mowi."methodOperationId";
+
+-- Drop the old work instruction tables
+DROP TABLE "quoteOperationWorkInstruction";
+DROP TABLE "jobOperationWorkInstruction";
+DROP TABLE "methodOperationWorkInstruction";
+
+-- Drop the associated trigger if it exists
+DROP TRIGGER IF EXISTS create_quote_operation_related_records ON public."quoteOperation";
+-- Drop the function that creates quote operation work instructions
+DROP FUNCTION IF EXISTS public.create_quote_operation_work_instruction();
+
+
+-- Drop the associated trigger for method operation
+DROP TRIGGER IF EXISTS create_part_make_method_related_records ON public."methodOperation";
+-- Drop the function that creates method operation work instructions
+DROP FUNCTION IF EXISTS public.create_method_operation_work_instruction();
+
+
+-- Drop the associated trigger for job operation (if it exists)
+DROP TRIGGER IF EXISTS create_job_operation_related_records ON public."jobOperation";
+-- Drop the function that creates job operation work instructions (if it exists)
+DROP FUNCTION IF EXISTS public.create_job_operation_work_instruction();
+
+
+DROP VIEW "quoteOperationsWithMakeMethods";
+COMMIT;
+CREATE OR REPLACE VIEW "quoteOperationsWithMakeMethods" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ mm.id AS "makeMethodId",
+ qo.*
+ FROM "quoteOperation" qo
+ INNER JOIN "quoteMakeMethod" qmm
+ ON qo."quoteMakeMethodId" = qmm.id
+ LEFT JOIN "makeMethod" mm
+ ON qmm."itemId" = mm."itemId";
\ No newline at end of file