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.

fix: add locationId to quoteLine

Rob Carrington97444d985415
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index bb154703fd..37b0a46367 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -3,7 +3,7 @@ export default {
info: {
description: "",
title: "standard public schema",
- version: "12.0.2 (a4e00ff)",
+ version: "12.0.1 (cd38da5)",
},
host: "0.0.0.0:3000",
basePath: "/",
@@ -30501,6 +30501,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteLine.additionalCharges",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteLine.locationId",
+ },
{
$ref: "#/parameters/select",
},
@@ -30626,6 +30629,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteLine.additionalCharges",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteLine.locationId",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -30705,6 +30711,9 @@ export default {
{
$ref: "#/parameters/rowFilter.quoteLine.additionalCharges",
},
+ {
+ $ref: "#/parameters/rowFilter.quoteLine.locationId",
+ },
{
$ref: "#/parameters/body.quoteLine",
},
@@ -45919,7 +45928,7 @@ export default {
properties: {
id: {
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",
},
@@ -45968,7 +45977,7 @@ export default {
},
supplierLocationId: {
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",
},
@@ -47491,8 +47500,7 @@ export default {
],
properties: {
itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
},
@@ -47532,6 +47540,7 @@ export default {
type: "boolean",
},
lotSize: {
+ default: 0,
format: "integer",
type: "integer",
},
@@ -49081,6 +49090,12 @@ export default {
additionalCharges: {
format: "jsonb",
},
+ locationId: {
+ description:
+ "Note:\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -68575,6 +68590,13 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.quoteLine.locationId": {
+ name: "locationId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"body.jobMaterialWithMakeMethodId": {
name: "jobMaterialWithMakeMethodId",
description: "jobMaterialWithMakeMethodId",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index e15f64e5c5..222cf36e1c 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6657,7 +6657,7 @@ export type Database = {
{
foreignKeyName: "itemReplenishment_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -13945,6 +13945,7 @@ export type Database = {
itemId: string
itemReadableId: string | null
itemType: string
+ locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
notes: Json | null
@@ -13969,6 +13970,7 @@ export type Database = {
itemId: string
itemReadableId?: string | null
itemType?: string
+ locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
notes?: Json | null
@@ -13993,6 +13995,7 @@ export type Database = {
itemId?: string
itemReadableId?: string | null
itemType?: string
+ locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
notes?: Json | null
@@ -14110,6 +14113,27 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "quoteLine_quoteId_fkey"
columns: ["quoteId"]
@@ -26760,14 +26784,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/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index fa9f864a73..6e972239ca 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -141,7 +141,7 @@ serve(async (req: Request) => {
description: line.description,
itemId: line.itemId,
itemReadableId: line.itemReadableId,
- locationId: quote.data.locationId,
+ locationId: line.locationId ?? quote.data.locationId,
methodType: line.methodType,
saleQuantity: selectedLines![line.id!].quantity,
status: "Ordered",
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index e15f64e5c5..222cf36e1c 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -6657,7 +6657,7 @@ export type Database = {
{
foreignKeyName: "itemReplenishment_itemId_fkey"
columns: ["itemId"]
- isOneToOne: false
+ isOneToOne: true
referencedRelation: "item"
referencedColumns: ["id"]
},
@@ -13945,6 +13945,7 @@ export type Database = {
itemId: string
itemReadableId: string | null
itemType: string
+ locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
notes: Json | null
@@ -13969,6 +13970,7 @@ export type Database = {
itemId: string
itemReadableId?: string | null
itemType?: string
+ locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
notes?: Json | null
@@ -13993,6 +13995,7 @@ export type Database = {
itemId?: string
itemReadableId?: string | null
itemType?: string
+ locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
notes?: Json | null
@@ -14110,6 +14113,27 @@ export type Database = {
referencedRelation: "item"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "location"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
+ },
+ {
+ foreignKeyName: "quoteLine_locationId_fkey"
+ columns: ["locationId"]
+ isOneToOne: false
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
+ },
{
foreignKeyName: "quoteLine_quoteId_fkey"
columns: ["quoteId"]
@@ -26760,14 +26784,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/20240924132243_add-quote-line-locationId.sql b/packages/database/supabase/migrations/20240924132243_add-quote-line-locationId.sql
new file mode 100644
index 0000000000..14c9db9c96
--- /dev/null
+++ b/packages/database/supabase/migrations/20240924132243_add-quote-line-locationId.sql
@@ -0,0 +1,5 @@
+-- Add the 'locationId' column to the 'quoteLine' table
+ALTER TABLE "quoteLine" ADD COLUMN IF NOT EXISTS "locationId" TEXT;
+
+-- Add a foreign key constraint for 'locationId' referencing the 'location' table
+ALTER TABLE "quoteLine" ADD CONSTRAINT "quoteLine_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE;