Skip to content

Commit bee4c49

Browse files
authored
fix: parse fee value with html tags (#105)
1 parent 1277864 commit bee4c49

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

app/schemas/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from datetime import datetime
23
from typing import Optional
34

@@ -56,7 +57,16 @@ def parse_str_to_date(cls, v: str):
5657
def parse_str_to_int(cls, v: str) -> Optional[int]:
5758
if not v or not any(char.isdigit() for char in v):
5859
return None
59-
value_str = v.lower().replace("€", "").replace("+", "").replace("'", "").strip()
60+
61+
# Clean up HTML tags if present
62+
if "<" in str(v):
63+
matches = re.findall(r"€([\d,.]+[kmb]?)", v.lower())
64+
if not matches:
65+
return None
66+
value_str = matches[0]
67+
else:
68+
value_str = v.lower().replace("€", "").replace("+", "").replace("'", "").strip()
69+
6070
if "k" in value_str:
6171
return int(float(value_str.replace("k", "")) * 1_000)
6272
elif "m" in value_str:

0 commit comments

Comments
 (0)