fix: 분석화면 총지출 금액 불일치 및 다국어 지원 개선
- 월별지출현황과 총지출요약 카드의 7월 금액 불일치 수정 - 현재 월은 currentPrice 사용, 과거 월은 이벤트 기간 체크 - 월별 차트 라벨 다국어 지원 추가 (한/영/일/중) - 홈/분석 화면 총지출 금액 통일을 위한 통화 변환 로직 모듈화 - ExchangeRateService에 convertBetweenCurrencies 메서드 추가 - CurrencyUtil 및 SubscriptionProvider 리팩토링 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -117,22 +117,13 @@ class CurrencyUtil {
|
||||
for (var subscription in subscriptions) {
|
||||
final price = subscription.currentPrice;
|
||||
|
||||
if (subscription.currency == defaultCurrency) {
|
||||
// 기본 통화면 그대로 합산
|
||||
total += price;
|
||||
} else if (subscription.currency == 'USD') {
|
||||
// USD면 기본 통화로 변환
|
||||
final converted = await _exchangeRateService.convertUsdToTarget(price, defaultCurrency);
|
||||
if (converted != null) {
|
||||
total += converted;
|
||||
}
|
||||
} else if (defaultCurrency == 'USD') {
|
||||
// 기본 통화가 USD인 경우 다른 통화를 USD로 변환
|
||||
final converted = await _exchangeRateService.convertTargetToUsd(price, subscription.currency);
|
||||
if (converted != null) {
|
||||
total += converted;
|
||||
}
|
||||
}
|
||||
final converted = await _exchangeRateService.convertBetweenCurrencies(
|
||||
price,
|
||||
subscription.currency,
|
||||
defaultCurrency,
|
||||
);
|
||||
|
||||
total += converted ?? price;
|
||||
}
|
||||
|
||||
return total;
|
||||
@@ -188,20 +179,13 @@ class CurrencyUtil {
|
||||
if (subscription.isCurrentlyInEvent) {
|
||||
final savings = subscription.eventSavings;
|
||||
|
||||
if (subscription.currency == defaultCurrency) {
|
||||
total += savings;
|
||||
} else if (subscription.currency == 'USD') {
|
||||
final converted = await _exchangeRateService.convertUsdToTarget(savings, defaultCurrency);
|
||||
if (converted != null) {
|
||||
total += converted;
|
||||
}
|
||||
} else if (defaultCurrency == 'USD') {
|
||||
// 기본 통화가 USD인 경우 다른 통화를 USD로 변환
|
||||
final converted = await _exchangeRateService.convertTargetToUsd(savings, subscription.currency);
|
||||
if (converted != null) {
|
||||
total += converted;
|
||||
}
|
||||
}
|
||||
final converted = await _exchangeRateService.convertBetweenCurrencies(
|
||||
savings,
|
||||
subscription.currency,
|
||||
defaultCurrency,
|
||||
);
|
||||
|
||||
total += converted ?? savings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,34 @@ class ExchangeRateService {
|
||||
}
|
||||
}
|
||||
|
||||
/// 두 통화 간 변환을 수행합니다. (USD를 거쳐서 변환)
|
||||
Future<double?> convertBetweenCurrencies(
|
||||
double amount,
|
||||
String fromCurrency,
|
||||
String toCurrency
|
||||
) async {
|
||||
if (fromCurrency == toCurrency) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
// fromCurrency → USD → toCurrency
|
||||
double? usdAmount;
|
||||
|
||||
if (fromCurrency == 'USD') {
|
||||
usdAmount = amount;
|
||||
} else {
|
||||
usdAmount = await convertTargetToUsd(amount, fromCurrency);
|
||||
}
|
||||
|
||||
if (usdAmount == null) return null;
|
||||
|
||||
if (toCurrency == 'USD') {
|
||||
return usdAmount;
|
||||
} else {
|
||||
return await convertUsdToTarget(usdAmount, toCurrency);
|
||||
}
|
||||
}
|
||||
|
||||
/// 현재 환율 정보를 포맷팅하여 텍스트로 반환합니다.
|
||||
Future<String> getFormattedExchangeRateInfo() async {
|
||||
final rate = await getUsdToKrwRate();
|
||||
|
||||
Reference in New Issue
Block a user