Moved the month_end utility from the "accounting.report.period.period" module to the new "accounting.report.period.month_end" module.

This commit is contained in:
2023-03-09 19:56:06 +08:00
parent 900d60d1ae
commit 5ebb89a6d5
3 changed files with 34 additions and 12 deletions

View File

@ -20,11 +20,11 @@ This file is largely taken from the NanoParma ERP project, first written in
2021/9/16 by imacat (imacat@nanoparma.com).
"""
import calendar
import typing as t
from datetime import date, timedelta
from .description import get_desc
from .month_end import month_end
from .specification import get_spec
@ -127,13 +127,3 @@ class Period:
if self.start is None:
return None
return Period(None, self.start - timedelta(days=1))
def month_end(day: date) -> date:
"""Returns the end day of month for a date.
:param day: The date.
:return: The end day of the month of that day.
"""
last_day: int = calendar.monthrange(day.year, day.month)[1]
return date(day.year, day.month, last_day)