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(sales): drop deleted lines from the quote summary total (#1853)
Brad Barbind188f346064a
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsxindex 2e4092cce3..7c542c62c8 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteSummary.tsx@@ -636,7 +636,13 @@ const QuoteSummary = ({[]);- const subtotal = Object.values(selectedLines).reduce((acc, line) => {+ // The selection is seeded once, so a line deleted since then still has an+ // entry — total only the lines the quote still has.+ const currentLines = (routeData?.lines ?? []).flatMap((line) =>+ line.id && selectedLines[line.id] ? [selectedLines[line.id]] : []+ );++ const subtotal = currentLines.reduce((acc, line) => {return (acc +(line.convertedNetUnitPrice ?? 0) * line.quantity +@@ -644,7 +650,7 @@ const QuoteSummary = ({(line.convertedShippingCost ?? 0));}, 0);- const totalDiscount = Object.values(selectedLines).reduce((acc, line) => {+ const totalDiscount = currentLines.reduce((acc, line) => {return (acc +(line.convertedUnitPrice ?? 0) *@@ -652,7 +658,7 @@ const QuoteSummary = ({(line.discountPercent ?? 0));}, 0);- const tax = Object.values(selectedLines).reduce((acc, line) => {+ const tax = currentLines.reduce((acc, line) => {return (acc +((line.convertedNetUnitPrice ?? 0) * line.quantity +diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.tsxindex c6a30abcf5..355ab41b5f 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.tsx@@ -44,6 +44,7 @@ export const handle: Handle = {realtime: [{ table: "quote", column: "id", param: "quoteId" },{ table: "quoteLine", column: "quoteId", param: "quoteId" },+ { table: "quoteLinePrice", column: "quoteId", param: "quoteId" },{ table: "quoteMaterial", column: "quoteId", param: "quoteId" },{ table: "quoteOperation", column: "quoteId", param: "quoteId" },{ table: "quoteMakeMethod", column: "quoteId", param: "quoteId" }diff --git a/packages/database/src/event-system/attachments.ts b/packages/database/src/event-system/attachments.tsindex 5b793c2311..5fc24eb01b 100644--- a/packages/database/src/event-system/attachments.ts+++ b/packages/database/src/event-system/attachments.ts@@ -260,6 +260,7 @@ export const attachments = {events: true,statement: ["broadcast_table_changes"]},+ quoteLinePrice: { statement: ["broadcast_table_changes"] },quoteMakeMethod: { statement: ["broadcast_table_changes"] },quoteMaterial: {before: ["sync_update_quote_material_make_method_item_id"],diff --git a/packages/database/supabase/migrations/20261006124819_quote-line-price-broadcast.sql b/packages/database/supabase/migrations/20261006124819_quote-line-price-broadcast.sqlnew file mode 100644index 0000000000..01c2e64939--- /dev/null+++ b/packages/database/supabase/migrations/20261006124819_quote-line-price-broadcast.sql@@ -0,0 +1,8 @@+-- Generated by `pnpm --filter @carbon/database authz migration` from packages/database/src/authz. Do not edit.++-- Ships these rules to databases where `authz sync` does not run after migrations yet.++-- event triggers (packages/database/src/event-system/attachments.ts)+SET lock_timeout = '5s';+SELECT set_event_triggers('quoteLinePrice', ARRAY[]::text[], ARRAY[]::text[], false, ARRAY['broadcast_table_changes']::text[]);+RESET lock_timeout;