saq1b commited on
Commit
2badb17
·
verified ·
1 Parent(s): a24a89d

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -1
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
- return f"${num:,.0f}"
 
 
 
 
 
 
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()):