débug objet des factures

This commit is contained in:
Ambulance Clerc
2022-05-22 18:42:33 +02:00
parent 8872267f84
commit 777accea98

156
main.py
View File

@@ -17,8 +17,9 @@ from tkinter.scrolledtext import ScrolledText
from threading import *
from class_invoices import *
from class_addresses import *
VERSION = "202200522 - 1457"
VERSION = "202200522 - 1702"
src_dir = os.getenv('APPDATA') + "\Attrib2Biz\src"
dest_dir = os.getenv('APPDATA') + "\Attrib2Biz\output"
@@ -36,6 +37,58 @@ if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
class SuggestionPopup(Toplevel):
def __init__(self, parent, item_1=None, item_2=None):
super().__init__(parent)
self.geometry("400x475")
self.resizable(True,True)
self.iconbitmap("./logo_clerc_03X_icon.ico")
self.title("Choix de l'adresse à conserver 1")
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
lbf_new = LabelFrame(self, text="Nouveau patient")
lbf_new.grid(row=0, column=0, sticky='WE', padx=5, pady=5)
Label(lbf_new, text=f"N° AVS de l'adresse \t {item_1['insurance_policy_number'].replace('.','')}").grid(row=0, column=0)
lbf_old = LabelFrame(self, text="Ancien patient")
lbf_old.grid(row=0, column=1, sticky='NSEW', padx=5, pady=5)
Label(lbf_old, text=f"N° AVS de l'adresse \t {item_2.AVS}").grid(row=0, column=0)
self.listbox = Listbox(self, height=10, width=20)
self.listbox.grid(row=1,column=0, columnspan= 2, pady=15)
self.btn = Button(self, text="Confirm selection", command=self.select)
self.btn.grid(row=2, pady=10)
for (idd, info) in ((0, "Ancienne"), (1, "Nouvelle")) :
self.listbox.insert(END, info)
self.selection = None
def destroy(self):
if self.selection is None:
self.selection = 0
super().destroy()
def select(self):
selection = self.listbox.curselection()
if selection:
self.selection = self.listbox.get(selection[0])
self.destroy()
def show(self):
self.deiconify()
self.wm_protocol("WM_DELETE_WINDOW", self.destroy)
self.wait_window(self)
return self.selection
class TextHandler(logging.Handler):
"""This class allows you to log to a Tkinter Text or ScrolledText widget"""
def __init__(self, text):
@@ -61,6 +114,8 @@ class ClercAttrib2Biz():
def __init__(self):
self.count_facture = 0
self.a_index = {"invoice": [], "intervention": [], "patient": [], "debtor": [], "articles": [], "global": []}
self.addresses = cls_Addresses()
self.index_counter = 0
self.bs_counter = 70
@@ -69,6 +124,8 @@ class ClercAttrib2Biz():
self.fenetre = Tk()
self.prompt = None
self.b_prompt_open = False
self.delete_after_parse = BooleanVar(self.fenetre)
self.export_format_biz = BooleanVar(self.fenetre)
@@ -81,6 +138,7 @@ class ClercAttrib2Biz():
self.draw_mainWindows()
self.refresh_ui()
self.read_addresses()
self.timer = self.fenetre.after(1000, self.main_timer_fn)
@@ -88,6 +146,9 @@ class ClercAttrib2Biz():
def main_timer_fn(self):
print("Pass tick timer main app")
self.timer = self.fenetre.after(5000, self.main_timer_fn)
@@ -188,6 +249,58 @@ class ClercAttrib2Biz():
self.thread = Thread(target=self.start_parsing)
def draw_addressesWindows(self):
# Init de la fenêtre addresses prompt
self.fenetre.iconbitmap("./logo_clerc_03X_icon.ico")
self.fenetre.title("Clerc Attrib2Biz v" + str(VERSION))
self.fenetre.resizable(True, True)
self.fenetre.geometry("700x475")
self.fenetre.columnconfigure(0, weight=3)
self.fenetre.columnconfigure(1, weight=1)
self.fenetre.rowconfigure(3, weight=1)
def disable_prompt(self):
self.prompt.destroy()
self.b_prompt_open = False
def draw_test(self, item_1=None, item_2=None):
return None
self.b_prompt_open = True
self.prompt = Toplevel()
self.prompt.geometry("400x275")
self.prompt.iconbitmap("./logo_clerc_03X_icon.ico")
self.prompt.title("Choix de l'adresse à conserver ")
self.prompt.protocol("WM_DELETE_WINDOW", self.disable_prompt)
self.prompt.columnconfigure(0, weight=1)
self.prompt.columnconfigure(1, weight=1)
lbf_new = LabelFrame(self.prompt, text="Nouveau patient")
lbf_new.grid(row=0,column=0,sticky='WE', padx=5, pady=5)
Label(lbf_new, text=f"N° AVS de l'adresse").grid(row=0,column=0)
lbf_old = LabelFrame(self.prompt, text="Ancien patient")
lbf_old.grid(row=0, column=1, sticky='NSEW', padx=5, pady=5)
Label(lbf_old, text=f"N° AVS de l'adresse").grid(row=0, column=0)
'''a = StringVar()
Label(root, text='enter something').pack()
Entry(root, textvariable=a).pack()
Button(root, text='Ok', command=lambda: self.DoSomethingWithInput(a.get, root)).pack()'''
def DoSomethingWithInput(self,var,root):
print("var")
root.destroy()
def refresh_ui(self):
print("pass refresh UI")
if self.export_one_file.get() and not self.export_format_biz.get():
@@ -200,6 +313,30 @@ class ClercAttrib2Biz():
self.run_excel_after_export.set(False)
def read_addresses(self):
file_addresses_path = os.path.join(dest_dir, f"adresses.csv")
if os.path.exists(file_addresses_path):
file = open(file_addresses_path)
csvreader = csv.reader(file, delimiter=';')
rows = []
for row in csvreader:
rows.append(row)
o_addresse = cls_addresse()
o_addresse.AVS = row[5]
o_addresse.lastName = row[9]
o_addresse.firstName = row[10]
o_addresse.birth = row[38]
o_addresse.street = row[11]
o_addresse.npa = row[13]
o_addresse.city = row[15]
self.addresses.add_addresse(o_addresse)
print(self.addresses.items)
file.close()
else:
messagebox.showwarning(title="Impossible d'ouvrir le fichier d'adresse existantes", message=f"Le fichier {file_addresses_path} est introuvable. Aucune vérification des adresses possible")
#messagebox.showerror(title="Erreur fichier déjà ouvert", message=f"Le fichier {self.export_filename} est déjà ouvert. Veuillez le fermer et recommencer")
def start_parsing(self):
@@ -318,9 +455,20 @@ class ClercAttrib2Biz():
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]
addresses_exist = self.addresses.get_item_by_AVS(data.Patient['insurance_policy_number'].replace(".", ""))
if addresses_exist is not None:
pass
#popup = SuggestionPopup(self.fenetre, item_1=data.Patient, item_2=addresses_exist)
#result = popup.show()
#print(f"Result Popup: {result}")
#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 ")
b_HRF = False
sHRF = ""
@@ -477,7 +625,7 @@ class ClercAttrib2Biz():
csv_col.data[72] = "BU - 73 - aff"
csv_col.data[73] = 0
csv_col.data[107] = 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[109] = datetime.strptime(data.Patient["birthdate"], "%Y-%m-%d").strftime("%d.%m.%Y") if data.Patient["birthdate"] is not None else "date naissance inconnue"
if data.Patient["insurance_policy_number"] is not None and '-' not in data.Patient["insurance_policy_number"]:
@@ -499,8 +647,8 @@ class ClercAttrib2Biz():
if data.Patient["country_name"] != "Suisse":
csv_col.data[113] += ", " + data.Patient["country_name"]
csv_col.data[115] = data.Patient["fip_number"]
csv_col.data[115] += " - " + data.data["comments"] if data.data["comments"] is not None else ""
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[116] = self.ifNotNull(data.Patient["category"]) + " - " + self.ifNotNull(data.Intervention["type"])
csv_col.data[135] = data.Intervention["base_name"]
csv_col.data[136] = 2 if data.Intervention["base_name"] == "Uvrier" else 3