fix(setup wizard): Validate FY dates (#15419)
- start date should be less than end date
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index a030381..82d6f6e 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -141,9 +141,7 @@
let me = this;
let exist;
- // validate fiscal year start and end dates
- if (this.values.fy_start_date == 'Invalid date' || this.values.fy_end_date == 'Invalid date') {
- frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
+ if (!this.validate_fy_dates()) {
return false;
}
@@ -170,6 +168,20 @@
return true;
},
+ validate_fy_dates: function() {
+ // validate fiscal year start and end dates
+ const invalid = this.values.fy_start_date == 'Invalid date' ||
+ this.values.fy_end_date == 'Invalid date';
+ const start_greater_than_end = this.values.fy_start_date > this.values.fy_end_date;
+
+ if (invalid || start_greater_than_end) {
+ frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
+ return false;
+ }
+
+ return true;
+ },
+
set_fy_dates: function (slide) {
var country = frappe.wizard.values.country;