Compare commits

...

20 Commits

Author SHA1 Message Date
Ambulance Clerc
756eeab00c refactor code 2024-11-09 17:26:52 +01:00
Ambulance Clerc
94ca5534e5 update dl_version 2024-11-09 17:25:29 +01:00
Ambulance Clerc
d751edd248 update version 2024-11-01 20:31:56 +01:00
Ambulance Clerc
516ab4ac3f update suite à MAJ Attrib 2024-11-01 20:29:46 +01:00
Ambulance Clerc
32c8a5ca3f débug auto-update 2023-12-01 17:21:08 +01:00
Ambulance Clerc
f2422762d2 comment line 2023-12-01 17:20:39 +01:00
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
Ambulance Clerc
5adbc77555 Débug de la feature adresse_livraison 2023-06-16 19:43:34 +02:00
Ambulance Clerc
1146ff01c7 Ajout de la comparaison de l'adresse de livraison 2023-06-16 17:29:35 +02:00
Ambulance Clerc
e4c075f6ef Ajout de la comparaison de l'adresse de livraison 2023-06-16 16:17:10 +02:00
Ambulance Clerc
f05a56bc5a Ajout de la comparaison de l'adresse de livraison 2023-06-16 16:16:49 +02:00
9 changed files with 572 additions and 290 deletions

View File

@@ -1,5 +1,6 @@
from version import * from version import *
import urllib.request import urllib.request
import urllib.error
import ssl import ssl
import io import io
@@ -22,15 +23,22 @@ class auto_updater:
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
data = urllib.request.urlopen("https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/raw/branch/master/dl_version", context=ctx) data = urllib.request.urlopen("https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/raw/branch/master/dl_version", context=ctx)
self.dl_version = str(data.read()).replace('b', '').replace("'", "") self.dl_version = str(data.read()).replace('b', '').replace("'", "").replace("\n","").replace('n',"")
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
if self.dl_version != VERSION: if self.dl_version != VERSION:
print(f"Version différente trouvée {self.dl_version} téléchargement en cours => {self.temp_dir}update.exe") print(f"Version différente trouvée {self.dl_version} téléchargement en cours => {self.temp_dir}clerc_update.exe")
try: try:
urllib.request.urlretrieve(url=f"https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/releases/download/{self.clean(self.dl_version)}/Clercattrib2Biz_setup.exe", filename=f"{self.temp_dir}update.exe") url = f"https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/releases/download/{self.clean(self.dl_version)}/Clercattrib2Biz_setup.exe"
except: urllib.request.urlretrieve(url=url, filename=f"{self.temp_dir}clerc_update.exe")
print("ERREUR de téléchargement mise à jours") except urllib.error.URLError as e:
print(f"ERREUR de téléchargement mise à jour : {e.reason} \n {url}")
return "ERROR"
except urllib.error.HTTPError as e:
print(f"ERREUR HTTP lors du téléchargement : {e.code} {e.reason} \n {url}")
return "ERROR"
except Exception as e:
print(f"Erreur inattendue : {e} \n {url}")
return "ERROR" return "ERROR"
ret = True ret = True
return ret return ret

222
cl_attriblink.py Normal file
View File

