diff --git a/models/doctype/SetupWizard/SetupWizard.js b/models/doctype/SetupWizard/SetupWizard.js index 1230f870..79c2d3d7 100644 --- a/models/doctype/SetupWizard/SetupWizard.js +++ b/models/doctype/SetupWizard/SetupWizard.js @@ -67,8 +67,13 @@ module.exports = { fieldtype: 'Date', formula: doc => { if (!doc.country) return; + let today = DateTime.local(); let fyStart = countryList[doc.country].fiscal_year_start; - return DateTime.fromFormat(fyStart, 'MM-dd').toISODate(); + return DateTime.fromFormat(fyStart, 'MM-dd') + .plus({ + year: [1, 2, 3].includes(today.month) ? -1 : 0 + }) + .toISODate(); }, required: 1 }, @@ -80,9 +85,10 @@ module.exports = { fieldtype: 'Date', formula: doc => { if (!doc.country) return; + let today = DateTime.local(); let fyEnd = countryList[doc.country].fiscal_year_end; return DateTime.fromFormat(fyEnd, 'MM-dd') - .plus({ year: 1 }) + .plus({ year: [1, 2, 3].includes(today.month) ? 0 : 1 }) .toISODate(); }, required: 1