from openprocurement_client.client import Client
from openprocurement_client.utils import get_tender_id_by_uaid
from openprocurement_client.exceptions import IdNotFound


def prepare_api_wrapper(key, host_url, api_version):
    return Client(key, host_url, api_version)

def get_complaint_internal_id(tender, complaintID):
    for complaint in tender.data.complaints:
        if complaint.complaintID == complaintID:
            return complaint.id
    raise IdNotFound


@@ -316,16 +316,29 @@
 intID):%0A
+    try:%0A    
     for 
@@ -382,16 +382,20 @@
         
+  
+  
 if compl
@@ -435,24 +435,28 @@
             
+  
+  
 return compl
@@ -463,16 +463,290 @@
 aint.id%0A
+    except AttributeError:%0A        pass%0A    try:%0A        for award in tender.data.awards:%0A            for complaint in award.complaints:%0A                if complaint.complaintID == complaintID:%0A                    return complaint.id%0A    except AttributeError:%0A        pass%0A
     rais

Update get_complaint_internal_id