Browse Source

Übersetzung mit Variante ohne Standort, um die Datensätze zu reduzieren

gc-server3 5 months ago
parent
commit
8b81697c3c
3 changed files with 31 additions and 9 deletions
  1. BIN
      gcstruct/dist/gcstruct_uebersetzung.exe
  2. 26 7
      gcstruct/gcstruct.py
  3. 5 2
      gcstruct/gcstruct_uebersetzung.py

BIN
gcstruct/dist/gcstruct_uebersetzung.exe


+ 26 - 7
gcstruct/gcstruct.py

@@ -1,15 +1,16 @@
-import pandas as pd
-import numpy as np
-import xml.etree.ElementTree as ET
-import json
 import csv
+import json
 import re
+import xml.etree.ElementTree as ET
+from functools import reduce
+from pathlib import Path
+
 import chevron
+import numpy as np
+import pandas as pd
 
 # from shutil import copyfile
 from bs4 import BeautifulSoup
-from functools import reduce
-from pathlib import Path
 
 
 def get_flat(node):
@@ -622,7 +623,11 @@ class GCStruct:
             df_source["Konto_Nr_Händler_mit_KST"] + " - " + df_source["Konto_Bezeichnung_Händler"]
         )
 
-        df_amount = df_source[df_source["Ebene1"] == "Umsatzerlöse"].reset_index()
+        kto_amount = df_source["Ebene63"] == "mit STK"
+        if kto_amount.sum() > 0:
+            df_amount = df_source[kto_amount].reset_index()
+        else:
+            df_amount = df_source[df_source["Ebene1"] == "Umsatzerlöse"].reset_index()
         df_amount["Ebene1"] = "verkaufte Stückzahlen"
         df_amount["Ebene72"] = "verkaufte Stückzahlen"
         df_amount["Konto_neu"] = "STK " + df_amount["Konto_neu"]
@@ -721,6 +726,20 @@ class GCStruct:
             encoding="latin-1",
             index=False,
         )
+        is_quantity = df_source["Konto"].str.startswith("STK")
+        df_source["Konto"] = np.where(
+            is_quantity,
+            df_source["Konto"].str.slice_replace(7, 9, "00"),
+            df_source["Konto"].str.slice_replace(3, 5, "00"),
+        )
+        df_source["Acct_Nr"] = df_source["Acct_Nr"].str.slice_replace(3, 5, "00")
+        df_department = df_source.drop_duplicates()
+        df_department.to_csv(
+            f"{self.config['path2']}/SKR51_Uebersetzung_ohne_Standort.csv",
+            sep=";",
+            encoding="latin-1",
+            index=False,
+        )
 
     def skr51_vars(self):
         self.get_structure_and_tree()

+ 5 - 2
gcstruct/gcstruct_uebersetzung.py

@@ -1,6 +1,9 @@
-from gcstruct import GCStruct
+import sys
 from pathlib import Path
 
+sys.path.insert(0, "C:\\Projekte\\Python\\gcstruct")
+from gcstruct import GCStruct  # noqa:E402
+
 
 def gcstruct_uebersetzung(base_dir=None):
     if base_dir is None:
@@ -16,7 +19,7 @@ def gcstruct_uebersetzung(base_dir=None):
             base_dir = base_dir.parent.parent
             import_dir = base_dir.joinpath("System/OPTIMA/Export")
     elif not base_dir.joinpath("GCStruct_Aufbereitung").exists():
-        base_dir = Path("//192.168.4.21/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/")
+        base_dir = Path("//192.168.2.21/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/")
         if not base_dir.exists():
             base_dir = Path("//media/fileserver1/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/")
         import_dir = base_dir