Compare commits

..

10 Commits

Author SHA1 Message Date
Ambulance Clerc
e8b52bcd17 Ajout du code débiteur 158 HRF Fribourg comme EBILL 2023-11-28 16:39:58 +01:00
Ambulance Clerc
90bb7e53b0 Débug custom_popup.py if name not exist in Debitor 2023-11-28 15:00:11 +01:00
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
6 changed files with 75 additions and 41 deletions

View File

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

View File

@@ -59,7 +59,7 @@ class cls_Invoice:
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 = patient['lastname'].replace('.','') + patient['firstname'].replace('.','') + self.ifNotNull(patient['complement']).strip()+ patient['street'].strip() + patient['street_number'].strip() + patient['postal_code'].strip() + patient['city'].strip()
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

View File

@@ -37,27 +37,31 @@ class Check_addresses_popup(Toplevel):
fonts = []
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="Nom:", str1=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="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="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="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="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="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=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=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(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"{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"{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"{self.ifNotNull(item_1['postal_code'])} {self.ifNotNull(item_1['city'])}", str2=f"{item_2.npa} {item_2.city}")
if int(debitor["code"]) < 100:
if item_1["selfish"]:
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))
str2=self.ifNotNull(item_2.addr_2),force_color_1=force_color)
str_address_1 += item_1['insurance_policy_number'].replace('.', '')
str_address_1 += item_1['lastname'].strip()
str_address_1 += item_1['firstname'].strip()
str_address_1 += self.ifNotNull(item_1['insurance_policy_number']).replace('.', '')
str_address_1 += self.ifNotNull(item_1['lastname']).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 += f"{item_1['street'].strip()} {item_1['street_number'].strip()}"
str_address_1 += f"{item_1['complement'].strip()}"
str_address_1 += f"{item_1['postal_code']} {item_1['city']}"
str_address_1 += f"{self.ifNotNull(item_1['street']).strip()} {self.ifNotNull(item_1['street_number']).strip()}"
str_address_1 += f"{self.ifNotNull(item_1['complement']).strip()}"
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 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)
value_color = "black"
value_color_1 = "black"
value_color_2 = "black"
con = ""
if str1 != str2:
value_color = "red"
value_color_1 = "red"
value_color_2 = "red"
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=con + str(str1) + con, fg=value_color, anchor="w", justify=LEFT).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=con + str(str2) + con, fg=value_color, anchor="w", justify=LEFT).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
@@ -175,6 +183,8 @@ class Check_debitor_popup(Toplevel):
Label(lbf_new, text="Débiteur sélectionné dans Attrib", font=label_font).grid(row=1, column=0, sticky="W")
text_name = Text(lbf_new, fg="red", height=3,width= 30)
text_name.grid(row=1, column=1, sticky="W")
if 'name' not in debitor:
debitor['name'] = ""
text_name.insert(END,debitor['name'])
text_name.configure(state='disabled')

View File

@@ -1 +1 @@
20230616-1943
20231128-1639

60
main.py
View File

@@ -289,7 +289,6 @@ class ClercAttrib2Biz():
file_addresses_path = os.path.join(temp_dir, f"adresses.dbf")
if os.path.exists(file_addresses_path):
for record in DBF(file_addresses_path, load=True):
o_addresse = cls_addresse()
o_addresse.AVS = str(record["AD_CODE"])
o_addresse.lastName =str( record["AD_NOM"])
@@ -397,23 +396,35 @@ class ClercAttrib2Biz():
return ret
def compare_old_and_new_adresses(self, new, old):
if new['insurance_policy_number'].replace('.','') != old.AVS:
def compare_old_and_new_adresses(self, new, old, code):
print(f"compare_old_and_new_adresses ")
if self.ifNotNull(new['insurance_policy_number']).replace('.','') != old.AVS:
print("compare adresse exit avs")
return False
if new['lastname'].replace('.','') != old.lastName:
if self.ifNotNull(new['lastname']).replace('.','') != old.lastName:
print("compare adresse exit lastname")
return False
if new['firstname'].replace('.','') != old.firstName:
if self.ifNotNull(new['firstname']).replace('.','') != old.firstName:
print("compare adresse exit firstname")
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
if f"{new['street'].strip()} {new['street_number'].strip()}" != f"{old.street.strip()}":
print(f"({new['street'].strip()} {new['street_number'].strip()}) != [" + old.street.strip()+"]")
if f"{self.ifNotNull(new['street']).strip()} {self.ifNotNull(new['street_number']).strip()}" != f"{self.ifNotNull(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
if f"{new['postal_code']} {new['city']}" != f"{old.npa} {old.city}":
return False
if new["addr_2"] != old.addr_2 and not new["selfish"]:
if f"{self.ifNotNull(new['postal_code'])} {self.ifNotNull(new['city'])}" != f"{self.ifNotNull(old.npa)} {self.ifNotNull(old.city)}":
print("compare adresse exit city")
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
@@ -433,8 +444,10 @@ class ClercAttrib2Biz():
cur_invoice_index = 0
total_facture_total = 0
total_facture_amount = 0
for ele in data["invoices"]:
cur_invoice_index += 1
self.progress_bar["value"] = cur_invoice_index / self.count_facture * 100
b_address_update = True
@@ -547,13 +560,13 @@ class ClercAttrib2Biz():
if self.check_addresses.get():
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'])
b_address_update = popup.show()
mode_selected = "Attrib" if b_address_update else "Winbiz"
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}")
else:
b_address_update = True
@@ -563,7 +576,11 @@ class ClercAttrib2Biz():
b_HRF = False
sHRF = ""
facture_total = 0
for article in data.Articles:
if 'price' in article:
facture_total += float(article['price'])
if "code" in article.keys():
if article["code"] == "HRF":
@@ -571,9 +588,12 @@ class ClercAttrib2Biz():
sHRF = article["line_1"].replace("h", ":")
print(f"pass HRF => {data.Patient['fip_number']} = {b_HRF}")
#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:
self.bs_counter += 1
@@ -646,7 +666,7 @@ class ClercAttrib2Biz():
print("NON mise à jour de l'adresse")
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:
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"]
@@ -751,7 +771,7 @@ class ClercAttrib2Biz():
csv_col.data[116] = self.ifNotNull(data.Patient["category"]) + " - " + self.ifNotNull(data.Intervention["type"])
csv_col.data[118] = data.Intervention["kilometers"]
csv_col.data[135] = data.Intervention["base_name"]
if data.Debtor["code"] == "100" or data.Debtor["code"] == "101":
if data.Debtor["code"] == "100" or data.Debtor["code"] == "101" or data.Debtor["code"] == "158":
csv_col.data[136] = "EBILL" #code présentation de facture
else:
csv_col.data[136] = 3 #code présentation de facture
@@ -761,6 +781,8 @@ class ClercAttrib2Biz():
lines.append(csv_col.data)
csv_col = None
print(f"total_facture_total = {total_facture_total} <> {total_facture_amount}")
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:
wr = csv.writer(csv_file, delimiter=';')

View File

@@ -1 +1,2 @@
VERSION = "20230616-1943"
VERSION = "20231128-1639"