"""Readable foreign-currency remeasurement and translation bridge.""" from math import isclose def money(amount: float) -> str: """Format dollars with commas and parentheses.""" number = f"{abs(amount):,.0f}" return "$(" + number + ")" if amount < 0 else "$" + number euro_receivable = 200_000.0 initial_amount = euro_receivable * 1.08 closing_amount = euro_receivable * 1.11 year_5_gain = closing_amount - initial_amount settlement_amount = euro_receivable * 1.10 next_period_gain_loss = settlement_amount - closing_amount translated_net_income = 780_000.0 - 700_000.0 ending_re = 190_000.0 + translated_net_income - 20_000.0 cta = 1_420_000.0 - 610_000.0 - 500_000.0 - ending_re print("Moraine — transaction remeasurement") for label, value in [ ("Initial receivable at $1.08/EUR", initial_amount), ("Closing receivable at $1.11/EUR", closing_amount), ("Year 5 transaction gain", year_5_gain), ("Next-period settlement gain/(loss)", next_period_gain_loss), ("Translated net income", translated_net_income), ("Ending retained earnings", ending_re), ("Translation adjustment (CTA)", cta), ]: print(f"{label:<38} {money(value):>14}") controls_pass = isclose(year_5_gain, 6_000, abs_tol=0.01) and isclose( cta, 60_000, abs_tol=0.01 ) print("\nControls:", "PASS" if controls_pass else "FAIL") print("Boundary: functional currency and rates are supplied, not selected here.")