Skip to content

Commit a685a70

Browse files
committed
[refactor] Improved readability of _monthly_subscription
1 parent f93534d commit a685a70

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

openwisp_radius/counters/resets.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def _monthly(user=None):
3636
def _monthly_subscription(user):
3737
dt = _today()
3838
day_joined = user.date_joined.day
39+
# subscription cycle starts on the day of month the user joined
3940
start = datetime(dt.year, dt.month, day_joined)
40-
if start > datetime.fromordinal(dt.toordinal()):
41+
# if the start date is in the future, shift to previous month
42+
if start > datetime(dt.year, dt.month, dt.day):
4143
start = start - relativedelta(months=1)
4244
end = datetime(start.year, start.month, day_joined) + relativedelta(months=1)
4345
return _timestamp(start, end)

0 commit comments

Comments
 (0)