class cls_Invoice: Intervention = None Patient = None Debtor = None Articles = None data = None def __init__(self): pass def parse_item(self, obj: object): self.Intervention = obj["intervention"] self.Patient = obj["patient"] self.Debtor = obj["debtor"] self.Articles = obj["articles"] self.data = obj self.a_index = {"invoice": [], "intervention": [], "patient": [], "debtor": [], "articles": []} self.index_counter = 0 self.format_debitor_addr_2() def format_debitor_addr_2(self): debitor = self.Debtor con = "" concat_str = "" if "name" in debitor.keys(): if debitor["name"] is not None: concat_str += con + debitor["name"] # con = "#chr(13)##chr(10)#" con = "\n" if debitor["gender"] is not None: concat_str += con + "Monsieur" if debitor["gender"] == "Masculin" else con + "Madame" # con = "#chr(13)##chr(10)#" con = "\n" if debitor["lastname"] is not None: concat_str += con + self.ifNotNull(debitor["lastname"]) + " " + self.ifNotNull( debitor["firstname"]) # con = "#chr(13)##chr(10)#" con = "\n" if debitor["complement"] is not None: concat_str += con + debitor["complement"] # con = "#chr(13)##chr(10)#" con = "\n" if debitor["street"] is not None: concat_str += con + self.ifNotNull(debitor["street"]) + " " + self.ifNotNull( debitor["street_number"]) # con = "#chr(13)##chr(10)#" con = "\n" if debitor["city"] is not None: concat_str += con + self.ifNotNull(debitor["postal_code"]) + " " + self.ifNotNull( debitor["city"]) # con = "#chr(13)##chr(10)#" con = "\n" if debitor["country_name"] != "Suisse": concat_str += con + debitor["country_name"] # con = "#chr(13)##chr(10)#" con = "\n" self.Patient["addr_2"] = concat_str self.Patient["selfish"] = self.is_addr_2_selfish(self.Patient) def is_addr_2_selfish(self, patient): print(patient) temp_addr_2 = str(patient["addr_2"]).replace("Monsieur","").replace("Madame","").replace("\n","").replace(" ","") str_compare = self.ifNotNull(patient['lastname']).replace('.','') + self.ifNotNull(patient['firstname']).replace('.','') + self.ifNotNull(patient['complement']).strip()+ self.ifNotNull(patient['street']).strip() + self.ifNotNull(patient['street_number']).strip() + self.ifNotNull(patient['postal_code']).strip() +self.ifNotNull(patient['city']).strip() str_compare = str_compare.replace(" ","") print(f"is_addr_2_selfish ? {str_compare} <> {temp_addr_2} = {str_compare == temp_addr_2}") return str_compare == temp_addr_2 def ifNotNull(self, value, ret=""): if value == None or value == "None": return ret return value.strip() class cls_Col: data = [] def __init__(self, winbiz = False): self.data = [] if winbiz == True: for x in range(170): self.data.append("")