|
|
|
|
@ -46,16 +46,18 @@ class BillListView(APIView): |
|
|
|
|
i['status'] = get_real_name(elem=i['status'][0], array=Invoice.BILL_STATUSES) |
|
|
|
|
i['bill'] = bill_obj |
|
|
|
|
i['yandex_pay'] = None |
|
|
|
|
invoice, _is_create = Invoice.objects.update_or_create(**i) |
|
|
|
|
if i['method'] == 'Y' and i['status'] == 'P': |
|
|
|
|
i['yandex_pay'], _is_create = Payment.objects.get_or_create( |
|
|
|
|
yandex_pay, _is_create = Payment.objects.get_or_create( |
|
|
|
|
order_amount=i['price'], |
|
|
|
|
order_number=bill_obj.id, |
|
|
|
|
order_number=invoice.id, |
|
|
|
|
customer_number=bill_obj.user.id, |
|
|
|
|
user=bill_obj.user, |
|
|
|
|
cps_email=bill_obj.user.email, |
|
|
|
|
) |
|
|
|
|
invoice.yandex_pay=yandex_pay |
|
|
|
|
invoice.save() |
|
|
|
|
|
|
|
|
|
invoice, _is_create = Invoice.objects.update_or_create(**i) |
|
|
|
|
invoices = [j for j in invoices if not j.id == invoice.id] |
|
|
|
|
|
|
|
|
|
[i.delete() for i in invoices] |
|
|
|
|
|