Added CurrencyTypeExtensions
This commit is contained in:
@@ -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 = "",
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
|
||||
namespace SPTarkov.Server.Core.Extensions
|
||||
{
|
||||
public static class CurrencyTypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets currency TPL from TAG
|
||||
/// </summary>
|
||||
/// <param name="currency"></param>
|
||||
/// <returns>Tpl of currency</returns>
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,21 +38,4 @@ public class PaymentHelper(ConfigServer configServer)
|
||||
|
||||
return _moneyTpls.Contains(tpl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets currency TPL from TAG
|
||||
/// </summary>
|
||||
/// <param name="currency"></param>
|
||||
/// <returns>Tpl of currency</returns>
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user