adamjstewart / fiscalyear

:calendar: Utilities for managing the fiscal calendar
MIT License
52 stars 13 forks source link

Fiscal Month Offset #18

Closed jbb04 closed 3 years ago

jbb04 commented 3 years ago

Fiscal Month offset does not appear to match fiscal periods

>>>fiscalyear.setup_fiscal_calendar('previous', 12, 29)
>>>c=FiscalMonth(2021, 1)
>>>c.start
FiscalDateTime(2020, 12, 29, 0, 0)
>>>c.end
FiscalDateTime(2021, 1, 28, 23, 59, 59)
>>>a = FiscalDate(2021, 1, 28)
>>>b = FiscalDate(2021, 1, 29)
>>>a.fiscal_month
2
>>>b.fiscal_month
2
>>>c.fiscal_month
1
>>>a in c
True
>>>b in c
False
adamjstewart commented 3 years ago

@nicmendoza can you take a look at this? If not I'll try to get to this later in the week. The problem is that our current logic for fiscal_month doesn't work properly when the fiscal calendar starts on any day other than the first day of the month.

nicmendoza commented 3 years ago

Sorry @adamjstewart, just seeing this. I can probably take a look Monday or Tuesday next week.

adamjstewart commented 3 years ago

Thanks! That would be great. It's almost the end of the semester for me and I'm swamped with final projects/presentations/exams.

adamjstewart commented 3 years ago

@nicmendoza did you get a chance to look at this?

adamjstewart commented 3 years ago

Ping @nicmendoza, if you can't look at this I'll try to take a look next week.

adamjstewart commented 3 years ago
fiscalyear.setup_fiscal_calendar('previous', 12, 29)

For the record, I wouldn't consider this a valid fiscal year since not all months have a 29th day. Or rather, it can work as a fiscal day as long as you don't care about fiscal months.

But the originally reported bug occurs regardless of which day is used, so I'll still try to fix that.

jbb04 commented 3 years ago

You are correct that every month doesn't have a 29th day. The actual application in the case where I discovered this is a fiscal calendar defined by the end date. I have a situation where an organization defines it's fiscal month end as the 28th of every month.