Skip to content

Commit

Permalink
Improve support for fiscal years #140 (#149)
Browse files Browse the repository at this point in the history
* Improve support for fiscal years #140

* Run pre-commit
  • Loading branch information
jpadilla authored Aug 13, 2020
1 parent c447e5f commit a3ee38a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions contratospr/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
)
from ..contracts.utils import get_current_fiscal_year

INITIAL_FISCAL_YEAR = 2016
CURRENT_FISCAL_YEAR = get_current_fiscal_year()
FISCAL_YEAR_CHOICES = [
(year, str(year)) for year in range(INITIAL_FISCAL_YEAR, CURRENT_FISCAL_YEAR)
]


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

class HomeSerializer(serializers.Serializer):
fiscal_year = serializers.ChoiceField(
choices=[(2016, "2016"), (2017, "2017"), (2018, "2018"), (2019, "2019")],
allow_null=False,
initial=get_current_fiscal_year() - 1,
choices=FISCAL_YEAR_CHOICES, allow_null=False, initial=CURRENT_FISCAL_YEAR - 1
)


Expand Down

0 comments on commit a3ee38a

Please sign in to comment.