рисовальный лагерь

remotes/origin/feature/drawing-camp
gzbender 7 years ago
parent d770acb648
commit 5a74af24f0
  1. 18
      apps/payment/models.py

@ -124,22 +124,6 @@ class Payment(PolymorphicModel):
verbose_name_plural = 'Платежи'
ordering = ('created_at',)
@classmethod
def add_months(cls, sourcedate, months=1, is_camp=False):
# Лагерь всегда до коонца месяца покупается
if is_camp:
return arrow.get(sourcedate.replace(day=1), settings.TIME_ZONE).shift(months=months).date() - timedelta(1)
# FIXME после мая 2019 убрать?
# Если хотят купить школу в мае, то оплатить ее можно только до 31 мая, потом школа закроется
if sourcedate.month == 5:
return sourcedate.replace(day=31)
result = arrow.get(sourcedate, settings.TIME_ZONE).shift(months=months)
if months == 1:
if (sourcedate.month == 2 and sourcedate.day >= 28) or (sourcedate.day == 31 and result.day <= 30) \
or (sourcedate.month == 1 and sourcedate.day >= 29 and result.day == 28):
result = result.replace(day=1, month=result.month + 1)
return result.datetime
@classmethod
def get_date_range(cls, date_start=None, days=0, months=0, is_camp=False):
school_start = date(now().year, 9, 1)
@ -152,6 +136,8 @@ class Payment(PolymorphicModel):
if is_camp:
if date_start < camp_start:
date_start = camp_start
if date_start.month == 6 and date_start.day > 15:
date_start = date_start.replace(month=7, day=1)
elif school_end < date_start < school_start:
date_start = school_start
date_end = arrow.get(date_start + timedelta(days=days), settings.TIME_ZONE).shift(months=months).date() - timedelta(1)

Loading…
Cancel
Save