@@ -0,0 +1,222 @@
class cl_AttribLink():
def __init__(self):
self.invoice_ID = None
self.FIP = None
self.comments = None
self.km = None
self.invoice_date = None
self.debtor_code = None
self.debtor_name = None
self.debtor_lastname = None
self.debtor_firstname = None
self.debtor_addr_complement = None
self.debtor_street = None
self.debtor_street_number = None
self.debtor_postal_code = None
self.debtor_city = None
self.debtor_country = None
self.debtor_gender = None
self.patient_AVS = None
self.patient_category = None
self.patient_birthdate = None
self.patient_lastname = None
self.patient_firstname = None
self.patient_addr_complement = None
self.patient_addr_2 = None
self.patient_street = None
self.patient_street_number = None
self.patient_postal_code = None
self.patient_city = None
self.patient_country = None
self.patient_gender = None
self.patient_insurance_name = None
self.intervention_type = None
self.intervention_base = None
self.intervention_team = None
self.intervention_start_time = None
self.intervention_end_time = None
#Intervention DEST
self.intervention_dest_name = None
self.intervention_dest_street = None
self.intervention_dest_street_number = None
self.intervention_dest_postal_code = None
self.intervention_dest_city = None
#Intervention Site
self.intervention_site_name = None
self.intervention_site_street = None
self.intervention_site_street_number = None
self.intervention_site_postal_code = None
self.intervention_site_city = None
self.src_key_invoice = {
"id": ["id"],
"total_price": ["total_price"],
"date": ["date"],
"comments": ["comments"],
}
self.src_key_debtor = {
"code": ["code"],
"name": ["name"],
"lastname": ["lastname"],
"firstname": ["firstname"],
"addr_complement": ["complement"],
"street": ["street"],
"addr_2": ["addr_2"],
"street_number": ["street_number"],
"postal_code": ["postal_code"],
"city": ["city"],
"country_name": ["country","country_name"],
"gender_name": ["gender","gender_name"],
}
self.src_key_patient = {
"fip": ["fip_number"],
"category_name": ["category", "category_name"],
"birthdate": ["birthdate"],
"AVS": ["insurance_policy_number"],
"lastname": ["lastname"],
"firstname": ["firstname"],
"addr_complement": ["complement"],
"street": ["street"],
"addr_2": ["addr_2"],
"street_number": ["street_number"],
"postal_code": ["postal_code"],
"city": ["city"],
"country_name": ["country","country_name"],
"gender_name": ["gender","gender_name"],
"insurance_name": ["insurance","insurance_name"],
}
self.src_key_article = {
"price": ["price"],
"code": ["code"],
"line_1": ["line_1"],
"line_2": ["line_2"],
"quantity": ["quantity"],
"unit_price": ["unit_price"],
"unit": ["unit", "unit_name"],
"price": ["price"],
}
self.src_key_intervention = {
"date": ["date"],
"type": ["type"],
"kilometers": ["kilometers"],
"start_time": ["start_time"],
"end_time": ["end_time"],
"base_name": ["base", "base_name"],
"team_name": ["team", "team_name"],
"destination_name": ["destination", "destination_name"],
"destination_street": ["destination", "destination_street"],
"destination_street_number": ["destination_street_number"],
"destination_city": ["destination_city"],
"destination_postal_code": ["destination_postal_code"],
"site_name": ["site", "site_name"],
"site_street": ["site", "site_street"],
"site_street_number": ["site_street_number"],
"site_city": ["site_city"],
"site_postal_code": ["site_postal_code"],
}
def parse_data(self, data):
self.invoice_ID = self.get_value_from_attrib(data=data, obj="data", key="id")
self.comments = self.get_value_from_attrib(data=data, obj="data", key="comments")
self.invoice_date = self.get_value_from_attrib(data=data, obj="data", key="date")
self.debtor_code = self.get_value_from_attrib(data=data, obj="debtor", key="code")
self.debtor_name = self.get_value_from_attrib(data=data, obj="debtor", key="name")
self.debtor_lastname = self.get_value_from_attrib(data=data,obj="debtor",key="lastname")
self.debtor_firstname = self.get_value_from_attrib(data=data,obj="debtor",key="firstname")
self.debtor_addr_complement = self.get_value_from_attrib(data=data,obj="debtor",key="addr_complement")
self.debtor_street = self.get_value_from_attrib(data=data,obj="debtor",key="street")
self.debtor_street_number = self.get_value_from_attrib(data=data,obj="debtor",key="street_number")
self.debtor_postal_code = self.get_value_from_attrib(data=data,obj="debtor",key="postal_code")
self.debtor_city = self.get_value_from_attrib(data=data,obj="debtor",key="city")
self.debtor_gender = self.get_value_from_attrib(data=data,obj="debtor",key="gender_name")
self.debtor_country = self.get_value_from_attrib(data=data,obj="debtor",key="country_name")
self.FIP = self.get_value_from_attrib(data=data, obj="patient", key="fip")
self.patient_category = self.get_value_from_attrib(data=data, obj="patient", key="category_name")
self.patient_birthdate = self.get_value_from_attrib(data=data, obj="patient", key="birthdate")
self.patient_lastname = self.get_value_from_attrib(data=data, obj="patient", key="lastname")
self.patient_addr_2 = self.get_value_from_attrib(data=data, obj="patient", key="addr_2")
self.patient_firstname = self.get_value_from_attrib(data=data, obj="patient", key="firstname")
self.patient_addr_complement = self.get_value_from_attrib(data=data, obj="patient", key="addr_complement")
self.patient_street = self.get_value_from_attrib(data=data,obj="patient",key="street")
self.patient_street_number = self.get_value_from_attrib(data=data,obj="patient",key="street_number")
self.patient_postal_code = self.get_value_from_attrib(data=data,obj="patient",key="postal_code")
self.patient_city = self.get_value_from_attrib(data=data,obj="patient",key="city")
self.patient_gender = self.get_value_from_attrib(data=data,obj="patient",key="gender_name")
self.patient_country = self.get_value_from_attrib(data=data,obj="patient",key="country_name")
self.patient_insurance_name = self.get_value_from_attrib(data=data,obj="patient",key="insurance_name")
self.km = self.get_value_from_attrib(data=data, obj="intervention", key="kilometers")
self.intervention_start_time = self.get_value_from_attrib(data=data, obj="intervention", key="start_time")
self.intervention_end_time = self.get_value_from_attrib(data=data, obj="intervention", key="end_time")
self.intervention_base = self.get_value_from_attrib(data=data, obj="intervention", key="base_name")
self.intervention_team = self.get_value_from_attrib(data=data, obj="intervention", key="team_name")
self.intervention_type = self.get_value_from_attrib(data=data, obj="intervention", key="type")
self.intervention_dest_name = self.get_value_from_attrib(data=data, obj="intervention", key="destination_name")
self.intervention_dest_street = self.get_value_from_attrib(data=data, obj="intervention", key="destination_street")
self.intervention_dest_street_number = self.get_value_from_attrib(data=data, obj="intervention", key="destination_street_number")
self.intervention_dest_postal_code = self.get_value_from_attrib(data=data, obj="intervention", key="destination_postal_code")
self.intervention_dest_city = self.get_value_from_attrib(data=data, obj="intervention", key="destination_city")
self.intervention_site_name = self.get_value_from_attrib(data=data, obj="intervention", key="site_name")
self.intervention_site_street = self.get_value_from_attrib(data=data, obj="intervention", key="site_street")
self.intervention_site_street_number = self.get_value_from_attrib(data=data, obj="intervention", key="site_street_number")
self.intervention_site_postal_code = self.get_value_from_attrib(data=data, obj="intervention", key="site_postal_code")
self.intervention_site_city = self.get_value_from_attrib(data=data, obj="intervention", key="site_city")
def on_error_not_found(self, obj, key):
print(f"ERROR AttribLink => obi[{obj}] and key [{key}] not found.")
def get_value_from_attrib(self,data,obj, key):
print(f"get value from {obj}=>{key}")
ret = False
t_obj = None
if obj == "data":
t_obj = data.data
key_src = self.src_key_invoice
elif obj == "debtor":
t_obj = data.Debtor
key_src = self.src_key_debtor
elif obj == "patient":
t_obj = data.Patient
key_src = self.src_key_patient
elif obj == "article":
t_obj = data
key_src = self.src_key_article
elif obj == "invoice":
t_obj = data
key_src = self.src_key_invoice
if obj == "intervention":
t_obj = data.Intervention
key_src = self.src_key_intervention
for t_key in key_src[key]:
if t_key in t_obj:
ret = t_obj[t_key]
if ret == False:
self.on_error_not_found(obj, key)
return None
else:
return ret

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
@@ -21,3 +22,4 @@ class cls_addresse:
street_cpl = None street_cpl = None
npa = None npa = None
city = None city = None
addr_2 = None

View File

@@ -30,7 +30,7 @@ class cls_debitors:
default = [] default = []
if int(code) < 100: if int(code) < 100:
return default return default
for deb in self.items: for deb in self.items: # items contient lensemble des objects détiteur provenant dun export BDD
if deb.code == int(code): if deb.code == int(code):
return deb.names return deb.names
return default return default

View File

@@ -16,6 +16,57 @@ class cls_Invoice:
self.data = obj self.data = obj
self.a_index = {"invoice": [], "intervention": [], "patient": [], "debtor": [], "articles": []} self.a_index = {"invoice": [], "intervention": [], "patient": [], "debtor": [], "articles": []}
self.index_counter = 0 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: class cls_Col:
data = [] data = []

View File

@@ -12,7 +12,7 @@ class Check_addresses_popup(Toplevel):
if(item_1["complement"] is None): if(item_1["complement"] is None):
item_1["complement"] = "" item_1["complement"] = ""
self.geometry(f"700x300+{parent.winfo_x() + 25 }+{parent.winfo_y() +25 }") self.geometry(f"700x450+{parent.winfo_x() + 25 }+{parent.winfo_y() +25 }")
self.resizable(True,True) self.resizable(True,True)
self.iconbitmap("./logo_clerc_03X_icon.ico") self.iconbitmap("./logo_clerc_03X_icon.ico")
self.title(f"Choix de l'adresse à conserver {item_1['fip_number']} / {factureID}. Code débiteur: {debitor['code']}") self.title(f"Choix de l'adresse à conserver {item_1['fip_number']} / {factureID}. Code débiteur: {debitor['code']}")
@@ -26,27 +26,42 @@ class Check_addresses_popup(Toplevel):
lbf_old = LabelFrame(self, text="Données Winbiz") lbf_old = LabelFrame(self, text="Données Winbiz")
lbf_old.grid(row=0, column=1, sticky='NSEW', padx=5, pady=5) lbf_old.grid(row=0, column=1, sticky='NSEW', padx=5, pady=5)
lbf_addr_2_new = LabelFrame(self, text="Livraison Attrib")
lbf_addr_2_new.grid(row=1, column=0, sticky='WE', padx=5, pady=5)
lbf_addr_2_old = LabelFrame(self, text="Livraison Winbiz")
lbf_addr_2_old.grid(row=1, column=1, sticky='NSEW', padx=5, pady=5)
str_address_1 = "" str_address_1 = ""
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}")
str_address_1 += item_1['insurance_policy_number'].replace('.', '') if int(debitor["code"]) < 100:
str_address_1 += item_1['lastname'].strip() if item_1["selfish"]:
str_address_1 += item_1['firstname'].strip() 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 += 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 += 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'])}"
@@ -63,10 +78,10 @@ class Check_addresses_popup(Toplevel):
str_address_2 += f"{item_2.npa} {item_2.city}" str_address_2 += f"{item_2.npa} {item_2.city}"
self.listbox = Listbox(self, height=3, width=35) self.listbox = Listbox(self, height=3, width=35)
self.listbox.grid(row=1,column=0, columnspan= 2, pady=15,padx=15, sticky='NSEW') self.listbox.grid(row=2,column=0, columnspan= 2, pady=15,padx=15, sticky='NSEW')
self.btn = Button(self, text="Valider", command=self.select) self.btn = Button(self, text="Valider", command=self.select)
self.btn.grid(row=2,columnspan=2 , pady=10,padx=10, sticky='NSEW') self.btn.grid(row=3,columnspan=2 , pady=10,padx=10, sticky='NSEW')
for (idd, info) in ((0, "Winbiz"), (1, "Attrib")) : for (idd, info) in ((0, "Winbiz"), (1, "Attrib")) :
self.listbox.insert(END, info) self.listbox.insert(END, info)
@@ -88,22 +103,28 @@ class Check_addresses_popup(Toplevel):
self.listbox.selection_set(1) self.listbox.selection_set(1)
print(f"adresse différente [{str_address_1}] ({str_address_2})") print(f"adresse différente [{str_address_1}] ({str_address_2})")
def ifNotNull(self, value, ret=""):
if value == None or value == "None":
return ret
return value.strip()
def add_compares_element(self,new_frame, old_frame,str1, str2, label, force_color_1=None):
def add_compares_element(self,new_frame, old_frame,str1, str2, label):
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
@@ -162,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") 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 = Text(lbf_new, fg="red", height=3,width= 30)
text_name.grid(row=1, column=1, sticky="W") text_name.grid(row=1, column=1, sticky="W")
if 'name' not in debitor:
debitor['name'] = ""
text_name.insert(END,debitor['name']) text_name.insert(END,debitor['name'])
text_name.configure(state='disabled') text_name.configure(state='disabled')

View File

@@ -1 +1 @@
20230426-1114 20241109-1726

485
main.py
View File

