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.

feat: select first supplier if no default supplier is selected in purchasing planning

Brad Barbin8885a6c7bbe4
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
index 6ce5ca7849..76f56696bf 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialsTable.tsx
@@ -46,7 +46,7 @@ const JobMaterialsTable = memo(({ data, count }: JobMaterialsTableProps) => {
const columns = useMemo<ColumnDef<JobMaterial>[]>(() => {
return [
{
- accessorKey: "itemReadableId",
+ accessorKey: "readableIdWithRevision",
header: "Item",
cell: ({ row }) => (
<HStack className="py-1">
diff --git a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
index 95f02145a1..ba4496d263 100644
--- a/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Planning/PurchasingPlanningTable.tsx
@@ -865,14 +865,25 @@ const PlanningTable = memo(
() => {
const initial: Record<string, string> = {};
data.forEach((item) => {
- initial[item.id] =
- // @ts-expect-error
- item.preferredSupplierId ?? item.suppliers?.[0]?.supplierId;
+ // If there's a preferred supplier, use it
+ if (item.preferredSupplierId) {
+ initial[item.id] = item.preferredSupplierId;
+ }
+ // If there's only one supplier, auto-select it regardless of preference
+ else if ((item.suppliers as SupplierPart[])?.length === 1) {
+ initial[item.id] = (item.suppliers as SupplierPart[])[0].supplierId;
+ }
+ // Otherwise, use the first available supplier if any
+ else if ((item.suppliers as SupplierPart[])?.length > 0) {
+ initial[item.id] = (item.suppliers as SupplierPart[])[0].supplierId;
+ }
});
+
return initial;
}
);
+ console.log(suppliersMap);
const isDisabled =
!permissions.can("create", "production") ||
bulkUpdateFetcher.state !== "idle" ||