From 3f4ffdc99569b372554e4d1207181e78a50328f2 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:04:55 +0200 Subject: [PATCH 1/3] BIG-237: Validate invoice due date. --- .../Sales/Invoices/InvoiceForm/InvoiceForm.schema.js | 11 ++++++++++- src/lang/ar/index.json | 6 ++++-- src/lang/en/index.json | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/containers/Sales/Invoices/InvoiceForm/InvoiceForm.schema.js b/src/containers/Sales/Invoices/InvoiceForm/InvoiceForm.schema.js index eaedac85f..9d68c079a 100644 --- a/src/containers/Sales/Invoices/InvoiceForm/InvoiceForm.schema.js +++ b/src/containers/Sales/Invoices/InvoiceForm/InvoiceForm.schema.js @@ -1,4 +1,5 @@ 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'; @@ -7,7 +8,15 @@ const getSchema = () => Yup.object().shape({ customer_id: Yup.string().label(intl.get('customer_name_')).required(), invoice_date: Yup.date().required().label(intl.get('invoice_date_')), - due_date: Yup.date().required().label(intl.get('due_date_')), + due_date: Yup.date() + .min(Yup.ref('invoice_date'), ({ path, min }) => + intl.get('invoice.validation.due_date', { + path, + min: moment(min).format('YYYY/MM/DD'), + }), + ) + .required() + .label(intl.get('due_date_')), invoice_no: Yup.string() .max(DATATYPES_LENGTH.STRING) .label(intl.get('invoice_no_')), diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json index cf6eb0632..b732b125b 100644 --- a/src/lang/ar/index.json +++ b/src/lang/ar/index.json @@ -1361,6 +1361,7 @@ "item.field.sell_account.hint": "أدخل السعر الذي ستبيعه لهذا العنصر.", "item_entries.products_services.hint": "أدخل المنتجات أو الخدمات التي تبيعها أو تشتريها لتتبع ما قمت ببيعه أو شرائه.", "item_entries.landed.hint": "يتيح لك هذه الخيار إمكانية إضافة تكلفة اضافية علي فاتورة الشراء متال علي ذلك تكاليف الشحن ، ثم تحديد هذه التكلفة لتحميلها علي فاتورة الشراء.", + "item_entries.remove_row": "حذف الصف", "invoice.auto_increment.auto": "يتم تعيين أرقام الفواتير على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟", "invoice.auto_increment.manually": "يتم تعيين أرقام فواتيرك يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟", "manual_journals.auto_increment.auto": "يتم تعيين أرقام القيود على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟", @@ -1847,6 +1848,7 @@ "warehouse_transfer.column.transfer_quantity": "الكمية ", "warehouse_transfer.column.source_warehouse": "المصدر", "warehouse_transfer.column.destination_warehouse": "الوجهة", + "warehouse_transfer.column.cost_price": "سعر التكلفة", "warehouse_transfer.auto_increment.auto": "يتم تعيين أرقام النقل على وضع الزيادة التلقائي. هل أنت متأكد من تغيير هذا الإعداد؟", "warehouse_transfer.auto_increment.manually": "يتم تعيين أرقام النقل يدوياً. هل أنت متأكد من تغيير هذه الإعدادات؟", "warehouse_transfer.setting_your_auto_generated_transfer_no": "تعيين رقم النقل الذي تم إنشاؤه تلقائيًا", @@ -2006,6 +2008,6 @@ "warehouse_transfer.empty_status.title": "إدارة عمليات النقل بين المستودعات", "warehouse_transfer.empty_status.description": "غالبًا ماتحتاج الاعمال ذات مستودعات متعددة لطلبات نقل البضائع من مستودع إلى آخر عندما تكون في حاجة ماسة إلى البائعين.", "item.error.you_could_not_delete_item_has_associated": "لا يمكنك حذف العنصر لديه معاملات مرتبطة به ", - "warehouse_transfer.quantity_cannot_be_zero_or_empty": "لا يمكن أن تكون الكمية صفراً أو فارغة." - + "warehouse_transfer.quantity_cannot_be_zero_or_empty": "لا يمكن أن تكون الكمية صفراً أو فارغة.", + "invoice.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 5911e4753..9d46f4090 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1338,6 +1338,7 @@ "item.field.sell_account.hint": "Enter price which you goint to sell this item.", "item_entries.products_services.hint": "Enter products or services you sell or buy to keep tracking what your sold or purchased.", "item_entries.landed.hint": "This options allows you to be able to add additional cost eg. freight then allocate cost to the items in your bills.", + "item_entries.remove_row": "Remove line", "invoice.auto_increment.auto": "Your invoice numbers are set on auto-increment mode. Are you sure changing this setting?", "invoice.auto_increment.manually": "Your invoice numbers are set on manual mode. Are you sure chaning this settings?", "manual_journals.auto_increment.auto": "Your Jouranl numbers are set on auto-increment mode. Are you sure changing this setting?", @@ -2007,5 +2008,6 @@ "warehouse_transfer.empty_status.description": "Business with multiply warehouses often transfers items from on warehouse to another when they are in immediate need of vendors.", "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." + "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}" } \ No newline at end of file From 373a695c4cf1af71bb4676a4adef525ac8cdcfc3 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:06:58 +0200 Subject: [PATCH 2/3] BIG-236: Validate estimate expiration date. --- .../Estimates/EstimateForm/EstimateForm.schema.js | 15 +++++++++------ src/lang/ar/index.json | 3 ++- src/lang/en/index.json | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) 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 From ce674466fedf8f2f9fa46012ae282963b46cbf62 Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:09:11 +0200 Subject: [PATCH 3/3] BIG-238: Validate bill due date. --- .../Purchases/Bills/BillForm/BillForm.schema.js | 17 ++++++++++------- src/lang/ar/index.json | 3 ++- src/lang/en/index.json | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) 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