|
|
|
@@ -285,7 +285,7 @@ class ClercAttrib2Biz():
|
|
|
|
self.count_facture = 0
|
|
|
|
self.count_facture = 0
|
|
|
|
x = 0
|
|
|
|
x = 0
|
|
|
|
|
|
|
|
|
|
|
|
self.export_filename = f"bizexdoc_export_Attrib_v{datetime.now().year}{datetime.now().month}{datetime.now().month}{datetime.now().hour}{datetime.now().minute}.csv"
|
|
|
|
self.export_filename = f"bizexdoc_export_Attrib_v{datetime.now().year}{datetime.now().month}{datetime.now().day}{datetime.now().hour}{datetime.now().minute}.csv"
|
|
|
|
|
|
|
|
|
|
|
|
if self.export_format_biz:
|
|
|
|
if self.export_format_biz:
|
|
|
|
if self.export_one_file.get() and os.path.exists(os.path.join(dest_dir, self.export_filename)):
|
|
|
|
if self.export_one_file.get() and os.path.exists(os.path.join(dest_dir, self.export_filename)):
|
|
|
|
@@ -306,7 +306,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
|
|
|
|
|
|
|
print(f"remove src.csv => {os.path.join(dest_dir, 'src.csv')}")
|
|
|
|
print(f"remove src.csv => {os.path.join(dest_dir, 'src.csv')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.progress_bar["value"] = 0
|
|
|
|
for filename in os.listdir(dir):
|
|
|
|
for filename in os.listdir(dir):
|
|
|
|
x += 1
|
|
|
|
x += 1
|
|
|
|
if ".json" in filename:
|
|
|
|
if ".json" in filename:
|
|
|
|
@@ -315,11 +315,17 @@ class ClercAttrib2Biz():
|
|
|
|
data = json.load(f)
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
if self.export_format_biz.get():
|
|
|
|
if self.export_format_biz.get():
|
|
|
|
self.parseFile(data, filename)
|
|
|
|
bRet = self.parseFile(data, filename)
|
|
|
|
|
|
|
|
if bRet:
|
|
|
|
|
|
|
|
messagebox.showinfo(title="Fin de conversion",
|
|
|
|
|
|
|
|
message="La conversion s'est terminée avec succès")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.convertFile(data, filename)
|
|
|
|
self.convertFile(data, filename)
|
|
|
|
if self.delete_after_parse.get():
|
|
|
|
if self.delete_after_parse.get():
|
|
|
|
os.remove(dir + "/" + filename)
|
|
|
|
os.remove(dir + "/" + filename)
|
|
|
|
|
|
|
|
|
|
|
|
self.progress_bar["value"] = x / len(os.listdir(dir)) * 100
|
|
|
|
self.progress_bar["value"] = x / len(os.listdir(dir)) * 100
|
|
|
|
self.fenetre.update_idletasks()
|
|
|
|
self.fenetre.update_idletasks()
|
|
|
|
self.nb_facture_var.set(self.count_facture)
|
|
|
|
self.nb_facture_var.set(self.count_facture)
|
|
|
|
@@ -345,6 +351,8 @@ class ClercAttrib2Biz():
|
|
|
|
data.Debtor["firstname"] = data.Debtor["firstname"].strip()
|
|
|
|
data.Debtor["firstname"] = data.Debtor["firstname"].strip()
|
|
|
|
if data.Debtor["street"] is not None:
|
|
|
|
if data.Debtor["street"] is not None:
|
|
|
|
data.Debtor["street"] = data.Debtor["street"].strip()
|
|
|
|
data.Debtor["street"] = data.Debtor["street"].strip()
|
|
|
|
|
|
|
|
if data.data["comments"] is not None:
|
|
|
|
|
|
|
|
data.data["comments"] = data.data["comments"].strip().replace("\n",'')
|
|
|
|
|
|
|
|
|
|
|
|
def check_code_validity(self, code,data):
|
|
|
|
def check_code_validity(self, code,data):
|
|
|
|
ret = True
|
|
|
|
ret = True
|
|
|
|
@@ -382,6 +390,7 @@ class ClercAttrib2Biz():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parseFile(self, data, filename):
|
|
|
|
def parseFile(self, data, filename):
|
|
|
|
|
|
|
|
self.progress_bar["value"] = 0
|
|
|
|
self.index_counter += 1
|
|
|
|
self.index_counter += 1
|
|
|
|
lines = []
|
|
|
|
lines = []
|
|
|
|
self.count_facture += len(data["invoices"])
|
|
|
|
self.count_facture += len(data["invoices"])
|
|
|
|
@@ -393,25 +402,34 @@ class ClercAttrib2Biz():
|
|
|
|
csv_col.data[5] = f""
|
|
|
|
csv_col.data[5] = f""
|
|
|
|
lines.append(csv_col.data)
|
|
|
|
lines.append(csv_col.data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur_invoice_index = 0
|
|
|
|
|
|
|
|
|
|
|
|
x = 70
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ele in data["invoices"]:
|
|
|
|
for ele in data["invoices"]:
|
|
|
|
|
|
|
|
cur_invoice_index += 1
|
|
|
|
|
|
|
|
self.progress_bar["value"] = cur_invoice_index / self.count_facture * 100
|
|
|
|
b_address_update = True
|
|
|
|
b_address_update = True
|
|
|
|
data = cls_Invoice()
|
|
|
|
data = cls_Invoice()
|
|
|
|
data.parse_item(ele)
|
|
|
|
data.parse_item(ele)
|
|
|
|
|
|
|
|
|
|
|
|
self.trim_all_data(data)
|
|
|
|
self.trim_all_data(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}")
|
|
|
|
print(f"Code débiteur => {data.data['id']}: {data.Debtor['code']}")
|
|
|
|
if data.Debtor["code"] is None or '.' in data.Debtor["code"]:
|
|
|
|
if data.Debtor["code"] is None or '.' in data.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 {data.data['id']} est faux: [{data.Debtor['code']}], merci de le corriger ")
|
|
|
|
inp_popup = Input_popup(self.fenetre, default=data.Debtor["code"], factureID=data.data['id'], fip=data.Patient['fip_number'])
|
|
|
|
inp_popup = Input_popup(self.fenetre, default=data.Debtor["code"], factureID=data.data['id'], fip=data.Patient['fip_number'])
|
|
|
|
data.Debtor["code"] = str(inp_popup.show())
|
|
|
|
data.Debtor["code"] = str(inp_popup.show())
|
|
|
|
|
|
|
|
if data.Debtor["code"] is None or '.' in data.Debtor["code"]:
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
if int(data.Debtor["code"]) == 1:
|
|
|
|
if int(data.Debtor["code"]) == 1:
|
|
|
|
if not self.check_code_validity(data.Debtor["code"],data):
|
|
|
|
if not self.check_code_validity(data.Debtor["code"],data):
|
|
|
|
|
|
|
|
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 False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -450,6 +468,15 @@ class ClercAttrib2Biz():
|
|
|
|
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(data.Debtor['code']),data.data['id'],data.Patient['fip_number'], object=self.o_debs)
|
|
|
|
data.Debtor["code"] = debitor_popup.show()
|
|
|
|
data.Debtor["code"] = debitor_popup.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data.Debtor["code"] is None or '.' in data.Debtor["code"]:
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data.Patient["complement"] != None:
|
|
|
|
if data.Patient["complement"] != None:
|
|
|
|
@@ -709,6 +736,9 @@ class ClercAttrib2Biz():
|
|
|
|
wr.writerow(cdr)
|
|
|
|
wr.writerow(cdr)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.save_file(lines,fileName=self.export_filename)
|
|
|
|
self.save_file(lines,fileName=self.export_filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def addToIndexs(self,obj,data,cat, key):
|
|
|
|
def addToIndexs(self,obj,data,cat, key):
|
|
|
|
#self.a_index[cat].append({"key":key,"index":len(obj.data)})
|
|
|
|
#self.a_index[cat].append({"key":key,"index":len(obj.data)})
|
|
|
|
if key not in self.a_index[cat]:
|
|
|
|
if key not in self.a_index[cat]:
|
|
|
|
|