diff --git a/src/containers/Purchases/Bills/BillForm/BillForm.schema.js b/src/containers/Purchases/Bills/BillForm/BillForm.schema.js index 6f77262b2..258ad5be4 100644 --- a/src/containers/Purchases/Bills/BillForm/BillForm.schema.js +++ b/src/containers/Purchases/Bills/BillForm/BillForm.schema.js @@ -1,16 +1,19 @@ import * as Yup from 'yup'; +import moment from 'moment'; import intl from 'react-intl-universal'; import { DATATYPES_LENGTH } from 'common/dataTypes'; import { isBlank } from 'utils'; const BillFormSchema = Yup.object().shape({ - vendor_id: Yup.number() - .required() - .label(intl.get('vendor_name_')), - bill_date: Yup.date() - .required() - .label(intl.get('bill_date_')), + vendor_id: Yup.number().required().label(intl.get('vendor_name_')), + bill_date: Yup.date().required().label(intl.get('bill_date_')), due_date: Yup.date() + .min(Yup.ref('bill_date'), ({ path, min }) => + intl.get('bill.validation.due_date', { + path, + min: moment(min).format('YYYY/MM/DD'), + }), + ) .required() .label(intl.get('due_date_')), bill_number: Yup.string() @@ -25,7 +28,7 @@ const BillFormSchema = Yup.object().shape({ open: Yup.boolean(), branch_id: Yup.string(), warehouse_id: Yup.string(), - exchange_rate:Yup.number(), + exchange_rate: Yup.number(), entries: Yup.array().of( Yup.object().shape({ quantity: Yup.number() diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json index 944d6ea7a..ca3cb74aa 100644 --- a/src/lang/ar/index.json +++ b/src/lang/ar/index.json @@ -2010,5 +2010,6 @@ "item.error.you_could_not_delete_item_has_associated": "لا يمكنك حذف العنصر لديه معاملات مرتبطة به ", "warehouse_transfer.quantity_cannot_be_zero_or_empty": "لا يمكن أن تكون الكمية صفراً أو فارغة.", "invoice.validation.due_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}", - "estimate.validation.expiration_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}" + "estimate.validation.expiration_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}", + "bill.validation.due_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}" } \ No newline at end of file diff --git a/src/lang/en/index.json b/src/lang/en/index.json index 2a4d0b094..7c10a8e5b 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -2010,5 +2010,6 @@ "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}", - "estimate.validation.expiration_date": "{path} field must be later than {min}" + "estimate.validation.expiration_date": "{path} field must be later than {min}", + "bill.validation.due_date": "{path} field must be later than {min}" } \ No newline at end of file