|
@@ -26,7 +26,7 @@ class GCHR:
|
|
|
|
|
|
self.account_translation = f"{self.base_dir}/data/Kontenrahmen_uebersetzt.csv"
|
|
|
self.account_bookings = list(Path(self.base_dir).joinpath("data").glob("GuV_Bilanz_Salden*.csv"))
|
|
|
- self.first_month_of_financial_year = "09"
|
|
|
+ self.first_month_of_financial_year = "01"
|
|
|
|
|
|
pd.set_option("display.max_rows", 500)
|
|
|
pd.set_option("display.float_format", lambda x: "%.2f" % x)
|
|
@@ -92,7 +92,7 @@ class GCHR:
|
|
|
df[acct_info] = df["Konto_Nr_SKR51"].str.split(pat="-", n=6, expand=True)
|
|
|
return df
|
|
|
|
|
|
- def export_all_periods(self):
|
|
|
+ def export_all_periods(self, overwrite=False):
|
|
|
dt = datetime.now()
|
|
|
prev = str(dt.year - 1)
|
|
|
periods = [(prev, str(x).zfill(2)) for x in range(dt.month, 13)] + [
|
|
@@ -100,7 +100,7 @@ class GCHR:
|
|
|
]
|
|
|
for year, month in periods:
|
|
|
filename = self.export_filename_for_period(year, month)
|
|
|
- if not Path(filename).exists():
|
|
|
+ if overwrite or not Path(filename).exists():
|
|
|
os.makedirs(Path(filename).parent.joinpath("info"), exist_ok=True)
|
|
|
self.export_period(year, month)
|
|
|
|
|
@@ -119,7 +119,7 @@ class GCHR:
|
|
|
# Kontensalden laden
|
|
|
df_bookings = self.load_bookings_from_file()
|
|
|
|
|
|
- if df_bookings.shape[0] == 0:
|
|
|
+ if df_bookings.shape[0] == 0 or len(set(df_bookings["Bookkeep Period"].to_list())) <= 1:
|
|
|
logging.error("ABBRUCH!!! Keine Daten vorhanden!")
|
|
|
return False
|
|
|
|
|
@@ -154,10 +154,11 @@ class GCHR:
|
|
|
index=["Konto_Nr_SKR51"],
|
|
|
columns=["period"],
|
|
|
values="amount",
|
|
|
- aggfunc=np.sum,
|
|
|
+ aggfunc="sum",
|
|
|
margins=True,
|
|
|
margins_name="CumulatedYear",
|
|
|
)
|
|
|
+ df_pivot.drop(index="CumulatedYear", inplace=True)
|
|
|
|
|
|
logging.info("df_pivot: " + str(df_pivot.shape))
|
|
|
|
|
@@ -482,7 +483,7 @@ def gchr_local(base_dir):
|
|
|
|
|
|
def gchr_export(base_dir):
|
|
|
gchr = GCHR(base_dir)
|
|
|
- gchr.export_all_periods()
|
|
|
+ gchr.export_all_periods(overwrite=True)
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|