@@ -29,6 +29,8 @@ from class_debitors import *
from version import * from version import *
from custom_popup import * from custom_popup import *
from cl_attriblink import cl_AttribLink
src_dir = os.getenv('APPDATA') + "\Attrib2Biz\src" src_dir = os.getenv('APPDATA') + "\Attrib2Biz\src"
dest_dir = os.getenv('APPDATA') + "\Attrib2Biz\output" dest_dir = os.getenv('APPDATA') + "\Attrib2Biz\output"
@@ -140,6 +142,10 @@ class ClercAttrib2Biz():
self.delete_after_parse.set(self.read_config_element("cfg_delete_after_parse", False)) self.delete_after_parse.set(self.read_config_element("cfg_delete_after_parse", False))
self.export_one_file.set(self.read_config_element("cfg_export_one_file", True)) self.export_one_file.set(self.read_config_element("cfg_export_one_file", True))
self.winbiz_folder_path.set(self.read_config_element("winbiz_folder_path", temp_dir)) self.winbiz_folder_path.set(self.read_config_element("winbiz_folder_path", temp_dir))
def add_statistique(self, stat_name, stat_value):
a_stats = None
if "a_stats" in self.config:
a_stats = self.config[""]
def read_config_element(self,name, default): def read_config_element(self,name, default):
val = self.config.get(name) val = self.config.get(name)
@@ -265,7 +271,7 @@ class ClercAttrib2Biz():
if update_available == True: if update_available == True:
self.logger.warning(f"Nouvelle version du script disponible. {auto_update.dl_version}") self.logger.warning(f"Nouvelle version du script disponible. {auto_update.dl_version}")
if messagebox.askyesno(title="Nouvelle version trouvée", message=f"Une nouvelle version a été trouvée, vous pouvez l'installer dès maintenant !", ): if messagebox.askyesno(title="Nouvelle version trouvée", message=f"Une nouvelle version a été trouvée, vous pouvez l'installer dès maintenant !", ):
subprocess.call(temp_dir + "\\update.exe") subprocess.call(temp_dir + "\\clerc_update.exe")
self.fenetre.destroy() self.fenetre.destroy()
elif update_available == "ERROR": elif update_available == "ERROR":
messagebox.showerror(title="ERREUR téléchargement", message="Erreur lors du téléchargement de la nouvelle mise à jour") messagebox.showerror(title="ERREUR téléchargement", message="Erreur lors du téléchargement de la nouvelle mise à jour")
@@ -284,7 +290,7 @@ 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): 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"])
@@ -298,6 +304,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"]).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:
@@ -351,66 +358,80 @@ class ClercAttrib2Biz():
return value.strip() return value.strip()
def trim_all_data(self, data): def trim_all_data(self, data):
if data.Patient["lastname"] is not None: if self.attrib_link.patient_lastname is not None:
data.Patient["lastname"] = data.Patient["lastname"].strip() self.attrib_link.patient_lastname = self.attrib_link.patient_lastname.strip()
if data.Patient["firstname"] is not None: if self.attrib_link.patient_firstname is not None:
data.Patient["firstname"] = data.Patient["firstname"].strip() self.attrib_link.patient_firstname = self.attrib_link.patient_firstname.strip()
if data.Patient["street"] is not None: if self.attrib_link.patient_street is not None:
data.Patient["street"] = data.Patient["street"].strip() self.attrib_link.patient_street = self.attrib_link.patient_street.strip()
if data.Debtor["lastname"] is not None: if self.attrib_link.debtor_lastname is not None:
data.Debtor["lastname"] = data.Debtor["lastname"].strip() self.attrib_link.debtor_lastname = self.attrib_link.debtor_lastname.strip()
if data.Debtor["firstname"] is not None: if self.attrib_link.debtor_firstname is not None:
data.Debtor["firstname"] = data.Debtor["firstname"].strip() self.attrib_link.debtor_firstname = self.attrib_link.debtor_firstname.strip()
if data.Debtor["street"] is not None: if self.attrib_link.debtor_street is not None:
data.Debtor["street"] = data.Debtor["street"].strip() self.attrib_link.debtor_street = self.attrib_link.debtor_street.strip()
if data.data["comments"] is not None: if self.attrib_link.comments is not None:
data.data["comments"] = data.data["comments"].strip().replace("\n",'') self.attrib_link.comments = self.attrib_link.comments.strip().replace("\n",'')
if data.Debtor["code"] is not None: if self.attrib_link.debtor_code is not None:
data.Debtor["code"] = data.Debtor["code"].strip() self.attrib_link.debtor_code = self.attrib_link.debtor_code.strip()
data.Debtor["code"] = re.sub(r'[^0-9]', '', data.Debtor["code"]) self.attrib_link.debtor_code = re.sub(r'[^0-9]', '', self.attrib_link.debtor_code)
if "name" in data.Debtor.keys() and data.Debtor["name"] is not None: if "name" in data.Debtor.keys() and self.attrib_link.debtor_name is not None:
data.Debtor["name"] = data.Debtor["name"].replace("(facturation)","") self.attrib_link.debtor_name = self.attrib_link.debtor_name.replace("(facturation)","")
data.Debtor["name"] = data.Debtor["name"].strip() self.attrib_link.debtor_name = self.attrib_link.debtor_name.strip()
def check_code_validity(self, code,data): def check_required_field_by_code(self, code, data):
ret = True required_fields = {
check_patients = ["firstname", "lastname", "street"] 1: ["firstname", "lastname", "street"], # facturation au patient code = 1
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 if code in required_fields:
for field in required_fields[code]:
def compare_old_and_new_adresses(self, new, old): if data.Patient[field] is None or data.Debtor[field] is None:
messagebox.showerror(
if new['insurance_policy_number'].replace('.','') != old.AVS: title="Erreur Critique",
return False message=f"Les informations de la facture [{self.attrib_link.invoice_ID}] comportent trop d'erreurs. Arrêt du processus.",
if new['lastname'].replace('.','') != old.lastName: )
return False 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'].strip()} {new['street_number'].strip()}" != f"{old.street.strip()}":
print(f"({new['street'].strip()} {new['street_number'].strip()}) != [" + old.street.strip()+"]")
return False
if f"{new['postal_code']} {new['city']}" != f"{old.npa} {old.city}":
return False
return True return True
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 self.ifNotNull(new['lastname']).replace('.','') != old.lastName:
print("compare adresse exit lastname")
return False
if self.ifNotNull(new['firstname']).replace('.','') != old.firstName:
print("compare adresse exit firstname")
return False
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"{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"{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
def parseFile(self, data, filename): def parseFile(self, data, filename):
self.attrib_link = cl_AttribLink()
self.progress_bar["value"] = 0 self.progress_bar["value"] = 0
self.index_counter += 1 self.index_counter += 1
lines = [] lines = []
@@ -425,8 +446,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
@@ -435,152 +458,134 @@ class ClercAttrib2Biz():
self.trim_all_data(data) self.trim_all_data(data)
self.attrib_link.parse_data(data)
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}")
if data.Debtor["code"] is None or '.' in data.Debtor["code"]: print(f"Code débiteur => {self.attrib_link.invoice_ID}: {self.attrib_link.debtor_code}")
if self.attrib_link.debtor_code is None or '.' in self.attrib_link.debtor_code:
print("ERROR code débiteur #1") 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 ") messagebox.showerror(title="Erreur code débiteur", message=f"Le code débiteur de la facture {self.attrib_link.invoice_ID} est faux: [{self.attrib_link.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']) inp_popup = Input_popup(self.fenetre, default=self.attrib_link.debtor_code, factureID=self.attrib_link.invoice_ID, fip=self.attrib_link.FIP)
data.Debtor["code"] = str(inp_popup.show()) self.attrib_link.debtor_code = str(inp_popup.show())
if data.Debtor["code"] is None or '.' in data.Debtor["code"]: if self.attrib_link.debtor_code is None or '.' in self.attrib_link.debtor_code:
messagebox.showerror(title="Erreur Critique", messagebox.showerror(title="Erreur Critique",
message=f"Les informations de la factures [{data.data['id']}] comportes trop d'erreur arrêt du processus ") message=f"Les informations de la factures [{self.attrib_link.invoice_ID}] comportes trop d'erreur arrêt du processus ")
return False return False
if int(data.Debtor["code"]) == 1: if int(self.attrib_link.debtor_code) == 1:
if not self.check_code_validity(data.Debtor["code"],data): if not self.check_required_field_by_code(self.attrib_link.debtor_code, data):
messagebox.showerror(title="Erreur Critique", messagebox.showerror(title="Erreur Critique",
message=f"Les informations de la factures [{data.data['id']}] comportes trop d'erreur arrêt du processus ") message=f"Les informations de la factures [{self.attrib_link.invoice_ID}] comportes trop d'erreur arrêt du processus ")
return False return False
if data.Debtor["code"] != "1" and data.Debtor["code"] != None and int(data.Debtor["code"]) < 100: if self.attrib_link.debtor_code != "1" and self.attrib_link.debtor_code != None and int(self.attrib_link.debtor_code) < 100:
if data.Patient["fip_number"] not in self.a_listings["to_check"]: if self.attrib_link.FIP not in self.a_listings["to_check"]:
self.a_listings["to_check"].append(data.Patient["fip_number"]) self.a_listings["to_check"].append(self.attrib_link.FIP)
#self.logger.warning(f"Vérifier facture N°: {data.data['id']} / {data.Patient['fip_number']} {data.Debtor['code']} {data.Debtor['lastname']} {data.Debtor['firstname']}") #self.logger.warning(f"Vérifier facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP} {self.attrib_link.debtor_code} {self.attrib_link.debtor_lastname} {self.attrib_link.debtor_firstname}")
for elem in data.Debtor:
pass
''' TODO activer ce code quand les débiteur auront un bon numéro
try:
if int(data.Debtor["code"]) > 100:
print("code débiteur > 100 => no update data")
b_update_debitor = False
except:
messagebox.showerror(title="Erreur de code débiteur", message=f"il y a une erreur dans le code débiteur, il faut le vérifier. \n(n'est pas un chiffre) {data.Patient['fip_number']}")
exit()
'''
'''
if data.Debtor["type"] == "Établissement":
self.a_listings["to_check"].append(data.Patient["fip_number"])
print(data.Patient["complement"])
self.logger.warn(f"Débiteur établissement facture N°: {data.data['id']} / {data.Patient['fip_number']} {data.Debtor['name']}")
'''
if int(data.Debtor["code"]) == 1: if int(self.attrib_link.debtor_code) == 1:
b_check_debitor = False b_check_debitor = False
if data.Debtor["lastname"] == None: if self.attrib_link.debtor_lastname == None:
b_check_debitor = True b_check_debitor = True
data.Debtor["lastname"] = "" self.attrib_link.debtor_lastname = ""
messagebox.showerror(title="Erreur", messagebox.showerror(title="Erreur",
message=f"Le débiteur n'a pas de nom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {data.data['id']} / {data.Patient['fip_number']}") message=f"Le débiteur n'a pas de nom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}")
if data.Debtor["firstname"] == None: if self.attrib_link.debtor_firstname == None:
b_check_debitor = True b_check_debitor = True
data.Debtor["firstname"] = "" self.attrib_link.debtor_firstname = ""
messagebox.showerror(title="Erreur", messagebox.showerror(title="Erreur",
message=f"Le débiteur n'a pas de prénom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {data.data['id']} / {data.Patient['fip_number']}") message=f"Le débiteur n'a pas de prénom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}")
if b_check_debitor: if b_check_debitor:
debitor_popup = Check_debitor_popup(self.fenetre, data.Debtor, debitor_popup = Check_debitor_popup(self.fenetre, data.Debtor,
self.o_debs.get_names_by_code(data.Debtor['code']), self.o_debs.get_names_by_code(self.attrib_link.debtor_code),
data.data['id'], self.attrib_link.invoice_ID,
data.Patient['fip_number'], object=self.o_debs) self.attrib_link.FIP, object=self.o_debs)
data.Debtor["code"] = debitor_popup.show() self.attrib_link.debtor_code = debitor_popup.show()
if data.Patient["lastname"] + data.Patient["firstname"] != data.Debtor["lastname"] + data.Debtor["firstname"]: if self.attrib_link.patient_lastname + self.attrib_link.patient_firstname != self.attrib_link.debtor_lastname + self.attrib_link.debtor_firstname:
self.a_listings["to_check"].append(data.Patient["fip_number"]) self.a_listings["to_check"].append(self.attrib_link.FIP)
print(data.Patient["complement"]) print(self.attrib_link.patient_addr_complement)
self.logger.warning(f"Débiteur différents: facture N°: {data.data['id']} / {data.Patient['fip_number']}") self.logger.warning(f"Débiteur différents: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}")
if int(data.Debtor["code"]) >= 100: if int(self.attrib_link.debtor_code) >= 100:
if "name" not in data.Debtor.keys(): if "name" not in data.Debtor.keys():
data.Debtor["name"] = "Invalide" self.attrib_link.debtor_name = "Invalide"
self.logger.warning( self.logger.warning(
f"Débiteur > 100 sans nom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {data.data['id']} / {data.Patient['fip_number']}") f"Débiteur > 100 sans nom, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}")
messagebox.showerror(title="Erreur", messagebox.showerror(title="Erreur",
message=f"Débiteur > 100 sans nom de débiteur ou d'établissement, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {data.data['id']} / {data.Patient['fip_number']}") message=f"Débiteur > 100 sans nom de débiteur ou d'établissement, vérifier la facture ATTRIB et vérifier le code débiteur: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}")
self.a_listings["to_check"].append(data.Patient["fip_number"]) self.a_listings["to_check"].append(self.attrib_link.FIP)
if not self.o_debs.is_in_debitor_name(code=data.Debtor["code"],search_name=data.Debtor["name"]): if not self.o_debs.is_in_debitor_name(code=self.attrib_link.debtor_code,search_name=self.attrib_link.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'])}") #messagebox.showerror(title="Erreur code débiteur erroné", message=f"Information débiteur incohérente: facture N°: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP}.\nCode débiteur: {self.attrib_link.debtor_code}\nNom du débiteur: {data.Debtor['name']}. \nAurait dû être: {self.o_debs.get_names_by_code(self.attrib_link.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) debitor_popup = Check_debitor_popup(self.fenetre,data.Debtor,self.o_debs.get_names_by_code(self.attrib_link.debtor_code),self.attrib_link.invoice_ID,self.attrib_link.FIP, object=self.o_debs)
data.Debtor["code"] = debitor_popup.show() self.attrib_link.debtor_code = debitor_popup.show()
if data.Debtor["code"] is None or '.' in data.Debtor["code"]: if self.attrib_link.debtor_code is None or '.' in self.attrib_link.debtor_code:
messagebox.showerror(title="Erreur Critique", messagebox.showerror(title="Erreur Critique",
message=f"Les informations de la factures [{data.data['id']}] comportes trop d'erreur arrêt du processus ") message=f"Les informations de la factures [{self.attrib_link.invoice_ID}] comportes trop d'erreur arrêt du processus ")
return False return False
if self.attrib_link.patient_AVS == None:
self.attrib_link.patient_AVS = f"{uuid.uuid4()}"[:15]
'''
Désactivé, plus utile
if data.Patient["complement"] != None :
self.a_listings["to_check"].append(data.Patient["fip_number"])
print(data.Patient["complement"])
self.logger.warning(f"Complément patient: facture N°: {data.data['id']} / {data.Patient['fip_number']}")
'''
if data.Patient['insurance_policy_number'] == None:
data.Patient['insurance_policy_number'] = f"{uuid.uuid4()}"[:15]
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(self.attrib_link.patient_AVS.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=self.attrib_link.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=self.attrib_link.invoice_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: {self.attrib_link.invoice_ID} / {self.attrib_link.FIP} {self.attrib_link.debtor_code} {self.attrib_link.debtor_lastname} {self.attrib_link.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
#self.draw_test(item_1=data.Patient, item_2=addresses_exist) #self.draw_test(item_1=data.Patient, item_2=addresses_exist)
#messagebox.showerror(title="AVS Trouvé", message=f"Le code AVS de l'adresse {data.Patient['insurance_policy_number']} est déjà existant: [{data.Debtor['code']}], merci de le corriger ") #messagebox.showerror(title="AVS Trouvé", message=f"Le code AVS de l'adresse {self.attrib_link.patient_AVS} est déjà existant: [{self.attrib_link.debtor_code}], merci de le corriger ")
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(self.attrib_link.get_value_from_attrib(data=article,obj="article",key="price"))
if "code" in article.keys(): if "code" in article.keys():
if article["code"] == "HRF": if self.attrib_link.get_value_from_attrib(data=article,obj="article",key="code") == "HRF":
b_HRF = True b_HRF = True
sHRF = article["line_1"].replace("h", ":") sHRF = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_1").replace("h", ":")
print(f"pass HRF => {data.Patient['fip_number']} = {b_HRF}") print(f"pass HRF => {self.attrib_link.FIP} = {b_HRF}")
#self.logger.warning(f"HRF: {data.data['id']}") #self.logger.warning(f"HRF: {self.attrib_link.invoice_ID}")
break
print(f"Lecture de la facture #{cur_invoice_index} {self.attrib_link.get_value_from_attrib(data=ele,obj="invoice",key="id")} montant total = {self.attrib_link.get_value_from_attrib(data=ele,obj="invoice",key="total_price")} <> {facture_total}")
if float(self.attrib_link.get_value_from_attrib(data=ele,obj="invoice",key="total_price")) != facture_total:
print(f"ERROR NOT SAME PRICE")
total_facture_total += facture_total
total_facture_amount += float(self.attrib_link.get_value_from_attrib(data=ele,obj="invoice",key="total_price"))
for article in data.Articles: for article in data.Articles:
self.bs_counter += 1 self.bs_counter += 1
csv_col = cls_Col(True) csv_col = cls_Col(True)
print(article) print(article)
if "code" in article.keys() and article["code"] == "HRF": if "code" in article.keys() and self.attrib_link.get_value_from_attrib(data=article,obj="article",key="code") == "HRF":
break break
##Donnée globales ##Donnée globales
csv_col.data[0] = data.data["id"] # N° document csv_col.data[0] = self.attrib_link.invoice_ID # N° document
csv_col.data[1] = 20 # Type of document 20 = facture débiteur 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[2] = datetime.strptime(self.attrib_link.invoice_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[4] = self.attrib_link.FIP # Référence
csv_col.data[10] = "<AUTO>" # Compte collectif du tiers = <AUTO> 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 csv_col.data[139] = "COND-30" # Conditions de payement à 30, COND-30 selon config dans winbiz
@@ -588,45 +593,45 @@ class ClercAttrib2Biz():
if "without_transportation" in data.Intervention.keys() and data.Intervention["without_transportation"] == True: if "without_transportation" in data.Intervention.keys() and data.Intervention["without_transportation"] == True:
csv_col.data[15] = "Sans transport" csv_col.data[15] = "Sans transport"
print(f"->NO DEST** {data.data['id']}") print(f"->NO DEST** {self.attrib_link.invoice_ID}")
elif data.Intervention["destination_name"] == None and data.Intervention["destination_street"] == None and data.Intervention["destination_city"] == None: elif self.attrib_link.intervention_dest_name == None and self.attrib_link.intervention_dest_street == None and self.attrib_link.intervention_dest_city == None:
csv_col.data[15] = "Sans destination" csv_col.data[15] = "Sans destination"
print(f"->NO DEST sans destination transmis à autruit** {data.data['id']}") print(f"->NO DEST sans destination transmis à autruit** {self.attrib_link.invoice_ID}")
else: else:
con = "" con = ""
concat_str = "" concat_str = ""
if data.Intervention["destination_name"] is not None: if self.attrib_link.intervention_dest_name is not None:
concat_str += con + data.Intervention["destination_name"] concat_str += con + self.attrib_link.intervention_dest_name
con = ", " con = ", "
if data.Intervention["destination_street"] is not None: if self.attrib_link.intervention_dest_street is not None:
concat_str += con + data.Intervention["destination_street"] + " " + self.ifNotNull(data.Intervention["destination_street_number"]) concat_str += con + self.attrib_link.intervention_dest_street + " " + self.ifNotNull(self.attrib_link.intervention_dest_street_number)
con = ", " con = ", "
concat_str += con + data.Intervention["destination_postal_code"] + " " + data.Intervention["destination_city"] concat_str += con + self.attrib_link.intervention_dest_postal_code + " " + self.attrib_link.intervention_dest_city
csv_col.data[15] = concat_str # Adresse DEST csv_col.data[15] = concat_str # Adresse DEST
con = "" con = ""
concat_str = "" concat_str = ""
if data.Intervention["site_name"] is not None: if self.attrib_link.intervention_site_name is not None:
concat_str += con + data.Intervention["site_name"] concat_str += con + self.attrib_link.intervention_site_name
con = ", " con = ", "
if data.Intervention["site_street"] is not None: if self.attrib_link.intervention_site_street is not None:
concat_str += con + self.ifNotNull(data.Intervention["site_street"]) + " " + self.ifNotNull(data.Intervention["site_street_number"]) concat_str += con + self.ifNotNull(self.attrib_link.intervention_site_street) + " " + self.ifNotNull(self.attrib_link.intervention_site_street_number)
con = ", " con = ", "
concat_str += con + self.ifNotNull(data.Intervention["site_postal_code"]) + " " + self.ifNotNull(data.Intervention["site_city"]) concat_str += con + self.ifNotNull(self.attrib_link.intervention_site_postal_code) + " " + self.ifNotNull(self.attrib_link.intervention_site_city)
csv_col.data[18] = concat_str # Adresse PEC csv_col.data[18] = concat_str # Adresse PEC
print(f'debug FIP:{data.Patient["fip_number"]} id:{data.data["id"]} code: {data.Debtor["code"]}') print(f'debug FIP:{self.attrib_link.FIP} id:{self.attrib_link.invoice_ID} code: {self.attrib_link.debtor_code}')
if int(data.Debtor["code"]) < 100: if int(self.attrib_link.debtor_code) < 100:
csv_col.data[19] = data.Patient['insurance_policy_number'].replace(".","") csv_col.data[19] = self.attrib_link.patient_AVS.replace(".","")
csv_col.data[22] = data.Patient["lastname"] csv_col.data[22] = self.attrib_link.patient_lastname
csv_col.data[23] = data.Patient["firstname"] csv_col.data[23] = self.attrib_link.patient_firstname
csv_col.data[24] = data.Patient["complement"] csv_col.data[24] = self.attrib_link.patient_addr_complement
csv_col.data[25] = self.ifNotNull(data.Patient["street"]) + " " + self.ifNotNull(data.Patient["street_number"]) csv_col.data[25] = self.ifNotNull(self.attrib_link.patient_street) + " " + self.ifNotNull(self.attrib_link.patient_street_number)
csv_col.data[26] = data.Patient["postal_code"] csv_col.data[26] = self.attrib_link.patient_postal_code
csv_col.data[27] = data.Patient["city"] csv_col.data[27] = self.attrib_link.patient_city
if data.Patient["country_name"] != "Suisse": if self.attrib_link.patient_country != "Suisse":
csv_col.data[29] = data.Patient["country_name"] csv_col.data[29] = self.attrib_link.patient_country
csv_col.data[41] = "Monsieur" if data.Patient["gender"] == "Masculin" else "Madame" csv_col.data[41] = "Monsieur" if self.attrib_link.patient_gender == "Masculin" else "Madame"
csv_col.data[44] = csv_col.data[41] csv_col.data[44] = csv_col.data[41]
#csv_col.data[46] = 0 # Maj adresse #csv_col.data[46] = 0 # Maj adresse
@@ -637,102 +642,70 @@ class ClercAttrib2Biz():
csv_col.data[46] = 1 # Maj adresse, ajoute, mais ne met pas à jour l'adresse si elle existe csv_col.data[46] = 1 # Maj adresse, ajoute, mais ne met pas à jour l'adresse si elle existe
print("NON mise à jour de l'adresse") print("NON mise à jour de l'adresse")
if int(data.Debtor["code"]) > 1: if int(self.attrib_link.debtor_code) > 1:
con = "" csv_col.data[42] = self.attrib_link.patient_addr_2.replace("\n", "#chr(13)##chr(10)#") #Adresse de livraison
concat_str = ""
if "name" in data.Debtor.keys():
if data.Debtor["name"] is not None:
concat_str += con + data.Debtor["name"]
con = "#chr(13)##chr(10)#"
else:
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:
concat_str += con + "Monsieur" if data.Debtor["gender"] == "Masculin" else con + "Madame"
con = "#chr(13)##chr(10)#"
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["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)#"
csv_col.data[42] = concat_str #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] = self.attrib_link.debtor_code # Code adresse à récupérer dans recherche d'adresse automatisée
csv_col.data[22] = data.Debtor["lastname"] csv_col.data[22] = self.attrib_link.debtor_lastname
csv_col.data[23] = data.Debtor["firstname"] csv_col.data[23] = self.attrib_link.debtor_firstname
csv_col.data[24] = data.Debtor["complement"] csv_col.data[24] = self.attrib_link.debtor_addr_complement
csv_col.data[25] = self.ifNotNull(data.Debtor["street"]) + " " + self.ifNotNull(data.Debtor["street_number"]) csv_col.data[25] = self.ifNotNull(self.attrib_link.debtor_street) + " " + self.ifNotNull(self.attrib_link.debtor_street_number)
csv_col.data[26] = data.Debtor["postal_code"] csv_col.data[26] = self.attrib_link.debtor_postal_code
csv_col.data[27] = data.Debtor["city"] csv_col.data[27] = self.attrib_link.debtor_city
if data.Debtor["country_name"] != "Suisse": if self.attrib_link.debtor_country != "Suisse":
csv_col.data[29] = data.Debtor["country_name"] csv_col.data[29] = self.attrib_link.debtor_country
csv_col.data[46] =1 # Maj adresse, ajoute, mais ne met pas à jour l'adresse si elle existe csv_col.data[46] =1 # Maj adresse, ajoute, mais ne met pas à jour l'adresse si elle existe
if "name" in data.Debtor.keys(): if "name" in data.Debtor.keys():
csv_col.data[21] = self.ifNotNull(data.Debtor["name"]) csv_col.data[21] = self.ifNotNull(self.attrib_link.debtor_name)
else: else:
csv_col.data[21] = '' csv_col.data[21] = ''
if data.Patient["birthdate"] is not None: if self.attrib_link.patient_birthdate is not None:
csv_col.data[40] = datetime.strptime(data.Patient["birthdate"], "%Y-%m-%d").strftime("%d.%m.%Y") csv_col.data[40] = datetime.strptime(self.attrib_link.patient_birthdate, "%Y-%m-%d").strftime("%d.%m.%Y")
else: else:
csv_col.data[40] = "" csv_col.data[40] = ""
messagebox.showerror(title="Erreur date de naissance", message=f"La date de naissance de la facture {data.data['id']} ({data.Patient['lastname']}) est faux: [{data.Patient['birthdate']}], merci de le corriger ") messagebox.showerror(title="Erreur date de naissance", message=f"La date de naissance de la facture {self.attrib_link.invoice_ID} ({self.attrib_link.patient_lastname}) est faux: [{self.attrib_link.patient_birthdate}], merci de le corriger ")
csv_col.data[48] = 0 csv_col.data[48] = 0
## Données prestations ## Données prestations
if "code" in article.keys(): if "code" in article.keys():
csv_col.data[49] = article["code"] # Code de prestations csv_col.data[49] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="code") # Code de prestations
csv_col.data[50] = article["line_1"] csv_col.data[50] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_1")
if article["line_2"] != None: if self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_2") != None:
csv_col.data[50] = article["line_1"] + "#chr(13)##chr(10)#" + article["line_2"] # Descriptions prestations csv_col.data[50] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_1") + "#chr(13)##chr(10)#" + self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_2") # Descriptions prestations
csv_col.data[52] = article["quantity"] # Quantité csv_col.data[52] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="quantity") # Quantité
csv_col.data[53] = article["unit_price"] # prix unitaire csv_col.data[53] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="unit_price") # prix unitaire
csv_col.data[54] = self.ifNotNull(article["unit"]) # unité csv_col.data[54] = self.ifNotNull(self.attrib_link.get_value_from_attrib(data=article,obj="article",key="unit")) # unité
csv_col.data[56] = article["price"] # prix total csv_col.data[56] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="price") # prix total
else: else:
csv_col.data[49] = "0" csv_col.data[49] = "0"
csv_col.data[50] = article["line_1"] csv_col.data[50] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_1")
if article["line_2"] != None: if self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_2") != None:
csv_col.data[50] = article["line_1"] + " / " + article["line_2"] # Descriptions prestations csv_col.data[50] = self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_1") + " / " + self.attrib_link.get_value_from_attrib(data=article,obj="article",key="line_2") # Descriptions prestations
csv_col.data[52] = 0 csv_col.data[52] = 0
csv_col.data[53] = 0 csv_col.data[53] = 0
csv_col.data[56] = 0 # prix total csv_col.data[56] = 0 # prix total
compte_number = None compte_number = None
if data.Intervention["base_name"] == "Uvrier": if self.attrib_link.intervention_base == "Uvrier":
compte_number = 3018 compte_number = 3018
else: else:
if data.Intervention["type"] == "P1": if self.attrib_link.intervention_type == "P1":
compte_number = 3001 if data.Intervention["team_name"] == "Planification" else 3011 compte_number = 3001 if self.attrib_link.intervention_team == "Planification" else 3011
if data.Intervention["type"] == "P2": if self.attrib_link.intervention_type == "P2":
compte_number = 3002 if data.Intervention["team_name"] == "Planification" else 3012 compte_number = 3002 if self.attrib_link.intervention_team == "Planification" else 3012
if data.Intervention["type"] == "P3": if self.attrib_link.intervention_type == "P3":
compte_number = 3003 if data.Intervention["team_name"] == "Planification" else 3013 compte_number = 3003 if self.attrib_link.intervention_team == "Planification" else 3013
if data.Intervention["type"] == "S1": if self.attrib_link.intervention_type == "S1":
compte_number = 3004 if data.Intervention["team_name"] == "Planification" else 3014 compte_number = 3004 if self.attrib_link.intervention_team == "Planification" else 3014
if data.Intervention["type"] == "S2": if self.attrib_link.intervention_type == "S2":
compte_number = 3005 if data.Intervention["team_name"] == "Planification" else 3015 compte_number = 3005 if self.attrib_link.intervention_team == "Planification" else 3015
if data.Intervention["type"] == "S3": if self.attrib_link.intervention_type == "S3":
compte_number = 3005 if data.Intervention["team_name"] == "Planification" else 3015 compte_number = 3005 if self.attrib_link.intervention_team == "Planification" else 3015
csv_col.data[59] = compte_number csv_col.data[59] = compte_number
csv_col.data[60] = 0 csv_col.data[60] = 0
@@ -745,46 +718,48 @@ class ClercAttrib2Biz():
csv_col.data[73] = 0 csv_col.data[73] = 0
#Objet facture #Objet facture
csv_col.data[108] = self.ifNotNull(data.Patient["lastname"]) + " " + self.ifNotNull(data.Patient["firstname"]) csv_col.data[108] = self.ifNotNull(self.attrib_link.patient_lastname) + " " + self.ifNotNull(self.attrib_link.patient_firstname)
csv_col.data[115] = data.Patient["complement"] csv_col.data[115] = self.attrib_link.patient_addr_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 "" csv_col.data[109] = datetime.strptime(self.attrib_link.patient_birthdate, "%Y-%m-%d").strftime("%d.%m.%Y") if self.attrib_link.patient_birthdate is not None else ""
if data.Patient["insurance_policy_number"] is not None and '-' not in data.Patient["insurance_policy_number"]: if self.attrib_link.patient_AVS is not None and '-' not in self.attrib_link.patient_AVS:
csv_col.data[109] += ", " + data.Patient["insurance_policy_number"] csv_col.data[109] += ", " + self.attrib_link.patient_AVS
csv_col.data[110] = data.Patient["insurance_name"] csv_col.data[110] = self.attrib_link.patient_insurance_name
date_PEC = datetime.strptime(data.Intervention["start_time"], "%Y-%m-%dT%H:%M:%S%z").strftime( date_PEC = datetime.strptime(self.attrib_link.intervention_start_time, "%Y-%m-%dT%H:%M:%S%z").strftime(
"%d.%m.%Y") "%d.%m.%Y")
csv_col.data[51] = date_PEC # Date de ligne articles csv_col.data[51] = date_PEC # Date de ligne articles
csv_col.data[111] =date_PEC # Date PEC 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( csv_col.data[111] += " - " + datetime.strptime(self.attrib_link.intervention_start_time, "%Y-%m-%dT%H:%M:%S%z").strftime(
"%H:%M") # Heure START PEC "%H:%M") # Heure START PEC
if b_HRF: if b_HRF:
csv_col.data[111] += "-" + sHRF csv_col.data[111] += "-" + sHRF
else: else:
csv_col.data[111] += "-" + datetime.strptime(data.Intervention["end_time"], "%Y-%m-%dT%H:%M:%S%z").strftime( csv_col.data[111] += "-" + datetime.strptime(self.attrib_link.intervention_end_time, "%Y-%m-%dT%H:%M:%S%z").strftime(
"%H:%M") # Heure END PEC "%H:%M") # Heure END PEC
csv_col.data[112] = self.ifNotNull(data.Patient["street"]) + " " + self.ifNotNull(data.Patient["street_number"]) csv_col.data[112] = self.ifNotNull(self.attrib_link.patient_street) + " " + self.ifNotNull(self.attrib_link.patient_street_number)
csv_col.data[113] = self.ifNotNull(data.Patient["postal_code"]) + " " + self.ifNotNull(data.Patient["city"]) csv_col.data[113] = self.ifNotNull(self.attrib_link.patient_postal_code) + " " + self.ifNotNull(self.attrib_link.patient_city)
if data.Patient["country_name"] != "Suisse": if self.attrib_link.patient_country != "Suisse":
csv_col.data[113] += ", " + data.Patient["country_name"] csv_col.data[113] += ", " + self.attrib_link.patient_country
csv_col.data[107] = data.Patient["fip_number"] csv_col.data[107] = self.attrib_link.FIP
csv_col.data[107] += " - " + data.data["comments"] if data.data["comments"] is not None else "" csv_col.data[107] += " - " + self.attrib_link.comments if self.attrib_link.comments is not None else ""
csv_col.data[116] = self.ifNotNull(data.Patient["category"]) + " - " + self.ifNotNull(data.Intervention["type"]) csv_col.data[116] = self.ifNotNull(self.attrib_link.patient_category) + " - " + self.ifNotNull(self.attrib_link.intervention_type)
csv_col.data[118] = data.Intervention["kilometers"] csv_col.data[118] = self.attrib_link.km
csv_col.data[135] = data.Intervention["base_name"] csv_col.data[135] = self.attrib_link.intervention_base
if data.Debtor["code"] == "100" or data.Debtor["code"] == "101": if self.attrib_link.debtor_code == "100" or self.attrib_link.debtor_code == "101" or self.attrib_link.debtor_code == "158":
csv_col.data[136] = "EBILL" #code présentation de facture csv_col.data[136] = "EBILL" #code présentation de facture
else: else:
csv_col.data[136] = 3 #code présentation de facture csv_col.data[136] = 3 #code présentation de facture
csv_col.data[146] = 3 #Code méthode de payement définit à 3 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[168] = 1 if self.attrib_link.intervention_team == "Planification" else 2
csv_col.data[169] = data.Patient['insurance_policy_number'] csv_col.data[169] = self.attrib_link.patient_AVS
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,2 @@
VERSION = "20230426-1114" VERSION = "20241109-1726"