Compare commits

...

9 Commits

Author SHA1 Message Date
Ambulance Clerc
56c23ae53c débug comparaison HRF et suppression du break au moment du HRF 2023-10-31 11:43:30 +01:00
Ambulance Clerc
5998bf48cb débug comparaison de l'adresse de livraison 2023-06-20 15:59:48 +02:00
Ambulance Clerc
5311208184 débug comparaison de l'adresse de livraison 2023-06-20 15:44:29 +02:00
Ambulance Clerc
86a2b99f39 débug comparaison de l'adresse de livraison 2023-06-20 15:44:04 +02:00
Ambulance Clerc
eb0e4b4429 débug comparaison de l'adresse de livraison 2023-06-20 15:02:52 +02:00
Ambulance Clerc
4387a1d00b débug comparaison de l'adresse de livraison 2023-06-20 14:53:20 +02:00
Ambulance Clerc
c722af1091 débug comparaison de l'adresse de livraison 2023-06-20 14:23:34 +02:00
Ambulance Clerc
92b3a76733 débug comparaison de l'adresse de livraison 2023-06-20 11:10:18 +02:00
Ambulance Clerc
5adbc77555 Débug de la feature adresse_livraison 2023-06-16 19:43:34 +02:00
6 changed files with 89 additions and 49 deletions

View File

@@ -7,6 +7,7 @@ class cls_Addresses:
self.items.append(items) self.items.append(items)
def get_item_by_AVS(self, seek): def get_item_by_AVS(self, seek):
for item in self.items: for item in self.items:
if item.AVS == seek: if item.AVS == seek:
return item return item

View File

@@ -25,36 +25,44 @@ class cls_Invoice:
if debitor["name"] is not None: if debitor["name"] is not None:
concat_str += con + debitor["name"] concat_str += con + debitor["name"]
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["gender"] is not None: if debitor["gender"] is not None:
concat_str += con + "Monsieur" if debitor["gender"] == "Masculin" else con + "Madame" concat_str += con + "Monsieur" if debitor["gender"] == "Masculin" else con + "Madame"
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["lastname"] is not None: if debitor["lastname"] is not None:
concat_str += con + self.ifNotNull(debitor["lastname"]) + " " + self.ifNotNull( concat_str += con + self.ifNotNull(debitor["lastname"]) + " " + self.ifNotNull(
debitor["firstname"]) debitor["firstname"])
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["complement"] is not None: if debitor["complement"] is not None:
concat_str += con + debitor["complement"] concat_str += con + debitor["complement"]
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["street"] is not None: if debitor["street"] is not None:
concat_str += con + self.ifNotNull(debitor["street"]) + " " + self.ifNotNull( concat_str += con + self.ifNotNull(debitor["street"]) + " " + self.ifNotNull(
debitor["street_number"]) debitor["street_number"])
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["city"] is not None: if debitor["city"] is not None:
concat_str += con + self.ifNotNull(debitor["postal_code"]) + " " + self.ifNotNull( concat_str += con + self.ifNotNull(debitor["postal_code"]) + " " + self.ifNotNull(
debitor["city"]) debitor["city"])
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
if debitor["country_name"] != "Suisse": if debitor["country_name"] != "Suisse":
concat_str += con + debitor["country_name"] concat_str += con + debitor["country_name"]
# con = "#chr(13)##chr(10)#" # con = "#chr(13)##chr(10)#"
con = "\r\n" con = "\n"
self.Patient["addr_2"] = concat_str 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=""): def ifNotNull(self, value, ret=""):
if value == None or value == "None": if value == None or value == "None":
return ret return ret

View File

