Upload main.py
Browse files
main.py
CHANGED
@@ -183,7 +183,13 @@ def format_currency(value: Any) -> Optional[str]:
|
|
183 |
num_str = str(value).replace('$', '').replace(',', '').strip()
|
184 |
if not num_str or num_str.lower() == 'n/a': return 'N/A'
|
185 |
num = float(num_str)
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
except (ValueError, TypeError):
|
188 |
# Allow text like "Event", "Unobtainable" etc. to pass through
|
189 |
if isinstance(value, str) and value.strip() and not re.match(r'^-?[\d,.$]+\$?$', value.strip()):
|
|
|
183 |
num_str = str(value).replace('$', '').replace(',', '').strip()
|
184 |
if not num_str or num_str.lower() == 'n/a': return 'N/A'
|
185 |
num = float(num_str)
|
186 |
+
# Check if the number has decimal places
|
187 |
+
if num == int(num):
|
188 |
+
# For whole numbers, display without decimal places
|
189 |
+
return f"${num:,.0f}"
|
190 |
+
else:
|
191 |
+
# For numbers with decimal places, preserve them
|
192 |
+
return f"${num:,}"
|
193 |
except (ValueError, TypeError):
|
194 |
# Allow text like "Event", "Unobtainable" etc. to pass through
|
195 |
if isinstance(value, str) and value.strip() and not re.match(r'^-?[\d,.$]+\$?$', value.strip()):
|