feat: add multi-currency support to cospend payments

- Add ExchangeRate model for currency conversion tracking
- Implement currency utility functions for formatting and conversion
- Add exchange rates API endpoint with caching and fallback rates
- Update Payment and RecurringPayment models to support multiple currencies
- Enhanced payment forms with currency selection and conversion display
- Update split method selector with better currency handling
- Add currency-aware payment display and balance calculations
- Support for EUR, USD, GBP, and CHF with automatic exchange rate fetching

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-14 19:54:31 +02:00
parent ac84de43e1
commit 90ea22497f
13 changed files with 936 additions and 59 deletions

View File

@@ -4,16 +4,16 @@ export interface IRecurringPayment {
_id?: string;
title: string;
description?: string;
amount: number;
currency: string;
amount: number; // Amount in the original currency
currency: string; // Original currency code
paidBy: string; // username/nickname of the person who paid
category: 'groceries' | 'shopping' | 'travel' | 'restaurant' | 'utilities' | 'fun' | 'settlement';
splitMethod: 'equal' | 'full' | 'proportional' | 'personal_equal';
splits: Array<{
username: string;
amount?: number;
amount?: number; // Amount in original currency
proportion?: number;
personalAmount?: number;
personalAmount?: number; // Amount in original currency
}>;
frequency: 'daily' | 'weekly' | 'monthly' | 'custom';
cronExpression?: string; // For custom frequencies using cron syntax
@@ -47,7 +47,7 @@ const RecurringPaymentSchema = new mongoose.Schema(
type: String,
required: true,
default: 'CHF',
enum: ['CHF']
uppercase: true
},
paidBy: {
type: String,