@@ -37,27 +37,31 @@ class Check_addresses_popup(Toplevel):
fonts = [] fonts = []
self.x_row = 0 self.x_row = 0
self.add_compares_element(new_frame=lbf_new,old_frame=lbf_old,label="N° AVS de l'adresse:",str1=item_1['insurance_policy_number'].replace('.',''), str2=item_2.AVS) self.add_compares_element(new_frame=lbf_new,old_frame=lbf_old,label="N° AVS de l'adresse:",str1=self.ifNotNull(item_1['insurance_policy_number']).replace('.',''), str2=item_2.AVS)
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Nom:", str1=item_1['lastname'], str2=item_2.lastName) self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Nom:", str1=self.ifNotNull(item_1['lastname']), str2=item_2.lastName)
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Prénom:", str1=item_1['firstname'], str2=item_2.firstName) self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Prénom:", str1=self.ifNotNull(item_1['firstname']), str2=item_2.firstName)
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Date de naissance:", str1=datetime.strptime(item_1['birthdate'], "%Y-%m-%d").strftime("%d.%m.%Y"), str2=item_2.birth) self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Date de naissance:", str1=datetime.strptime(self.ifNotNull(item_1['birthdate']), "%Y-%m-%d").strftime("%d.%m.%Y"), str2=item_2.birth)
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Adresse:", str1=f"{item_1['street'].strip()} {item_1['street_number'].strip()}", str2=item_2.street.strip()) self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Adresse:", str1=f"{self.ifNotNull(item_1['street']).strip()} {self.ifNotNull(item_1['street_number']).strip()}", str2=item_2.street.strip())
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Complément:", str1=f"{item_1['complement'].strip()}", str2=item_2.street_cpl.strip()) self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="Complément:", str1=f"{self.ifNotNull(item_1['complement']).strip()}", str2=item_2.street_cpl.strip())
self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="NPA/Localité:", str1=f"{item_1['postal_code']} {item_1['city']}", str2=f"{item_2.npa} {item_2.city}") self.add_compares_element(new_frame=lbf_new, old_frame=lbf_old, label="NPA/Localité:", str1=f"{self.ifNotNull(item_1['postal_code'])} {self.ifNotNull(item_1['city'])}", str2=f"{item_2.npa} {item_2.city}")
if int(debitor["code"]) < 100:
self.add_compares_element(new_frame=lbf_addr_2_new, old_frame=lbf_addr_2_old, label="Adresse livraison:", str1=item_1["addr_2"], if item_1["selfish"]:
str2=self.ifNotNull(item_2.addr_2)) force_color = "green"
else:
force_color = None
self.add_compares_element(new_frame=lbf_addr_2_new, old_frame=lbf_addr_2_old, label="Adresse livraison:", str1=item_1["addr_2"],
str2=self.ifNotNull(item_2.addr_2),force_color_1=force_color)
str_address_1 += item_1['insurance_policy_number'].replace('.', '') str_address_1 += self.ifNotNull(item_1['insurance_policy_number']).replace('.', '')
str_address_1 += item_1['lastname'].strip() str_address_1 += self.ifNotNull(item_1['lastname']).strip()
str_address_1 += item_1['firstname'].strip() str_address_1 +=self.ifNotNull( item_1['firstname']).strip()
str_address_1 += datetime.strptime(item_1['birthdate'], "%Y-%m-%d").strftime("%d.%m.%Y") str_address_1 += datetime.strptime(item_1['birthdate'], "%Y-%m-%d").strftime("%d.%m.%Y")
str_address_1 += f"{item_1['street'].strip()} {item_1['street_number'].strip()}" str_address_1 += f"{self.ifNotNull(item_1['street']).strip()} {self.ifNotNull(item_1['street_number']).strip()}"
str_address_1 += f"{item_1['complement'].strip()}" str_address_1 += f"{self.ifNotNull(item_1['complement']).strip()}"
str_address_1 += f"{item_1['postal_code']} {item_1['city']}" str_address_1 += f"{self.ifNotNull(item_1['postal_code'])} {self.ifNotNull(item_1['city'])}"
@@ -104,19 +108,23 @@ class Check_addresses_popup(Toplevel):
return ret return ret
return value.strip() return value.strip()
def add_compares_element(self,new_frame, old_frame,str1, str2, label): def add_compares_element(self,new_frame, old_frame,str1, str2, label, force_color_1=None):
label_font = font.Font(weight='bold', size=9) label_font = font.Font(weight='bold', size=9)
value_color = "black" value_color_1 = "black"
value_color_2 = "black"
con = "" con = ""
if str1 != str2: if str1 != str2:
value_color = "red" value_color_1 = "red"
value_color_2 = "red"
con = "*" con = "*"
if force_color_1 is not None:
value_color_1 = force_color_1
Label(new_frame, text=str(label), font=label_font).grid(row=self.x_row, column=0, sticky="W") Label(new_frame, text=str(label), font=label_font).grid(row=self.x_row, column=0, sticky="W")
Label(new_frame, text=con + str(str1) + con, fg=value_color).grid(row=self.x_row, column=1, sticky="W") Label(new_frame, text=con + str(str1) + con, fg=value_color_1, anchor="w", justify=LEFT).grid(row=self.x_row, column=1, sticky="W")
Label(old_frame, text=str(label), font=label_font).grid(row=self.x_row, column=0, sticky="W") Label(old_frame, text=str(label), font=label_font).grid(row=self.x_row, column=0, sticky="W")
Label(old_frame, text=con + str(str2) + con, fg=value_color).grid(row=self.x_row, column=1, sticky="W") Label(old_frame, text=con + str(str2) + con, fg=value_color_2, anchor="w", justify=LEFT).grid(row=self.x_row, column=1, sticky="W")
self.x_row += 1 self.x_row += 1

View File

@@ -1 +1 @@
20230616-1729 20231031-1142

61
main.py
View File

