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 embeddings for suppliers and customers

Gaurav Bhatte6031cc1b23f
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index e3731f1e2b..4ca6688753 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -17529,6 +17529,9 @@ export default {
{
$ref: "#/parameters/rowFilter.timeCardEntries.locationName",
},
+ {
+ $ref: "#/parameters/rowFilter.timeCardEntries.status",
+ },
{
$ref: "#/parameters/select",
},
@@ -34389,6 +34392,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesInvoiceLines.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.salesInvoiceLines.nonTaxableAddOnCost",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesInvoiceLines.convertedNonTaxableAddOnCost",
+ },
{
$ref: "#/parameters/rowFilter.salesInvoiceLines.itemReadableId",
},
@@ -40755,6 +40764,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLines.sentDate",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.nonTaxableAddOnCost",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.convertedNonTaxableAddOnCost",
+ },
{
$ref: "#/parameters/rowFilter.salesOrderLines.itemReadableId",
},
@@ -65266,6 +65281,188 @@ export default {
tags: ["(rpc) get_jobs_by_date_range"],
},
},
+ "/rpc/calculate_quantity_to_order": {
+ get: {
+ parameters: [
+ {
+ format: '"itemReorderingPolicy"',
+ in: "query",
+ name: "p_reordering_policy",
+ required: true,
+ type: "string",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_reorder_point",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_reorder_quantity",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_minimum_order_quantity",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_maximum_order_quantity",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_order_multiple",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_lot_size",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "numeric",
+ in: "query",
+ name: "p_maximum_inventory_quantity",
+ required: true,
+ type: "number",
+ },
+ {
+ format: "integer",
+ in: "query",
+ name: "p_demand_accumulation_period",
+ required: true,
+ type: "integer",
+ },
+ {
+ format: "numeric",
+ in: "query",
+ name: "p_demand_accumulation_safety_stock",
+ required: true,
+ type: "number",
+ },
+ {
+ format: "numeric[]",
+ in: "query",
+ name: "p_projections",
+ required: true,
+ type: "string",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) calculate_quantity_to_order"],
+ },
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ p_demand_accumulation_period: {
+ format: "integer",
+ type: "integer",
+ },
+ p_demand_accumulation_safety_stock: {
+ format: "numeric",
+ type: "number",
+ },
+ p_lot_size: {
+ format: "integer",
+ type: "integer",
+ },
+ p_maximum_inventory_quantity: {
+ format: "numeric",
+ type: "number",
+ },
+ p_maximum_order_quantity: {
+ format: "integer",
+ type: "integer",
+ },
+ p_minimum_order_quantity: {
+ format: "integer",
+ type: "integer",
+ },
+ p_order_multiple: {
+ format: "integer",
+ type: "integer",
+ },
+ p_projections: {
+ format: "numeric[]",
+ items: {
+ type: "number",
+ },
+ type: "array",
+ },
+ p_reorder_point: {
+ format: "integer",
+ type: "integer",
+ },
+ p_reorder_quantity: {
+ format: "integer",
+ type: "integer",
+ },
+ p_reordering_policy: {
+ format: '"itemReorderingPolicy"',
+ type: "string",
+ },
+ },
+ required: [
+ "p_reordering_policy",
+ "p_reorder_point",
+ "p_reorder_quantity",
+ "p_minimum_order_quantity",
+ "p_maximum_order_quantity",
+ "p_order_multiple",
+ "p_lot_size",
+ "p_maximum_inventory_quantity",
+ "p_demand_accumulation_period",
+ "p_demand_accumulation_safety_stock",
+ "p_projections",
+ ],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) calculate_quantity_to_order"],
+ },
+ },
"/rpc/get_period_end_date": {
get: {
parameters: [
@@ -65856,6 +66053,41 @@ export default {
tags: ["(rpc) get_item_quantities_by_tracking_id"],
},
},
+ "/rpc/get_inventory_value_by_location": {
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ company_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["company_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) get_inventory_value_by_location"],
+ },
+ },
"/rpc/get_quote_methods_by_method_id": {
get: {
parameters: [
@@ -73587,7 +73819,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",
},
@@ -73636,7 +73868,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",
},
@@ -78091,6 +78323,10 @@ export default {
format: "text",
type: "string",
},
+ status: {
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -85799,6 +86035,14 @@ export default {
format: "text",
type: "string",
},
+ nonTaxableAddOnCost: {
+ format: "numeric",
+ type: "number",
+ },
+ convertedNonTaxableAddOnCost: {
+ format: "numeric",
+ type: "number",
+ },
itemReadableId: {
format: "text",
type: "string",
@@ -88656,6 +88900,14 @@ export default {
format: "date",
type: "string",
},
+ nonTaxableAddOnCost: {
+ format: "numeric",
+ type: "number",
+ },
+ convertedNonTaxableAddOnCost: {
+ format: "numeric",
+ type: "number",
+ },
itemReadableId: {
format: "text",
type: "string",
@@ -96396,7 +96648,7 @@ export default {
],
properties: {
id: {
- default: "public.xid()",
+ default: "public.id('tce'::text)",
description: "Note:\nThis is a Primary Key.<pk/>",
format: "text",
type: "string",
@@ -109879,6 +110131,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.timeCardEntries.status": {
+ name: "status",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.materialDimensions": {
name: "materialDimensions",
description: "materialDimensions",
@@ -118569,6 +118827,18 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.salesInvoiceLines.nonTaxableAddOnCost": {
+ name: "nonTaxableAddOnCost",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesInvoiceLines.convertedNonTaxableAddOnCost": {
+ name: "convertedNonTaxableAddOnCost",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.salesInvoiceLines.itemReadableId": {
name: "itemReadableId",
required: false,
@@ -121786,6 +122056,18 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.salesOrderLines.nonTaxableAddOnCost": {
+ name: "nonTaxableAddOnCost",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.convertedNonTaxableAddOnCost": {
+ name: "convertedNonTaxableAddOnCost",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.salesOrderLines.itemReadableId": {
name: "itemReadableId",
required: false,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 16a3fb0450..08044dbedc 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -30813,6 +30813,7 @@ export type Database = {
assetId: string | null
companyId: string
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedSetupPrice: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
@@ -30830,6 +30831,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
+ nonTaxableAddOnCost: number
opportunityId: string | null
quantity: number
salesOrderId: string | null
@@ -30849,6 +30851,7 @@ export type Database = {
assetId?: string | null
companyId: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedSetupPrice?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
@@ -30866,6 +30869,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
opportunityId?: string | null
quantity?: number
salesOrderId?: string | null
@@ -30885,6 +30889,7 @@ export type Database = {
assetId?: string | null
companyId?: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedSetupPrice?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
@@ -30902,6 +30907,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
opportunityId?: string | null
quantity?: number
salesOrderId?: string | null
@@ -31746,6 +31752,7 @@ export type Database = {
assetId: string | null
companyId: string
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
createdAt: string
@@ -31761,6 +31768,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
+ nonTaxableAddOnCost: number
promisedDate: string | null
quantityInvoiced: number | null
quantitySent: number | null
@@ -31788,6 +31796,7 @@ export type Database = {
assetId?: string | null
companyId: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
createdAt?: string
@@ -31803,6 +31812,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
promisedDate?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
@@ -31830,6 +31840,7 @@ export type Database = {
assetId?: string | null
companyId?: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
createdAt?: string
@@ -31845,6 +31856,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
promisedDate?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
@@ -33329,48 +33341,6 @@ export type Database = {
},
]
}
- searchIndex_3VCMFwYSx4XmioYxbouFts: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
searchIndexRegistry: {
Row: {
companyId: string
@@ -52163,6 +52133,7 @@ export type Database = {
assetId: string | null
companyId: string | null
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedSetupPrice: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
@@ -52186,6 +52157,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"] | null
modelUploadId: string | null
+ nonTaxableAddOnCost: number | null
opportunityId: string | null
quantity: number | null
salesOrderId: string | null
@@ -52494,21 +52466,21 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52793,6 +52765,7 @@ export type Database = {
autodeskUrn: string | null
companyId: string | null
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
createdAt: string | null
@@ -52816,6 +52789,7 @@ export type Database = {
modelPath: string | null
modelSize: number | null
modelUploadId: string | null
+ nonTaxableAddOnCost: number | null
orderDate: string | null
promisedDate: string | null
quantityInvoiced: number | null
@@ -53051,14 +53025,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"]
@@ -56755,6 +56729,19 @@ export type Database = {
usageLast90Days: number
}[]
}
+ get_inventory_value_by_location: {
+ Args: { company_id: string }
+ Returns: {
+ itemName: string
+ itemReadableId: string
+ locationName: string
+ quantityOnHand: number
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ totalValue: number
+ unitCost: number
+ unitOfMeasureCode: string
+ }[]
+ }
get_item_quantities_by_tracking_id: {
Args: { company_id: string; item_id: string; location_id: string }
Returns: {
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 16a3fb0450..08044dbedc 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -30813,6 +30813,7 @@ export type Database = {
assetId: string | null
companyId: string
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedSetupPrice: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
@@ -30830,6 +30831,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
+ nonTaxableAddOnCost: number
opportunityId: string | null
quantity: number
salesOrderId: string | null
@@ -30849,6 +30851,7 @@ export type Database = {
assetId?: string | null
companyId: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedSetupPrice?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
@@ -30866,6 +30869,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
opportunityId?: string | null
quantity?: number
salesOrderId?: string | null
@@ -30885,6 +30889,7 @@ export type Database = {
assetId?: string | null
companyId?: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedSetupPrice?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
@@ -30902,6 +30907,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
opportunityId?: string | null
quantity?: number
salesOrderId?: string | null
@@ -31746,6 +31752,7 @@ export type Database = {
assetId: string | null
companyId: string
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
createdAt: string
@@ -31761,6 +31768,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"]
modelUploadId: string | null
+ nonTaxableAddOnCost: number
promisedDate: string | null
quantityInvoiced: number | null
quantitySent: number | null
@@ -31788,6 +31796,7 @@ export type Database = {
assetId?: string | null
companyId: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
createdAt?: string
@@ -31803,6 +31812,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
promisedDate?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
@@ -31830,6 +31840,7 @@ export type Database = {
assetId?: string | null
companyId?: string
convertedAddOnCost?: number | null
+ convertedNonTaxableAddOnCost?: number | null
convertedShippingCost?: number | null
convertedUnitPrice?: number | null
createdAt?: string
@@ -31845,6 +31856,7 @@ export type Database = {
locationId?: string | null
methodType?: Database["public"]["Enums"]["methodType"]
modelUploadId?: string | null
+ nonTaxableAddOnCost?: number
promisedDate?: string | null
quantityInvoiced?: number | null
quantitySent?: number | null
@@ -33329,48 +33341,6 @@ export type Database = {
},
]
}
- searchIndex_3VCMFwYSx4XmioYxbouFts: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
searchIndexRegistry: {
Row: {
companyId: string
@@ -52163,6 +52133,7 @@ export type Database = {
assetId: string | null
companyId: string | null
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedSetupPrice: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
@@ -52186,6 +52157,7 @@ export type Database = {
locationId: string | null
methodType: Database["public"]["Enums"]["methodType"] | null
modelUploadId: string | null
+ nonTaxableAddOnCost: number | null
opportunityId: string | null
quantity: number | null
salesOrderId: string | null
@@ -52494,21 +52466,21 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["shipmentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["shipmentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52793,6 +52765,7 @@ export type Database = {
autodeskUrn: string | null
companyId: string | null
convertedAddOnCost: number | null
+ convertedNonTaxableAddOnCost: number | null
convertedShippingCost: number | null
convertedUnitPrice: number | null
createdAt: string | null
@@ -52816,6 +52789,7 @@ export type Database = {
modelPath: string | null
modelSize: number | null
modelUploadId: string | null
+ nonTaxableAddOnCost: number | null
orderDate: string | null
promisedDate: string | null
quantityInvoiced: number | null
@@ -53051,14 +53025,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"]
@@ -56755,6 +56729,19 @@ export type Database = {
usageLast90Days: number
}[]
}
+ get_inventory_value_by_location: {
+ Args: { company_id: string }
+ Returns: {
+ itemName: string
+ itemReadableId: string
+ locationName: string
+ quantityOnHand: number
+ replenishmentSystem: Database["public"]["Enums"]["itemReplenishmentSystem"]
+ totalValue: number
+ unitCost: number
+ unitOfMeasureCode: string
+ }[]
+ }
get_item_quantities_by_tracking_id: {
Args: { company_id: string; item_id: string; location_id: string }
Returns: {
diff --git a/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql b/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql
new file mode 100644
index 0000000000..af458ea5b4
--- /dev/null
+++ b/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql
@@ -0,0 +1,102 @@
+-- =============================================================================
+-- Fix Embedding Triggers
+-- The search-refactor migration (20260109) dropped trigger functions that had
+-- dual responsibility: updating the old search table AND queuing embedding jobs.
+-- The new async search system replaced search indexing but did not re-add the
+-- embedding pipeline. This migration creates standalone embedding triggers.
+-- =============================================================================
+
+-- Queue embedding on item insert
+CREATE OR REPLACE FUNCTION queue_item_embedding()
+RETURNS TRIGGER AS $$
+BEGIN
+ PERFORM util.queue_embeddings(NEW.id, 'item');
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Queue embedding on item update (only when name or description changes)
+CREATE OR REPLACE FUNCTION queue_item_embedding_on_update()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF (OLD.name IS DISTINCT FROM NEW.name OR OLD.description IS DISTINCT FROM NEW.description) THEN
+ NEW.embedding = NULL;
+ PERFORM util.queue_embeddings(NEW.id, 'item');
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Queue embedding on customer insert
+CREATE OR REPLACE FUNCTION queue_customer_embedding()
+RETURNS TRIGGER AS $$
+BEGIN
+ PERFORM util.queue_embeddings(NEW.id, 'customer');
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Queue embedding on customer update (only when name changes)
+CREATE OR REPLACE FUNCTION queue_customer_embedding_on_update()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF (OLD.name IS DISTINCT FROM NEW.name) THEN
+ NEW.embedding = NULL;
+ PERFORM util.queue_embeddings(NEW.id, 'customer');
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Queue embedding on supplier insert
+CREATE OR REPLACE FUNCTION queue_supplier_embedding()
+RETURNS TRIGGER AS $$
+BEGIN
+ PERFORM util.queue_embeddings(NEW.id, 'supplier');
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Queue embedding on supplier update (only when name changes)
+CREATE OR REPLACE FUNCTION queue_supplier_embedding_on_update()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF (OLD.name IS DISTINCT FROM NEW.name) THEN
+ NEW.embedding = NULL;
+ PERFORM util.queue_embeddings(NEW.id, 'supplier');
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- Attach triggers
+CREATE TRIGGER queue_item_embedding
+ BEFORE INSERT ON "item"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_item_embedding();
+
+CREATE TRIGGER queue_item_embedding_on_update
+ BEFORE UPDATE ON "item"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_item_embedding_on_update();
+
+CREATE TRIGGER queue_customer_embedding
+ BEFORE INSERT ON "customer"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_customer_embedding();
+
+CREATE TRIGGER queue_customer_embedding_on_update
+ BEFORE UPDATE ON "customer"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_customer_embedding_on_update();
+
+CREATE TRIGGER queue_supplier_embedding
+ BEFORE INSERT ON "supplier"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_supplier_embedding();
+
+CREATE TRIGGER queue_supplier_embedding_on_update
+ BEFORE UPDATE ON "supplier"
+ FOR EACH ROW
+ EXECUTE FUNCTION queue_supplier_embedding_on_update();
+
diff --git a/packages/jobs/trigger/cleanup.ts b/packages/jobs/trigger/cleanup.ts
index 415dae9d3d..a5a3c75ddc 100644
--- a/packages/jobs/trigger/cleanup.ts
+++ b/packages/jobs/trigger/cleanup.ts
@@ -88,8 +88,8 @@ export const cleanup = schedules.task({
.from("purchasingRfq")
.select("*")
.in("status", ["Draft", "Requested"])
- .not("dueDate", "is", null)
- .lt("dueDate", new Date().toISOString());
+ .not("expirationDate", "is", null)
+ .lt("expirationDate", new Date().toISOString());
if (expiredRfqs.error) {
console.error(