|
@@ -2,6 +2,7 @@ import csv
|
|
|
import logging
|
|
|
import os
|
|
|
import xml.etree.ElementTree as ET
|
|
|
+from dataclasses import dataclass
|
|
|
from datetime import datetime
|
|
|
from pathlib import Path
|
|
|
from xml.dom import minidom
|
|
@@ -35,6 +36,11 @@ TRANSLATE = [
|
|
|
]
|
|
|
|
|
|
|
|
|
+@dataclass
|
|
|
+class GchrConfig:
|
|
|
+ first_month_of_financial_year: str
|
|
|
+
|
|
|
+
|
|
|
class GCHR:
|
|
|
booking_date: datetime
|
|
|
df_bookings: pd.DataFrame = None
|
|
@@ -192,7 +198,7 @@ class GCHR:
|
|
|
filename = self.export_filename
|
|
|
if i > 0:
|
|
|
filename = f"{filename[:-4]}_{main_site}.xml"
|
|
|
- self.export_xml(
|
|
|
+ self.export_skr51_xml(
|
|
|
df.to_dict(orient="records"),
|
|
|
self.bookkeep_filter,
|
|
|
period_no,
|
|
@@ -476,7 +482,7 @@ class GCHR:
|
|
|
def export_filename_for_period(self, year, month):
|
|
|
return f"{self.base_dir}/Export/{year}/export_{year}-{month}.xml"
|
|
|
|
|
|
- def export_xml(self, records, bk_filter, period_no, makes_used, sites_used, main_site, filename):
|
|
|
+ def export_skr51_xml(self, records, bk_filter, period_no, makes_used, sites_used, main_site, filename):
|
|
|
record_elements = ACCOUNT_INFO + ["Decimals"] + list(bk_filter.values())[:period_no] + ["CumulatedYear"]
|
|
|
root = ET.Element("HbvData")
|
|
|
h = ET.SubElement(root, "Header")
|
|
@@ -534,7 +540,7 @@ class GCHR:
|
|
|
self.sites = {"01-01": "1844"}
|
|
|
with open(csvfile, "r", encoding="latin-1") as frh:
|
|
|
csv_reader = csv.DictReader(frh, delimiter=";")
|
|
|
- self.export_xml(csv_reader, self.bookkeep_filter(), 1, list(self.sites.values())[0], xmlfile)
|
|
|
+ self.export_skr51_xml(csv_reader, self.bookkeep_filter(), 1, list(self.sites.values())[0], xmlfile)
|
|
|
|
|
|
|
|
|
def gchr_local():
|