Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Add config settings to set the start and the end of the financial year.

David Martin24fb6cefb9c8
diff --git a/paperless.conf.example b/paperless.conf.example
index a17aac327..bb8259348 100644
--- a/paperless.conf.example
+++ b/paperless.conf.example
@@ -162,6 +162,12 @@ PAPERLESS_PASSPHRASE="secret"
#PAPERLESS_TIME_ZONE=UTC
+# If set, Paperless will show document filters per financial year.
+# The dates must be in the format "mm-dd", for example "07-15" for July 15.
+#PAPERLESS_FINANCIAL_YEAR_START="mm-dd"
+#PAPERLESS_FINANCIAL_YEAR_END="mm-dd"
+
+
# The number of items on each page in the web UI. This value must be a
# positive integer, but if you don't define one in paperless.conf, a default of
# 100 will be used.
diff --git a/src/documents/admin.py b/src/documents/admin.py
index 4304293f0..17f78ffb3 100644
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@ -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):
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index 2e525ae41..f7b2244a7 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -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")