Skip to content

Bug Report: Incorrect Currency Calculation in Subscription Total #1

@AbhiramVSA

Description

@AbhiramVSA

Bug: Changing Currency while creating a new subscription leads to it applying the same arithmetic regardless of exchange rates

Bug Description

When creating a new subscription with a different currency, the application performs simple arithmetic addition without considering exchange rates, leading to incorrect total calculations.

Steps to Reproduce

  1. Create a subscription with USD 10.00
  2. Create another subscription with INR 10.99
  3. View the total subscriptions value
  4. Expected: Total should be calculated using proper exchange rates
  5. Actual: Total shows 20.99 (simple addition without currency conversion)

Current Behavior

  • Application adds subscription amounts directly: 10.00 + 10.99 = 20.99
  • No currency conversion applied
  • Totals are mathematically incorrect when multiple currencies are involved

Expected Behavior

  • Convert all currencies to a base currency (e.g., USD) before calculation
  • Apply real-time or cached exchange rates
  • Display accurate total in the selected base currency
  • Example: USD 10.00 + INR 10.99 (≈ $0.13) = $10.13

Impact

  • High Priority: Financial calculations are incorrect
  • Affects user trust and decision-making
  • Could lead to budget miscalculations
  • Multi-currency users receive wrong financial insights

Suggested Solution

  1. Add currency conversion service (e.g., ExchangeRate-API, Fixer.io)
  2. Implement base currency selection in user preferences
  3. Convert all amounts to base currency before calculations
  4. Cache exchange rates to minimize API calls
  5. Display original + converted amounts for transparency

Technical Implementation

// Proposed structure
const convertToBaseCurrency = async (amount, fromCurrency, toCurrency) => {
  const rate = await getExchangeRate(fromCurrency, toCurrency);
  return amount * rate;
};

// Usage in subscription calculations
const totalInBaseCurrency = subscriptions.reduce((total, sub) => {
  const convertedAmount = convertToBaseCurrency(sub.amount, sub.currency, userBaseCurrency);
  return total + convertedAmount;
}, 0);

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions