Compare commits

..

30 Commits

Author SHA1 Message Date
Ambulance Clerc
714f6101ff Débug check_adresses 2022-06-06 18:22:14 +02:00
Ambulance Clerc
075ab7cee7 débug affichage check_adresse (doublon AVS) 2022-06-06 17:48:22 +02:00
Ambulance Clerc
16cb31d859 new release 2022-06-06 17:42:39 +02:00
Ambulance Clerc
b3c4ab9e0b Merge remote-tracking branch 'origin/master'
# Conflicts:
#	dl_version
2022-06-06 17:39:48 +02:00
Ambulance Clerc
bb57b3edff new release 2022-06-06 17:38:37 +02:00
Ambulance Clerc
ab248478c0 débug auto-update 2022-06-06 17:38:18 +02:00
Ambulance Clerc
2a1fcd7437 débug auto-update 2022-06-06 17:35:53 +02:00
49297d23ef Mise à jour de 'dl_version' 2022-06-06 17:34:58 +02:00
Ambulance Clerc
8995d412f9 débug auto-update 2022-06-06 17:30:31 +02:00
Ambulance Clerc
b8bca94f65 débug auto-update 2022-06-06 17:29:10 +02:00
Ambulance Clerc
e3c4ee9d3e New version 2022-06-06 17:28:34 +02:00
Ambulance Clerc
80fa01633e New version 2022-06-06 17:17:02 +02:00
Ambulance Clerc
d8fea135a9 Merge check_adress 2022-06-06 17:14:55 +02:00
Ambulance Clerc
ccb2b73d51 Merge remote-tracking branch 'origin/addresses'
# Conflicts:
#	main.py
2022-06-06 17:08:07 +02:00
Ambulance Clerc
393e9c844d Amélioration système auto-update 2022-06-06 13:46:06 +02:00
Ambulance Clerc
dbc0bab3e2 ajout système auto-update 2022-06-06 13:31:13 +02:00
Ambulance Clerc
66da1c212a Changement version 2022-06-06 13:12:57 +02:00
Ambulance Clerc
22a0ed46f6 Ajout note version déporté 2022-06-06 11:46:27 +02:00
Ambulance Clerc
2a0ab15e7d Ajout note version déporté 2022-06-06 11:11:16 +02:00
Ambulance Clerc
e92d92deec Ajout note version déporté 2022-06-06 11:07:30 +02:00
Ambulance Clerc
0f5fbe6778 Ajout des sans destination 2022-06-02 16:59:40 +02:00
Ambulance Clerc
b678c85400 Ajout des sans destination 2022-06-02 16:58:26 +02:00
Ambulance Clerc
521db9851e Modification détection sans transport 2022-06-02 16:41:33 +02:00
Ambulance Clerc
9acdf7a0f5 Modification détection sans transport 2022-06-02 16:41:15 +02:00
Ambulance Clerc
2a42096dcb Changement affichage date naissance 2022-06-02 16:36:54 +02:00
Ambulance Clerc
8ee93aefb0 Débug HRF 2022-06-02 15:09:56 +02:00
Ambulance Clerc
f5755c77f0 Débug HRF 2022-06-02 15:01:10 +02:00
Ambulance Clerc
f569dee4c2 Changement collone pour les kilomètres 2022-05-30 15:56:39 +02:00
Ambulance Clerc
71f736fd83 Débug des virgule dans adresse de PEC et adresse DEST + ajout des KM 2022-05-30 11:03:46 +02:00
Ambulance Clerc
3567b6942f Débug des virgule dans adresse de PEC et adresse DEST + ajout des KM 2022-05-30 10:57:06 +02:00
5 changed files with 112 additions and 29 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/update.exe

39
auto_update.py Normal file
View File

@@ -0,0 +1,39 @@
from version import *
import urllib.request
import ssl
import io
class auto_updater:
dl_version = 0
temp_dir = ""
def clean(self, str):
str = str.replace('/','')
str = str.replace(':', '')
str = str.replace('{', '')
str = str.replace('(', '')
str = str.replace("\\", '')
return str
def new_update_available(self):
ret = False
ctx = ssl.create_default_context()
ctx.check_hostname = False
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)
self.dl_version = str(data.read()).replace('b', '').replace("'", "")
ssl._create_default_https_context = ssl._create_unverified_context
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")
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")
except:
print("ERREUR de téléchargement mise à jours")
return "ERROR"
ret = True
return ret

1
dl_version Normal file
View File

