adridoesthings zrewidował ten Gist . Przejdź do rewizji
1 file changed, 13 insertions, 4 deletions
bc100_fgr.py
@@ -25,10 +25,19 @@ df = df[ | |||
25 | 25 | ] | |
26 | 26 | ||
27 | 27 | current_amount = df["Betrag"].sum() | |
28 | - | max_amount = round(((BC_END_DATE - TODAY).days / 365) * PRICE * 0.25, 2) | |
28 | + | bc_use_percentage= ((BC_END_DATE - TODAY).days / 365) | |
29 | + | max_amount = bc_use_percentage * PRICE * 0.25 | |
29 | 30 | ||
30 | - | print("{:.2f} € von {:.2f} € ({}%)".format( | |
31 | - | df["Betrag"].sum(), | |
31 | + | effective_price = PRICE - (current_amount * (1 / bc_use_percentage)) | |
32 | + | ||
33 | + | print("Fahrgastrechte: {:.2f}€ von {:.2f}€ ({:.0f}%)".format( | |
34 | + | current_amount, | |
32 | 35 | max_amount, | |
33 | - | round((current_amount / max_amount) * 100) | |
36 | + | (current_amount / max_amount) * 100 | |
34 | 37 | )) | |
38 | + | ||
39 | + | print("Effektiver Preis der BC100 wird statt {:.2f}€ {:.2f}€ sein ({:.0f}% Rabatt)".format( | |
40 | + | PRICE, | |
41 | + | effective_price, | |
42 | + | (1 - (effective_price / PRICE)) * 100 | |
43 | + | )) |
adridoesthings zrewidował ten Gist . Przejdź do rewizji
1 file changed, 34 insertions
bc100_fgr.py(stworzono plik)
@@ -0,0 +1,34 @@ | |||
1 | + | import pandas as pd | |
2 | + | ||
3 | + | from datetime import datetime, date, timedelta | |
4 | + | ||
5 | + | BC_START_DATE = date(2025, 3, 6) | |
6 | + | PRICE = 2988.00 | |
7 | + | FILENAME = "Transaktionen.csv" | |
8 | + | ||
9 | + | TODAY = date.today() | |
10 | + | BC_END_DATE = BC_START_DATE + timedelta(days=365) | |
11 | + | ||
12 | + | df = pd.read_csv( | |
13 | + | FILENAME, | |
14 | + | converters={ | |
15 | + | "Betrag": lambda x: float(x.replace(",", ".")), | |
16 | + | "Buchungsdatum": lambda x: datetime.strptime(x, "%d.%m.%Y").date() | |
17 | + | } | |
18 | + | ) | |
19 | + | ||
20 | + | df = df[ | |
21 | + | (df["Zahlungsempfänger"] == "Deutsche Bahn") & | |
22 | + | (df["Verwendungszweck"].str.contains("Fahrgastrechtsfall", case=False)) & | |
23 | + | (df["Betrag"] == 10) & | |
24 | + | (df["Buchungsdatum"] >= BC_START_DATE) | |
25 | + | ] | |
26 | + | ||
27 | + | current_amount = df["Betrag"].sum() | |
28 | + | max_amount = round(((BC_END_DATE - TODAY).days / 365) * PRICE * 0.25, 2) | |
29 | + | ||
30 | + | print("{:.2f} € von {:.2f} € ({}%)".format( | |
31 | + | df["Betrag"].sum(), | |
32 | + | max_amount, | |
33 | + | round((current_amount / max_amount) * 100) | |
34 | + | )) |