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(purchasing,invoicing): correct required-field labels on order and invoice lines

Raul4ddbe20bffa4
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
index 9d4f79ffbb..d36b5b4264 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
@@ -69,7 +69,9 @@ export default function PurchaseInvoiceExplorer() {
const purchaseInvoiceLineInitialValues = {
invoiceId: invoiceId,
- invoiceLineType: "Item" as ItemType,
+ // "Item" is the picker's generic mode, not a member of the line-type
+ // enum; posting it failed validation with "Type is required".
+ invoiceLineType: "Part" as ItemType,
purchaseQuantity: 1,
locationId:
purchaseInvoiceData?.purchaseInvoice?.locationId ??
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 7b575c9bee..aa8dcad198 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -568,6 +568,9 @@ const PurchaseInvoiceLineForm = ({
validItemTypes={[...itemType]}
locationId={locationId}
replenishmentSystem="Buy"
+ // Required by a refine rather than the schema object,
+ // so the field can't infer this for itself.
+ isOptional={false}
onChange={(value) => {
onItemChange(value?.value as string);
}}
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
index 01380db712..e4a2581e9d 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
@@ -66,7 +66,9 @@ export default function SalesInvoiceExplorer() {
const salesInvoiceLineInitialValues = {
invoiceId: invoiceId,
- invoiceLineType: "Item" as ItemType,
+ // "Item" is the picker's generic mode, not a member of the line-type
+ // enum; posting it failed validation with "Type is required".
+ invoiceLineType: "Part" as ItemType,
quantity: 1,
locationId:
salesInvoiceData?.salesInvoice?.locationId ?? defaults.locationId ?? "",
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
index aeed46cb0b..dfd488594d 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
@@ -525,6 +525,9 @@ const SalesInvoiceLineForm = ({
type={lineType}
validItemTypes={[...itemType]}
locationId={locationId}
+ // Required by a refine rather than the schema object,
+ // so the field can't infer this for itself.
+ isOptional={false}
onChange={(value) => {
onItemChange(value?.value as string);
}}
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
index 9a75965325..3a85af53d8 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
@@ -69,7 +69,11 @@ export default function PurchaseOrderExplorer() {
const purchaseOrderLineInitialValues = {
purchaseOrderId: orderId,
- purchaseOrderLineType: "Item" as ItemType,
+ // "Item" is the picker's generic mode, not a member of the line-type enum.
+ // Posting it made the validator fail with "Type is required" — an error
+ // naming a field the modal doesn't show. Start from a real type; the item
+ // picker overwrites it with the selected item's type on change.
+ purchaseOrderLineType: "Part" as ItemType,
purchaseQuantity: 1,
supplierUnitPrice: 0,
locationId:
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
index 18a057d3f4..d0dc347a1c 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
@@ -613,6 +613,10 @@ const PurchaseOrderLineForm = ({
replenishmentSystem={
isOutsideProcessing ? undefined : "Buy"
}
+ // itemId is optional on the schema object and made
+ // required by a refine, so the field can't infer its
+ // own requiredness — every item-typed line needs one.
+ isOptional={false}
onChange={(value) => {
onItemChange(value?.value as string);
}}
@@ -623,7 +627,6 @@ const PurchaseOrderLineForm = ({
label={t`Description`}
name="description"
value={itemData.description}
- isOptional={false}
/>
<InputControlled
diff --git a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.new.tsx b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.new.tsx
index 4cac657e39..31cba6186f 100644
--- a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.new.tsx
+++ b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.new.tsx
@@ -99,7 +99,9 @@ export default function NewPurchaseInvoiceLineRoute() {
const initialValues = {
invoiceId: invoiceId,
- invoiceLineType: "Item" as MethodItemType,
+ // "Item" is the picker's generic mode, not a member of the line-type
+ // enum; posting it failed validation with "Type is required".
+ invoiceLineType: "Part" as MethodItemType,
purchaseQuantity: 1,
locationId:
purchaseInvoiceData?.purchaseInvoice?.locationId ??
diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.new.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.new.tsx
index e89c48c694..253fd29a17 100644
--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.new.tsx
+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.new.tsx
@@ -112,7 +112,9 @@ export default function NewPurchaseOrderLineRoute() {
inventoryUnitOfMeasureCode: "",
itemId: "",
purchaseOrderId: orderId,
- purchaseOrderLineType: "Item" as MethodItemType,
+ // See PurchaseOrderExplorer — "Item" is the picker's generic mode and is
+ // not a valid line type.
+ purchaseOrderLineType: "Part" as MethodItemType,
purchaseQuantity: 1,
purchaseUnitOfMeasureCode: "",
requiredDate: undefined,
diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.new.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.new.tsx
index f203b4f29f..db6a09c25c 100644
--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.new.tsx
+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.new.tsx
@@ -104,7 +104,9 @@ export default function NewSalesInvoiceLineRoute() {
const initialValues = {
invoiceId: invoiceId,
- invoiceLineType: "Item" as MethodItemType,
+ // "Item" is the picker's generic mode, not a member of the line-type
+ // enum; posting it failed validation with "Type is required".
+ invoiceLineType: "Part" as MethodItemType,
quantity: 1,
unitOfMeasureCode: "EA",
locationId: