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: custom fields for purchase order delivery form

Brad Barbin99bac678f78c
diff --git a/apps/carbon/app/modules/purchasing/purchasing.service.ts b/apps/carbon/app/modules/purchasing/purchasing.service.ts
index 53accac6e6..168e4829a6 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.service.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.service.ts
@@ -792,10 +792,12 @@ export async function upsertPurchaseOrderDelivery(
purchaseOrderDelivery:
| (z.infer<typeof purchaseOrderDeliveryValidator> & {
createdBy: string;
+ customFields?: Json;
})
| (z.infer<typeof purchaseOrderDeliveryValidator> & {
id: string;
updatedBy: string;
+ customFields?: Json;
})
) {
if ("id" in purchaseOrderDelivery) {
diff --git a/apps/carbon/app/routes/x+/purchase-order+/$orderId.delivery.tsx b/apps/carbon/app/routes/x+/purchase-order+/$orderId.delivery.tsx
index adf892c8f6..39c279e3af 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/$orderId.delivery.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/$orderId.delivery.tsx
@@ -14,6 +14,7 @@ import {
} from "~/modules/purchasing";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
+import { getCustomFields, setCustomFields } from "~/utils/form";
import { assertIsPost } from "~/utils/http";
import { path } from "~/utils/path";
import { error, success } from "~/utils/result";
@@ -82,8 +83,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { orderId } = params;
if (!orderId) throw new Error("Could not find orderId");
+ const formData = await request.formData();
const validation = await validator(purchaseOrderDeliveryValidator).validate(
- await request.formData()
+ formData
);
if (validation.error) {
@@ -96,6 +98,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
...validation.data,
id: orderId,
updatedBy: userId,
+ customFields: setCustomFields(formData),
}
);
if (updatePurchaseOrderDelivery.error) {
@@ -134,6 +137,7 @@ export default function PurchaseOrderDeliveryRoute() {
dropShipment: purchaseOrderDelivery.dropShipment ?? false,
customerId: purchaseOrderDelivery.customerId ?? "",
customerLocationId: purchaseOrderDelivery.customerLocationId ?? "",
+ ...getCustomFields(purchaseOrderDelivery.customFields),
};
return (