diff --git a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs index a58b73e6..11f4f921 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs @@ -1,4 +1,5 @@ using SPTarkov.DI.Annotations; +using SPTarkov.Server.Core.Extensions; using SPTarkov.Server.Core.Generators; using SPTarkov.Server.Core.Helpers; using SPTarkov.Server.Core.Models.Common; @@ -1309,11 +1310,7 @@ public class RagfairController Action = "TradingConfirm", SchemeItems = [ - new IdWithCount - { - Id = _paymentHelper.GetCurrency(currency), - Count = Math.Round(value), - }, + new IdWithCount { Id = currency.GetCurrencyTpl(), Count = Math.Round(value) }, ], Type = "", ItemId = "", diff --git a/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs b/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs new file mode 100644 index 00000000..a1fa64ea --- /dev/null +++ b/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs @@ -0,0 +1,24 @@ +using SPTarkov.Server.Core.Models.Enums; + +namespace SPTarkov.Server.Core.Extensions +{ + public static class CurrencyTypeExtensions + { + /// + /// Gets currency TPL from TAG + /// + /// + /// Tpl of currency + public static string GetCurrencyTpl(this CurrencyType currency) + { + return currency switch + { + CurrencyType.EUR => Money.EUROS, + CurrencyType.USD => Money.DOLLARS, + CurrencyType.RUB => Money.ROUBLES, + CurrencyType.GP => Money.GP, + _ => string.Empty, + }; + } + } +} diff --git a/Libraries/SPTarkov.Server.Core/Helpers/PaymentHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/PaymentHelper.cs index b6c8d695..100d24b8 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/PaymentHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/PaymentHelper.cs @@ -38,21 +38,4 @@ public class PaymentHelper(ConfigServer configServer) return _moneyTpls.Contains(tpl); } - - /// - /// Gets currency TPL from TAG - /// - /// - /// Tpl of currency - public string GetCurrency(CurrencyType? currency) - { - return currency switch - { - CurrencyType.EUR => Money.EUROS, - CurrencyType.USD => Money.DOLLARS, - CurrencyType.RUB => Money.ROUBLES, - CurrencyType.GP => Money.GP, - _ => string.Empty, - }; - } } diff --git a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs index 7f2533f9..a0a1732c 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs @@ -1,4 +1,5 @@ using SPTarkov.DI.Annotations; +using SPTarkov.Server.Core.Extensions; using SPTarkov.Server.Core.Helpers; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; @@ -122,7 +123,7 @@ public class PaymentService( // Convert the amount to the trader's currency and update the sales sum. var costOfPurchaseInCurrency = _handbookHelper.FromRUB( _handbookHelper.InRUB(currencyAmount ?? 0, currencyTpl), - _paymentHelper.GetCurrency(trader.Currency) + trader.Currency.Value.GetCurrencyTpl() ); // Only update traders @@ -138,7 +139,7 @@ public class PaymentService( // Convert the handbook price to the trader's currency and update the sales sum. var costOfPurchaseInCurrency = _handbookHelper.FromRUB( GetTraderItemHandbookPriceRouble(request.ItemId, request.TransactionId) ?? 0, - _paymentHelper.GetCurrency(trader.Currency) + trader.Currency.Value.GetCurrencyTpl() ); pmcData.TradersInfo[request.TransactionId].SalesSum += costOfPurchaseInCurrency; @@ -211,7 +212,7 @@ public class PaymentService( return; } - var currencyTpl = _paymentHelper.GetCurrency(trader.Currency); + var currencyTpl = trader.Currency.Value.GetCurrencyTpl(); var calcAmount = _handbookHelper.FromRUB( _handbookHelper.InRUB(amountToSend ?? 0, currencyTpl), currencyTpl