thr-consulting / thr-addons

Monorepo for THR support packages.
https://thr-consulting.github.io/thr-addons/
MIT License
4 stars 0 forks source link

getFiscalYearRange mid-month year end bug #391

Closed Spoowy closed 2 months ago

Spoowy commented 7 months ago

getFiscalYearRange in thr-addons assumes that year ends are always on the 30th of a given month, which leads to an unexpected behaviour as seen here:

const {start, end} = getFiscalYearRange(date, yearEnd);
{
  yearEnd: LocalDate { _year: 2022, _month: 9, _day: 20 },
  date: LocalDate { _year: 2024, _month: 9, _day: 30 },
  start: LocalDate { _year: 2024, _month: 10, _day: 1 },
  end: LocalDate { _year: 2025, _month: 9, _day: 30 }
}

It jumps from year end day 20 to 30.. This could lead to reporting issues if a client in fact has a mid-month year end, mid-month year ends are legit in accounting. But nonetheless, any change to this function needs to be thoroughly tested as a lot in mymc relies on it.

shaynethiessen commented 7 months ago

Accounts have a year end date. We should be using that to calculate the range