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
fix: don't filter out inactive parts when there is a type filter on item
Brad Barbina7b68a9d2624
diff --git a/apps/erp/app/components/Form/Item.tsx b/apps/erp/app/components/Form/Item.tsxindex 6a74f2c5ab..87a6d7b9bd 100644--- a/apps/erp/app/components/Form/Item.tsx+++ b/apps/erp/app/components/Form/Item.tsx@@ -74,36 +74,35 @@ const Item = ({const [items] = useItems();const options = useMemo(() => {- const results =- (props?.replenishmentSystem || props?.includeInactive !== true- ? items.filter(- (item) =>- (type === item.type ||- (type === "Item" &&- (validItemTypes === undefined ||- // @ts-ignore- validItemTypes?.includes(item.type)))) &&- (props.replenishmentSystem === undefined ||- item.replenishmentSystem === props.replenishmentSystem ||- item.replenishmentSystem === "Buy and Make" ||- props.replenishmentSystem === item.replenishmentSystem) &&- (item.active === true || props?.includeInactive === true)- )- : items- )- .filter(- (item) =>- item.type === type ||- (type === "Item" &&- (validItemTypes === undefined ||- // @ts-ignore- validItemTypes?.includes(item.type)))- )- .map((item) => ({- value: item.id,- label: item.readableId,- helper: item.name,- })) ?? [];+ const results = items+ .filter((item) => {+ // Filter by type+ // @ts-ignore+ if (validItemTypes && !validItemTypes.includes(item.type)) return false;++ if (type !== "Item" && type !== item.type) return false;++ // Filter by active status+ // Filter by active status+ if (!props.includeInactive && !item.active) return false;++ // Filter by replenishment system+ if (props.replenishmentSystem) {+ const systemMatches =+ item.replenishmentSystem === props.replenishmentSystem ||+ item.replenishmentSystem === "Buy and Make" ||+ props.replenishmentSystem === item.replenishmentSystem;++ if (!systemMatches) return false;+ }++ return true;+ })+ .map((item) => ({+ value: item.id,+ label: item.readableId,+ helper: item.name,+ }));if (props.disabledItems) {return results.filter(diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.tsindex 84e61784d2..525cfe0b8b 100644--- a/apps/erp/app/modules/items/items.service.ts+++ b/apps/erp/app/modules/items/items.service.ts@@ -1147,15 +1147,6 @@ export async function getTools(}).eq("companyId", companyId);- const includeInactive = args?.filters?.some(- (filter) =>- (filter.column === "active" && filter.value === "false") ||- (filter.column === "active" && filter.operator === "in")- );- if (!includeInactive) {- query = query.eq("active", true);- }-if (args.search) {query = query.or(`id.ilike.%${args.search}%,name.ilike.%${args.search}%,description.ilike.%${args.search}%,supplierIds.ilike.%${args.search}%`