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:
parent
900d60d1ae
commit
5ebb89a6d5
31
src/accounting/report/period/month_end.py
Normal file
31
src/accounting/report/period/month_end.py
Normal file
@ -0,0 +1,31 @@
|
||||
# The Mia! Accounting Flask Project.
|
||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/4
|
||||
|
||||
# Copyright (c) 2023 imacat.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""The utility to return the end of a month.
|
||||
|
||||
"""
|
||||
import calendar
|
||||
from datetime import date
|
||||
|
||||
|
||||
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)
|
@ -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)
|
||||
|
@ -20,7 +20,8 @@
|
||||
from datetime import date, timedelta
|
||||
|
||||
from accounting.locale import gettext
|
||||
from .period import Period, month_end
|
||||
from .month_end import month_end
|
||||
from .period import Period
|
||||
|
||||
|
||||
class ThisMonth(Period):
|
||||
|
Loading…
Reference in New Issue
Block a user