|
|
|
|
@@ -74,6 +74,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.count_facture = 0
|
|
|
|
|
self.a_index = {"invoice": [], "intervention": [], "patient": [], "debtor": [], "articles": [], "global": []}
|
|
|
|
|
self.addresses = cls_Addresses()
|
|
|
|
|
self.o_debs = cls_debitors(filepath=temp_dir)
|
|
|
|
|
|
|
|
|
|
self.index_counter = 0
|
|
|
|
|
self.bs_counter = 70
|
|
|
|
|
@@ -101,7 +102,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.refresh_ui()
|
|
|
|
|
self.read_addresses()
|
|
|
|
|
|
|
|
|
|
self.o_debs = cls_debitors(filepath=temp_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timer = self.fenetre.after(1000, self.main_timer_fn)
|
|
|
|
|
@@ -209,6 +210,14 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.cb_run = Checkbutton(lbf_3, text="Lancer la conversion excel", variable=self.run_excel_after_export, onvalue=True, offvalue=False)
|
|
|
|
|
self.cb_run.grid(row=4, sticky='W')
|
|
|
|
|
|
|
|
|
|
menu_bar = Menu(self.fenetre)
|
|
|
|
|
menu_param = Menu(menu_bar, tearoff=0)
|
|
|
|
|
menu_param.add_command(label="Affichage des débiteurs", command=self.o_debs.print_all_debs)
|
|
|
|
|
menu_bar.add_cascade(label="Paramètre", menu=menu_param)
|
|
|
|
|
|
|
|
|
|
self.fenetre.config(menu=menu_bar)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -353,6 +362,23 @@ class ClercAttrib2Biz():
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
def compare_old_and_new_adresses(self, new, old):
|
|
|
|
|
|
|
|
|
|
if new['insurance_policy_number'].replace('.','') != old.AVS:
|
|
|
|
|
return False
|
|
|
|
|
if new['lastname'].replace('.','') != old.lastName:
|
|
|
|
|
return False
|
|
|
|
|
if new['firstname'].replace('.','') != old.firstName:
|
|
|
|
|
return False
|
|
|
|
|
if datetime.strptime(new['birthdate'], "%Y-%m-%d").strftime("%d.%m.%Y") != old.birth:
|
|
|
|
|
return False
|
|
|
|
|
if f"{new['street']} {new['street_number']}" != old.street:
|
|
|
|
|
return False
|
|
|
|
|
if f"{new['postal_code']} {new['city']}" != f"{old.npa} {old.city}":
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parseFile(self, data, filename):
|
|
|
|
|
self.index_counter += 1
|
|
|
|
|
@@ -377,18 +403,18 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.trim_all_data(data)
|
|
|
|
|
|
|
|
|
|
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}")
|
|
|
|
|
if data.Debtor["code"] is None or '.' in str(data.Debtor["code"]):
|
|
|
|
|
if data.Debtor["code"] is None or '.' in data.Debtor["code"]:
|
|
|
|
|
print("ERROR code débiteur #1")
|
|
|
|
|
messagebox.showerror(title="Erreur code débiteur", message=f"Le code débiteur de la facture {data.data['id']} est faux: [{data.Debtor['code']}], merci de le corriger ")
|
|
|
|
|
inp_popup = Input_popup(self.fenetre, default=data.Debtor["code"], factureID=data.data['id'], fip=data.Patient['fip_number'])
|
|
|
|
|
data.Debtor["code"] = int(inp_popup.show())
|
|
|
|
|
data.Debtor["code"] = str(inp_popup.show())
|
|
|
|
|
|
|
|
|
|
if data.Debtor["code"] == 1:
|
|
|
|
|
if int(data.Debtor["code"]) == 1:
|
|
|
|
|
if not self.check_code_validity(data.Debtor["code"],data):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if int(data.Debtor["code"]) != "1" and data.Debtor["code"] != None and int(data.Debtor["code"]) < 100:
|
|
|
|
|
if data.Debtor["code"] != "1" and data.Debtor["code"] != None and int(data.Debtor["code"]) < 100:
|
|
|
|
|
if data.Patient["fip_number"] not in self.a_listings["to_check"]:
|
|
|
|
|
self.a_listings["to_check"].append(data.Patient["fip_number"])
|
|
|
|
|
self.logger.warning(f"Vérifier facture N°: {data.data['id']} / {data.Patient['fip_number']} {data.Debtor['code']} {data.Debtor['lastname']} {data.Debtor['firstname']}")
|
|
|
|
|
@@ -421,7 +447,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
if not self.o_debs.is_in_debitor_name(code=data.Debtor["code"],search_name=data.Debtor["name"]):
|
|
|
|
|
#messagebox.showerror(title="Erreur code débiteur erroné", message=f"Information débiteur incohérente: facture N°: {data.data['id']} / {data.Patient['fip_number']}.\nCode débiteur: {data.Debtor['code']}\nNom du débiteur: {data.Debtor['name']}. \nAurait dû être: {self.o_debs.get_names_by_code(data.Debtor['code'])}")
|
|
|
|
|
debitor_popup = Check_debitor_popup(self.fenetre,data.Debtor,self.o_debs.get_names_by_code(data.Debtor['code']),data.data['id'],data.Patient['fip_number'], object=self.o_debs)
|
|
|
|
|
data.Debtor["code"] = int(debitor_popup.show())
|
|
|
|
|
data.Debtor["code"] = debitor_popup.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -436,7 +462,7 @@ 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:
|
|
|
|
|
if addresses_exist is not None and not self.compare_old_and_new_adresses(new=data.Patient, old=addresses_exist):
|
|
|
|
|
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()
|
|
|
|
|
print(f"Result Popup: {b_address_update}")
|
|
|
|
|
@@ -478,6 +504,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
csv_col.data[139] = "COND-30" # Conditions de payement à 30, COND-30 selon config dans winbiz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "without_transportation" in data.Intervention.keys() and data.Intervention["without_transportation"] == True:
|
|
|
|
|
csv_col.data[15] = "Sans transport"
|
|
|
|
|
print(f"->NO DEST** {data.data['id']}")
|
|
|
|
|
@@ -546,15 +573,19 @@ class ClercAttrib2Biz():
|
|
|
|
|
if data.Debtor["lastname"] is not None:
|
|
|
|
|
concat_str += con + self.ifNotNull(data.Debtor["lastname"]) + " " + self.ifNotNull(data.Debtor["firstname"])
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
if data.Debtor["street"] is not None:
|
|
|
|
|
concat_str += con + self.ifNotNull(data.Debtor["street"]) + " " + self.ifNotNull(data.Debtor["street_number"])
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
if data.Debtor["complement"] is not None:
|
|
|
|
|
concat_str += con + data.Debtor["complement"]
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
if data.Debtor["street"] is not None:
|
|
|
|
|
concat_str += con + self.ifNotNull(data.Debtor["street"]) + " " + self.ifNotNull(data.Debtor["street_number"])
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
if data.Debtor["city"] is not None:
|
|
|
|
|
concat_str += con + self.ifNotNull(data.Debtor["postal_code"]) + " " + self.ifNotNull(data.Debtor["city"])
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
if data.Debtor["country_name"] != "Suisse":
|
|
|
|
|
concat_str += con + data.Debtor["country_name"]
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -632,15 +663,18 @@ class ClercAttrib2Biz():
|
|
|
|
|
csv_col.data[72] = "BU - 73 - aff"
|
|
|
|
|
csv_col.data[73] = 0
|
|
|
|
|
|
|
|
|
|
csv_col.data[115] = self.ifNotNull(data.Patient["lastname"]) + " " + self.ifNotNull(data.Patient["firstname"])
|
|
|
|
|
csv_col.data[108] = data.Patient["complement"]
|
|
|
|
|
#Objet facture
|
|
|
|
|
csv_col.data[108] = self.ifNotNull(data.Patient["lastname"]) + " " + self.ifNotNull(data.Patient["firstname"])
|
|
|
|
|
csv_col.data[115] = data.Patient["complement"]
|
|
|
|
|
csv_col.data[109] = datetime.strptime(data.Patient["birthdate"], "%Y-%m-%d").strftime("%d.%m.%Y") if data.Patient["birthdate"] is not None else ""
|
|
|
|
|
if data.Patient["insurance_policy_number"] is not None and '-' not in data.Patient["insurance_policy_number"]:
|
|
|
|
|
csv_col.data[109] += ", " + data.Patient["insurance_policy_number"]
|
|
|
|
|
|
|
|
|
|
csv_col.data[110] = data.Patient["insurance_name"]
|
|
|
|
|
csv_col.data[111] = datetime.strptime(data.Intervention["start_time"], "%Y-%m-%dT%H:%M:%S%z").strftime(
|
|
|
|
|
"%d.%m.%Y") # Date PEC
|
|
|
|
|
date_PEC = datetime.strptime(data.Intervention["start_time"], "%Y-%m-%dT%H:%M:%S%z").strftime(
|
|
|
|
|
"%d.%m.%Y")
|
|
|
|
|
csv_col.data[51] = date_PEC # Date de ligne articles
|
|
|
|
|
csv_col.data[111] =date_PEC # Date PEC
|
|
|
|
|
csv_col.data[111] += " - " + datetime.strptime(data.Intervention["start_time"], "%Y-%m-%dT%H:%M:%S%z").strftime(
|
|
|
|
|
"%H:%M") # Heure START PEC
|
|
|
|
|
|
|
|
|
|
@@ -660,8 +694,8 @@ 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"]
|
|
|
|
|
csv_col.data[136] = 2 if data.Intervention["base_name"] == "Uvrier" else 3
|
|
|
|
|
csv_col.data[146] = csv_col.data[136]
|
|
|
|
|
csv_col.data[136] = 3 if data.Debtor["code"] != "101" else "EBILL" #code présentation de facture
|
|
|
|
|
csv_col.data[146] = 3 #Code méthode de payement définit à 3
|
|
|
|
|
csv_col.data[168] = 1 if data.Intervention["team_name"] == "Planification" else 2
|
|
|
|
|
csv_col.data[169] = data.Patient['insurance_policy_number']
|
|
|
|
|
|
|
|
|
|
@@ -681,7 +715,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.a_index["global"].append(key)
|
|
|
|
|
obj.data.append(data)
|
|
|
|
|
|
|
|
|
|
def convertFile(self, data, filename):
|
|
|
|
|
def convertFile(self, data, filename): #à utiliser pour un export avec fichier excel de Thomas
|
|
|
|
|
self.count_facture += len(data["invoices"])
|
|
|
|
|
self.a_listings["to_check"] = []
|
|
|
|
|
|
|
|
|
|
@@ -696,7 +730,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
b_update_debitor = True
|
|
|
|
|
|
|
|
|
|
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}" )
|
|
|
|
|
if data.Debtor["code"] == "None" or '.' in str(data.Debtor["code"]):
|
|
|
|
|
if data.Debtor["code"] == "None" or '.' in data.Debtor["code"]:
|
|
|
|
|
print("ERROR code débiteur")
|
|
|
|
|
messagebox.showerror(title="Erreur code débiteur", message=f"Le code débiteur de la facture {data.data['id']} est faux: [{data.Debtor['code']}], merci de le corriger ")
|
|
|
|
|
inp_popup = Input_popup(self.fenetre,default=data.Debtor["code"],factureID=data.data['id'], fip=data.Patient['fip_number'])
|
|
|
|
|
|