Skip to content

EasyInvoice - Fix Dashboard stat cards to display totals separately per currency #106

@coderabbitai

Description

@coderabbitai

Problem

The Dashboard stat cards currently sum amounts across different currencies without conversion, producing meaningless totals. For example, adding $100 USD + €50 EUR directly results in an incorrect total of "150".

This issue was identified during the review of PR #98 where the new Subscription components correctly implement multi-currency aggregation by showing separate totals for each currency.

Affected Components

Based on code analysis, the following Dashboard components have this currency aggregation issue:

  • Dashboard Subscriptions (src/components/dashboard/subscriptions.tsx)
  • Dashboard Invoices Received (src/components/dashboard/invoices-received.tsx)
  • Dashboard Invoices Sent (src/components/dashboard/invoices-sent.tsx)

Solution

Update the Dashboard stat cards to follow the same pattern implemented in the Subscription components in PR #98:

  1. Replace single-currency StatCard with MultiCurrencyStatCard for revenue/amount totals
  2. Implement proper currency aggregation using BigNumber for precision:
    const totalRevenue = payments.reduce((acc, payment) => {
      const currency = payment.currency;
      const amount = BigNumber.from(payment.amount);
      
      if (acc[currency]) {
        acc[currency] = acc[currency].add(amount);
      } else {
        acc[currency] = amount;
      }
      return acc;
    }, {} as Record<string, BigNumber>);
  3. Display separate totals per currency instead of one incorrect sum

Context

Acceptance Criteria

  • Dashboard stat cards show separate totals for each currency
  • No more mixing of different currencies in single totals
  • Consistent implementation across all Dashboard components
  • Use MultiCurrencyStatCard component like in Subscription components

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions