|
|
|
|
@@ -245,7 +245,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_addresses(self):
|
|
|
|
|
file_addresses_path = os.path.join(dest_dir, f"adresses.csv")
|
|
|
|
|
file_addresses_path = os.path.join(dest_dir, f"adresses.txt")
|
|
|
|
|
if os.path.exists(file_addresses_path):
|
|
|
|
|
file = open(file_addresses_path)
|
|
|
|
|
csvreader = csv.reader(file, delimiter=';')
|
|
|
|
|
@@ -262,7 +262,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
o_addresse.city = row[15]
|
|
|
|
|
self.addresses.add_addresse(o_addresse)
|
|
|
|
|
|
|
|
|
|
print(self.addresses.items)
|
|
|
|
|
|
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
@@ -322,6 +322,54 @@ class ClercAttrib2Biz():
|
|
|
|
|
return ret
|
|
|
|
|
return value.strip()
|
|
|
|
|
|
|
|
|
|
def trim_all_data(self, data):
|
|
|
|
|
if data.Patient["lastname"] is not None:
|
|
|
|
|
data.Patient["lastname"] = data.Patient["lastname"].strip()
|
|
|
|
|
if data.Patient["firstname"] is not None:
|
|
|
|
|
data.Patient["firstname"] = data.Patient["firstname"].strip()
|
|
|
|
|
if data.Patient["street"] is not None:
|
|
|
|
|
data.Patient["street"] = data.Patient["street"].strip()
|
|
|
|
|
if data.Debtor["lastname"] is not None:
|
|
|
|
|
data.Debtor["lastname"] = data.Debtor["lastname"].strip()
|
|
|
|
|
if data.Debtor["firstname"] is not None:
|
|
|
|
|
data.Debtor["firstname"] = data.Debtor["firstname"].strip()
|
|
|
|
|
if data.Debtor["street"] is not None:
|
|
|
|
|
data.Debtor["street"] = data.Debtor["street"].strip()
|
|
|
|
|
|
|
|
|
|
def check_code_validity(self, code,data):
|
|
|
|
|
ret = True
|
|
|
|
|
check_patients = ["firstname", "lastname", "street"]
|
|
|
|
|
check_Debtor = ["firstname", "lastname", "street"]
|
|
|
|
|
if code == 1:
|
|
|
|
|
for check in check_patients:
|
|
|
|
|
if data.Patient[check] is None:
|
|
|
|
|
ret = False
|
|
|
|
|
for check in check_Debtor:
|
|
|
|
|
if data.Debtor[check] is None:
|
|
|
|
|
ret = False
|
|
|
|
|
if not ret:
|
|
|
|
|
messagebox.showerror(title="Erreur Critique", message=f"Les informations de la factures [{data.data['id']}] comportes trop d'erreur arrêt du processus ")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@@ -343,15 +391,19 @@ class ClercAttrib2Biz():
|
|
|
|
|
data = cls_Invoice()
|
|
|
|
|
data.parse_item(ele)
|
|
|
|
|
|
|
|
|
|
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"]):
|
|
|
|
|
print("ERROR code débiteur")
|
|
|
|
|
messagebox.showerror(title="Erreur code débiteur erroné", message=f"Le code débiteur de la facture {data.data['id']} est faux: [{data.Debtor['code']}], merci de le corriger ")
|
|
|
|
|
if data.Debtor["code"] is None:
|
|
|
|
|
data.Debtor["code"] = 1
|
|
|
|
|
else:
|
|
|
|
|
data.Debtor["code"] = str(data.Debtor["code"]).replace('.', '')
|
|
|
|
|
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())
|
|
|
|
|
|
|
|
|
|
if 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.Patient["fip_number"] not in self.a_listings["to_check"]:
|
|
|
|
|
@@ -401,7 +453,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}")
|
|
|
|
|
@@ -429,12 +481,18 @@ class ClercAttrib2Biz():
|
|
|
|
|
self.bs_counter += 1
|
|
|
|
|
csv_col = cls_Col(True)
|
|
|
|
|
|
|
|
|
|
print(article)
|
|
|
|
|
if "code" in article.keys() and article["code"] == "HRF":
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##Donnée globales
|
|
|
|
|
csv_col.data[0] = data.data["id"] # N° document
|
|
|
|
|
csv_col.data[1] = 20 # Type of document 20 = facture débiteur
|
|
|
|
|
csv_col.data[2] = datetime.strptime(data.data["date"], "%Y-%m-%d").strftime("%d.%m.%Y") # Date du document
|
|
|
|
|
csv_col.data[4] = data.Patient["fip_number"] # Référence
|
|
|
|
|
csv_col.data[10] = "<AUTO>" # Compte collectif du tiers = <AUTO>
|
|
|
|
|
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:
|
|
|
|
|
@@ -496,7 +554,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
concat_str += con + data.Debtor["name"]
|
|
|
|
|
con = "#chr(13)##chr(10)#"
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror(title="Erreur nom débiteur erroné", message=f"Le nom débiteur de la facture {data.data['id']} est faux: [{data.Debtor['name']}], merci de le corriger ")
|
|
|
|
|
messagebox.showerror(title="Erreur nom débiteur", message=f"Le nom débiteur de la facture {data.data['id']} est faux: [{data.Debtor['name']}], merci de le corriger ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data.Debtor["gender"] is not None:
|
|
|
|
|
@@ -505,12 +563,12 @@ 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)#"
|
|
|
|
|
@@ -591,8 +649,9 @@ 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"]
|
|
|
|
|
@@ -657,8 +716,9 @@ class ClercAttrib2Biz():
|
|
|
|
|
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}" )
|
|
|
|
|
if data.Debtor["code"] == "None" or '.' in str(data.Debtor["code"]):
|
|
|
|
|
print("ERROR code débiteur")
|
|
|
|
|
messagebox.showerror(title="Erreur code débiteur erroné", message=f"Le code débiteur de la facture {data.data['id']} est faux: [{data.Debtor['code']}], merci de le corriger ")
|
|
|
|
|
data.Debtor["code"] = str(data.Debtor["code"]).replace('.', '')
|
|
|
|
|
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"] = str(inp_popup.show())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data.Debtor["code"] != "1" and data.Debtor["code"] != None and int(data.Debtor["code"]) < 100:
|
|
|
|
|
|