@@ -289,7 +289,6 @@ class ClercAttrib2Biz():
file_addresses_path = os.path.join(temp_dir, f"adresses.dbf") file_addresses_path = os.path.join(temp_dir, f"adresses.dbf")
if os.path.exists(file_addresses_path): if os.path.exists(file_addresses_path):
for record in DBF(file_addresses_path, load=True): for record in DBF(file_addresses_path, load=True):
o_addresse = cls_addresse() o_addresse = cls_addresse()
o_addresse.AVS = str(record["AD_CODE"]) o_addresse.AVS = str(record["AD_CODE"])
o_addresse.lastName =str( record["AD_NOM"]) o_addresse.lastName =str( record["AD_NOM"])
@@ -303,7 +302,7 @@ class ClercAttrib2Biz():
o_addresse.street_cpl =str( record["AD_RUE_1"]) o_addresse.street_cpl =str( record["AD_RUE_1"])
o_addresse.npa =str( record["AD_NPA"]) o_addresse.npa =str( record["AD_NPA"])
o_addresse.city = str(record["AD_VILLE"]) o_addresse.city = str(record["AD_VILLE"])
o_addresse.addr_2 = str(record["AD_ADR2"]) o_addresse.addr_2 = str(record["AD_ADR2"]).replace("\r\n","\n")
self.addresses.add_addresse(o_addresse) self.addresses.add_addresse(o_addresse)
logging.warning(f"Chargement du fichier adresses.dbf terminé ! {len(self.addresses.items)} adresses trouvées ") logging.warning(f"Chargement du fichier adresses.dbf terminé ! {len(self.addresses.items)} adresses trouvées ")
else: else:
@@ -397,26 +396,39 @@ class ClercAttrib2Biz():
return ret return ret
def compare_old_and_new_adresses(self, new, old): def compare_old_and_new_adresses(self, new, old, code):
print(f"compare_old_and_new_adresses ")
if new['insurance_policy_number'].replace('.','') != old.AVS: if self.ifNotNull(new['insurance_policy_number']).replace('.','') != old.AVS:
print("compare adresse exit avs")
return False return False
if new['lastname'].replace('.','') != old.lastName: if self.ifNotNull(new['lastname']).replace('.','') != old.lastName:
print("compare adresse exit lastname")
return False return False
if new['firstname'].replace('.','') != old.firstName: if self.ifNotNull(new['firstname']).replace('.','') != old.firstName:
print("compare adresse exit firstname")
return False return False
if datetime.strptime(new['birthdate'], "%Y-%m-%d").strftime("%d.%m.%Y") != old.birth: if datetime.strptime(self.ifNotNull(new['birthdate']), "%Y-%m-%d").strftime("%d.%m.%Y") != old.birth:
print("compare adresse exit date")
return False return False
if f"{new['street'].strip()} {new['street_number'].strip()}" != f"{old.street.strip()}": if f"{self.ifNotNull(new['street']).strip()} {self.ifNotNull(new['street_number']).strip()}" != f"{self.ifNotNull(old.street).strip()}":
print(f"({new['street'].strip()} {new['street_number'].strip()}) != [" + old.street.strip()+"]") print(f"compare adresse exit ({self.ifNotNull(new['street']).strip()} {self.ifNotNull(new['street_number']).strip()}) != [" + self.ifNotNull(old.street).strip()+"]")
return False return False
if f"{new['postal_code']} {new['city']}" != f"{old.npa} {old.city}": if f"{self.ifNotNull(new['postal_code'])} {self.ifNotNull(new['city'])}" != f"{self.ifNotNull(old.npa)} {self.ifNotNull(old.city)}":
return False print("compare adresse exit city")
if new["addr_2"] != old.addr_2:
return False return False
if new["addr_2"] != old.addr_2 and int(code) < 100:
if not new["selfish"]:
print(f"Exit selfish")
return False
if old.addr_2 != "None":
print(f"Exit addr_2 = {old.addr_2}/{new['selfish']}")
print(old.addr_2 != "None")
return False
print("return True (same)")
return True return True
def parseFile(self, data, filename): def parseFile(self, data, filename):
self.progress_bar["value"] = 0 self.progress_bar["value"] = 0
self.index_counter += 1 self.index_counter += 1
@@ -432,8 +444,10 @@ class ClercAttrib2Biz():
cur_invoice_index = 0 cur_invoice_index = 0
total_facture_total = 0
total_facture_amount = 0
for ele in data["invoices"]: for ele in data["invoices"]:
cur_invoice_index += 1 cur_invoice_index += 1
self.progress_bar["value"] = cur_invoice_index / self.count_facture * 100 self.progress_bar["value"] = cur_invoice_index / self.count_facture * 100
b_address_update = True b_address_update = True
@@ -546,13 +560,13 @@ class ClercAttrib2Biz():
if self.check_addresses.get(): if self.check_addresses.get():
addresses_exist = self.addresses.get_item_by_AVS(data.Patient['insurance_policy_number'].replace(".", "")) addresses_exist = self.addresses.get_item_by_AVS(data.Patient['insurance_policy_number'].replace(".", ""))
if addresses_exist is not None and not self.compare_old_and_new_adresses(new=data.Patient, old=addresses_exist): if addresses_exist is not None and not self.compare_old_and_new_adresses(new=data.Patient, old=addresses_exist, code=data.Debtor['code']):
popup = Check_addresses_popup(self.fenetre, item_1=data.Patient, item_2=addresses_exist, debitor=data.Debtor, factureID=data.data['id']) popup = Check_addresses_popup(self.fenetre, item_1=data.Patient, item_2=addresses_exist, debitor=data.Debtor, factureID=data.data['id'])
b_address_update = popup.show() b_address_update = popup.show()
mode_selected = "Attrib" if b_address_update else "Winbiz" mode_selected = "Attrib" if b_address_update else "Winbiz"
self.logger.warning( self.logger.warning(
f"Adresse connue donnée [{mode_selected}] conservé: : {data.data['id']} / {data.Patient['fip_number']} {data.Debtor['code']} {data.Debtor['lastname']} {data.Debtor['firstname']}") f"Adresse connue données {mode_selected} conservées: {data.data['id']} / {data.Patient['fip_number']} {data.Debtor['code']} {data.Debtor['lastname']} {data.Debtor['firstname']}")
print(f"Result Popup: {b_address_update}") print(f"Result Popup: {b_address_update}")
else: else:
b_address_update = True b_address_update = True
@@ -562,7 +576,11 @@ class ClercAttrib2Biz():
b_HRF = False b_HRF = False
sHRF = "" sHRF = ""
facture_total = 0
for article in data.Articles: for article in data.Articles:
if 'price' in article:
facture_total += float(article['price'])
if "code" in article.keys(): if "code" in article.keys():
if article["code"] == "HRF": if article["code"] == "HRF":
@@ -570,9 +588,12 @@ class ClercAttrib2Biz():
sHRF = article["line_1"].replace("h", ":") sHRF = article["line_1"].replace("h", ":")
print(f"pass HRF => {data.Patient['fip_number']} = {b_HRF}") print(f"pass HRF => {data.Patient['fip_number']} = {b_HRF}")
#self.logger.warning(f"HRF: {data.data['id']}") #self.logger.warning(f"HRF: {data.data['id']}")
break
print(f"Lecture de la facture #{cur_invoice_index} {ele['id']} montant total = {ele['total_price']} <> {facture_total}")
if float(ele['total_price']) != facture_total:
print(f"ERROR NOT SAME PRICE")
total_facture_total += facture_total
total_facture_amount += float(ele['total_price'])
for article in data.Articles: for article in data.Articles:
self.bs_counter += 1 self.bs_counter += 1
@@ -645,7 +666,7 @@ class ClercAttrib2Biz():
print("NON mise à jour de l'adresse") print("NON mise à jour de l'adresse")
if int(data.Debtor["code"]) > 1: if int(data.Debtor["code"]) > 1:
csv_col.data[42] = data.Patient["addr_2"].replace("\r\n", "#chr(13)##chr(10)#") #Adresse de livraison csv_col.data[42] = data.Patient["addr_2"].replace("\n", "#chr(13)##chr(10)#") #Adresse de livraison
else: else:
csv_col.data[19] = data.Debtor["code"] # Code adresse à récupérer dans recherche d'adresse automatisée csv_col.data[19] = data.Debtor["code"] # Code adresse à récupérer dans recherche d'adresse automatisée
csv_col.data[22] = data.Debtor["lastname"] csv_col.data[22] = data.Debtor["lastname"]
@@ -760,6 +781,8 @@ class ClercAttrib2Biz():
lines.append(csv_col.data) lines.append(csv_col.data)
csv_col = None csv_col = None
print(f"total_facture_total = {total_facture_total} <> {total_facture_amount}")
if not self.export_one_file.get(): if not self.export_one_file.get():
with open(os.path.join(dest_dir, f"bizexdoc_" + filename.replace(".json", "") + ".csv"), "w+", errors='replace', newline='') as csv_file: with open(os.path.join(dest_dir, f"bizexdoc_" + filename.replace(".json", "") + ".csv"), "w+", errors='replace', newline='') as csv_file:
wr = csv.writer(csv_file, delimiter=';') wr = csv.writer(csv_file, delimiter=';')

View File

@@ -1 +1 @@
VERSION = "20230616-1729" VERSION = "20231031-1142"