@@ -0,0 +1 @@
20220606-1821

99
main.py
View File

@@ -3,6 +3,7 @@ import json
import os import os
import logging import logging
import shutil import shutil
import subprocess
import textwrap import textwrap
import time import time
import uuid import uuid
@@ -19,12 +20,14 @@ from threading import *
from class_invoices import * from class_invoices import *
from class_addresses import * from class_addresses import *
from auto_update import *
VERSION = "202200522 - 1848" from version import *
#test master 2 #test master 2
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"
temp_dir = os.getenv('APPDATA') + '\Attrib2Biz\.temp'
file_path ="" #os.path.dirname(__file__) file_path ="" #os.path.dirname(__file__)
Elements = [] Elements = []
@@ -38,9 +41,13 @@ if not os.path.exists(src_dir):
if not os.path.exists(dest_dir): if not os.path.exists(dest_dir):
os.makedirs(dest_dir) os.makedirs(dest_dir)
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
class SuggestionPopup(Toplevel): class SuggestionPopup(Toplevel):
x_row = 0 x_row = 0
no_selection_possible = False
def __init__(self, parent, item_1=None, item_2=None, debitor=None): def __init__(self, parent, item_1=None, item_2=None, debitor=None):
super().__init__(parent) super().__init__(parent)
@@ -106,13 +113,17 @@ class SuggestionPopup(Toplevel):
self.listbox.insert(END, f"Aucun changement possible, code débiteur {debitor['code']}") self.listbox.insert(END, f"Aucun changement possible, code débiteur {debitor['code']}")
self.listbox.configure(state='disabled') self.listbox.configure(state='disabled')
self.no_selection_possible = True
if int(debitor["code"]) == 1:
if str_address_1 == str_address_2:
self.listbox.selection_set(0)
print("adresse identique")
else:
self.listbox.selection_set(1)
print(f"adresse différente [{str_address_1}] ({str_address_2})")
if str_address_1 == str_address_2:
self.listbox.selection_set(0)
print("adresse identique")
else:
self.listbox.selection_set(1)
print(f"adresse différente [{str_address_1}] ({str_address_2})")
@@ -143,7 +154,9 @@ class SuggestionPopup(Toplevel):
if selection: if selection:
self.selection = self.listbox.get(selection[0]) self.selection = self.listbox.get(selection[0])
self.selection = True if self.selection == "Nouvelle" else False self.selection = True if self.selection == "Nouvelle" else False
self.destroy() self.destroy()
if self.no_selection_possible:
self.destroy()
def show(self): def show(self):
self.deiconify() self.deiconify()
@@ -190,11 +203,13 @@ class ClercAttrib2Biz():
self.prompt = None self.prompt = None
self.b_prompt_open = False self.b_prompt_open = False
self.check_addresses = BooleanVar(self.fenetre)
self.delete_after_parse = BooleanVar(self.fenetre) self.delete_after_parse = BooleanVar(self.fenetre)
self.export_format_biz = BooleanVar(self.fenetre) self.export_format_biz = BooleanVar(self.fenetre)
self.export_one_file = BooleanVar(self.fenetre) self.export_one_file = BooleanVar(self.fenetre)
self.run_excel_after_export = BooleanVar(self.fenetre) self.run_excel_after_export = BooleanVar(self.fenetre)
self.check_addresses.set(True)
self.export_one_file.set(True) self.export_one_file.set(True)
self.run_excel_after_export.set(False) self.run_excel_after_export.set(False)
self.export_format_biz.set(True) self.export_format_biz.set(True)
@@ -298,11 +313,12 @@ class ClercAttrib2Biz():
lbf_3 = LabelFrame(self.fenetre, text="Options") lbf_3 = LabelFrame(self.fenetre, text="Options")
lbf_3.grid(row=0, column=1, rowspan=2, sticky='NSEW', padx=5, pady=5) lbf_3.grid(row=0, column=1, rowspan=2, sticky='NSEW', padx=5, pady=5)
Checkbutton(lbf_3, text="Supprimer fichiers après conversion", variable= self.delete_after_parse, onvalue=True, offvalue=False).grid(row=0, sticky='W') Checkbutton(lbf_3, text="Vérifier les Adresses", variable=self.check_addresses, onvalue=True, offvalue=False).grid(row=0, sticky='W')
Checkbutton(lbf_3, text="Export au format .biz", variable= self.export_format_biz, onvalue=True, offvalue=False, command=self.refresh_ui).grid(row=1, sticky='W') Checkbutton(lbf_3, text="Supprimer fichiers après conversion", variable= self.delete_after_parse, onvalue=True, offvalue=False).grid(row=1, sticky='W')
Checkbutton(lbf_3, text="Export en 1 seul fichier", variable= self.export_one_file, onvalue=True, offvalue=False, command=self.refresh_ui).grid(row=2, sticky='W') Checkbutton(lbf_3, text="Export au format .biz", variable= self.export_format_biz, onvalue=True, offvalue=False, command=self.refresh_ui).grid(row=2, sticky='W')
Checkbutton(lbf_3, text="Export en 1 seul fichier", variable= self.export_one_file, onvalue=True, offvalue=False, command=self.refresh_ui).grid(row=3, sticky='W')
self.cb_run = Checkbutton(lbf_3, text="Lancer la conversion excel", variable=self.run_excel_after_export, onvalue=True, offvalue=False) 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=3, sticky='W') self.cb_run.grid(row=4, sticky='W')
@@ -312,6 +328,17 @@ class ClercAttrib2Biz():
self.thread = Thread(target=self.start_parsing) self.thread = Thread(target=self.start_parsing)
auto_update = auto_updater()
auto_update.temp_dir = temp_dir + '\\'
update_available = auto_update.new_update_available()
if update_available == True:
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 !", ):
subprocess.call(temp_dir + "\\update.exe")
self.fenetre.destroy()
elif update_available == "ERROR":
messagebox.showerror(title="ERREUR téléchargement", message="Erreur lors du téléchargement de la nouvelle mise à jour")
def disable_prompt(self): def disable_prompt(self):
self.prompt.destroy() self.prompt.destroy()
self.b_prompt_open = False self.b_prompt_open = False
@@ -475,28 +502,33 @@ class ClercAttrib2Biz():
if data.Patient['insurance_policy_number'] == None: if data.Patient['insurance_policy_number'] == None:
data.Patient['insurance_policy_number'] = f"{uuid.uuid4()}"[:15] data.Patient['insurance_policy_number'] = f"{uuid.uuid4()}"[:15]
addresses_exist = self.addresses.get_item_by_AVS(data.Patient['insurance_policy_number'].replace(".", "")) if self.check_addresses.get():
if addresses_exist is not None: addresses_exist = self.addresses.get_item_by_AVS(data.Patient['insurance_policy_number'].replace(".", ""))
if addresses_exist is not None:
popup = SuggestionPopup(self.fenetre, item_1=data.Patient, item_2=addresses_exist, debitor=data.Debtor)
b_address_update = popup.show()
print(f"Result Popup: {b_address_update}")
else:
b_address_update = True
popup = SuggestionPopup(self.fenetre, item_1=data.Patient, item_2=addresses_exist,debitor=data.Debtor )
b_address_update = popup.show()
print(f"Result Popup: {b_address_update}")
#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 {data.Patient['insurance_policy_number']} est déjà existant: [{data.Debtor['code']}], merci de le corriger ")
b_HRF = False b_HRF = False
sHRF = "" sHRF = ""
for article in data.Articles: for article in data.Articles:
if "code" in article.keys(): if "code" in article.keys():
if article["code"] == "HRF": if article["code"] == "HRF":
b_HRF = True b_HRF = True
sHRF = article["line_1"].replace("h", ":") sHRF = article["line_1"].replace("h", ":")
print(f"pass HRF => {data.Patient['fip_number']}") print(f"pass HRF => {data.Patient['fip_number']} = {b_HRF}")
#self.logger.warning(f"HRF: {data.data['id']}")
break break
for article in data.Articles:
self.bs_counter += 1 self.bs_counter += 1
csv_col = cls_Col(True) csv_col = cls_Col(True)
@@ -508,16 +540,21 @@ class ClercAttrib2Biz():
csv_col.data[10] = "<AUTO>" # Compte collectif du tiers = <AUTO> csv_col.data[10] = "<AUTO>" # Compte collectif du tiers = <AUTO>
if "destination_name" not in data.Intervention.keys() or data.Intervention["destination_name"] == None: 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']}")
elif data.Intervention["destination_name"] == None and data.Intervention["destination_street"] == None and data.Intervention["destination_city"] == None:
csv_col.data[15] = "Sans destination"
print(f"->NO DEST sans destination transmis à autruit** {data.data['id']}")
else: else:
con = "" con = ""
concat_str = "" concat_str = ""
if data.Intervention["destination_name"] is not None: if data.Intervention["destination_name"] is not None:
concat_str += con + data.Intervention["destination_name"] concat_str += con + data.Intervention["destination_name"]
con = ", " con = ", "
concat_str += con + data.Intervention["destination_street"] + " " + self.ifNotNull(data.Intervention["destination_street_number"]) if data.Intervention["destination_street"] is not None:
con = ", " concat_str += con + data.Intervention["destination_street"] + " " + self.ifNotNull(data.Intervention["destination_street_number"])
con = ", "
concat_str += con + data.Intervention["destination_postal_code"] + " " + data.Intervention["destination_city"] concat_str += con + data.Intervention["destination_postal_code"] + " " + data.Intervention["destination_city"]
csv_col.data[15] = concat_str # Adresse DEST csv_col.data[15] = concat_str # Adresse DEST
@@ -526,8 +563,9 @@ class ClercAttrib2Biz():
if data.Intervention["site_name"] is not None: if data.Intervention["site_name"] is not None:
concat_str += con + data.Intervention["site_name"] concat_str += con + data.Intervention["site_name"]
con = ", " con = ", "
concat_str += con + self.ifNotNull(data.Intervention["site_street"]) + " " + self.ifNotNull(data.Intervention["site_street_number"]) if data.Intervention["site_street"] is not None:
con = ", " concat_str += con + self.ifNotNull(data.Intervention["site_street"]) + " " + self.ifNotNull(data.Intervention["site_street_number"])
con = ", "
concat_str += con + self.ifNotNull(data.Intervention["site_postal_code"]) + " " + self.ifNotNull(data.Intervention["site_city"]) concat_str += con + self.ifNotNull(data.Intervention["site_postal_code"]) + " " + self.ifNotNull(data.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:{data.Patient["fip_number"]} id:{data.data["id"]} code: {data.Debtor["code"]}')
@@ -650,7 +688,7 @@ class ClercAttrib2Biz():
csv_col.data[115] = self.ifNotNull(data.Patient["lastname"]) + " " + self.ifNotNull(data.Patient["firstname"]) csv_col.data[115] = self.ifNotNull(data.Patient["lastname"]) + " " + self.ifNotNull(data.Patient["firstname"])
csv_col.data[108] = data.Patient["complement"] csv_col.data[108] = 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 "date naissance inconnue" 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"]: 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[109] += ", " + data.Patient["insurance_policy_number"]
@@ -659,6 +697,7 @@ class ClercAttrib2Biz():
"%d.%m.%Y") # Date PEC "%d.%m.%Y") # 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(data.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:
@@ -673,6 +712,7 @@ class ClercAttrib2Biz():
csv_col.data[107] = data.Patient["fip_number"] csv_col.data[107] = data.Patient["fip_number"]
csv_col.data[107] += " - " + data.data["comments"] if data.data["comments"] is not None else "" csv_col.data[107] += " - " + data.data["comments"] if data.data["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(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[135] = data.Intervention["base_name"]
csv_col.data[136] = 2 if data.Intervention["base_name"] == "Uvrier" else 3 csv_col.data[136] = 2 if data.Intervention["base_name"] == "Uvrier" else 3
csv_col.data[146] = csv_col.data[136] csv_col.data[146] = csv_col.data[136]
@@ -750,7 +790,7 @@ class ClercAttrib2Biz():
if data.Patient["complement"] != None : if data.Patient["complement"] != None :
self.a_listings["to_check"].append(data.Patient["fip_number"]) self.a_listings["to_check"].append(data.Patient["fip_number"])
print(data.Patient["complement"]) print(data.Patient["complement"])
self.logger.warning(f"Complément patient: facture N°: {data.data['id']} / {data.Patient['fip_number']}") self.logger.warning(f"Complément 22 patient: facture N°: {data.data['id']} / {data.Patient['fip_number']}")
if data.Patient['insurance_policy_number'] == None: if data.Patient['insurance_policy_number'] == None:
@@ -766,6 +806,7 @@ class ClercAttrib2Biz():
b_HRF = True b_HRF = True
sHRF = article["line_1"].replace("h",":") sHRF = article["line_1"].replace("h",":")
print(f"pass HRF => {data.Patient['fip_number']}") print(f"pass HRF => {data.Patient['fip_number']}")
break break

1
version.py Normal file
View File

@@ -0,0 +1 @@
VERSION = "20220606-1821"