mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Add config settings to set the start and the end of the financial year.
Now we allow to filter for any financial year dates. Note that we also only show the financial year filter if the dates are actually set.
This commit is contained in:
@@ -41,12 +41,14 @@ class FinancialYearFilter(admin.SimpleListFilter):
|
||||
|
||||
def _fy_start(self, year):
|
||||
"""Return date of the start of financial year for the given year."""
|
||||
fy_start = "{}-07-01".format(str(year))
|
||||
assert settings.FY_START
|
||||
fy_start = "{}-{}".format(str(year), settings.FY_START)
|
||||
return datetime.strptime(fy_start, "%Y-%m-%d").date()
|
||||
|
||||
def _fy_end(self, year):
|
||||
"""Return date of the end of financial year for the given year."""
|
||||
fy_end = "{}-06-30".format(str(year))
|
||||
assert settings.FY_END
|
||||
fy_end = "{}-{}".format(str(year), settings.FY_END)
|
||||
return datetime.strptime(fy_end, "%Y-%m-%d").date()
|
||||
|
||||
def _determine_fy(self, date):
|
||||
@@ -105,7 +107,11 @@ class DocumentAdmin(CommonAdmin):
|
||||
|
||||
search_fields = ("correspondent__name", "title", "content")
|
||||
list_display = ("title", "created", "thumbnail", "correspondent", "tags_")
|
||||
list_filter = ("tags", "correspondent", FinancialYearFilter, MonthListFilter)
|
||||
list_filter = ("tags", "correspondent")
|
||||
if settings.FY_START and settings.FY_END:
|
||||
list_filter += (FinancialYearFilter,)
|
||||
list_filter += (MonthListFilter,)
|
||||
|
||||
ordering = ["-created", "correspondent"]
|
||||
|
||||
def has_add_permission(self, request):
|
||||
|
@@ -254,3 +254,6 @@ POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
|
||||
# positive integer, but if you don't define one in paperless.conf, a default of
|
||||
# 100 will be used.
|
||||
PAPERLESS_LIST_PER_PAGE = int(os.getenv("PAPERLESS_LIST_PER_PAGE", 100))
|
||||
|
||||
FY_START = os.getenv("PAPERLESS_FINANCIAL_YEAR_START")
|
||||
FY_END = os.getenv("PAPERLESS_FINANCIAL_YEAR_END")
|
||||
|
Reference in New Issue
Block a user