Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit a3ee38a

Browse files
authored
Improve support for fiscal years #140 (#149)
* Improve support for fiscal years #140 * Run pre-commit
1 parent c447e5f commit a3ee38a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

contratospr/api/serializers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
)
1111
from ..contracts.utils import get_current_fiscal_year
1212

13+
INITIAL_FISCAL_YEAR = 2016
14+
CURRENT_FISCAL_YEAR = get_current_fiscal_year()
15+
FISCAL_YEAR_CHOICES = [
16+
(year, str(year)) for year in range(INITIAL_FISCAL_YEAR, CURRENT_FISCAL_YEAR)
17+
]
18+
1319

1420
class RecursiveSerializer(serializers.Serializer):
1521
def to_native(self, value):
@@ -18,9 +24,7 @@ def to_native(self, value):
1824

1925
class HomeSerializer(serializers.Serializer):
2026
fiscal_year = serializers.ChoiceField(
21-
choices=[(2016, "2016"), (2017, "2017"), (2018, "2018"), (2019, "2019")],
22-
allow_null=False,
23-
initial=get_current_fiscal_year() - 1,
27+
choices=FISCAL_YEAR_CHOICES, allow_null=False, initial=CURRENT_FISCAL_YEAR - 1
2428
)
2529

2630

0 commit comments

Comments
 (0)