diff --git a/finance/views.py b/finance/views.py index 47d7ef9..6523f36 100644 --- a/finance/views.py +++ b/finance/views.py @@ -109,8 +109,7 @@ class InvoiceDetailView(APIView): price = request.JSON.get('price', None) comment = request.JSON.get('comment', None) real_price = request.JSON.get('real_price', None) - # rebilling_on = request.JSON.get('is_rebilling', False) - pay_count = int(request.JSON.get('pay_count', 0)) + 1 + pay_count = int(request.JSON.get('pay_count', '1')) if bill_id is None: return Response("Не передан id счёта", status=400) @@ -137,7 +136,6 @@ class InvoiceDetailView(APIView): is_open=is_open, rebilling_on=True, ) - invoice.create_child_pays(pay_count) else: try: @@ -174,6 +172,9 @@ class InvoiceDetailView(APIView): invoice.is_open = is_open invoice.comment = comment + if pay_count > 1: + invoice.create_child_pays(pay_count) + if invoice.method == 'Y' and invoice.yandex_pay is None: yandex_pay = Payment.objects.create( order_amount=invoice.price,