gcstruct_uebersetzung.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from pathlib import Path
  2. from gcstruct.gcstruct import GCStruct
  3. def get_base_and_import_dir(base_dir):
  4. if base_dir is None:
  5. base_dir = Path(".").absolute()
  6. else:
  7. base_dir = Path(base_dir)
  8. import_dir = base_dir
  9. if base_dir.name == "scripts":
  10. if base_dir.parent.parent.name == "Portal":
  11. base_dir = base_dir.parent.parent.parent
  12. import_dir = base_dir.joinpath("Portal/System/IQD/Belege/Kontenrahmen")
  13. else:
  14. base_dir = base_dir.parent.parent
  15. import_dir = base_dir.joinpath("System/OPTIMA/Export")
  16. elif not base_dir.joinpath("GCStruct_Aufbereitung").exists():
  17. base_dir = Path("//192.168.2.21/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/")
  18. if not base_dir.exists():
  19. base_dir = Path("//media/fileserver1/verwaltung/Kunden/Luchtenberg/1 Umstellung SKR51/")
  20. import_dir = base_dir
  21. return base_dir, import_dir
  22. def gcstruct_uebersetzung(base_dir=None):
  23. base_dir, import_dir = get_base_and_import_dir(base_dir)
  24. struct = GCStruct(str(base_dir.joinpath("GCStruct_Aufbereitung")))
  25. input_files = [f for f in import_dir.glob("Kontenrahmen_kombiniert*.csv")]
  26. print("Quelldateien:")
  27. for file in input_files:
  28. print("* " + file.name)
  29. struct.skr51_translate(input_files)
  30. print("Kontenrahmen_uebersetzt.csv erstellt.")
  31. # copyfile('c:/Projekte/Python/Gcstruct/Kontenrahmen_kombiniert.csv', base_dir + 'GCStruct_Modell/Export/Kontenrahmen_kombiniert.csv')
  32. struct2 = GCStruct(str(base_dir.joinpath("GCStruct_Modell")))
  33. struct2.skr51_translate2(str(base_dir.joinpath("GCStruct_Aufbereitung/Export/Kontenrahmen_uebersetzt.csv")))
  34. print("SKR51_Uebersetzung.csv erstellt.")
  35. struct2.skr51_vars()
  36. print("SKR51_Struktur.csv erstellt.")
  37. if __name__ == "__main__":
  38. gcstruct_uebersetzung()