fix(accounting): tax report degrades gracefully if cost side fails (+ surface the error)

The cost side is supplementary — it must never 500 the core revenue report.
getTaxReport now wraps loadCosts in try/catch: on failure it returns empty
costs + a costsError string and logs the real error. The tax page shows the
revenue report plus a non-fatal amber banner with the cost-side error message,
so the actual cause is visible in the UI instead of an opaque 500.
This commit is contained in:
Luca
2026-06-12 17:43:42 +02:00
parent ea8f6bc88a
commit 9f8511114a
3 changed files with 31 additions and 4 deletions
@@ -358,6 +358,19 @@ export const TaxReportPage: React.FC = () => {
)}
</div>
{/* Non-fatal: the revenue report loaded but the cost side errored. */}
{report?.costsError && (
<Card padding="md">
<div className="flex items-start gap-3 text-amber-700 dark:text-amber-400">
<AlertCircle className="w-5 h-5 flex-shrink-0 mt-0.5" />
<div>
<p className="font-medium">{t('taxReport.costsErrorTitle', 'Costs could not be loaded')}</p>
<p className="text-sm text-neutral-600 dark:text-neutral-400 mt-1 break-words">{report.costsError}</p>
</div>
</div>
</Card>
)}
{/* Results */}
{isLoading ? (
<Card padding="lg"><Loading /></Card>
@@ -97,6 +97,8 @@ export interface TaxReport {
/** Cost side (#4). Present when the accounting tables exist; empty
* otherwise. */
costs: TaxReportCosts;
/** Non-fatal: set when the cost side failed to load (revenue still shown). */
costsError?: string | null;
/** Income/cost/result summary (#4). */
summary: TaxReportSummary;
currency: string;