From 3c28c27bd55b9665187571c9e2129b63e4fb7ef7 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 16 Mar 2018 13:37:04 +0300 Subject: [PATCH] pay --- finance/views.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/finance/views.py b/finance/views.py index 800786c..5d6f2ae 100644 --- a/finance/views.py +++ b/finance/views.py @@ -63,9 +63,17 @@ class BillListView(APIView): for i in children: status = get_real_name(elem=i['status'], array=Invoice.BILL_STATUSES) try: - invoice = Invoice.objects.get(id=i['id']) - if invoice.status == "P" or invoice.status == status: - continue + invoice_id = i['id'] + except KeyError: + invoice_id = None + + try: + if not invoice_id is None: + invoice = Invoice.objects.get(id=i['id']) + if invoice.status == "P" or invoice.status == status: + continue + else: + raise Invoice.DoesNotExist except Invoice.DoesNotExist: i['method'] = get_real_name(elem=i['method'], array=Invoice.BILL_METHOD)