feat: Improve currency conversion logic in BillingManager to handle multiple currencies and enhance accuracy in RUB calculations
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 6m11s

This commit is contained in:
2025-08-08 14:29:22 +07:00
parent 1f1ee7161c
commit 68e9d5be7d
+12 -2
View File
@@ -292,8 +292,18 @@ function BillingManager() {
function convertToRUB(amount, currency) {
if (!amount) return 0;
const rate = exchangeRates[currency] || 1;
return amount * rate * exchangeRates.RUB;
// Курсы получены с базой USD (1 USD = rates[CCY])
const rubPerUsd = Number(exchangeRates.RUB) || 1;
if (!currency || currency === 'RUB') return amount; // уже в рублях
if (currency === 'USD') return amount * rubPerUsd;
const ccyPerUsd = Number(exchangeRates[currency]);
if (!ccyPerUsd || ccyPerUsd === 0) {
// нет курса — возвращаем как есть
return amount;
}
// amount в валюте CCY -> USD -> RUB
const amountUsd = amount / ccyPerUsd;
return amountUsd * rubPerUsd;
}
function formatCurrencyInRUB(amount, currency) {