Last active 1753297680

adridoesthings's Avatar adridoesthings revised this gist 1753297680. Go to revision

1 file changed, 3 insertions, 2 deletions

bc100_fgr.py

@@ -4,10 +4,11 @@ import re
4 4 from datetime import datetime, date, timedelta
5 5
6 6 BC_START_DATE = date(2025, 3, 6)
7 + FGR_AVERAGE_PROCESSING_TIME = timedelta(days=5)
7 8 PRICE = 2988.00
8 9 FILENAME = "Transaktionen.csv"
9 10
10 - TODAY = date.today()
11 + TODAY = date.today() - FGR_AVERAGE_PROCESSING_TIME
11 12 BC_END_DATE = BC_START_DATE + timedelta(days=365)
12 13
13 14 def parse_journey_date(value):
@@ -34,7 +35,7 @@ df = df[
34 35 ]
35 36
36 37 current_amount = df["Betrag"].sum()
37 - bc_use_percentage= ((BC_END_DATE - TODAY).days / 365)
38 + bc_use_percentage= ((TODAY - BC_START_DATE).days / 365)
38 39 max_amount = bc_use_percentage * PRICE * 0.25
39 40
40 41 effective_price = PRICE - (current_amount * (1 / bc_use_percentage))

adridoesthings's Avatar adridoesthings revised this gist 1752354162. Go to revision

1 file changed, 10 insertions, 1 deletion

bc100_fgr.py

@@ -1,4 +1,5 @@
1 1 import pandas as pd
2 + import re
2 3
3 4 from datetime import datetime, date, timedelta
4 5
@@ -9,6 +10,11 @@ FILENAME = "Transaktionen.csv"
9 10 TODAY = date.today()
10 11 BC_END_DATE = BC_START_DATE + timedelta(days=365)
11 12
13 + def parse_journey_date(value):
14 + match = re.search(r"Bahnreise am (\d{1,2}\.\d{1,2}\.\d{4})", str(value))
15 + if match:
16 + return datetime.strptime(match.groups()[0], "%d.%m.%Y").date()
17 +
12 18 df = pd.read_csv(
13 19 FILENAME,
14 20 converters={
@@ -17,11 +23,14 @@ df = pd.read_csv(
17 23 }
18 24 )
19 25
26 + df["Reisedatum"] = df["Verwendungszweck"].map(parse_journey_date)
27 +
20 28 df = df[
21 29 (df["Zahlungsempfänger"] == "Deutsche Bahn") &
22 30 (df["Verwendungszweck"].str.contains("Fahrgastrechtsfall", case=False)) &
23 31 (df["Betrag"] == 10) &
24 - (df["Buchungsdatum"] >= BC_START_DATE)
32 + (df["Buchungsdatum"] > BC_START_DATE) &
33 + (df["Reisedatum"] >= BC_START_DATE)
25 34 ]
26 35
27 36 current_amount = df["Betrag"].sum()

adridoesthings's Avatar adridoesthings revised this gist 1751989945. Go to revision

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's Avatar adridoesthings revised this gist 1751989030. Go to revision

1 file changed, 34 insertions

bc100_fgr.py(file created)

@@ -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 + ))
Newer Older