Compare commits

..

No commits in common. "09d8838886e60bdee3d68fac90879acd898d893f" and "f3aa4d781b3c8a34ce3460237b81e04e59bb6e51" have entirely different histories.

2 changed files with 12 additions and 30 deletions

View File

@ -11,8 +11,8 @@ app.config['SESSION_TYPE'] = 'filesystem'
app.config['SESSION_FILE_DIR'] = './.flask_session/'
Session(app)
STRIPE_STARTING_COLS = ['Type', 'ID', 'Created', 'Description', 'Amount', 'Currency', 'Converted Amount']
RAISENOW_STARTING_COLS = ['Identifikationsnummer', 'Erstellt', 'UTC-Offset', 'Status', 'Betrag', 'Währung']
STRIPE_STARTING_COLS = ['Type', 'ID', 'Created', 'Description', 'Amount', 'Currency', 'Converted Amount', 'Fees', 'Net', 'Converted Currency', 'Details']
RAISENOW_STARTING_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):
@ -36,7 +36,7 @@ def get_merged_df(table_name): # return table_name: str
- no pandas merge suffixes at all
- all original columns (including Raisenow's norm_zweck) preserved
"""
print('calculate DataFrame...')
print('calculated DataFrame')
# --- load & normalize Stripe ---
stripe_import = get_dataframe('stripe_import')
@ -125,11 +125,10 @@ def get_merged_df(table_name): # return table_name: str
)
# additional assignment: build a mask of rows where norm_zweck is still empty/NaN
mask = raisenow['norm_zweck'].isna() | (raisenow['norm_zweck'] == '')
if mask.any() and 'raisenow_parameters.product.source_url' in raisenow.columns:
raisenow.loc[mask, 'norm_zweck'] = (
raisenow.loc[mask, 'raisenow_parameters.product.source_url']
.str.extract(r'https?://[^/]+/([^/?#]+)')[0]
)
raisenow.loc[mask, 'norm_zweck'] = (
raisenow.loc[mask, 'raisenow_parameters.product.source_url']
.str.extract(r'https?://[^/]+/([^/?#]+)')[0]
)
# --- return raw tables if requested ---
if table_name == 'stripe_import':
@ -344,10 +343,10 @@ def upload():
raw = (
pd.read_csv(f) if f.filename.lower().endswith('.csv') else pd.read_excel(f)
)
raw = raw.dropna(how='all')
raw = raw.dropna(how='all').dropna(axis=1, how='all')
print('number of rows:', len(raw))
raw = raw.astype(object).replace({np.nan: None})
cols = list(raw.columns)
if cols[:len(STRIPE_STARTING_COLS)] == STRIPE_STARTING_COLS:
key = 'stripe_import'
dedupe_col = 'ID'
@ -355,12 +354,8 @@ def upload():
key = 'raisenow_import'
dedupe_col = 'Identifikationsnummer'
else:
print('file does not match expected formats:', f.filename)
return jsonify({
"status": "error",
"message": f"File '{f.filename}' does not match expected formats."
}), 400
continue
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)

View File

@ -176,21 +176,8 @@
columns: cols,
};
// add sum_amount to the footer using column calculations
// If you want to sum the "amount" column, add a bottomCalc to the column definition
cols.forEach(col => {
if (col.field === 'amount') {
col.bottomCalc = 'sum';
col.bottomCalcFormatter = cell => cell.getValue().toFixed(2);
}
});
// Recreate table with updated columns
if (table) table.destroy();
table = new Tabulator('#table', {
...opts,
columns: cols,
});
table = new Tabulator('#table', opts);
} catch (err) {
console.error(err); alert('Failed to load table data');
} finally { hideLoading(); }