Fix dashboard outstanding amount showing wrong currency label#405
Open
Cryptoteep wants to merge 4 commits into
Open
Fix dashboard outstanding amount showing wrong currency label#405Cryptoteep wants to merge 4 commits into
Cryptoteep wants to merge 4 commits into
Conversation
The dashboard's Outstanding and Overdue KPI cards always formatted totals using the tax system's currency (EUR for Germany), regardless of the currency an invoice was actually issued in. An unpaid USD invoice was therefore shown with a EUR label, silently mixing currencies whenever invoices used more than one. compute_kpis now tracks outstanding/overdue totals per invoice currency (KPISummary.outstanding_by_currency / overdue_by_currency). to_rpc_dict formats using the invoice's real currency when only one is present, and shows each amount separately (joined) when multiple currencies are outstanding, instead of summing them under one wrong label. Fixes tuttle-dev#400
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #400.
The dashboard's Outstanding and Overdue KPI cards always formatted their totals using the tax system's currency (e.g. EUR for a freelancer operating in Germany), regardless of the currency each invoice was actually issued in. As reported in the issue, an unpaid invoice issued in USD was displayed on the dashboard labeled as EUR — and outstanding amounts in different currencies were being summed together under a single, potentially wrong, currency symbol.
Fix
compute_kpis(intuttle/kpi.py) now tracks unpaid/overdue totals per invoice currency (KPISummary.outstanding_by_currency/overdue_by_currency), using the same currency resolution already used elsewhere for invoices (invoice.contract.currency, falling back to"EUR").KPISummary.to_rpc_dict()now formatsoutstanding_amount_formatted/overdue_amount_formattedusing the invoice's real currency when only one currency is present. When invoices use multiple currencies, each currency's amount is formatted and shown separately instead of being summed under one (possibly incorrect) label.Test plan
TestComputeKPIs.test_outstanding_currency_matches_invoice_currency,test_outstanding_amounts_in_different_currencies_not_mixed, andtest_overdue_currency_matches_invoice_currencyintuttle_tests/test_dashboard.py, covering: a USD-only invoice labeled$, mixed EUR+USD invoices not silently summed, and overdue amounts following the same logic.TestFormatAmountByCurrencyunit tests for the new_format_amount_by_currencyhelper.uv run pytest tuttle_tests/) except one pre-existing, unrelated failure (test_rendering.py::TestRenderTimesheet::test_creates_only_final_file), confirmed to fail identically onmainbefore this change.