|
@@ -18,6 +18,7 @@ def get_flat(node):
|
|
{
|
|
{
|
|
"id": node["id"],
|
|
"id": node["id"],
|
|
"text": node["text"],
|
|
"text": node["text"],
|
|
|
|
+ "amount_text": node["amount_text"],
|
|
"children": [x["id"] for x in node["children"]],
|
|
"children": [x["id"] for x in node["children"]],
|
|
"children2": [],
|
|
"children2": [],
|
|
"parents": node["parents"],
|
|
"parents": node["parents"],
|
|
@@ -209,7 +210,7 @@ class GCStruct:
|
|
"Case",
|
|
"Case",
|
|
"Info",
|
|
"Info",
|
|
],
|
|
],
|
|
- }[filetype]
|
|
|
|
|
|
+ }.get(filetype, [])
|
|
|
|
|
|
def accounts_from_csv(self, struct):
|
|
def accounts_from_csv(self, struct):
|
|
max_rows = (len(self.config["default"]) + 1) * 10
|
|
max_rows = (len(self.config["default"]) + 1) * 10
|
|
@@ -292,19 +293,55 @@ class GCStruct:
|
|
|
|
|
|
def export(self):
|
|
def export(self):
|
|
for s in self.config["export"].keys():
|
|
for s in self.config["export"].keys():
|
|
|
|
+ if len(self.config["export"][s]["files"]) == 0:
|
|
|
|
+ continue
|
|
|
|
+ struct_info = {e["id"]: e for e in self.json_result["flat"][s]}
|
|
for filetype, filename in self.config["export"][s]["files"].items():
|
|
for filetype, filename in self.config["export"][s]["files"].items():
|
|
- with open(self.config["path2"] + "/" + filename, "w") as fwh:
|
|
|
|
- fwh.write("Konto_Nr_Hersteller;Konto_Nr_Split;Konto_Nr_Haendler;Info\n")
|
|
|
|
- # 'Hersteller'Konto_Nr;Konto_Bezeichnung;Case;Info'
|
|
|
|
|
|
+ with open(self.config["path2"] + "/" + filename, "w", encoding="latin-1", errors="ignore") as fwh:
|
|
|
|
+ fwh.write(";".join(self.export_header(filetype)) + "\n")
|
|
|
|
+ unique_accounts = []
|
|
for a in self.json_result["accounts"]:
|
|
for a in self.json_result["accounts"]:
|
|
- if a["Herstellerkonto_Nr"] != "":
|
|
|
|
- account = chevron.render(
|
|
|
|
- self.config["export"]["SKR51"]["format"]["HerstellerkontoFormat"],
|
|
|
|
- a,
|
|
|
|
- )
|
|
|
|
- fwh.write(
|
|
|
|
- account + ";" + account + ";" + a["Konto_Nr"] + ";" + "\n"
|
|
|
|
- ) # a['Herstellerkonto_Bez']
|
|
|
|
|
|
+ if a["Herstellerkonto_Nr"] == "":
|
|
|
|
+ continue
|
|
|
|
+
|
|
|
|
+ account = chevron.render(
|
|
|
|
+ self.config["export"]["SKR51"]["format"]["HerstellerkontoFormat"],
|
|
|
|
+ a,
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ amount_text = struct_info.get(a[s], {}).get("amount_text", "")
|
|
|
|
+ if amount_text == "" or " - " not in amount_text:
|
|
|
|
+ amount_text += " - "
|
|
|
|
+ account_amount_nr, account_amount_text = amount_text.split(" - ")
|
|
|
|
+ a2 = a.copy()
|
|
|
|
+ a2["Herstellerkonto_Nr"] = account_amount_nr
|
|
|
|
+ a2["Herstellerkonto_Bez"] = account_amount_text
|
|
|
|
+ account2 = chevron.render(
|
|
|
|
+ self.config["export"]["SKR51"]["format"]["HerstellerkontoFormat"],
|
|
|
|
+ a2,
|
|
|
|
+ )
|
|
|
|
+ if filetype == "ExportUebersetzungStk" and a["Konto_STK"] != "1":
|
|
|
|
+ continue
|
|
|
|
+
|
|
|
|
+ if filetype == "ExportHerstellerKontenrahmen":
|
|
|
|
+ if account not in unique_accounts:
|
|
|
|
+ unique_accounts.append(account)
|
|
|
|
+ account_text = chevron.render(
|
|
|
|
+ self.config["export"]["SKR51"]["format"]["HerstellerBezeichnungFormat"],
|
|
|
|
+ a,
|
|
|
|
+ )
|
|
|
|
+ fwh.write(account + ";" + account_text + ";2;" + a["Herstellerkonto_Bez"] + "\n")
|
|
|
|
+ if account_amount_nr != "" and account2 not in unique_accounts:
|
|
|
|
+ unique_accounts.append(account2)
|
|
|
|
+ account_text = chevron.render(
|
|
|
|
+ self.config["export"]["SKR51"]["format"]["HerstellerBezeichnungFormat"],
|
|
|
|
+ a2,
|
|
|
|
+ )
|
|
|
|
+ fwh.write(account2 + ";" + account_text + ";2;" + a["Herstellerkonto_Bez"] + "\n")
|
|
|
|
+ elif filetype == "ExportUebersetzungStk":
|
|
|
|
+ fwh.write(account2 + ";" + account2 + ";" + a["Konto_Nr"] + ";" + "\n")
|
|
|
|
+ else:
|
|
|
|
+ fwh.write(account + ";" + account + ";" + a["Konto_Nr"] + ";" + "\n")
|
|
|
|
|
|
def get_tree(self, node, parents, structure):
|
|
def get_tree(self, node, parents, structure):
|
|
result = []
|
|
result = []
|
|
@@ -321,6 +358,7 @@ class GCStruct:
|
|
"accounts": self.get_accounts(structure, id),
|
|
"accounts": self.get_accounts(structure, id),
|
|
"level": len(parents),
|
|
"level": len(parents),
|
|
"form": child.attrib.get("Split", ""),
|
|
"form": child.attrib.get("Split", ""),
|
|
|
|
+ "amount_text": child.attrib.get("NameStk", ""),
|
|
}
|
|
}
|
|
)
|
|
)
|
|
parents.pop()
|
|
parents.pop()
|
|
@@ -336,6 +374,7 @@ class GCStruct:
|
|
"accounts": [],
|
|
"accounts": [],
|
|
"level": 0,
|
|
"level": 0,
|
|
"form": "",
|
|
"form": "",
|
|
|
|
+ "amount_text": "",
|
|
}
|
|
}
|
|
|
|
|
|
def post_structure_and_tree(self):
|
|
def post_structure_and_tree(self):
|
|
@@ -805,13 +844,6 @@ class GCStruct:
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
-def dresen():
|
|
|
|
- struct = GCStruct("c:/projekte/GCHRStruct_Hyundai_Export")
|
|
|
|
- struct.get_structure_and_tree()
|
|
|
|
- struct.export_structure_and_tree()
|
|
|
|
- struct.export()
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def reisacher():
|
|
def reisacher():
|
|
base_dir = "X:/Robert/Planung Reisacher/GCStruct_neue_Struktur_Planung"
|
|
base_dir = "X:/Robert/Planung Reisacher/GCStruct_neue_Struktur_Planung"
|
|
if not Path(base_dir).exists():
|
|
if not Path(base_dir).exists():
|