2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

fix: Fiscal Year in Jan, Feb, Mar

This commit is contained in:
Faris Ansari 2020-01-02 22:38:01 +05:30
parent 86f346913b
commit bb80e2ec3a

View File

@ -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