Update "add day" ammount calc

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent de8a47c6c6
commit ec0a931b60
  1. 13
      apps/payment/models.py
  2. 2
      apps/payment/views.py

@ -167,8 +167,19 @@ class SchoolPayment(Payment):
models.Sum('month_price'),
)
if self.add_days:
_school_payment = SchoolPayment.objects.filter(
add_days=False,
date_start__lte=self.date_start,
date_end__gte=self.date_end,
status__in=[
Pingback.PINGBACK_TYPE_REGULAR,
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
).last()
weekday_count = weekday_in_date_range(self.date_start, self.date_end, self.weekdays[0])
month_price_sum = aggregate.get('month_price__sum', 0) * weekday_count / 30
all_weekday_count = weekday_in_date_range(_school_payment.date_start, _school_payment.date_end, self.weekdays[0])
month_price_sum = aggregate.get('month_price__sum', 0) * weekday_count // all_weekday_count
else:
month_price_sum = aggregate.get('month_price__sum', 0)
if month_price_sum > config.SERVICE_DISCOUNT_MIN_AMOUNT:

@ -107,7 +107,7 @@ class SchoolBuyView(TemplateView):
user=request.user,
weekdays=weekdays,
date_start=now().date(),
date_end=now().date(),
date_end=_school_payment.date_end,
add_days=True,
)
if school_payment.amount <= 0:

Loading…
Cancel
Save