diff --git a/client/src/containers/Sales/Estimate/EstimateForm.js b/client/src/containers/Sales/Estimate/EstimateForm.js index 97ead1a26..6a172266f 100644 --- a/client/src/containers/Sales/Estimate/EstimateForm.js +++ b/client/src/containers/Sales/Estimate/EstimateForm.js @@ -116,7 +116,13 @@ const EstimateForm = ({ .label(formatMessage({ id: 'note' })), entries: Yup.array().of( Yup.object().shape({ - quantity: Yup.number().nullable(), + quantity: Yup.number() + .nullable() + .when(['rate'], { + is: (rate) => rate, + then: Yup.number().required(), + }), + rate: Yup.number().nullable(), item_id: Yup.number() .nullable() .when(['quantity', 'rate'], { diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.js b/client/src/containers/Sales/Invoice/InvoiceForm.js index b7f425157..761c7cf38 100644 --- a/client/src/containers/Sales/Invoice/InvoiceForm.js +++ b/client/src/containers/Sales/Invoice/InvoiceForm.js @@ -115,7 +115,12 @@ function InvoiceForm({ entries: Yup.array().of( Yup.object().shape({ - quantity: Yup.number().nullable(), + quantity: Yup.number() + .nullable() + .when(['rate'], { + is: (rate) => rate, + then: Yup.number().required(), + }), rate: Yup.number().nullable(), item_id: Yup.number() .nullable() diff --git a/client/src/containers/Sales/Receipt/ReceiptForm.js b/client/src/containers/Sales/Receipt/ReceiptForm.js index 14b4b0320..129491b96 100644 --- a/client/src/containers/Sales/Receipt/ReceiptForm.js +++ b/client/src/containers/Sales/Receipt/ReceiptForm.js @@ -116,7 +116,12 @@ function ReceiptForm({ entries: Yup.array().of( Yup.object().shape({ - quantity: Yup.number().nullable(), + quantity: Yup.number() + .nullable() + .when(['rate'], { + is: (rate) => rate, + then: Yup.number().required(), + }), rate: Yup.number().nullable(), item_id: Yup.number() .nullable()