diff --git a/apps/payment/management/commands/payment_fix_amounts.py b/apps/payment/management/commands/payment_fix_amounts.py new file mode 100644 index 00000000..e4ca313e --- /dev/null +++ b/apps/payment/management/commands/payment_fix_amounts.py @@ -0,0 +1,22 @@ +from decimal import Decimal +from django.core.management.base import BaseCommand +from django.db.models import F + +from apps.payment.models import Payment, AuthorBalance + + +class Command(BaseCommand): + help = 'Fix payment and author balance amount based on payment.data.effective_price_amount' + + def handle(self, *args, **options): + + for payment in Payment.objects.exclude(data__effective_price_amount=''): + if payment.data.get('effective_price_amount'): + payment.amount = Decimal(payment.data.get('effective_price_amount')) + payment.save() + + for ab in AuthorBalance.objects.exclude(payment__amount=F('amount')).select_related('payment'): + ab.amount = ab.payment.amount + ab.save() + + diff --git a/apps/payment/views.py b/apps/payment/views.py index 4137b74b..fd7bd14e 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -203,7 +203,7 @@ class PaymentwallCallbackView(View): payment.status = pingback.get_type() payment.data = payment_raw_data if pingback.is_deliverable(): - effective_amount = pingback.get_parameter('effective_price_amount') + effective_amount = payment_raw_data.get('effective_price_amount') if effective_amount: payment.amount = effective_amount diff --git a/project/templates/blocks/promo.html b/project/templates/blocks/promo.html index f02cf6ed..904fb142 100644 --- a/project/templates/blocks/promo.html +++ b/project/templates/blocks/promo.html @@ -22,7 +22,7 @@ data-day="{{ school_schedule.weekday }}" href='#' {% else %} - href="{{ school_schedule.current_live_lesson.get_absolute_url }}" + href="{% url 'school:school' %}" {% endif %} class="main__btn btn" >{% if not school_schedule.weekday in school_schedules_purchased %}Получить доступ{% else %}Смотреть урок{% endif %} @@ -41,7 +41,7 @@ data-day="{{ school_schedule.weekday }}" href='#' {% else %} - href="{{ school_schedule.current_live_lesson.get_absolute_url }}" + href="{% url 'school:school' %}" {% endif %} class="main__btn btn" >{% if not school_schedule.weekday in school_schedules_purchased %}Получить доступ{% else %}Смотреть урок{% endif %}