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.

UI changes

Gaurav Bhatt3dd37fe5580f
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
index 7bbf35e5e4..78c316a2da 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
@@ -109,7 +109,7 @@ const SupplierPartForm = ({
if (!open) onClose();
}}
>
- <DrawerContent>
+ <DrawerContent size="lg">
<ValidatedForm
defaultValues={initialValues}
validator={supplierPartValidator}
@@ -160,7 +160,7 @@ const SupplierPartForm = ({
)}
{/* Show quantity price breaks if available */}
{priceBreaks.length > 0 && (
- <div className="text-sm bg-muted/50 rounded-md p-3 space-y-2">
+ <div className="text-sm bg-muted/50 rounded-md p-3 space-y-2 w-full">
<div className="font-medium text-foreground">
Price Breaks
</div>
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
index 187f0cce7e..737200c90b 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
@@ -227,7 +227,8 @@ export async function action(args: ActionFunctionArgs) {
await client
.from("supplierPart")
.update({
- unitPrice: (bestPrice.unitPrice ?? 0) / conversionFactor
+ unitPrice: (bestPrice.unitPrice ?? 0) / conversionFactor,
+ minimumOrderQuantity: bestPrice.quantity ?? 1
})
.eq("id", supplierPartId);
}
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 0220e2dabe..97d122b9d0 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -1621,19 +1621,23 @@ serve(async (req: Request) => {
.execute();
}
- // Update each supplierPart.unitPrice with the best (lowest) price
- // across all tiers (quotes + POs + manual)
+ // Update each supplierPart with the best (lowest) price and its
+ // corresponding MOQ across all tiers (quotes + POs + manual)
for (const [, spId] of supplierPartIdByItemId) {
- const result = await trx
+ const bestTier = await trx
.selectFrom("supplierPartPrice")
- .select((eb) => eb.fn.min("unitPrice").as("minPrice"))
+ .select(["unitPrice", "quantity"])
.where("supplierPartId", "=", spId)
+ .orderBy("unitPrice", "asc")
.executeTakeFirst();
- if (result?.minPrice != null) {
+ if (bestTier) {
await trx
.updateTable("supplierPart")
- .set({ unitPrice: Number(result.minPrice) })
+ .set({
+ unitPrice: Number(bestTier.unitPrice),
+ minimumOrderQuantity: Number(bestTier.quantity),
+ })
.where("id", "=", spId)
.execute();
}