Skip to content

Commit

Permalink
Merge pull request #23 from openimis/OMT-212-Policy_migration
Browse files Browse the repository at this point in the history
Omt 212 policy migration
  • Loading branch information
xgill authored Nov 23, 2020
2 parents a76d44b + 4d3bfc3 commit 3078630
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build
dist
*.egg-info
**/.vscode
**/*.mo
locale/__init__.py
1 change: 1 addition & 0 deletions core/datetimes/ne_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from nepalicalendar import NepDate
from nepalicalendar import values
import datetime as py_datetime

from .shared import datetimedelta

"""
Expand Down
13 changes: 5 additions & 8 deletions core/datetimes/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,11 @@ def from_timedelta(cls, td):
return datetimedelta(years=0, months=0, days=td.days, seconds=td.seconds, microseconds=td.microseconds)

def _add_years(self, dt):
from core import calendar
for i in range(abs(self._years)):
for j in range(calendar.yearmonthscount(dt.year)):
if self._years > 0:
dt = _add_month(dt)
else:
dt = _sub_month(dt)
return dt
while True: # there are many '29/02' in nepali calendar
try:
return dt.replace(year=dt.year + self._years)
except ValueError:
return (dt - datetimedelta(days=1)) + self

def _add_months(self, dt):
for i in range(abs(self._months)):
Expand Down
6 changes: 6 additions & 0 deletions core/datetimes/test_ad_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def test_add_sub_years(self):
(dt - datetimedelta(years=-2)))
self.assertEquals(core.datetime.date(2018, 10, 22),
(dt - datetimedelta(years=2)))
dt = core.datetime.date(2020, 10, 29)
self.assertEquals(core.datetime.date(2021, 10, 29),
(dt + datetimedelta(years=1)))
dt = core.datetime.date(2024, 2, 29)
self.assertEquals(core.datetime.date(2023, 2, 28),
(dt + datetimedelta(years=1)))

def test_add_sub_months(self):
dt = core.datetime.date(2020, 10, 22)
Expand Down
1 change: 1 addition & 0 deletions core/gql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Meta:
model = Officer
interfaces = (graphene.relay.Node,)
filter_fields = {
"id": ["exact"],
"uuid": ["exact"],
"code": ["exact", "icontains"],
"last_name": ["exact", "icontains"],
Expand Down

0 comments on commit 3078630

Please sign in to comment.