Skip to content

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.

fix: invoice shipment with the multiple isntances of the same part

Brad Barbinec420fb02b2b
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 1d8feea012..dbae623b22 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -1018,10 +1018,12 @@ serve(async (req: Request) => {
if (shipmentLines.error) throw shipmentLines.error;
+ // Accumulate quantities for each sales order line
const quantitiesByLine = shipmentLines.data.reduce<
Record<string, number>
>((acc, line) => {
- acc[line.lineId!] = line.shippedQuantity;
+ const lineId = line.lineId!;
+ acc[lineId] = (acc[lineId] || 0) + line.shippedQuantity;
return acc;
}, {});