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.

- new fields to items import

Gaurav Bhatte3654bd84665
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index 8e4be22fe6..600467e310 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -748,6 +748,7 @@ export const supplierPartValidator = z.object({
supplierPartId: z.string().optional(),
supplierUnitOfMeasureCode: zfd.text(z.string().optional()),
minimumOrderQuantity: zfd.numeric(z.number().min(0)),
+ orderMultiple: zfd.numeric(z.number().min(1)).optional(),
conversionFactor: zfd.numeric(z.number().min(0)),
unitPrice: zfd.numeric(z.number().min(0).optional())
});
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
index 9da303cf6c..95440a6643 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
@@ -205,6 +205,11 @@ const SupplierPartForm = ({
label={t`Minimum Order Quantity`}
minValue={0}
/>
+ <Number
+ name="orderMultiple"
+ label={t`Order Multiple`}
+ minValue={1}
+ />
<CustomFormFields table="partSupplier" />
</div>
<PriceBreaks
diff --git a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningOrderDrawer.tsx b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningOrderDrawer.tsx
index 1d6d8369ce..0afadbe1e9 100644
--- a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningOrderDrawer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningOrderDrawer.tsx
@@ -419,6 +419,7 @@ export const PurchasingPlanningOrderDrawer = memo(
unitPrice: 0,
supplierUnitOfMeasureCode: "EA",
minimumOrderQuantity: 1,
+ orderMultiple: 1,
conversionFactor: 1
}}
unitOfMeasureCode={selectedItem.unitOfMeasureCode ?? ""}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
index a66bd94540..afd9e267d4 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
@@ -149,6 +149,7 @@ export default function EditConsumableSupplierRoute() {
unitPrice: supplierPart.unitPrice ?? 0,
supplierUnitOfMeasureCode: supplierPart.supplierUnitOfMeasureCode ?? "EA",
minimumOrderQuantity: supplierPart.minimumOrderQuantity ?? 1,
+ orderMultiple: supplierPart.orderMultiple ?? 1,
conversionFactor: supplierPart.conversionFactor ?? 1
};
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
index a229bdb8d9..6b92f0c0d3 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
@@ -93,6 +93,7 @@ export default function NewConsumableSupplierRoute() {
unitPrice: 0,
supplierUnitOfMeasureCode: "EA",
minimumOrderQuantity: 1,
+ orderMultiple: 1,
conversionFactor: 1
};
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
index 85fbd7b966..97122183fc 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
@@ -149,6 +149,7 @@ export default function EditMaterialSupplierRoute() {
unitPrice: supplierPart.unitPrice ?? 0,
supplierUnitOfMeasureCode: supplierPart.supplierUnitOfMeasureCode ?? "EA",
minimumOrderQuantity: supplierPart.minimumOrderQuantity ?? 1,
+ orderMultiple: supplierPart.orderMultiple ?? 1,
conversionFactor: supplierPart.conversionFactor ?? 1
};
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx
index dc7a8b0d26..d4cc49cfaa 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx
@@ -89,6 +89,7 @@ export default function NewMaterialSupplierRoute() {
unitPrice: 0,
supplierUnitOfMeasureCode: "EA",
minimumOrderQuantity: 1,
+ orderMultiple: 1,
conversionFactor: 1
};
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
index 7bdc5e97fa..d29ef898d8 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
@@ -149,6 +149,7 @@ export default function EditPartSupplierRoute() {
unitPrice: supplierPart.unitPrice ?? 0,
supplierUnitOfMeasureCode: supplierPart.supplierUnitOfMeasureCode ?? "EA",
minimumOrderQuantity: supplierPart.minimumOrderQuantity ?? 1,
+ orderMultiple: supplierPart.orderMultiple ?? 1,
conversionFactor: supplierPart.conversionFactor ?? 1
};
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx
index 4b082c23b3..e6ded1eb7c 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx
@@ -93,6 +93,7 @@ export default function NewPartSupplierRoute() {
unitPrice: 0,
supplierUnitOfMeasureCode: "EA",
minimumOrderQuantity: 1,
+ orderMultiple: 1,
conversionFactor: 1
};
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
index b4503dbbe6..eac1915460 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
@@ -149,6 +149,7 @@ export default function EditToolSupplierRoute() {
unitPrice: supplierPart.unitPrice ?? 0,
supplierUnitOfMeasureCode: supplierPart.supplierUnitOfMeasureCode ?? "EA",
minimumOrderQuantity: supplierPart.minimumOrderQuantity ?? 1,
+ orderMultiple: supplierPart.orderMultiple ?? 1,
conversionFactor: supplierPart.conversionFactor ?? 1
};
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx
index b4a15f6c8f..5fe3932a4f 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx
@@ -96,6 +96,7 @@ export default function NewToolSupplierRoute() {
unitPrice: 0,
supplierUnitOfMeasureCode: "EA",
minimumOrderQuantity: 1,
+ orderMultiple: 1,
conversionFactor: 1
};
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 3075aa669b..e24e1e37aa 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -1936,45 +1936,6 @@ export type Database = {
}
Relationships: []
}
- auditLog_NS5Wm1Sh7DdquQ12z8wUPd: {
- Row: {
- actorId: string | null
- createdAt: string
- diff: Json | null
- entityId: string
- entityType: string
- id: string
- metadata: Json | null
- operation: string
- recordId: string | null
- tableName: string
- }
- Insert: {
- actorId?: string | null
- createdAt?: string
- diff?: Json | null
- entityId: string
- entityType: string
- id?: string
- metadata?: Json | null
- operation: string
- recordId?: string | null
- tableName: string
- }
- Update: {
- actorId?: string | null
- createdAt?: string
- diff?: Json | null
- entityId?: string
- entityType?: string
- id?: string
- metadata?: Json | null
- operation?: string
- recordId?: string | null
- tableName?: string
- }
- Relationships: []
- }
auditLogArchive: {
Row: {
archivePath: string
@@ -2037,6 +1998,180 @@ export type Database = {
},
]
}
+ balloon: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ inspectionDocumentId: string
+ inspectionFeatureId: string
+ pageNumber: number
+ regionHeight: number
+ regionWidth: number
+ regionX: number
+ regionY: number
+ updatedAt: string | null
+ updatedBy: string | null
+ xCoordinate: number
+ yCoordinate: number
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ inspectionDocumentId: string
+ inspectionFeatureId: string
+ pageNumber: number
+ regionHeight: number
+ regionWidth: number
+ regionX: number
+ regionY: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ xCoordinate: number
+ yCoordinate: number
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ inspectionDocumentId?: string
+ inspectionFeatureId?: string
+ pageNumber?: number
+ regionHeight?: number
+ regionWidth?: number
+ regionX?: number
+ regionY?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ xCoordinate?: number
+ yCoordinate?: number
+ }
+ Relationships: [
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "balloon_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocument"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocuments"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_inspectionFeatureId_fkey"
+ columns: ["inspectionFeatureId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionFeature"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
batchProperty: {
Row: {
companyId: string
@@ -4518,7 +4653,7 @@ export type Database = {
logo: string | null
name: string
phone: string | null
- readableId: string | null
+ readableId: string
salesContactId: string | null
tags: string[] | null
taxPercent: number
@@ -4544,7 +4679,7 @@ export type Database = {
logo?: string | null
name: string
phone?: string | null
- readableId?: string | null
+ readableId: string
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -4570,7 +4705,7 @@ export type Database = {
logo?: string | null
name?: string
phone?: string | null
- readableId?: string | null
+ readableId?: string
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -12207,6 +12342,403 @@ export type Database = {
},
]
}
+ inspectionDocument: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ defaultPageHeight: number | null
+ defaultPageWidth: number | null
+ drawingNumber: string | null
+ fileName: string | null
+ id: string
+ pageCount: number | null
+ partId: string
+ storagePath: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ uploadedBy: string | null
+ version: number
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ defaultPageHeight?: number | null
+ defaultPageWidth?: number | null
+ drawingNumber?: string | null
+ fileName?: string | null
+ id?: string
+ pageCount?: number | null
+ partId: string
+ storagePath?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ uploadedBy?: string | null
+ version?: number
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ defaultPageHeight?: number | null
+ defaultPageWidth?: number | null
+ drawingNumber?: string | null
+ fileName?: string | null
+ id?: string
+ pageCount?: number | null
+ partId?: string
+ storagePath?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ uploadedBy?: string | null
+ version?: number
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ inspectionFeature: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ description: string | null
+ id: string
+ inspectionDocumentId: string
+ label: string
+ nominalValue: string | null
+ pageNumber: number
+ toleranceMinus: string | null
+ tolerancePlus: string | null
+ type: Database["public"]["Enums"]["procedureStepType"]
+ unit: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ description?: string | null
+ id?: string
+ inspectionDocumentId: string
+ label: string
+ nominalValue?: string | null
+ pageNumber: number
+ toleranceMinus?: string | null
+ tolerancePlus?: string | null
+ type?: Database["public"]["Enums"]["procedureStepType"]
+ unit?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ description?: string | null
+ id?: string
+ inspectionDocumentId?: string
+ label?: string
+ nominalValue?: string | null
+ pageNumber?: number
+ toleranceMinus?: string | null
+ tolerancePlus?: string | null
+ type?: Database["public"]["Enums"]["procedureStepType"]
+ unit?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocument"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocuments"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
integration: {
Row: {
id: string
@@ -37770,49 +38302,7 @@ export type Database = {
},
]
}
- searchIndex_NS5Wm1Sh7DdquQ12z8wUPd: {
- 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: []
- }
- searchIndex_X9wBhevBUjpWSP5uHVTCAe: {
+ searchIndex_6qJP4DpjAYZeV75SoNq112: {
Row: {
createdAt: string
description: string | null
@@ -40417,7 +40907,7 @@ export type Database = {
name: string
phone: string | null
purchasingContactId: string | null
- readableId: string | null
+ readableId: string
supplierStatus:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -40445,7 +40935,7 @@ export type Database = {
name: string
phone?: string | null
purchasingContactId?: string | null
- readableId?: string | null
+ readableId: string
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -40473,7 +40963,7 @@ export type Database = {
name?: string
phone?: string | null
purchasingContactId?: string | null
- readableId?: string | null
+ readableId?: string
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -41211,6 +41701,7 @@ export type Database = {
id: string
itemId: string
minimumOrderQuantity: number | null
+ orderMultiple: number | null
supplierId: string
supplierPartId: string | null
supplierUnitOfMeasureCode: string | null
@@ -41229,6 +41720,7 @@ export type Database = {
id?: string
itemId: string
minimumOrderQuantity?: number | null
+ orderMultiple?: number | null
supplierId: string
supplierPartId?: string | null
supplierUnitOfMeasureCode?: string | null
@@ -41247,6 +41739,7 @@ export type Database = {
id?: string
itemId?: string
minimumOrderQuantity?: number | null
+ orderMultiple?: number | null
supplierId?: string
supplierPartId?: string | null
supplierUnitOfMeasureCode?: string | null
@@ -50079,6 +50572,203 @@ export type Database = {
},
]
}
+ inspectionDocuments: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ defaultPageHeight: number | null
+ defaultPageWidth: number | null
+ drawingNumber: string | null
+ fileName: string | null
+ id: string | null
+ pageCount: number | null
+ partId: string | null
+ partReadableId: string | null
+ storagePath: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ uploadedBy: string | null
+ version: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
integrations: {
Row: {
active: boolean | null
@@ -54743,14 +55433,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -63844,6 +64534,20 @@ export type Database = {
Args: { p_item_id: string; p_receipt_id: string }
Returns: string
}
+ save_inspection_document_atomic: {
+ Args: {
+ p_balloons?: Json
+ p_company_id: string
+ p_default_page_height?: number
+ p_default_page_width?: number
+ p_features?: Json
+ p_inspection_document_id: string
+ p_page_count?: number
+ p_pdf_url?: string
+ p_user_id: string
+ }
+ Returns: Json
+ }
search_company_index: {
Args: {
p_company_id: string
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index b02328b42d..7d138aa1c0 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -590,6 +590,11 @@ type ItemPurchasingLeadTime = {
leadTime: string;
};
+type ItemPlanningOrderMultiple = {
+ itemId: string;
+ orderMultiple: string;
+};
+
async function writeSupplierPartLinks(
trx: typeof db,
links: SupplierPartImportLink[],
@@ -664,9 +669,10 @@ async function writeSupplierPartLinks(
// Set the item-level purchasing lead time (the "Purchasing" tab field).
// The itemReplenishment row is created by the create_item_related_records
-// AFTER INSERT trigger on item (default purchasingLeadTime 0), so within this
-// transaction the row already exists for every item we just upserted — we only
-// need to UPDATE it.
+// AFTER INSERT trigger on item (default leadTime 7, per migration
+// 20250610000433_demand-planning.sql which renamed purchasingLeadTime →
+// leadTime), so within this transaction the row already exists for every
+// item we just upserted — we only need to UPDATE it.
async function writeItemPurchasingLeadTimes(
trx: typeof db,
entries: ItemPurchasingLeadTime[],
@@ -681,7 +687,40 @@ async function writeItemPurchasingLeadTimes(
await trx
.updateTable("itemReplenishment")
.set({
- purchasingLeadTime: numericLeadTime,
+ leadTime: numericLeadTime,
+ updatedAt: now,
+ updatedBy: userId,
+ })
+ .where("itemId", "=", entry.itemId)
+ .where("companyId", "=", companyId)
+ .execute();
+ }
+}
+
+// Set the item-level planning order multiple. itemPlanning has one row per
+// (item, location) pair, all created by create_item_related_records at item
+// insert time (SELECT FROM location WHERE companyId = ...). A single UPDATE
+// scoped by itemId + companyId therefore covers every location row for that
+// item — matching the "order multiple is unique across every location"
+// expectation. Mirrors the same CSV value already written to
+// supplierPart.orderMultiple in writeSupplierPartLinks; both are intentionally
+// kept in sync at import time even though they're structurally distinct
+// fields (supplier case-pack vs MRP preferred multiple).
+async function writeItemPlanningOrderMultiples(
+ trx: typeof db,
+ entries: ItemPlanningOrderMultiple[],
+ companyId: string,
+ userId: string
+): Promise<void> {
+ if (entries.length === 0) return;
+ const now = new Date().toISOString();
+ for (const entry of entries) {
+ const numericOrderMultiple = Number.parseInt(entry.orderMultiple, 10);
+ if (Number.isNaN(numericOrderMultiple) || numericOrderMultiple < 1) continue;
+ await trx
+ .updateTable("itemPlanning")
+ .set({
+ orderMultiple: numericOrderMultiple,
updatedAt: now,
updatedBy: userId,
})
@@ -1284,6 +1323,12 @@ serve(async (req: Request) => {
// known (immediately for updates, post-insert for new items).
const leadTimeForInserts: Array<string | undefined> = [];
const purchasingLeadTimes: ItemPurchasingLeadTime[] = [];
+ // Same shape for the item-level planning order multiple. CSV's
+ // "Order Multiple" column populates both supplierPart.orderMultiple
+ // (per-supplier case-pack) and itemPlanning.orderMultiple
+ // (per-(item, location) MRP setting) at import time.
+ const orderMultipleForInserts: Array<string | undefined> = [];
+ const itemPlanningOrderMultiples: ItemPlanningOrderMultiple[] = [];
const itemValidator = z.object({
id: z.string(),
@@ -1371,6 +1416,13 @@ serve(async (req: Request) => {
});
}
+ if (record.orderMultiple) {
+ itemPlanningOrderMultiples.push({
+ itemId: existingEntityId,
+ orderMultiple: record.orderMultiple,
+ });
+ }
+
if (table === "material") {
const material = materialValidator.safeParse(record);
if (material.success) {
@@ -1426,6 +1478,7 @@ serve(async (req: Request) => {
unitPrice: record.unitPrice,
});
leadTimeForInserts.push(record.leadTime);
+ orderMultipleForInserts.push(record.orderMultiple);
if (table === "material") {
const material = materialValidator.safeParse(record);
@@ -1549,6 +1602,13 @@ serve(async (req: Request) => {
leadTime,
});
}
+ const orderMultiple = orderMultipleForInserts[i];
+ if (orderMultiple && insertedItems[i].id) {
+ itemPlanningOrderMultiples.push({
+ itemId: insertedItems[i].id!,
+ orderMultiple,
+ });
+ }
}
}
@@ -1625,6 +1685,13 @@ serve(async (req: Request) => {
companyId,
userId
);
+
+ await writeItemPlanningOrderMultiples(
+ trx,
+ itemPlanningOrderMultiples,
+ companyId,
+ userId
+ );
});
break;
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 3075aa669b..e24e1e37aa 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -1936,45 +1936,6 @@ export type Database = {
}
Relationships: []
}
- auditLog_NS5Wm1Sh7DdquQ12z8wUPd: {
- Row: {
- actorId: string | null
- createdAt: string
- diff: Json | null
- entityId: string
- entityType: string
- id: string
- metadata: Json | null
- operation: string
- recordId: string | null
- tableName: string
- }
- Insert: {
- actorId?: string | null
- createdAt?: string
- diff?: Json | null
- entityId: string
- entityType: string
- id?: string
- metadata?: Json | null
- operation: string
- recordId?: string | null
- tableName: string
- }
- Update: {
- actorId?: string | null
- createdAt?: string
- diff?: Json | null
- entityId?: string
- entityType?: string
- id?: string
- metadata?: Json | null
- operation?: string
- recordId?: string | null
- tableName?: string
- }
- Relationships: []
- }
auditLogArchive: {
Row: {
archivePath: string
@@ -2037,6 +1998,180 @@ export type Database = {
},
]
}
+ balloon: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ id: string
+ inspectionDocumentId: string
+ inspectionFeatureId: string
+ pageNumber: number
+ regionHeight: number
+ regionWidth: number
+ regionX: number
+ regionY: number
+ updatedAt: string | null
+ updatedBy: string | null
+ xCoordinate: number
+ yCoordinate: number
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ id?: string
+ inspectionDocumentId: string
+ inspectionFeatureId: string
+ pageNumber: number
+ regionHeight: number
+ regionWidth: number
+ regionX: number
+ regionY: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ xCoordinate: number
+ yCoordinate: number
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ id?: string
+ inspectionDocumentId?: string
+ inspectionFeatureId?: string
+ pageNumber?: number
+ regionHeight?: number
+ regionWidth?: number
+ regionX?: number
+ regionY?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ xCoordinate?: number
+ yCoordinate?: number
+ }
+ Relationships: [
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "balloon_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "balloon_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocument"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocuments"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_inspectionFeatureId_fkey"
+ columns: ["inspectionFeatureId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionFeature"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "balloon_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
batchProperty: {
Row: {
companyId: string
@@ -4518,7 +4653,7 @@ export type Database = {
logo: string | null
name: string
phone: string | null
- readableId: string | null
+ readableId: string
salesContactId: string | null
tags: string[] | null
taxPercent: number
@@ -4544,7 +4679,7 @@ export type Database = {
logo?: string | null
name: string
phone?: string | null
- readableId?: string | null
+ readableId: string
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -4570,7 +4705,7 @@ export type Database = {
logo?: string | null
name?: string
phone?: string | null
- readableId?: string | null
+ readableId?: string
salesContactId?: string | null
tags?: string[] | null
taxPercent?: number
@@ -12207,6 +12342,403 @@ export type Database = {
},
]
}
+ inspectionDocument: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ defaultPageHeight: number | null
+ defaultPageWidth: number | null
+ drawingNumber: string | null
+ fileName: string | null
+ id: string
+ pageCount: number | null
+ partId: string
+ storagePath: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ uploadedBy: string | null
+ version: number
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ defaultPageHeight?: number | null
+ defaultPageWidth?: number | null
+ drawingNumber?: string | null
+ fileName?: string | null
+ id?: string
+ pageCount?: number | null
+ partId: string
+ storagePath?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ uploadedBy?: string | null
+ version?: number
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ defaultPageHeight?: number | null
+ defaultPageWidth?: number | null
+ drawingNumber?: string | null
+ fileName?: string | null
+ id?: string
+ pageCount?: number | null
+ partId?: string
+ storagePath?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ uploadedBy?: string | null
+ version?: number
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ inspectionFeature: {
+ Row: {
+ companyId: string
+ createdAt: string
+ createdBy: string
+ description: string | null
+ id: string
+ inspectionDocumentId: string
+ label: string
+ nominalValue: string | null
+ pageNumber: number
+ toleranceMinus: string | null
+ tolerancePlus: string | null
+ type: Database["public"]["Enums"]["procedureStepType"]
+ unit: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ companyId: string
+ createdAt?: string
+ createdBy: string
+ description?: string | null
+ id?: string
+ inspectionDocumentId: string
+ label: string
+ nominalValue?: string | null
+ pageNumber: number
+ toleranceMinus?: string | null
+ tolerancePlus?: string | null
+ type?: Database["public"]["Enums"]["procedureStepType"]
+ unit?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ companyId?: string
+ createdAt?: string
+ createdBy?: string
+ description?: string | null
+ id?: string
+ inspectionDocumentId?: string
+ label?: string
+ nominalValue?: string | null
+ pageNumber?: number
+ toleranceMinus?: string | null
+ tolerancePlus?: string | null
+ type?: Database["public"]["Enums"]["procedureStepType"]
+ unit?: string | null
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocument"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_document_company_fkey"
+ columns: ["inspectionDocumentId", "companyId"]
+ isOneToOne: false
+ referencedRelation: "inspectionDocuments"
+ referencedColumns: ["id", "companyId"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionFeature_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
integration: {
Row: {
id: string
@@ -37770,49 +38302,7 @@ export type Database = {
},
]
}
- searchIndex_NS5Wm1Sh7DdquQ12z8wUPd: {
- 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: []
- }
- searchIndex_X9wBhevBUjpWSP5uHVTCAe: {
+ searchIndex_6qJP4DpjAYZeV75SoNq112: {
Row: {
createdAt: string
description: string | null
@@ -40417,7 +40907,7 @@ export type Database = {
name: string
phone: string | null
purchasingContactId: string | null
- readableId: string | null
+ readableId: string
supplierStatus:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -40445,7 +40935,7 @@ export type Database = {
name: string
phone?: string | null
purchasingContactId?: string | null
- readableId?: string | null
+ readableId: string
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -40473,7 +40963,7 @@ export type Database = {
name?: string
phone?: string | null
purchasingContactId?: string | null
- readableId?: string | null
+ readableId?: string
supplierStatus?:
| Database["public"]["Enums"]["supplierStatusType"]
| null
@@ -41211,6 +41701,7 @@ export type Database = {
id: string
itemId: string
minimumOrderQuantity: number | null
+ orderMultiple: number | null
supplierId: string
supplierPartId: string | null
supplierUnitOfMeasureCode: string | null
@@ -41229,6 +41720,7 @@ export type Database = {
id?: string
itemId: string
minimumOrderQuantity?: number | null
+ orderMultiple?: number | null
supplierId: string
supplierPartId?: string | null
supplierUnitOfMeasureCode?: string | null
@@ -41247,6 +41739,7 @@ export type Database = {
id?: string
itemId?: string
minimumOrderQuantity?: number | null
+ orderMultiple?: number | null
supplierId?: string
supplierPartId?: string | null
supplierUnitOfMeasureCode?: string | null
@@ -50079,6 +50572,203 @@ export type Database = {
},
]
}
+ inspectionDocuments: {
+ Row: {
+ companyId: string | null
+ createdAt: string | null
+ createdBy: string | null
+ defaultPageHeight: number | null
+ defaultPageWidth: number | null
+ drawingNumber: string | null
+ fileName: string | null
+ id: string | null
+ pageCount: number | null
+ partId: string | null
+ partReadableId: string | null
+ storagePath: string | null
+ updatedAt: string | null
+ updatedBy: string | null
+ uploadedBy: string | null
+ version: number | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "consumables"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "materials"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "parts"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "services"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_partId_fkey"
+ columns: ["partId"]
+ isOneToOne: false
+ referencedRelation: "tools"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "inspectionDocument_uploadedBy_fkey"
+ columns: ["uploadedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
integrations: {
Row: {
active: boolean | null
@@ -54743,14 +55433,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -63844,6 +64534,20 @@ export type Database = {
Args: { p_item_id: string; p_receipt_id: string }
Returns: string
}
+ save_inspection_document_atomic: {
+ Args: {
+ p_balloons?: Json
+ p_company_id: string
+ p_default_page_height?: number
+ p_default_page_width?: number
+ p_features?: Json
+ p_inspection_document_id: string
+ p_page_count?: number
+ p_pdf_url?: string
+ p_user_id: string
+ }
+ Returns: Json
+ }
search_company_index: {
Args: {
p_company_id: string