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 : demo issues
Gaurav Bhatt2faef8ef5c66
diff --git a/apps/erp/app/components/Editable/EditableNumber.tsx b/apps/erp/app/components/Editable/EditableNumber.tsxindex 4e69deeae8..7ad5b438bb 100644--- a/apps/erp/app/components/Editable/EditableNumber.tsx+++ b/apps/erp/app/components/Editable/EditableNumber.tsx@@ -1,7 +1,6 @@import type { NumberFieldProps } from "@carbon/react";-import { Input, NumberField } from "@carbon/react";+import { NumberField, NumberInput } from "@carbon/react";import type { PostgrestSingleResponse } from "@supabase/supabase-js";-import type { FocusEvent, KeyboardEvent } from "react";import type { EditableTableCellComponentProps } from "~/components/Editable";const EditableNumber =@@ -20,55 +19,33 @@ const EditableNumber =onError,onUpdate}: EditableTableCellComponentProps<T>) => {- const updateNumber = async (newValue: string) => {- const numberValue = Number(newValue);- // this is the optimistic update on the FE- onUpdate({ [accessorKey]: numberValue });-- // the is the actual update on the BE- // @ts-ignore- mutation(accessorKey, numberValue, row)- .then(({ error }) => {- if (error) {- onError();- onUpdate({ [accessorKey]: value });- }- })- .catch(() => {- onError();- onUpdate({ [accessorKey]: value });- });- };-- const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {- // only run the update if they click enter- if (event.key === "Enter" || event.key === "Tab") {- if (event.currentTarget.value !== value) {- updateNumber(event.currentTarget.value);- }- }- };+ return (+ <NumberField+ {...numberFieldProps}+ value={value as number}+ onChange={(numberValue) => {+ if (!Number.isFinite(numberValue) || numberValue === value) return;- // run update if focus is lost- const onBlur = (event: FocusEvent<HTMLInputElement>) => {- if (event.currentTarget.value !== value) {- updateNumber(event.currentTarget.value);- }- };+ onUpdate({ [accessorKey]: numberValue });- return (- <NumberField {...numberFieldProps} defaultValue={value as number}>- <Input+ // @ts-ignore+ mutation(accessorKey, numberValue, row)+ .then(({ error }) => {+ if (error) {+ onError();+ onUpdate({ [accessorKey]: value });+ }+ })+ .catch(() => {+ onError();+ onUpdate({ [accessorKey]: value });+ });+ }}+ >+ <NumberInputsize="sm"- className="w-full rounded-none outline-none border-none focus-visible:ring-0 out"+ className="w-full rounded-none outline-none border-none focus-visible:ring-0"autoFocus- onKeyDown={onKeyDown}- onBlur={onBlur}- ref={(input) => {- if (input) {- input.select();- }- }}/></NumberField>);diff --git a/apps/erp/app/modules/purchasing/purchasing.models.ts b/apps/erp/app/modules/purchasing/purchasing.models.tsindex d33cd527ee..7ae4ccecd4 100644--- a/apps/erp/app/modules/purchasing/purchasing.models.ts+++ b/apps/erp/app/modules/purchasing/purchasing.models.ts@@ -126,7 +126,6 @@ export const supplierQuoteFinalizeValidator = z.object({notification: z.enum(["Email", "Share"]).optional(),supplierContact: zfd.text(z.string().optional()),- sendAttachments: zfd.checkbox(),cc: z.array(z.string()).optional()}).refine(diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsxindex d458d3c340..a25604ad12 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx@@ -1,9 +1,7 @@import { ValidatedForm } from "@carbon/form";import {Button,- Checkbox,Copy,- HStack,Input,InputGroup,InputRightElement,@@ -50,8 +48,6 @@ const SupplierQuoteSendModal = ({const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "Share");- const [sendAttachments, setSendAttachments] = useState(true);-const digitalQuoteUrl =externalLinkId && typeof window !== "undefined"? `${window.location.origin}${path.to.externalSupplierQuote(@@ -112,7 +108,6 @@ const SupplierQuoteSendModal = ({defaultValues={{notification: notificationType as "Email" | "Share",supplierContact: quote?.supplierContactId ?? undefined,- sendAttachments: sendAttachments,cc: defaultCc}}fetcher={fetcher}@@ -171,19 +166,6 @@ const SupplierQuoteSendModal = ({supplier={quote?.supplierId ?? undefined}/><EmailRecipients name="cc" label="CC" type="employee" />- <HStack spacing={2}>- <Checkbox- id="sendAttachments"- name="sendAttachments"- isChecked={sendAttachments}- onCheckedChange={(checked) =>- setSendAttachments(checked === true)- }- />- <label htmlFor="sendAttachments" className="text-sm">- Send documents attached to line items- </label>- </HStack></>)}</VStack>diff --git a/apps/erp/app/routes/share+/supplier-quote.$id.tsx b/apps/erp/app/routes/share+/supplier-quote.$id.tsxindex a5f5399a33..dea9971bfe 100644--- a/apps/erp/app/routes/share+/supplier-quote.$id.tsx+++ b/apps/erp/app/routes/share+/supplier-quote.$id.tsx@@ -815,11 +815,32 @@ const Quote = ({}}, [fetcher.state, submitModal, declineModal]);- // Initialize selected lines - don't select by default+ // Initialize selected lines from existing pricing dataconst [selectedLines, setSelectedLines] = useState<Record<string, Record<number, SelectedLine>>>(() => {- return {};+ const initial: Record<string, Record<number, SelectedLine>> = {};+ for (const price of quoteLinePrices) {+ if (!price.supplierQuoteLineId) continue;+ if (+ (price.supplierUnitPrice && price.supplierUnitPrice > 0) ||+ (price.leadTime && price.leadTime > 0)+ ) {+ if (!initial[price.supplierQuoteLineId]) {+ initial[price.supplierQuoteLineId] = {};+ }+ initial[price.supplierQuoteLineId][price.quantity] = {+ quantity: price.quantity,+ supplierUnitPrice: price.supplierUnitPrice ?? 0,+ unitPrice: price.unitPrice ?? 0,+ leadTime: price.leadTime ?? 0,+ shippingCost: price.shippingCost ?? 0,+ supplierShippingCost: price.supplierShippingCost ?? 0,+ supplierTaxAmount: price.supplierTaxAmount ?? 0+ };+ }+ }+ return initial;});// Handler to save notes for a linediff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsxindex 0fdf25bc68..272e110032 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx@@ -89,7 +89,6 @@ export async function action(args: ActionFunctionArgs) {const {notification,supplierContact: supplierContactId,- sendAttachments,cc: ccSelections} = validation.data;@@ -113,24 +112,52 @@ export async function action(args: ActionFunctionArgs) {throw new Error("Failed to get supplier quote");if (!user.data) throw new Error("Failed to get user");- // Fetch all line items and their attached documents if sendAttachments is enabledconst attachments: Array<{ filename: string; content: string }> = [];- if (sendAttachments) {- // Fetch top-level supplier interaction documents- const interactionId = supplierQuote.data.supplierInteractionId;- if (interactionId) {- const topDocs = await getSupplierInteractionDocuments(+ // Fetch top-level supplier interaction documents+ const interactionId = supplierQuote.data.supplierInteractionId;+ if (interactionId) {+ const topDocs = await getSupplierInteractionDocuments(+ client,+ companyId,+ interactionId+ );++ for (const doc of topDocs) {+ const { data: fileData } = await client.storage+ .from("private")+ .download(+ `${companyId}/supplier-interaction/${interactionId}/${doc.name}`+ );++ if (fileData) {+ const arrayBuffer = await fileData.arrayBuffer();+ const base64 = Buffer.from(arrayBuffer).toString("base64");++ attachments.push({+ filename: doc.name,+ content: base64+ });+ }+ }+ }++ // Fetch line-level supplier interaction documents+ const lines = await getSupplierQuoteLines(client, id);++ if (lines.data) {+ for (const line of lines.data) {+ const docs = await getSupplierInteractionLineDocuments(client,companyId,- interactionId+ line.id ?? "");- for (const doc of topDocs) {+ for (const doc of docs) {const { data: fileData } = await client.storage.from("private").download(- `${companyId}/supplier-interaction/${interactionId}/${doc.name}`+ `${companyId}/supplier-interaction-line/${line.id}/${doc.name}`);if (fileData) {@@ -144,37 +171,6 @@ export async function action(args: ActionFunctionArgs) {}}}-- // Fetch line-level supplier interaction documents- const lines = await getSupplierQuoteLines(client, id);-- if (lines.data) {- for (const line of lines.data) {- const docs = await getSupplierInteractionLineDocuments(- client,- companyId,- line.id ?? ""- );-- for (const doc of docs) {- const { data: fileData } = await client.storage- .from("private")- .download(- `${companyId}/supplier-interaction-line/${line.id}/${doc.name}`- );-- if (fileData) {- const arrayBuffer = await fileData.arrayBuffer();- const base64 = Buffer.from(arrayBuffer).toString("base64");-- attachments.push({- filename: doc.name,- content: base64- });- }- }- }- }}const requestUrl = new URL(request.url);