diff --git a/app/app.py b/app/app.py index 4a532f2..2e2f710 100644 --- a/app/app.py +++ b/app/app.py @@ -14,15 +14,15 @@ STRIPE_COLS = ['Type', 'ID', 'Created', 'Description', 'Amount', 'Currency', 'Co RAISENOW_COLS = ['Identifikationsnummer', 'Erstellt', 'UTC-Offset', 'Status', 'Betrag', 'Währung', 'Übernommene Gebühren - Betrag', 'Übernommene Gebühren - Währung', 'Zahlungsmethode', 'Zahlungsanbieter', 'Nettobetrag', 'Auszahlungswährung'] -def get_dataframe(key, cols): +def get_dataframe(key): """ - Load a DataFrame from session or create an empty one with the given columns. + Load a DataFrame from session. """ records = session.get(key, []) if records: df = pd.DataFrame(records) else: - df = pd.DataFrame(columns=cols) + df = pd.DataFrame() return df @@ -37,11 +37,16 @@ def get_merged_df(table_name): """ # --- load & normalize Stripe --- - stripe = ( - get_dataframe('stripe_import', STRIPE_COLS) - .query("Type == 'Charge'") - .copy() - ) + stripe = get_dataframe('stripe_import') + if not stripe.empty: + stripe = ( + stripe + .query("Type == 'Charge'") + .copy() + ) + else: + return stripe + stripe['idx_stripe'] = stripe.index stripe['norm_date'] = pd.to_datetime(stripe['Created'], format='%Y-%m-%d %H:%M') stripe['norm_amount'] = stripe['Amount'].astype(str).str.replace(',', '.').astype(float) @@ -51,12 +56,16 @@ def get_merged_df(table_name): ) # --- load & normalize Raisenow --- - raisenow = ( - get_dataframe('raiseNow_import', RAISENOW_COLS) - .query("Zahlungsmethode != 'paypal'") - .query("Status == 'succeeded'") - .copy() - ) + raisenow = get_dataframe('raiseNow_import') + if not raisenow.empty: + raisenow = ( + raisenow + .query("Zahlungsmethode != 'paypal'") + .query("Status == 'succeeded'") + .copy() + ) + else: + return raisenow raisenow['idx_raisenow'] = raisenow.index raisenow['norm_date'] = pd.to_datetime(raisenow['Erstellt'], format='%Y-%m-%d %H:%M') @@ -180,7 +189,7 @@ def upload(): else: continue - existing = get_dataframe(key, []) + existing = get_dataframe(key) combined = pd.concat([existing, raw], ignore_index=True) deduped = combined.drop_duplicates(subset=[dedupe_col], keep='first').reset_index(drop=True) diff --git a/app/templates/index.html b/app/templates/index.html index ef1cc69..91dcb8a 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -3,32 +3,46 @@ - Multi‐Table Excel Import + CDH Merger -
-

Excel Importer

+
+

CDH Merger

-
-
- - + +
+ + + - -
- -
-
- -
-
- @@ -38,70 +52,81 @@
-
+ +
+ +
+
+
Loading...
+

Loading, please wait...

+
+
+