Financial Balance Sheet Identity Checker
When extracting key values from balance sheets, numbers are often parsed as strings with mixed formats (e.g., $1,200,000, 500M, 12.5K, or empty/missing values).
Implement a function verify_balance_sheet(assets_str, liabilities_str, equity_str) that:
- Normalizes and parses the text inputs into numeric floats. Support suffixes:
M/m(Millions),K/k(Thousands),B/b(Billions). - Handles missing/empty/None values by treating them as
0.0. - Verifies if the fundamental accounting identity holds true: $\text{Assets} = \text{Liabilities} + \text{Equity}$
- Return a tuple of
(is_balanced: bool, discrepancy: float). Round the discrepancy to 2 decimal places.
Example
verify_balance_sheet("$1.2M", "800K", "400,000")
# Returns: (True, 0.0)