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: purchase invoice line price update trigger
Brad Barbin1f91b7221fd7
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.jsonindex 13ab1aed4e..9211febe6f 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json@@ -1,5 +1,5 @@{- "generated": "2026-04-14T16:17:40.073Z",+ "generated": "2026-04-16T18:24:47.881Z","totalTools": 1016,"modules": 15,"tools": [diff --git a/packages/database/supabase/migrations/20260416000000_fix-purchase-invoice-line-price-change-interceptor.sql b/packages/database/supabase/migrations/20260416000000_fix-purchase-invoice-line-price-change-interceptor.sqlnew file mode 100644index 0000000000..8fd7dca449--- /dev/null+++ b/packages/database/supabase/migrations/20260416000000_fix-purchase-invoice-line-price-change-interceptor.sql@@ -0,0 +1,14 @@+-- =============================================================================+-- Move sync_purchase_invoice_line_price_change from BEFORE to AFTER interceptor.+--+-- unitPrice on purchaseInvoiceLine is a GENERATED STORED column. In PostgreSQL,+-- generated columns are not populated in NEW during BEFORE triggers, so the+-- interceptor saw NEW."unitPrice" as NULL and violated the NOT NULL constraint+-- on purchaseInvoicePriceChange."newPrice". Running the interceptor AFTER the+-- row is finalized restores the original legacy-trigger semantics.+-- =============================================================================++SELECT attach_event_trigger('purchaseInvoiceLine',+ ARRAY[]::TEXT[],+ ARRAY['sync_purchase_invoice_line_price_change']::TEXT[]+);diff --git a/packages/database/supabase/snippets/Untitled query 567.sql b/packages/database/supabase/snippets/Untitled query 567.sqlnew file mode 100644index 0000000000..8fd7dca449--- /dev/null+++ b/packages/database/supabase/snippets/Untitled query 567.sql@@ -0,0 +1,14 @@+-- =============================================================================+-- Move sync_purchase_invoice_line_price_change from BEFORE to AFTER interceptor.+--+-- unitPrice on purchaseInvoiceLine is a GENERATED STORED column. In PostgreSQL,+-- generated columns are not populated in NEW during BEFORE triggers, so the+-- interceptor saw NEW."unitPrice" as NULL and violated the NOT NULL constraint+-- on purchaseInvoicePriceChange."newPrice". Running the interceptor AFTER the+-- row is finalized restores the original legacy-trigger semantics.+-- =============================================================================++SELECT attach_event_trigger('purchaseInvoiceLine',+ ARRAY[]::TEXT[],+ ARRAY['sync_purchase_invoice_line_price_change']::TEXT[]+);