Skip to content

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

feat: tables for quotes

Brad Barbinb9cf935e1ea6
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 5e56fbc23b..f6072b8d45 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -12424,14 +12424,16 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ estimatorId: string | null
expirationDate: string | null
id: string
locationId: string | null
- name: string | null
- notes: string | null
+ notes: Json | null
quoteDate: string | null
quoteId: string
revisionId: number
+ salesPersonId: string | null
+ salesRfqId: string | null
status: Database["public"]["Enums"]["quoteStatus"]
updatedAt: string | null
updatedBy: string | null
@@ -12446,14 +12448,16 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
- name?: string | null
- notes?: string | null
+ notes?: Json | null
quoteDate?: string | null
quoteId: string
revisionId?: number
+ salesPersonId?: string | null
+ salesRfqId?: string | null
status?: Database["public"]["Enums"]["quoteStatus"]
updatedAt?: string | null
updatedBy?: string | null
@@ -12468,14 +12472,16 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
- name?: string | null
- notes?: string | null
+ notes?: Json | null
quoteDate?: string | null
quoteId?: string
revisionId?: number
+ salesPersonId?: string | null
+ salesRfqId?: string | null
status?: Database["public"]["Enums"]["quoteStatus"]
updatedAt?: string | null
updatedBy?: string | null
@@ -12615,276 +12621,147 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- quoteAssembly: {
- Row: {
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- itemId: string
- parentAssemblyId: string | null
- quantityPerParent: number
- quoteId: string
- quoteLineId: string
- unitOfMeasureCode: string | null
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- id?: string
- itemId: string
- parentAssemblyId?: string | null
- quantityPerParent?: number
- quoteId: string
- quoteLineId: string
- unitOfMeasureCode?: string | null
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- id?: string
- itemId?: string
- parentAssemblyId?: string | null
- quantityPerParent?: number
- quoteId?: string
- quoteLineId?: string
- unitOfMeasureCode?: string | null
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteAssembly_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "item"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["itemId"]
- },
- {
- foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
- columns: ["parentAssemblyId"]
- isOneToOne: false
- referencedRelation: "quoteAssembly"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteLineId_fkey"
- columns: ["quoteLineId"]
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
isOneToOne: false
- referencedRelation: "quoteLine"
+ referencedRelation: "salesRfq"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_quoteLineId_fkey"
- columns: ["quoteLineId"]
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
isOneToOne: false
- referencedRelation: "quoteLines"
+ referencedRelation: "salesRfqs"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
- isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
- },
- {
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -12972,6 +12849,7 @@ export type Database = {
customerPartRevision: string | null
customFields: Json | null
description: string
+ estimatorId: string | null
id: string
itemId: string
itemReadableId: string | null
@@ -12990,6 +12868,7 @@ export type Database = {
customerPartRevision?: string | null
customFields?: Json | null
description: string
+ estimatorId?: string | null
id?: string
itemId: string
itemReadableId?: string | null
@@ -13008,6 +12887,7 @@ export type Database = {
customerPartRevision?: string | null
customFields?: Json | null
description?: string
+ estimatorId?: string | null
id?: string
itemId?: string
itemReadableId?: string | null
@@ -13083,6 +12963,41 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quoteLine_itemId_fkey"
columns: ["itemId"]
@@ -13119,42 +13034,196 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
+ foreignKeyName: "quoteLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ quoteLinePrice: {
+ Row: {
+ createdAt: string
+ createdBy: string
+ discountPercent: number
+ extendedPrice: number
+ id: string
+ leadTime: number
+ markupPercent: number
+ quantity: number
+ quoteId: string
+ quoteLineId: string
+ unitCost: number
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ createdAt?: string
+ createdBy: string
+ discountPercent?: number
+ extendedPrice?: number
+ id?: string
+ leadTime?: number
+ markupPercent?: number
+ quantity?: number
+ quoteId: string
+ quoteLineId: string
+ unitCost?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ createdAt?: string
+ createdBy?: string
+ discountPercent?: number
+ extendedPrice?: number
+ id?: string
+ leadTime?: number
+ markupPercent?: number
+ quantity?: number
+ quoteId?: string
+ quoteLineId?: string
+ unitCost?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quote"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quoteCustomerDetails"
+ referencedColumns: ["quoteId"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quotes"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ columns: ["quoteLineId"]
+ isOneToOne: false
+ referencedRelation: "quoteLine"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ columns: ["quoteLineId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "quoteLines"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -13162,153 +13231,212 @@ export type Database = {
},
]
}
- quoteLinePrice: {
+ quoteMakeMethod: {
Row: {
+ companyId: string
createdAt: string
createdBy: string
- discountPercent: number
- extendedPrice: number
+ customFields: Json | null
+ description: string | null
id: string
- leadTime: number
- markupPercent: number
- quantity: number
+ itemId: string
+ parentMaterialId: string | null
+ quantityPerParent: number
quoteId: string
quoteLineId: string
- unitCost: number
+ unitOfMeasureCode: string | null
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ companyId: string
createdAt?: string
createdBy: string
- discountPercent?: number
- extendedPrice?: number
+ customFields?: Json | null
+ description?: string | null
id?: string
- leadTime?: number
- markupPercent?: number
- quantity?: number
+ itemId: string
+ parentMaterialId?: string | null
+ quantityPerParent?: number
quoteId: string
quoteLineId: string
- unitCost?: number
+ unitOfMeasureCode?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ companyId?: string
createdAt?: string
createdBy?: string
- discountPercent?: number
- extendedPrice?: number
+ customFields?: Json | null
+ description?: string | null
id?: string
- leadTime?: number
- markupPercent?: number
- quantity?: number
+ itemId?: string
+ parentMaterialId?: string | null
+ quantityPerParent?: number
quoteId?: string
quoteLineId?: string
- unitCost?: number
+ unitOfMeasureCode?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_parentMaterialId_fkey"
+ columns: ["parentMaterialId"]
+ isOneToOne: false
+ referencedRelation: "quoteMaterial"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quote"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quoteCustomerDetails"
referencedColumns: ["quoteId"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quotes"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteLineId_fkey"
columns: ["quoteLineId"]
isOneToOne: false
referencedRelation: "quoteLine"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteLineId_fkey"
columns: ["quoteLineId"]
isOneToOne: false
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -13328,7 +13456,8 @@ export type Database = {
quantity: number
quoteId: string
quoteLineId: string
- quoteOperationId: string
+ quoteMakeMethodId: string | null
+ quoteOperationId: string | null
unitCost: number
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -13345,7 +13474,8 @@ export type Database = {
quantity?: number
quoteId: string
quoteLineId: string
- quoteOperationId: string
+ quoteMakeMethodId?: string | null
+ quoteOperationId?: string | null
unitCost?: number
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -13362,7 +13492,8 @@ export type Database = {
quantity?: number
quoteId?: string
quoteLineId?: string
- quoteOperationId?: string
+ quoteMakeMethodId?: string | null
+ quoteOperationId?: string | null
unitCost?: number
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -13481,6 +13612,13 @@ export type Database = {
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteMaterial_quoteMakeMethodId_fkey"
+ columns: ["quoteMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteMakeMethod"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quoteMaterial_quoteOperationId_fkey"
columns: ["quoteOperationId"]
@@ -13544,9 +13682,9 @@ export type Database = {
laborRate: number
overheadRate: number
productionStandard: number
- quoteAssemblyId: string | null
quoteId: string
quoteLineId: string
+ quoteMakeMethodId: string | null
quotingRate: number
setupHours: number
standardFactor: Database["public"]["Enums"]["factor"]
@@ -13565,9 +13703,9 @@ export type Database = {
laborRate?: number
overheadRate?: number
productionStandard?: number
- quoteAssemblyId?: string | null
quoteId: string
quoteLineId: string
+ quoteMakeMethodId?: string | null
quotingRate?: number
setupHours?: number
standardFactor?: Database["public"]["Enums"]["factor"]
@@ -13586,9 +13724,9 @@ export type Database = {
laborRate?: number
overheadRate?: number
productionStandard?: number
- quoteAssemblyId?: string | null
quoteId?: string
quoteLineId?: string
+ quoteMakeMethodId?: string | null
quotingRate?: number
setupHours?: number
standardFactor?: Database["public"]["Enums"]["factor"]
@@ -13667,13 +13805,6 @@ export type Database = {
referencedRelation: "equipmentType"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "quoteOperation_quoteAssemblyId_fkey"
- columns: ["quoteAssemblyId"]
- isOneToOne: false
- referencedRelation: "quoteAssembly"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "quoteOperation_quoteId_fkey"
columns: ["quoteId"]
@@ -13709,6 +13840,13 @@ export type Database = {
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteOperation_quoteMakeMethodId_fkey"
+ columns: ["quoteMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteMakeMethod"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quoteOperation_updatedBy_fkey"
columns: ["updatedBy"]
@@ -14245,7 +14383,6 @@ export type Database = {
id: string
notes: string | null
orderDate: string
- quoteId: string | null
revisionId: number
salesOrderId: string
status: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14268,7 +14405,6 @@ export type Database = {
id?: string
notes?: string | null
orderDate?: string
- quoteId?: string | null
revisionId?: number
salesOrderId: string
status?: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14291,7 +14427,6 @@ export type Database = {
id?: string
notes?: string | null
orderDate?: string
- quoteId?: string | null
revisionId?: number
salesOrderId?: string
status?: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14474,27 +14609,6 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "salesOrder_updatedBy_fkey"
columns: ["updatedBy"]
@@ -22769,6 +22883,7 @@ export type Database = {
customerPartRevision: string | null
customFields: Json | null
description: string | null
+ estimatorId: string | null
id: string | null
itemId: string | null
itemReadableId: string | null
@@ -22850,6 +22965,41 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quoteLine_itemId_fkey"
columns: ["itemId"]
@@ -22940,17 +23090,19 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ estimatorId: string | null
expirationDate: string | null
favorite: boolean | null
id: string | null
itemIds: string[] | null
locationId: string | null
locationName: string | null
- name: string | null
- notes: string | null
+ notes: Json | null
quoteDate: string | null
quoteId: string | null
revisionId: number | null
+ salesPersonId: string | null
+ salesRfqId: string | null
status: Database["public"]["Enums"]["quoteStatus"] | null
updatedAt: string | null
updatedBy: string | null
@@ -23089,6 +23241,41 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
@@ -23117,6 +23304,55 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["locationId"]
},
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfq"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfqs"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
@@ -23626,7 +23862,6 @@ export type Database = {
notes: string | null
orderDate: string | null
paymentTermName: string | null
- quoteId: string | null
receiptPromisedDate: string | null
receiptRequestedDate: string | null
revisionId: number | null
@@ -23815,27 +24050,6 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "salesOrder_updatedBy_fkey"
columns: ["updatedBy"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 5e56fbc23b..f6072b8d45 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -12424,14 +12424,16 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ estimatorId: string | null
expirationDate: string | null
id: string
locationId: string | null
- name: string | null
- notes: string | null
+ notes: Json | null
quoteDate: string | null
quoteId: string
revisionId: number
+ salesPersonId: string | null
+ salesRfqId: string | null
status: Database["public"]["Enums"]["quoteStatus"]
updatedAt: string | null
updatedBy: string | null
@@ -12446,14 +12448,16 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
- name?: string | null
- notes?: string | null
+ notes?: Json | null
quoteDate?: string | null
quoteId: string
revisionId?: number
+ salesPersonId?: string | null
+ salesRfqId?: string | null
status?: Database["public"]["Enums"]["quoteStatus"]
updatedAt?: string | null
updatedBy?: string | null
@@ -12468,14 +12472,16 @@ export type Database = {
customerLocationId?: string | null
customerReference?: string | null
customFields?: Json | null
+ estimatorId?: string | null
expirationDate?: string | null
id?: string
locationId?: string | null
- name?: string | null
- notes?: string | null
+ notes?: Json | null
quoteDate?: string | null
quoteId?: string
revisionId?: number
+ salesPersonId?: string | null
+ salesRfqId?: string | null
status?: Database["public"]["Enums"]["quoteStatus"]
updatedAt?: string | null
updatedBy?: string | null
@@ -12615,276 +12621,147 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "location"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "purchaseOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_locationId_fkey"
- columns: ["locationId"]
- isOneToOne: false
- referencedRelation: "salesOrders"
- referencedColumns: ["locationId"]
- },
- {
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quote_updatedBy_fkey"
- columns: ["updatedBy"]
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
- ]
- }
- quoteAssembly: {
- Row: {
- companyId: string
- createdAt: string
- createdBy: string
- customFields: Json | null
- description: string | null
- id: string
- itemId: string
- parentAssemblyId: string | null
- quantityPerParent: number
- quoteId: string
- quoteLineId: string
- unitOfMeasureCode: string | null
- updatedAt: string | null
- updatedBy: string | null
- }
- Insert: {
- companyId: string
- createdAt?: string
- createdBy: string
- customFields?: Json | null
- description?: string | null
- id?: string
- itemId: string
- parentAssemblyId?: string | null
- quantityPerParent?: number
- quoteId: string
- quoteLineId: string
- unitOfMeasureCode?: string | null
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Update: {
- companyId?: string
- createdAt?: string
- createdBy?: string
- customFields?: Json | null
- description?: string | null
- id?: string
- itemId?: string
- parentAssemblyId?: string | null
- quantityPerParent?: number
- quoteId?: string
- quoteLineId?: string
- unitOfMeasureCode?: string | null
- updatedAt?: string | null
- updatedBy?: string | null
- }
- Relationships: [
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "companies"
- referencedColumns: ["id"]
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "company"
+ referencedRelation: "location"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "customFieldTables"
- referencedColumns: ["companyId"]
+ referencedRelation: "purchaseOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_companyId_fkey"
- columns: ["companyId"]
+ foreignKeyName: "quote_locationId_fkey"
+ columns: ["locationId"]
isOneToOne: false
- referencedRelation: "integrations"
- referencedColumns: ["companyId"]
+ referencedRelation: "salesOrders"
+ referencedColumns: ["locationId"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_createdBy_fkey"
- columns: ["createdBy"]
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteAssembly_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "item"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_itemId_fkey"
- columns: ["itemId"]
- isOneToOne: false
- referencedRelation: "itemQuantities"
- referencedColumns: ["itemId"]
- },
- {
- foreignKeyName: "quoteAssembly_parentAssemblyId_fkey"
- columns: ["parentAssemblyId"]
- isOneToOne: false
- referencedRelation: "quoteAssembly"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "quoteAssembly_quoteLineId_fkey"
- columns: ["quoteLineId"]
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
isOneToOne: false
- referencedRelation: "quoteLine"
+ referencedRelation: "salesRfq"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_quoteLineId_fkey"
- columns: ["quoteLineId"]
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
isOneToOne: false
- referencedRelation: "quoteLines"
+ referencedRelation: "salesRfqs"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
- isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
- },
- {
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteAssembly_updatedBy_fkey"
+ foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -12972,6 +12849,7 @@ export type Database = {
customerPartRevision: string | null
customFields: Json | null
description: string
+ estimatorId: string | null
id: string
itemId: string
itemReadableId: string | null
@@ -12990,6 +12868,7 @@ export type Database = {
customerPartRevision?: string | null
customFields?: Json | null
description: string
+ estimatorId?: string | null
id?: string
itemId: string
itemReadableId?: string | null
@@ -13008,6 +12887,7 @@ export type Database = {
customerPartRevision?: string | null
customFields?: Json | null
description?: string
+ estimatorId?: string | null
id?: string
itemId?: string
itemReadableId?: string | null
@@ -13083,6 +12963,41 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quoteLine_itemId_fkey"
columns: ["itemId"]
@@ -13119,42 +13034,196 @@ export type Database = {
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_unitOfMeasureCode_fkey"
- columns: ["unitOfMeasureCode", "companyId"]
+ foreignKeyName: "quoteLine_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_updatedBy_fkey"
+ columns: ["updatedBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ ]
+ }
+ quoteLinePrice: {
+ Row: {
+ createdAt: string
+ createdBy: string
+ discountPercent: number
+ extendedPrice: number
+ id: string
+ leadTime: number
+ markupPercent: number
+ quantity: number
+ quoteId: string
+ quoteLineId: string
+ unitCost: number
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ createdAt?: string
+ createdBy: string
+ discountPercent?: number
+ extendedPrice?: number
+ id?: string
+ leadTime?: number
+ markupPercent?: number
+ quantity?: number
+ quoteId: string
+ quoteLineId: string
+ unitCost?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ createdAt?: string
+ createdBy?: string
+ discountPercent?: number
+ extendedPrice?: number
+ id?: string
+ leadTime?: number
+ markupPercent?: number
+ quantity?: number
+ quoteId?: string
+ quoteLineId?: string
+ unitCost?: number
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ columns: ["createdBy"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quote"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quoteCustomerDetails"
+ referencedColumns: ["quoteId"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ columns: ["quoteId"]
+ isOneToOne: false
+ referencedRelation: "quotes"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ columns: ["quoteLineId"]
+ isOneToOne: false
+ referencedRelation: "quoteLine"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ columns: ["quoteLineId"]
isOneToOne: false
- referencedRelation: "unitOfMeasure"
- referencedColumns: ["code", "companyId"]
+ referencedRelation: "quoteLines"
+ referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLine_updatedBy_fkey"
+ foreignKeyName: "quoteLinePrice_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -13162,153 +13231,212 @@ export type Database = {
},
]
}
- quoteLinePrice: {
+ quoteMakeMethod: {
Row: {
+ companyId: string
createdAt: string
createdBy: string
- discountPercent: number
- extendedPrice: number
+ customFields: Json | null
+ description: string | null
id: string
- leadTime: number
- markupPercent: number
- quantity: number
+ itemId: string
+ parentMaterialId: string | null
+ quantityPerParent: number
quoteId: string
quoteLineId: string
- unitCost: number
+ unitOfMeasureCode: string | null
updatedAt: string | null
updatedBy: string | null
}
Insert: {
+ companyId: string
createdAt?: string
createdBy: string
- discountPercent?: number
- extendedPrice?: number
+ customFields?: Json | null
+ description?: string | null
id?: string
- leadTime?: number
- markupPercent?: number
- quantity?: number
+ itemId: string
+ parentMaterialId?: string | null
+ quantityPerParent?: number
quoteId: string
quoteLineId: string
- unitCost?: number
+ unitOfMeasureCode?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Update: {
+ companyId?: string
createdAt?: string
createdBy?: string
- discountPercent?: number
- extendedPrice?: number
+ customFields?: Json | null
+ description?: string | null
id?: string
- leadTime?: number
- markupPercent?: number
- quantity?: number
+ itemId?: string
+ parentMaterialId?: string | null
+ quantityPerParent?: number
quoteId?: string
quoteLineId?: string
- unitCost?: number
+ unitOfMeasureCode?: string | null
updatedAt?: string | null
updatedBy?: string | null
}
Relationships: [
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "companies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "company"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "customFieldTables"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_companyId_fkey"
+ columns: ["companyId"]
+ isOneToOne: false
+ referencedRelation: "integrations"
+ referencedColumns: ["companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_createdBy_fkey"
+ foreignKeyName: "quoteMakeMethod_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_parentMaterialId_fkey"
+ columns: ["parentMaterialId"]
+ isOneToOne: false
+ referencedRelation: "quoteMaterial"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quote"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quoteCustomerDetails"
referencedColumns: ["quoteId"]
},
{
- foreignKeyName: "quoteLinePrice_quoteId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteId_fkey"
columns: ["quoteId"]
isOneToOne: false
referencedRelation: "quotes"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteLineId_fkey"
columns: ["quoteLineId"]
isOneToOne: false
referencedRelation: "quoteLine"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_quoteLineId_fkey"
+ foreignKeyName: "quoteMakeMethod_quoteLineId_fkey"
columns: ["quoteLineId"]
isOneToOne: false
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode", "companyId"]
+ isOneToOne: false
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code", "companyId"]
+ },
+ {
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "quoteLinePrice_updatedBy_fkey"
+ foreignKeyName: "quoteMakeMethod_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -13328,7 +13456,8 @@ export type Database = {
quantity: number
quoteId: string
quoteLineId: string
- quoteOperationId: string
+ quoteMakeMethodId: string | null
+ quoteOperationId: string | null
unitCost: number
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -13345,7 +13474,8 @@ export type Database = {
quantity?: number
quoteId: string
quoteLineId: string
- quoteOperationId: string
+ quoteMakeMethodId?: string | null
+ quoteOperationId?: string | null
unitCost?: number
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -13362,7 +13492,8 @@ export type Database = {
quantity?: number
quoteId?: string
quoteLineId?: string
- quoteOperationId?: string
+ quoteMakeMethodId?: string | null
+ quoteOperationId?: string | null
unitCost?: number
unitOfMeasureCode?: string | null
updatedAt?: string | null
@@ -13481,6 +13612,13 @@ export type Database = {
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteMaterial_quoteMakeMethodId_fkey"
+ columns: ["quoteMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteMakeMethod"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quoteMaterial_quoteOperationId_fkey"
columns: ["quoteOperationId"]
@@ -13544,9 +13682,9 @@ export type Database = {
laborRate: number
overheadRate: number
productionStandard: number
- quoteAssemblyId: string | null
quoteId: string
quoteLineId: string
+ quoteMakeMethodId: string | null
quotingRate: number
setupHours: number
standardFactor: Database["public"]["Enums"]["factor"]
@@ -13565,9 +13703,9 @@ export type Database = {
laborRate?: number
overheadRate?: number
productionStandard?: number
- quoteAssemblyId?: string | null
quoteId: string
quoteLineId: string
+ quoteMakeMethodId?: string | null
quotingRate?: number
setupHours?: number
standardFactor?: Database["public"]["Enums"]["factor"]
@@ -13586,9 +13724,9 @@ export type Database = {
laborRate?: number
overheadRate?: number
productionStandard?: number
- quoteAssemblyId?: string | null
quoteId?: string
quoteLineId?: string
+ quoteMakeMethodId?: string | null
quotingRate?: number
setupHours?: number
standardFactor?: Database["public"]["Enums"]["factor"]
@@ -13667,13 +13805,6 @@ export type Database = {
referencedRelation: "equipmentType"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "quoteOperation_quoteAssemblyId_fkey"
- columns: ["quoteAssemblyId"]
- isOneToOne: false
- referencedRelation: "quoteAssembly"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "quoteOperation_quoteId_fkey"
columns: ["quoteId"]
@@ -13709,6 +13840,13 @@ export type Database = {
referencedRelation: "quoteLines"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quoteOperation_quoteMakeMethodId_fkey"
+ columns: ["quoteMakeMethodId"]
+ isOneToOne: false
+ referencedRelation: "quoteMakeMethod"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quoteOperation_updatedBy_fkey"
columns: ["updatedBy"]
@@ -14245,7 +14383,6 @@ export type Database = {
id: string
notes: string | null
orderDate: string
- quoteId: string | null
revisionId: number
salesOrderId: string
status: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14268,7 +14405,6 @@ export type Database = {
id?: string
notes?: string | null
orderDate?: string
- quoteId?: string | null
revisionId?: number
salesOrderId: string
status?: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14291,7 +14427,6 @@ export type Database = {
id?: string
notes?: string | null
orderDate?: string
- quoteId?: string | null
revisionId?: number
salesOrderId?: string
status?: Database["public"]["Enums"]["salesOrderStatus"]
@@ -14474,27 +14609,6 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "salesOrder_updatedBy_fkey"
columns: ["updatedBy"]
@@ -22769,6 +22883,7 @@ export type Database = {
customerPartRevision: string | null
customFields: Json | null
description: string | null
+ estimatorId: string | null
id: string | null
itemId: string | null
itemReadableId: string | null
@@ -22850,6 +22965,41 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quoteLine_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quoteLine_itemId_fkey"
columns: ["itemId"]
@@ -22940,17 +23090,19 @@ export type Database = {
customerLocationId: string | null
customerReference: string | null
customFields: Json | null
+ estimatorId: string | null
expirationDate: string | null
favorite: boolean | null
id: string | null
itemIds: string[] | null
locationId: string | null
locationName: string | null
- name: string | null
- notes: string | null
+ notes: Json | null
quoteDate: string | null
quoteId: string | null
revisionId: number | null
+ salesPersonId: string | null
+ salesRfqId: string | null
status: Database["public"]["Enums"]["quoteStatus"] | null
updatedAt: string | null
updatedBy: string | null
@@ -23089,6 +23241,41 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_estimatorId_fkey"
+ columns: ["estimatorId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
{
foreignKeyName: "quote_locationId_fkey"
columns: ["locationId"]
@@ -23117,6 +23304,55 @@ export type Database = {
referencedRelation: "salesOrders"
referencedColumns: ["locationId"]
},
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "user"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employeeSummary"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employees"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "employeesAcrossCompanies"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesPersonId_fkey"
+ columns: ["salesPersonId"]
+ isOneToOne: false
+ referencedRelation: "userDefaults"
+ referencedColumns: ["userId"]
+ },
+ {
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfq"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "quote_salesRfqId_fkey"
+ columns: ["salesRfqId"]
+ isOneToOne: false
+ referencedRelation: "salesRfqs"
+ referencedColumns: ["id"]
+ },
{
foreignKeyName: "quote_updatedBy_fkey"
columns: ["updatedBy"]
@@ -23626,7 +23862,6 @@ export type Database = {
notes: string | null
orderDate: string | null
paymentTermName: string | null
- quoteId: string | null
receiptPromisedDate: string | null
receiptRequestedDate: string | null
revisionId: number | null
@@ -23815,27 +24050,6 @@ export type Database = {
referencedRelation: "customerLocation"
referencedColumns: ["id"]
},
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quote"
- referencedColumns: ["id"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quoteCustomerDetails"
- referencedColumns: ["quoteId"]
- },
- {
- foreignKeyName: "salesOrder_quoteId_fkey"
- columns: ["quoteId"]
- isOneToOne: false
- referencedRelation: "quotes"
- referencedColumns: ["id"]
- },
{
foreignKeyName: "salesOrder_updatedBy_fkey"
columns: ["updatedBy"]
diff --git a/packages/database/supabase/migrations/20240324175747_assignee.sql b/packages/database/supabase/migrations/20240324175747_assignee.sql
index 891e4d92a1..d29171d6b2 100644
--- a/packages/database/supabase/migrations/20240324175747_assignee.sql
+++ b/packages/database/supabase/migrations/20240324175747_assignee.sql
@@ -86,24 +86,7 @@ CREATE OR REPLACE VIEW "purchaseInvoices" WITH(SECURITY_INVOKER=true) AS
FROM "purchaseInvoice" pi
LEFT JOIN "paymentTerm" pt ON pt."id" = pi."paymentTermId";
-DROP VIEW "quotes";
-ALTER TABLE "quote" DROP COLUMN "ownerId";
-CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
- SELECT
- q.*,
- l."name" AS "locationName",
- ql."itemIds",
- EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
- FROM "quote" q
- LEFT JOIN (
- SELECT
- "quoteId",
- array_agg("itemId") AS "itemIds"
- FROM "quoteLine"
- GROUP BY "quoteId"
- ) ql ON ql."quoteId" = q.id
- LEFT JOIN "location" l
- ON l.id = q."locationId";
+
DROP VIEW "receipts";
CREATE OR REPLACE VIEW "receipts" WITH(SECURITY_INVOKER=true) AS
diff --git a/packages/database/supabase/migrations/20240412224648_sales-orders.sql b/packages/database/supabase/migrations/20240412224648_sales-orders.sql
index a69dda7869..facb4b6902 100644
--- a/packages/database/supabase/migrations/20240412224648_sales-orders.sql
+++ b/packages/database/supabase/migrations/20240412224648_sales-orders.sql
@@ -20,7 +20,7 @@ CREATE TABLE "salesOrder" (
"customerLocationId" TEXT,
"customerContactId" TEXT,
"customerReference" TEXT,
- "quoteId" TEXT,
+ -- "quoteId" TEXT,
"assignee" TEXT,
"companyId" TEXT NOT NULL,
"closedAt" DATE,
@@ -38,7 +38,7 @@ CREATE TABLE "salesOrder" (
CONSTRAINT "salesOrder_currencyCode_fkey" FOREIGN KEY ("currencyCode", "companyId") REFERENCES "currency" ("code", "companyId") ON DELETE RESTRICT,
CONSTRAINT "salesOrder_customerLocationId_fkey" FOREIGN KEY ("customerLocationId") REFERENCES "customerLocation" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "salesOrder_customerContactId_fkey" FOREIGN KEY ("customerContactId") REFERENCES "customerContact" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
- CONSTRAINT "salesOrder_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ -- CONSTRAINT "salesOrder_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "salesOrder_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "salesOrder_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "salesOrder_closedBy_fkey" FOREIGN KEY ("closedBy") REFERENCES "user" ("id") ON DELETE RESTRICT,
@@ -49,7 +49,7 @@ CREATE TABLE "salesOrder" (
CREATE INDEX "salesOrder_salesOrderId_idx" ON "salesOrder" ("salesOrderId", "companyId");
CREATE INDEX "salesOrder_customerId_idx" ON "salesOrder" ("customerId", "companyId");
CREATE INDEX "salesOrder_status_idx" ON "salesOrder" ("status", "companyId");
-CREATE INDEX "salesOrder_quoteId_idx" ON "salesOrder" ("quoteId", "companyId");
+-- CREATE INDEX "salesOrder_quoteId_idx" ON "salesOrder" ("quoteId", "companyId");
CREATE INDEX "salesOrder_companyId_idx" ON "salesOrder" ("companyId");
CREATE TYPE "salesOrderLineType" AS ENUM (
diff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240715024405_quotes.sql
similarity index 72%
rename from packages/database/supabase/migrations/20240206224405_quotes.sql
rename to packages/database/supabase/migrations/20240715024405_quotes.sql
index 547a6d57b2..2bcac5c12b 100644
--- a/packages/database/supabase/migrations/20240206224405_quotes.sql
+++ b/packages/database/supabase/migrations/20240715024405_quotes.sql
@@ -15,12 +15,13 @@ CREATE TABLE "quote" (
"id" TEXT NOT NULL DEFAULT xid(),
"quoteId" TEXT NOT NULL,
"revisionId" INTEGER NOT NULL DEFAULT 0,
- "ownerId" TEXT NOT NULL,
- "name" TEXT,
- "status" "quoteStatus" NOT NULL DEFAULT 'Draft',
+ "salesRfqId" TEXT,
"quoteDate" DATE,
"expirationDate" DATE,
- "notes" TEXT,
+ "status" "quoteStatus" NOT NULL DEFAULT 'Draft',
+ "notes" JSON DEFAULT '{}'::json,
+ "salesPersonId" TEXT,
+ "estimatorId" TEXT,
"customerId" TEXT NOT NULL,
"customerLocationId" TEXT,
"customerContactId" TEXT,
@@ -36,11 +37,13 @@ CREATE TABLE "quote" (
CONSTRAINT "quote_pkey" PRIMARY KEY ("id"),
CONSTRAINT "quote_quoteId_key" UNIQUE ("quoteId", "companyId"),
- CONSTRAINT "quote_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quote_salesRfqId_fkey" FOREIGN KEY ("salesRfqId") REFERENCES "salesRfq" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "quote_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customer" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quote_customerLocationId_fkey" FOREIGN KEY ("customerLocationId") REFERENCES "customerLocation" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quote_customerContactId_fkey" FOREIGN KEY ("customerContactId") REFERENCES "customerContact" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quote_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quote_salesPersonId_fkey" FOREIGN KEY ("salesPersonId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "quote_estimatorId_fkey" FOREIGN KEY ("estimatorId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "quote_assignee_fkey" FOREIGN KEY ("assignee") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "quote_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quote_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -48,7 +51,6 @@ CREATE TABLE "quote" (
);
CREATE INDEX "quote_quoteId_idx" ON "quote" ("quoteId", "companyId");
-CREATE INDEX "quote_ownerId_idx" ON "quote" ("ownerId", "companyId");
CREATE INDEX "quote_customerId_idx" ON "quote" ("customerId", "companyId");
CREATE INDEX "quote_locationId_idx" ON "quote" ("locationId", "companyId");
CREATE INDEX "quote_companyId_idx" ON "quote" ("companyId");
@@ -64,6 +66,7 @@ CREATE TABLE "quoteLine" (
"quoteId" TEXT NOT NULL,
"quoteRevisionId" INTEGER NOT NULL DEFAULT 0,
"status" "quoteLineStatus" NOT NULL DEFAULT 'Draft',
+ "estimatorId" TEXT,
"itemId" TEXT NOT NULL,
"itemReadableId" TEXT,
"description" TEXT NOT NULL,
@@ -79,6 +82,7 @@ CREATE TABLE "quoteLine" (
CONSTRAINT "quoteLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "quoteLine_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteLine_estimatorId_fkey" FOREIGN KEY ("estimatorId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "quoteLine_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -88,11 +92,42 @@ CREATE TABLE "quoteLine" (
CREATE INDEX "quoteLine_quoteId_idx" ON "quoteLine" ("quoteId");
-CREATE TABLE "quoteAssembly" (
+CREATE TABLE "quoteMaterial" (
"id" TEXT NOT NULL DEFAULT xid(),
"quoteId" TEXT NOT NULL,
"quoteLineId" TEXT NOT NULL,
- "parentAssemblyId" TEXT,
+ "itemId" TEXT NOT NULL,
+ "description" TEXT NOT NULL,
+ "quantity" NUMERIC(10, 2) NOT NULL DEFAULT 0,
+ "unitOfMeasureCode" TEXT,
+ "unitCost" NUMERIC(10, 2) NOT NULL DEFAULT 0,
+ "companyId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP WITH TIME ZONE,
+ "updatedBy" TEXT,
+ "customFields" JSONB,
+
+ CONSTRAINT "quoteMaterial_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "quoteMaterial_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMaterial_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+CREATE INDEX "quoteMaterial_quoteId_idx" ON "quoteMaterial" ("quoteId");
+CREATE INDEX "quoteMaterial_quoteLineId_idx" ON "quoteMaterial" ("quoteLineId");
+
+
+
+CREATE TABLE "quoteMakeMethod" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "quoteId" TEXT NOT NULL,
+ "quoteLineId" TEXT NOT NULL,
+ "parentMaterialId" TEXT,
"itemId" TEXT NOT NULL,
"description" TEXT,
"unitOfMeasureCode" TEXT,
@@ -104,26 +139,29 @@ CREATE TABLE "quoteAssembly" (
"updatedBy" TEXT,
"customFields" JSONB,
- CONSTRAINT "quoteAssembly_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "quoteAssembly_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_parentAssemblyId_fkey" FOREIGN KEY ("parentAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteAssembly_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+ CONSTRAINT "quoteMakeMethod_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "quoteMakeMethod_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_parentMaterialId_fkey" FOREIGN KEY ("parentMaterialId") REFERENCES "quoteMaterial" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "quoteMakeMethod_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-CREATE INDEX "quoteAssembly_quoteId_idx" ON "quoteAssembly" ("quoteId");
-CREATE INDEX "quoteAssembly_quoteLineId_idx" ON "quoteAssembly" ("quoteLineId");
-CREATE INDEX "quoteAssembly_parentAssemblyId_idx" ON "quoteAssembly" ("parentAssemblyId");
+CREATE INDEX "quoteMakeMethod_quoteId_idx" ON "quoteMakeMethod" ("quoteId");
+CREATE INDEX "quoteMakeMethod_quoteLineId_idx" ON "quoteMakeMethod" ("quoteLineId");
+CREATE INDEX "quoteMakeMethod_parentMaterialId_idx" ON "quoteMakeMethod" ("parentMaterialId");
+
+ALTER TABLE "quoteMaterial" ADD COLUMN "quoteMakeMethodId" TEXT,
+ ADD CONSTRAINT "quoteMaterial_quoteMakeMethodId_fkey" FOREIGN KEY ("quoteMakeMethodId") REFERENCES "quoteMakeMethod" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
CREATE TABLE "quoteOperation" (
"id" TEXT NOT NULL DEFAULT xid(),
"quoteId" TEXT NOT NULL,
"quoteLineId" TEXT NOT NULL,
- "quoteAssemblyId" TEXT,
+ "quoteMakeMethodId" TEXT,
"workCellTypeId" TEXT NOT NULL,
"equipmentTypeId" TEXT,
"description" TEXT,
@@ -143,7 +181,7 @@ CREATE TABLE "quoteOperation" (
CONSTRAINT "quoteOperation_pkey" PRIMARY KEY ("id"),
CONSTRAINT "quoteOperation_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteOperation_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteOperation_quoteAssemblyId_fkey" FOREIGN KEY ("quoteAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "quoteOperation_quoteMakeMethodId_fkey" FOREIGN KEY ("quoteMakeMethodId") REFERENCES "quoteMakeMethod" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteOperation_workCellTypeId_fkey" FOREIGN KEY ("workCellTypeId") REFERENCES "workCellType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteOperation_equipmentTypeId_fkey" FOREIGN KEY ("equipmentTypeId") REFERENCES "equipmentType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteOperation_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
@@ -153,38 +191,11 @@ CREATE TABLE "quoteOperation" (
CREATE INDEX "quoteOperation_quoteId_idx" ON "quoteOperation" ("quoteId");
CREATE INDEX "quoteOperation_quoteLineId_idx" ON "quoteOperation" ("quoteLineId");
-CREATE INDEX "quoteOperation_quoteAssemblyId_idx" ON "quoteOperation" ("quoteAssemblyId");
-
-CREATE TABLE "quoteMaterial" (
- "id" TEXT NOT NULL DEFAULT xid(),
- "quoteId" TEXT NOT NULL,
- "quoteLineId" TEXT NOT NULL,
- "quoteOperationId" TEXT NOT NULL,
- "itemId" TEXT NOT NULL,
- "description" TEXT NOT NULL,
- "quantity" NUMERIC(10, 2) NOT NULL DEFAULT 0,
- "unitOfMeasureCode" TEXT,
- "unitCost" NUMERIC(10, 2) NOT NULL DEFAULT 0,
- "companyId" TEXT NOT NULL,
- "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
- "createdBy" TEXT NOT NULL,
- "updatedAt" TIMESTAMP WITH TIME ZONE,
- "updatedBy" TEXT,
- "customFields" JSONB,
+CREATE INDEX "quoteOperation_quoteMakeMethodId_idx" ON "quoteOperation" ("quoteMakeMethodId");
- CONSTRAINT "quoteMaterial_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "quoteMaterial_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_quoteOperationId_fkey" FOREIGN KEY ("quoteOperationId") REFERENCES "quoteOperation" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode", "companyId") REFERENCES "unitOfMeasure" ("code", "companyId") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "quoteMaterial_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
-);
+ALTER TABLE "quoteMaterial" ADD COLUMN "quoteOperationId" TEXT,
+ ADD CONSTRAINT "quoteMaterial_quoteOperationId_fkey" FOREIGN KEY ("quoteOperationId") REFERENCES "quoteOperation" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
-CREATE INDEX "quoteMaterial_quoteId_idx" ON "quoteMaterial" ("quoteId");
-CREATE INDEX "quoteMaterial_quoteLineId_idx" ON "quoteMaterial" ("quoteLineId");
CREATE INDEX "quoteMaterial_quoteOperationId_idx" ON "quoteMaterial" ("quoteOperationId");
CREATE TABLE "quoteFavorite" (
@@ -218,67 +229,17 @@ CREATE POLICY "Users can delete their own quote favorites" ON "quoteFavorite"
CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
SELECT
- q."id",
- q."quoteId",
- q."customerId",
- q."customerLocationId",
- q."customerContactId",
- q."name",
- q."status",
- q."notes",
- q."quoteDate",
- q."expirationDate",
- q."customerReference",
- q."locationId",
- q."createdAt",
- q."createdBy",
- q."ownerId",
- q."customFields",
- q."companyId",
- uo."fullName" AS "ownerFullName",
- uo."avatarUrl" AS "ownerAvatar",
- c."name" AS "customerName",
- uc."fullName" AS "createdByFullName",
- uc."avatarUrl" AS "createdByAvatar",
- uu."fullName" AS "updatedByFullName",
- uu."avatarUrl" AS "updatedByAvatar",
+ q.*,
l."name" AS "locationName",
- array_agg(ql."itemId") AS "itemIds",
+ ql."itemIds",
EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite
-FROM "quote" q
-LEFT JOIN "customer" c
- ON c.id = q."customerId"
-LEFT JOIN "location" l
- ON l.id = q."locationId"
-LEFT JOIN "quoteLine" ql
- ON ql."quoteId" = q.id
-LEFT JOIN "user" uo
- ON uo.id = q."ownerId"
-LEFT JOIN "user" uc
- ON uc.id = q."createdBy"
-LEFT JOIN "user" uu
- ON uu.id = q."updatedBy"
-GROUP BY
- q."id",
- q."quoteId",
- q."customerId",
- q."customerLocationId",
- q."customerContactId",
- q."name",
- q."status",
- q."notes",
- q."quoteDate",
- q."expirationDate",
- q."customerReference",
- q."locationId",
- q."createdAt",
- q."createdBy",
- q."customFields",
- c."name",
- uo."fullName",
- uo."avatarUrl",
- uc."fullName",
- uc."avatarUrl",
- uu."fullName",
- uu."avatarUrl",
- l."name";
\ No newline at end of file
+ FROM "quote" q
+ LEFT JOIN (
+ SELECT
+ "quoteId",
+ array_agg("itemId") AS "itemIds"
+ FROM "quoteLine"
+ GROUP BY "quoteId"
+ ) ql ON ql."quoteId" = q.id
+ LEFT JOIN "location" l
+ ON l.id = q."locationId";
\ No newline at end of file
diff --git a/packages/database/supabase/migrations/20240213043906_quote-rls.sql b/packages/database/supabase/migrations/20240715043906_quote-rls.sql
similarity index 94%
rename from packages/database/supabase/migrations/20240213043906_quote-rls.sql
rename to packages/database/supabase/migrations/20240715043906_quote-rls.sql
index 3abe8b4ffa..21800bc2de 100644
--- a/packages/database/supabase/migrations/20240213043906_quote-rls.sql
+++ b/packages/database/supabase/migrations/20240715043906_quote-rls.sql
@@ -153,16 +153,16 @@ CREATE POLICY "Customers with sales_delete can delete lines on their own quote"
)
);
-ALTER TABLE "quoteAssembly" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "quoteMakeMethod" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with sales_view can view quote assemblies" ON "quoteAssembly"
+CREATE POLICY "Employees with sales_view can view quote make methods" ON "quoteMakeMethod"
FOR SELECT
USING (
has_role('employee', get_company_id_from_foreign_key("quoteId", 'quote')) AND
has_company_permission('sales_view', get_company_id_from_foreign_key("quoteId", 'quote'))
);
-CREATE POLICY "Customers with sales_view can their own quote assemblies" ON "quoteAssembly"
+CREATE POLICY "Customers with sales_view can their own quote make methods" ON "quoteMakeMethod"
FOR SELECT
USING (
has_role('customer', get_company_id_from_foreign_key("quoteId", 'quote')) AND
@@ -176,21 +176,21 @@ CREATE POLICY "Customers with sales_view can their own quote assemblies" ON "quo
)
);
-CREATE POLICY "Employees with sales_create can create quote assemblies" ON "quoteAssembly"
+CREATE POLICY "Employees with sales_create can create quote make methods" ON "quoteMakeMethod"
FOR INSERT
WITH CHECK (
has_role('employee', get_company_id_from_foreign_key("quoteId", 'quote')) AND
has_company_permission('sales_create', get_company_id_from_foreign_key("quoteId", 'quote'))
);
-CREATE POLICY "Employees with sales_update can update quote assemblies" ON "quoteAssembly"
+CREATE POLICY "Employees with sales_update can update quote make methods" ON "quoteMakeMethod"
FOR UPDATE
USING (
has_role('employee', get_company_id_from_foreign_key("quoteId", 'quote')) AND
has_company_permission('sales_update', get_company_id_from_foreign_key("quoteId", 'quote'))
);
-CREATE POLICY "Employees with sales_delete can delete quote assemblies" ON "quoteAssembly"
+CREATE POLICY "Employees with sales_delete can delete quote make methods" ON "quoteMakeMethod"
FOR DELETE
USING (
has_role('employee', get_company_id_from_foreign_key("quoteId", 'quote')) AND
diff --git a/packages/database/supabase/migrations/20240209055738_quote-files.sql b/packages/database/supabase/migrations/20240715055738_quote-files.sql
similarity index 100%
rename from packages/database/supabase/migrations/20240209055738_quote-files.sql
rename to packages/database/supabase/migrations/20240715055738_quote-files.sql
diff --git a/packages/database/supabase/migrations/20240329034816_quote-pricing.sql b/packages/database/supabase/migrations/20240715134816_quote-pricing.sql
similarity index 100%
rename from packages/database/supabase/migrations/20240329034816_quote-pricing.sql
rename to packages/database/supabase/migrations/20240715134816_quote-pricing.sql
diff --git a/packages/database/supabase/migrations/20240321035710_quote-locations.sql b/packages/database/supabase/migrations/20240715135710_quote-locations.sql
similarity index 100%
rename from packages/database/supabase/migrations/20240321035710_quote-locations.sql
rename to packages/database/supabase/migrations/20240715135710_quote-locations.sql