diff --git a/src/containers/Sales/Estimates/EstimateForm/EstimateForm.schema.js b/src/containers/Sales/Estimates/EstimateForm/EstimateForm.schema.js index 46bd23f5f..78cc4139d 100644 --- a/src/containers/Sales/Estimates/EstimateForm/EstimateForm.schema.js +++ b/src/containers/Sales/Estimates/EstimateForm/EstimateForm.schema.js @@ -2,16 +2,19 @@ import * as Yup from 'yup'; import intl from 'react-intl-universal'; import { DATATYPES_LENGTH } from 'common/dataTypes'; import { isBlank } from 'utils'; +import moment from 'moment'; const Schema = Yup.object().shape({ - customer_id: Yup.number() - .label(intl.get('customer_name_')) - .required(), - estimate_date: Yup.date() - .required() - .label(intl.get('estimate_date_')), + customer_id: Yup.number().label(intl.get('customer_name_')).required(), + estimate_date: Yup.date().required().label(intl.get('estimate_date_')), expiration_date: Yup.date() .required() + .min(Yup.ref('estimate_date'), ({ path, min }) => + intl.get('estimate.validation.expiration_date', { + path, + min: moment(min).format('YYYY/MM/DD'), + }), + ) .label(intl.get('expiration_date_')), estimate_number: Yup.string() .max(DATATYPES_LENGTH.STRING) diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json index b732b125b..944d6ea7a 100644 --- a/src/lang/ar/index.json +++ b/src/lang/ar/index.json @@ -2009,5 +2009,6 @@ "warehouse_transfer.empty_status.description": "غالبًا ماتحتاج الاعمال ذات مستودعات متعددة لطلبات نقل البضائع من مستودع إلى آخر عندما تكون في حاجة ماسة إلى البائعين.", "item.error.you_could_not_delete_item_has_associated": "لا يمكنك حذف العنصر لديه معاملات مرتبطة به ", "warehouse_transfer.quantity_cannot_be_zero_or_empty": "لا يمكن أن تكون الكمية صفراً أو فارغة.", - "invoice.validation.due_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}" + "invoice.validation.due_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}", + "estimate.validation.expiration_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}" } \ No newline at end of file diff --git a/src/lang/en/index.json b/src/lang/en/index.json index 9d46f4090..2a4d0b094 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -2009,5 +2009,6 @@ "warehouse_transfer.form.reason.label": "Reason", "warehouse_transfer.form.reason.placeholder": "Enter the reason behind the transfer order.", "warehouse_transfer.quantity_cannot_be_zero_or_empty": "Quantity cannot be zero or empty.", - "invoice.validation.due_date": "{path} field must be later than {min}" + "invoice.validation.due_date": "{path} field must be later than {min}", + "estimate.validation.expiration_date": "{path} field must be later than {min}" } \ No newline at end of file