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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: removed blocked and add pull from inventory to item table
Brad Barbin20bde6789681
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsxindex 53e1a15481..422692e981 100644--- a/apps/carbon/app/components/Form/Item.tsx+++ b/apps/carbon/app/components/Form/Item.tsx@@ -55,7 +55,7 @@ const Item = ({ type, ...props }: ItemSelectProps) => {itemInventoryType: "Inventory",replenishmentSystem: "Buy and Make",unitOfMeasureCode: "EA",- blocked: false,+ pullFromInventory: false,active: true,}}/>@@ -74,7 +74,7 @@ const Item = ({ type, ...props }: ItemSelectProps) => {description: "",itemInventoryType: "Inventory",unitOfMeasureCode: "EA",- blocked: false,+ pullFromInventory: false,active: true,}}/>diff --git a/apps/carbon/app/components/Form/Part.tsx b/apps/carbon/app/components/Form/Part.tsxindex 995f89710b..59900a11e2 100644--- a/apps/carbon/app/components/Form/Part.tsx+++ b/apps/carbon/app/components/Form/Part.tsx@@ -52,7 +52,7 @@ const Part = ({ partReplenishmentSystem, ...props }: PartSelectProps) => {itemInventoryType: "Inventory" as "Inventory",replenishmentSystem: partReplenishmentSystem ?? "Buy and Make",unitOfMeasureCode: "EA",- blocked: false,+ pullFromInventory: false,active: true,}}/>diff --git a/apps/carbon/app/components/Search/Search/Search.tsx b/apps/carbon/app/components/Search/Search/Search.tsxindex 17e78e8486..a022ba5bec 100644--- a/apps/carbon/app/components/Search/Search/Search.tsx+++ b/apps/carbon/app/components/Search/Search/Search.tsx@@ -296,7 +296,7 @@ const SearchButton = () => {function useGroupedSubmodules() {const modules = useModules();- const parts = useItemsSubmodules();+ const items = useItemsSubmodules();// const jobs = useJobsSidebar();const inventory = useInventorySubmodules();// const scheduling = useSchedulingSidebar();@@ -322,7 +322,7 @@ function useGroupedSubmodules() {}[];}> = {- parts,+ items,inventory,sales,purchasing,diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.tsindex 7f9711e552..a1029aa3f7 100644--- a/apps/carbon/app/modules/items/items.models.ts+++ b/apps/carbon/app/modules/items/items.models.ts@@ -37,10 +37,10 @@ export const itemValidator = z.object({message: "Part type is required",}),}),+ pullFromInventory: zfd.checkbox(),unitOfMeasureCode: z.string().min(1, { message: "Unit of Measure is required" }),- blocked: zfd.checkbox(),active: zfd.checkbox(),});diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.tsindex 16bdcf8ba0..7280ffc651 100644--- a/apps/carbon/app/modules/items/items.service.ts+++ b/apps/carbon/app/modules/items/items.service.ts@@ -128,7 +128,6 @@ export async function getConsumablesList(.select("id, name, readableId").eq("type", "Consumable").eq("companyId", companyId)- .eq("blocked", false).eq("active", true);return query.order("name");@@ -187,7 +186,6 @@ export async function getFixturesList(.select("id, name, readableId").eq("type", "Fixture").eq("companyId", companyId)- .eq("blocked", false).eq("active", true);return query.order("name");@@ -343,7 +341,6 @@ export async function getMaterialsList(.select("id, name, readableId").eq("type", "Material").or(`companyId.eq.${companyId},companyId.is.null`)- .eq("blocked", false).eq("active", true);return query.order("name");@@ -516,7 +513,6 @@ export async function getPartsList(.select("id, name, readableId").eq("type", "Part").eq("companyId", companyId)- .eq("blocked", false).eq("active", true);return query.order("name");@@ -612,7 +608,6 @@ export async function getServicesList(.select("id, name").eq("type", "Service").eq("companyId", companyId)- .eq("blocked", false).eq("active", true).order("name");@@ -684,7 +679,6 @@ export async function getToolsList(.select("id, name, readableId").eq("type", "Tool").eq("companyId", companyId)- .eq("blocked", false).eq("active", true);return query.order("name");@@ -794,6 +788,8 @@ export async function upsertConsumable(itemGroupId: consumable.itemGroupId,itemInventoryType: consumable.itemInventoryType,unitOfMeasureCode: consumable.unitOfMeasureCode,+ pullFromInventory: consumable.pullFromInventory,+ active: consumable.active,companyId: consumable.companyId,createdBy: consumable.createdBy,})@@ -822,8 +818,8 @@ export async function upsertConsumable(itemGroupId: consumable.itemGroupId,itemInventoryType: consumable.itemInventoryType,unitOfMeasureCode: consumable.unitOfMeasureCode,+ pullFromInventory: consumable.pullFromInventory,active: consumable.active,- blocked: consumable.blocked,};const consumableUpdate = {@@ -874,6 +870,8 @@ export async function upsertFixture(itemGroupId: fixture.itemGroupId,itemInventoryType: fixture.itemInventoryType,unitOfMeasureCode: "EA",+ pullFromInventory: true,+ active: fixture.active,companyId: fixture.companyId,createdBy: fixture.createdBy,})@@ -905,7 +903,7 @@ export async function upsertFixture(itemInventoryType: fixture.itemInventoryType,unitOfMeasureCode: "EA",active: fixture.active,- blocked: fixture.blocked,+ pullFromInventory: fixture.pullFromInventory,};const fixtureUpdate = {@@ -957,6 +955,8 @@ export async function upsertPart(itemGroupId: part.itemGroupId,itemInventoryType: part.itemInventoryType,unitOfMeasureCode: part.unitOfMeasureCode,+ pullFromInventory: part.pullFromInventory,+ active: part.active,companyId: part.companyId,createdBy: part.createdBy,})@@ -987,7 +987,7 @@ export async function upsertPart(itemInventoryType: part.itemInventoryType,unitOfMeasureCode: part.unitOfMeasureCode,active: part.active,- blocked: part.blocked,+ pullFromInventory: part.pullFromInventory,};const partUpdate = {@@ -1205,6 +1205,8 @@ export async function upsertMaterial(itemGroupId: material.itemGroupId,itemInventoryType: material.itemInventoryType,unitOfMeasureCode: material.unitOfMeasureCode,+ pullFromInventory: material.pullFromInventory,+ active: material.active,companyId: material.companyId,createdBy: material.createdBy,})@@ -1239,7 +1241,7 @@ export async function upsertMaterial(itemInventoryType: material.itemInventoryType,unitOfMeasureCode: material.unitOfMeasureCode,active: material.active,- blocked: material.blocked,+ pullFromInventory: material.pullFromInventory,};const materialUpdate = {@@ -1360,6 +1362,8 @@ export async function upsertService(itemGroupId: service.itemGroupId,itemInventoryType: service.itemInventoryType,unitOfMeasureCode: null,+ pullFromInventory: false,+ active: service.active,companyId: service.companyId,createdBy: service.createdBy,})@@ -1388,7 +1392,7 @@ export async function upsertService(itemInventoryType: service.itemInventoryType,unitOfMeasureCode: null,active: service.active,- blocked: service.blocked,+ pullFromInventory: service.pullFromInventory,};const serviceUpdate = {@@ -1469,6 +1473,8 @@ export async function upsertTool(itemGroupId: tool.itemGroupId,itemInventoryType: tool.itemInventoryType,unitOfMeasureCode: tool.unitOfMeasureCode,+ pullFromInventory: tool.pullFromInventory,+ active: tool.active,companyId: tool.companyId,createdBy: tool.createdBy,})@@ -1498,7 +1504,7 @@ export async function upsertTool(itemInventoryType: tool.itemInventoryType,unitOfMeasureCode: tool.unitOfMeasureCode,active: tool.active,- blocked: tool.blocked,+ pullFromInventory: tool.pullFromInventory,};const toolUpdate = {diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsxindex 6622f2f15e..41d0583432 100644--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableForm.tsx@@ -125,7 +125,7 @@ const ConsumableForm = ({<Selectname="itemInventoryType"- label="Consumable Type"+ label="Tracking Type"options={itemInventoryTypeOptions}/><UnitOfMeasure@@ -133,8 +133,8 @@ const ConsumableForm = ({label="Unit of Measure"/>- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="pullFromInventory" label="Pull from Inventory" />+ <Boolean name="active" label="Active" /><CustomFormFields table="consumable" /></div>diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsxindex 1b4c199cb5..85c81225f6 100644--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx@@ -103,12 +103,10 @@ const ConsumableProperties = () => {</VStack><VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Inventory Type</h3>+ <h3 className="text-xs text-muted-foreground">Tracking Type</h3><EnumerableclassName={cn(- (routeData?.consumableSummary?.active === false ||- routeData?.consumableSummary?.blocked) &&- "opacity-50"+ routeData?.consumableSummary?.active === false && "opacity-50")}value={routeData?.consumableSummary?.itemInventoryType ?? null}/>diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsxindex ffaa397961..95c879a3d7 100644--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx@@ -91,21 +91,6 @@ const ConsumablesTable = memo(pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -191,7 +176,6 @@ const ConsumablesTable = memo(defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsxindex c467bd40b3..b9e4d19565 100644--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx@@ -94,6 +94,7 @@ const FixtureForm = ({<ModalCardBody><Hidden name="type" value={type} /><Hidden name="unitOfMeasureCode" value="EA" />+ <Hidden name="pullFromInventory" value="on" /><divclassName={cn("grid w-full gap-x-8 gap-y-4",@@ -126,13 +127,11 @@ const FixtureForm = ({<Selectname="itemInventoryType"- label="Fixture Type"+ label="Tracking Type"options={itemInventoryTypeOptions}/><Customer name="customerId" label="Customer" />-- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="active" label="Active" /><CustomFormFields table="fixture" /></div>diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsxindex b0b864bc41..f211e032c7 100644--- a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx@@ -114,21 +114,6 @@ const FixturesTable = memo(pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -214,7 +199,6 @@ const FixturesTable = memo(defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsxindex 3c2a62e89b..b9c90fb3bb 100644--- a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx@@ -60,8 +60,6 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {<ItemGroup name="itemGroupId" label="Item Group" /><Boolean name="active" label="Active" />- <Boolean name="blocked" label="Blocked" />-<CustomFormFields table="part" /></div></CardContent>diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsxindex a8cd3da3af..e3d80d694d 100644--- a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx@@ -142,7 +142,7 @@ const MaterialForm = ({<Selectname="itemInventoryType"- label="Material Type"+ label="Tracking Type"options={itemInventoryTypeOptions}/><UnitOfMeasure@@ -150,8 +150,8 @@ const MaterialForm = ({label="Unit of Measure"/>- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="pullFromInventory" label="Pull from Inventory" />+ <Boolean name="active" label="Active" /><CustomFormFields table="material" /></div>diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsxindex 5358687ed6..33d82d8796 100644--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx@@ -115,12 +115,10 @@ const MaterialProperties = () => {</VStack><VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Inventory Type</h3>+ <h3 className="text-xs text-muted-foreground">Tracking Type</h3><EnumerableclassName={cn(- (routeData?.materialSummary?.active === false ||- routeData?.materialSummary?.blocked) &&- "opacity-50"+ routeData?.materialSummary?.active === false && "opacity-50")}value={routeData?.materialSummary?.itemInventoryType ?? null}/>diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsxindex 9b3757b0b2..b194b66e9b 100644--- a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx@@ -138,21 +138,6 @@ const MaterialsTable = memo(pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -238,7 +223,6 @@ const MaterialsTable = memo(defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsxindex 6fbef12f19..6f75fd3760 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx@@ -135,7 +135,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {/><Selectname="itemInventoryType"- label="Part Type"+ label="Tracking Type"options={itemInventoryTypeOptions}/><UnitOfMeasure@@ -143,8 +143,8 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {label="Unit of Measure"/>- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="pullFromInventory" label="Pull from Inventory" />+ <Boolean name="active" label="Active" /><CustomFormFields table="part" /></div>diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsxindex a15c0f9a29..50719db12f 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx@@ -106,21 +106,17 @@ const PartProperties = () => {<h3 className="text-xs text-muted-foreground">Replenishment</h3><EnumerableclassName={cn(- (routeData?.partSummary?.active === false ||- routeData?.partSummary?.blocked) &&- "opacity-50"+ routeData?.partSummary?.active === false && "opacity-50")}value={routeData?.partSummary?.replenishmentSystem ?? null}/></VStack><VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Inventory Type</h3>+ <h3 className="text-xs text-muted-foreground">Tracking Type</h3><EnumerableclassName={cn(- (routeData?.partSummary?.active === false ||- routeData?.partSummary?.blocked) &&- "opacity-50"+ routeData?.partSummary?.active === false && "opacity-50")}value={routeData?.partSummary?.itemInventoryType ?? null}/>diff --git a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsxindex 4a56cc2b48..5ed78d4423 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx@@ -104,21 +104,6 @@ const PartsTable = memo(({ data, count, itemGroups }: PartsTableProps) => {pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -204,7 +189,6 @@ const PartsTable = memo(({ data, count, itemGroups }: PartsTableProps) => {defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsxindex 0a20505c26..47eff18b79 100644--- a/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx+++ b/apps/carbon/app/modules/items/ui/Services/ServiceForm.tsx@@ -59,6 +59,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {<CardContent><Hidden name="itemInventoryType" value="Non-Inventory" /><Hidden name="unitOfMeasureCode" value="EA" />+ <Hidden name="pullFromInventory" value="off" /><divclassName={cn("grid w-full gap-x-8 gap-y-4",@@ -88,8 +89,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {options={serviceTypeOptions}/>- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="active" label="Active" /><CustomFormFields table="service" /></div></CardContent>diff --git a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsxindex 0501348079..61a7590048 100644--- a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx+++ b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx@@ -90,21 +90,6 @@ const ServicesTable = memo(pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -189,7 +174,6 @@ const ServicesTable = memo(defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsxindex 14d9ad0c3e..37c39ea831 100644--- a/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx+++ b/apps/carbon/app/modules/items/ui/Tools/ToolForm.tsx@@ -121,7 +121,7 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {<Selectname="itemInventoryType"- label="Tool Type"+ label="Tracking Type"options={itemInventoryTypeOptions}/><UnitOfMeasure@@ -129,8 +129,8 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {label="Unit of Measure"/>- <Boolean name="blocked" label="Blocked" />- {isEditing && <Boolean name="active" label="Active" />}+ <Boolean name="pullFromInventory" label="Pull from Inventory" />+ <Boolean name="active" label="Active" /><CustomFormFields table="tool" /></div>diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsxindex 5a32e62f2f..f259de8be5 100644--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx@@ -103,12 +103,10 @@ const ToolProperties = () => {</VStack><VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Inventory Type</h3>+ <h3 className="text-xs text-muted-foreground">Tracking Type</h3><EnumerableclassName={cn(- (routeData?.toolSummary?.active === false ||- routeData?.toolSummary?.blocked) &&- "opacity-50"+ routeData?.toolSummary?.active === false && "opacity-50")}value={routeData?.toolSummary?.itemInventoryType ?? null}/>diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsxindex a8f1bc14e6..118fcaf73b 100644--- a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx+++ b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx@@ -90,21 +90,6 @@ const ToolsTable = memo(({ data, count, itemGroups }: ToolsTableProps) => {pluralHeader: "Active Statuses",},},- {- accessorKey: "blocked",- header: "Blocked",- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,- meta: {- filter: {- type: "static",- options: [- { value: "true", label: "Blocked" },- { value: "false", label: "Not Blocked" },- ],- },- pluralHeader: "Blocked Statuses",- },- },{id: "assignee",header: "Assignee",@@ -190,7 +175,6 @@ const ToolsTable = memo(({ data, count, itemGroups }: ToolsTableProps) => {defaultColumnVisibility={{description: false,active: false,- blocked: false,createdBy: false,createdAt: false,updatedBy: false,diff --git a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsxindex 3d4de3013b..44252eb2d4 100644--- a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx+++ b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx@@ -47,7 +47,6 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {.select("id, readableId, name, type").eq("companyId", companyId).eq("active", true)- .eq("blocked", false).order("name"),supabase.from("supplier")@@ -110,7 +109,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {switch (payload.eventType) {case "INSERT":const { new: inserted } = payload;- if (inserted.active && !inserted.blocked) {+ if (inserted.active) {setItems((items) =>[...items,@@ -126,6 +125,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {break;case "UPDATE":const { new: updated } = payload;+ // TODO: handle active status changessetItems((items) =>items.map((i) => {diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsxindex dfa7eb17ec..a776a8b9e1 100644--- a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx@@ -72,7 +72,8 @@ export default function ConsumableDetailsRoute() {itemInventoryType:consumableData.consumableSummary?.itemInventoryType ?? "Inventory",active: consumableData.consumableSummary?.active ?? true,- blocked: consumableData.consumableSummary?.blocked ?? false,+ pullFromInventory:+ consumableData.consumableSummary?.pullFromInventory ?? false,unitOfMeasureCode:consumableData.consumableSummary?.unitOfMeasureCode ?? "EA",...getCustomFields(consumableData.consumableSummary?.customFields ?? {}),diff --git a/apps/carbon/app/routes/x+/consumable+/new.tsx b/apps/carbon/app/routes/x+/consumable+/new.tsxindex 3f5c8f630b..006cee2fda 100644--- a/apps/carbon/app/routes/x+/consumable+/new.tsx+++ b/apps/carbon/app/routes/x+/consumable+/new.tsx@@ -30,7 +30,6 @@ export async function action({ request }: ActionFunctionArgs) {const createConsumable = await upsertConsumable(client, {...validation.data,- active: true,companyId,customFields: setCustomFields(formData),createdBy: userId,@@ -68,8 +67,8 @@ export default function ConsumablesNewRoute() {description: "",itemInventoryType: "Non-Inventory" as "Non-Inventory",unitOfMeasureCode: "EA",- blocked: false,- active: false,+ pullFromInventory: true,+ active: true,};return (diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsxindex a1042eb19c..e8d3b39ea2 100644--- a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx@@ -68,7 +68,7 @@ export default function FixtureDetailsRoute() {itemInventoryType:fixtureData.fixtureSummary?.itemInventoryType ?? "Inventory",active: fixtureData.fixtureSummary?.active ?? true,- blocked: fixtureData.fixtureSummary?.blocked ?? false,+ pullFromInventory: fixtureData.fixtureSummary?.pullFromInventory ?? false,customerId: fixtureData.fixtureSummary?.customerId ?? "",unitOfMeasureCode: "EA",...getCustomFields(fixtureData.fixtureSummary?.customFields ?? {}),diff --git a/apps/carbon/app/routes/x+/fixture+/new.tsx b/apps/carbon/app/routes/x+/fixture+/new.tsxindex 471f6ce173..0409faed1c 100644--- a/apps/carbon/app/routes/x+/fixture+/new.tsx+++ b/apps/carbon/app/routes/x+/fixture+/new.tsx@@ -26,7 +26,6 @@ export async function action({ request }: ActionFunctionArgs) {const createFixture = await upsertFixture(client, {...validation.data,- active: true,companyId,customFields: setCustomFields(formData),createdBy: userId,@@ -64,8 +63,8 @@ export default function FixturesNewRoute() {description: "",itemInventoryType: "Inventory" as "Inventory",unitOfMeasureCode: "EA",- blocked: false,- active: false,+ pullFromInventory: true,+ active: true,};return (diff --git a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx b/apps/carbon/app/routes/x+/material+/$itemId.details.tsxindex 91f4054f27..301b35e8a6 100644--- a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/material+/$itemId.details.tsx@@ -81,7 +81,7 @@ export default function MaterialDetailsRoute() {itemInventoryType:materialData.materialSummary?.itemInventoryType ?? "Inventory",active: materialData.materialSummary?.active ?? true,- blocked: materialData.materialSummary?.blocked ?? false,+ pullFromInventory: materialData.materialSummary?.pullFromInventory ?? false,unitOfMeasureCode: materialData.materialSummary?.unitOfMeasureCode ?? "EA",...getCustomFields(materialData.materialSummary?.customFields ?? {}),};diff --git a/apps/carbon/app/routes/x+/material+/new.tsx b/apps/carbon/app/routes/x+/material+/new.tsxindex 6f0909e188..0fa77467aa 100644--- a/apps/carbon/app/routes/x+/material+/new.tsx+++ b/apps/carbon/app/routes/x+/material+/new.tsx@@ -30,7 +30,6 @@ export async function action({ request }: ActionFunctionArgs) {const createMaterial = await upsertMaterial(client, {...validation.data,- active: true,companyId,customFields: setCustomFields(formData),createdBy: userId,@@ -70,8 +69,8 @@ export default function MaterialsNewRoute() {materialSubstanceId: "",itemInventoryType: "Inventory" as "Inventory",unitOfMeasureCode: "EA",- blocked: false,- active: false,+ pullFromInventory: false,+ active: true,};return (diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsxindex 441f4834b4..488322ec2f 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx@@ -64,7 +64,7 @@ export default function PartDetailsRoute() {itemGroupId: partData.partSummary?.itemGroupId ?? "",itemInventoryType: partData.partSummary?.itemInventoryType ?? "Inventory",active: partData.partSummary?.active ?? true,- blocked: partData.partSummary?.blocked ?? false,+ pullFromInventory: partData.partSummary?.pullFromInventory ?? false,replenishmentSystem: partData.partSummary?.replenishmentSystem ?? "Buy",unitOfMeasureCode: partData.partSummary?.unitOfMeasureCode ?? "EA",...getCustomFields(partData.partSummary?.customFields ?? {}),diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsxindex 0adc11baf4..7f45e914ae 100644--- a/apps/carbon/app/routes/x+/part+/new.tsx+++ b/apps/carbon/app/routes/x+/part+/new.tsx@@ -26,7 +26,6 @@ export async function action({ request }: ActionFunctionArgs) {const createPart = await upsertPart(client, {...validation.data,- active: true,companyId,customFields: setCustomFields(formData),createdBy: userId,@@ -59,8 +58,8 @@ export default function PartsNewRoute() {itemInventoryType: "Inventory" as "Inventory",replenishmentSystem: "Buy" as "Buy",unitOfMeasureCode: "EA",- blocked: false,- active: false,+ pullFromInventory: false,+ active: true,};return (diff --git a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx b/apps/carbon/app/routes/x+/service+/$itemId.details.tsxindex 19f0f33783..cd07ea1f92 100644--- a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx@@ -63,7 +63,8 @@ export default function ServiceDetailsRoute() {itemGroupId: routeData.service?.itemGroupId ?? undefined,itemInventoryType: "Non-Inventory" as const,active: routeData.service?.active ?? true,- blocked: routeData.service?.blocked ?? false,+ unitOfMeasureCode: "EA",+ pullFromInventory: false,...getCustomFields(routeData.service?.customFields),};diff --git a/apps/carbon/app/routes/x+/service+/new.tsx b/apps/carbon/app/routes/x+/service+/new.tsxindex bbc3d1f751..6b29413e0e 100644--- a/apps/carbon/app/routes/x+/service+/new.tsx+++ b/apps/carbon/app/routes/x+/service+/new.tsx@@ -31,7 +31,6 @@ export async function action({ request }: ActionFunctionArgs) {const createService = await upsertService(client, {...validation.data,companyId,- active: true,createdBy: userId,customFields: setCustomFields(formData),});@@ -64,6 +63,7 @@ export default function ServiceNewRoute() {name: "",description: "",serviceType: "External" as "External",+ active: true,};return (diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsxindex 09132b0f36..c0b9b93f6a 100644--- a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx+++ b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx@@ -64,7 +64,7 @@ export default function ToolDetailsRoute() {itemGroupId: toolData.toolSummary?.itemGroupId ?? "",itemInventoryType: toolData.toolSummary?.itemInventoryType ?? "Inventory",active: toolData.toolSummary?.active ?? true,- blocked: toolData.toolSummary?.blocked ?? false,+ pullFromInventory: toolData.toolSummary?.pullFromInventory ?? false,unitOfMeasureCode: toolData.toolSummary?.unitOfMeasureCode ?? "EA",...getCustomFields(toolData.toolSummary?.customFields ?? {}),};diff --git a/apps/carbon/app/routes/x+/tool+/new.tsx b/apps/carbon/app/routes/x+/tool+/new.tsxindex bf3798fadb..0b8e2b510d 100644--- a/apps/carbon/app/routes/x+/tool+/new.tsx+++ b/apps/carbon/app/routes/x+/tool+/new.tsx@@ -26,7 +26,6 @@ export async function action({ request }: ActionFunctionArgs) {const createTool = await upsertTool(client, {...validation.data,- active: true,companyId,customFields: setCustomFields(formData),createdBy: userId,@@ -58,8 +57,8 @@ export default function ToolsNewRoute() {description: "",itemInventoryType: "Inventory" as "Inventory",unitOfMeasureCode: "EA",- blocked: false,- active: false,+ pullFromInventory: true,+ active: true,};return (diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 5e63e1aa2b..46e1274d08 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -6019,7 +6019,6 @@ export type Database = {Row: {active: booleanassignee: string | null- blocked: booleancompanyId: string | nullcreatedAt: stringcreatedBy: string@@ -6038,7 +6037,6 @@ export type Database = {Insert: {active?: booleanassignee?: string | null- blocked?: booleancompanyId?: string | nullcreatedAt?: stringcreatedBy: string@@ -6057,7 +6055,6 @@ export type Database = {Update: {active?: booleanassignee?: string | null- blocked?: booleancompanyId?: string | nullcreatedAt?: stringcreatedBy?: string@@ -20108,7 +20105,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -20122,6 +20118,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | null@@ -20846,7 +20843,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -20862,6 +20858,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullupdatedAt: string | nullupdatedBy: string | null@@ -21304,7 +21301,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -21325,6 +21321,7 @@ export type Database = {materialSubstance: string | nullmaterialSubstanceId: string | nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | null@@ -21635,14 +21632,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]@@ -21690,7 +21687,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -21705,6 +21701,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullreplenishmentSystem:| Database["public"]["Enums"]["itemReplenishmentSystem"]| null@@ -24030,7 +24027,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -24042,6 +24038,7 @@ export type Database = {itemGroupId: string | nullitemId: string | nullname: string | null+ pullFromInventory: boolean | nullserviceType: Database["public"]["Enums"]["serviceType"] | nullsupplierIds: string[] | nulltoDate: string | null@@ -24604,7 +24601,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -24618,6 +24614,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | nulldiff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 5e63e1aa2b..46e1274d08 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -6019,7 +6019,6 @@ export type Database = {Row: {active: booleanassignee: string | null- blocked: booleancompanyId: string | nullcreatedAt: stringcreatedBy: string@@ -6038,7 +6037,6 @@ export type Database = {Insert: {active?: booleanassignee?: string | null- blocked?: booleancompanyId?: string | nullcreatedAt?: stringcreatedBy: string@@ -6057,7 +6055,6 @@ export type Database = {Update: {active?: booleanassignee?: string | null- blocked?: booleancompanyId?: string | nullcreatedAt?: stringcreatedBy?: string@@ -20108,7 +20105,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -20122,6 +20118,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | null@@ -20846,7 +20843,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -20862,6 +20858,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullupdatedAt: string | nullupdatedBy: string | null@@ -21304,7 +21301,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -21325,6 +21321,7 @@ export type Database = {materialSubstance: string | nullmaterialSubstanceId: string | nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | null@@ -21635,14 +21632,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]@@ -21690,7 +21687,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -21705,6 +21701,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullreplenishmentSystem:| Database["public"]["Enums"]["itemReplenishmentSystem"]| null@@ -24030,7 +24027,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -24042,6 +24038,7 @@ export type Database = {itemGroupId: string | nullitemId: string | nullname: string | null+ pullFromInventory: boolean | nullserviceType: Database["public"]["Enums"]["serviceType"] | nullsupplierIds: string[] | nulltoDate: string | null@@ -24604,7 +24601,6 @@ export type Database = {approved: boolean | nullapprovedBy: string | nullassignee: string | null- blocked: boolean | nullcompanyId: string | nullcreatedAt: string | nullcreatedBy: string | null@@ -24618,6 +24614,7 @@ export type Database = {| Database["public"]["Enums"]["itemInventoryType"]| nullname: string | null+ pullFromInventory: boolean | nullsupplierIds: string[] | nullunitOfMeasure: string | nullunitOfMeasureCode: string | nulldiff --git a/packages/database/supabase/migrations/20240619095417_methods.sql b/packages/database/supabase/migrations/20240619095417_methods.sqlindex 0cd57d5728..e9c59de4b8 100644--- a/packages/database/supabase/migrations/20240619095417_methods.sql+++ b/packages/database/supabase/migrations/20240619095417_methods.sql@@ -12,7 +12,6 @@ CREATE TABLE "makeMethod" ("updatedAt" TIMESTAMP WITH TIME ZONE,"updatedBy" TEXT,-CONSTRAINT "method_pkey" PRIMARY KEY ("id"),CONSTRAINT "method_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON UPDATE CASCADE ON DELETE CASCADE,CONSTRAINT "method_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company" ("id") ON UPDATE CASCADE ON DELETE CASCADE,@@ -25,7 +24,7 @@ BEGIN-- if part.replenishmentSystem is 'Make' or 'Buy and Make' then create a make method recordIF new."replenishmentSystem" = 'Make' OR new."replenishmentSystem" = 'Buy and Make' THENINSERT INTO public."makeMethod"("itemId", "createdBy", "companyId")- VALUES (new.id, new."createdBy", new."companyId");+ VALUES (new."itemId", new."createdBy", new."companyId");END IF;RETURN new;@@ -38,12 +37,7 @@ BEGIN-- if part.replenishmentSystem is 'Make' or 'Buy and Make' then create a make method recordIF old."replenishmentSystem" = 'Buy' AND (new."replenishmentSystem" = 'Make' OR new."replenishmentSystem" = 'Buy and Make') THENINSERT INTO public."makeMethod"("itemId", "createdBy", "companyId")- VALUES (new.id, new."createdBy", new."companyId");- END IF;-- -- if old replenishment system is 'Make' or 'Buy and Make' and new replenishment system is 'Buy' then delete make method record- IF (old."replenishmentSystem" = 'Make' OR old."replenishmentSystem" = 'Buy and Make') AND new."replenishmentSystem" = 'Buy' THEN- DELETE FROM public."makeMethod" WHERE "itemId" = old.id;+ VALUES (new."itemId", new."createdBy", new."companyId");END IF;RETURN new;diff --git a/packages/database/supabase/migrations/20240620095152_remove-blocked.sql b/packages/database/supabase/migrations/20240620095152_remove-blocked.sqlnew file mode 100644index 0000000000..2fbdd64695--- /dev/null+++ b/packages/database/supabase/migrations/20240620095152_remove-blocked.sql@@ -0,0 +1,163 @@+DROP VIEW "parts";+DROP VIEW "services";+DROP VIEW "materials";+DROP VIEW "tools";+DROP VIEW "consumables";+DROP VIEW "fixtures";+ALTER TABLE "item" DROP COLUMN "blocked";++CREATE OR REPLACE VIEW "parts" WITH(SECURITY_INVOKER=true) AS+ SELECT+ i.name,+ i.description,+ i."itemGroupId",+ i."itemInventoryType",+ i."unitOfMeasureCode",+ i.active,+ i."pullFromInventory",+ i.assignee,+ p.*,+ pg.name AS "itemGroup",+ ps."supplierIds",+ uom.name as "unitOfMeasure"+ FROM "part" p+ INNER JOIN "item" i ON i.id = p."itemId"+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(ps."supplierId") AS "supplierIds"+ FROM "buyMethod" ps+ GROUP BY "itemId"+ ) ps ON ps."itemId" = p."itemId"+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";+++CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS+ SELECT+ s.*,+ i.name,+ i.description,+ i."itemGroupId",+ i.active,+ i."pullFromInventory",+ i.assignee,+ pg.name AS "itemGroup",+ ss."supplierIds"+ FROM "service" s+ INNER JOIN "item" i ON i.id = s."itemId"+ LEFT JOIN "itemGroup" pg ON pg.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(ss."supplierId") AS "supplierIds"+ FROM "buyMethod" ss+ GROUP BY "itemId"+ ) ss ON ss."itemId" = s."itemId";++CREATE OR REPLACE VIEW "materials" WITH(SECURITY_INVOKER=true) AS+ SELECT+ i.name,+ i.description,+ i."itemGroupId",+ i."itemInventoryType",+ i."unitOfMeasureCode",+ i.active,+ i."pullFromInventory",+ i.assignee,+ m.*,+ mf."name" AS "materialForm",+ ms."name" AS "materialSubstance",+ ig.name AS "itemGroup",+ s."supplierIds",+ uom.name as "unitOfMeasure"+ FROM "material" m+ INNER JOIN "item" i ON i.id = m."itemId"+ LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(s."supplierId") AS "supplierIds"+ FROM "buyMethod" s+ GROUP BY "itemId"+ ) s ON s."itemId" = m."itemId"+ LEFT JOIN "materialForm" mf ON mf.id = m."materialFormId"+ LEFT JOIN "materialSubstance" ms ON ms.id = m."materialSubstanceId"+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";++CREATE OR REPLACE VIEW "tools" WITH(SECURITY_INVOKER=true) AS+ SELECT+ i.name,+ i.description,+ i."itemGroupId",+ i."itemInventoryType",+ i.active,+ i."pullFromInventory",+ i.assignee,+ i."unitOfMeasureCode",+ t.*,+ ig.name AS "itemGroup",+ s."supplierIds",+ uom.name as "unitOfMeasure"+ FROM "tool" t+ INNER JOIN "item" i ON i.id = t."itemId"+ LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(s."supplierId") AS "supplierIds"+ FROM "buyMethod" s+ GROUP BY "itemId"+ ) s ON s."itemId" = t."itemId"+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";++CREATE OR REPLACE VIEW "consumables" WITH(SECURITY_INVOKER=true) AS+ SELECT+ i.name,+ i.description,+ i."itemGroupId",+ i."itemInventoryType",+ i."unitOfMeasureCode",+ i.active,+ i."pullFromInventory",+ i.assignee,+ c.*,+ ig.name AS "itemGroup",+ s."supplierIds",+ uom.name as "unitOfMeasure"+ FROM "consumable" c+ INNER JOIN "item" i ON i.id = c."itemId"+ LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(s."supplierId") AS "supplierIds"+ FROM "buyMethod" s+ GROUP BY "itemId"+ ) s ON s."itemId" = c."itemId"+ LEFT JOIN "unitOfMeasure" uom ON uom.code = i."unitOfMeasureCode" AND uom."companyId" = i."companyId";++CREATE OR REPLACE VIEW "fixtures" WITH(SECURITY_INVOKER=true) AS+ SELECT+ i.name,+ i.description,+ i."itemGroupId",+ i."itemInventoryType",+ i.active,+ i."pullFromInventory",+ i.assignee,+ f.*,+ ig.name AS "itemGroup",+ s."supplierIds",+ c.name as "customer"+ FROM "fixture" f+ INNER JOIN "item" i ON i.id = f."itemId"+ LEFT JOIN "itemGroup" ig ON ig.id = i."itemGroupId"+ LEFT JOIN (+ SELECT+ "itemId",+ array_agg(s."supplierId") AS "supplierIds"+ FROM "buyMethod" s+ GROUP BY "itemId"+ ) s ON s."itemId" = f."itemId"+ LEFT JOIN "customer" c ON c.id = f."customerId";