From 9148a1e564c8e245dd85b338562e1de2cf6140ea Mon Sep 17 00:00:00 2001 From: Kukks Date: Fri, 10 Feb 2023 09:10:10 +0100 Subject: [PATCH] fix #4570 --- .../HostedServices/StoreEmailRuleProcessorSender.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/HostedServices/StoreEmailRuleProcessorSender.cs b/BTCPayServer/HostedServices/StoreEmailRuleProcessorSender.cs index 9a83957f8..d4021bf6a 100644 --- a/BTCPayServer/HostedServices/StoreEmailRuleProcessorSender.cs +++ b/BTCPayServer/HostedServices/StoreEmailRuleProcessorSender.cs @@ -10,6 +10,7 @@ using BTCPayServer.Events; using BTCPayServer.Services; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Mails; +using BTCPayServer.Services.Rates; using BTCPayServer.Services.Stores; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; @@ -22,18 +23,19 @@ public class StoreEmailRuleProcessorSender : EventHostedServiceBase private readonly StoreRepository _storeRepository; private readonly EmailSenderFactory _emailSenderFactory; private readonly LinkGenerator _linkGenerator; - private readonly BTCPayServerEnvironment _environment; + private readonly CurrencyNameTable _currencyNameTable; public StoreEmailRuleProcessorSender(StoreRepository storeRepository, EventAggregator eventAggregator, ILogger logger, EmailSenderFactory emailSenderFactory, - LinkGenerator linkGenerator, BTCPayServerEnvironment environment) : base( + LinkGenerator linkGenerator, + CurrencyNameTable currencyNameTable) : base( eventAggregator, logger) { _storeRepository = storeRepository; _emailSenderFactory = emailSenderFactory; _linkGenerator = linkGenerator; - _environment = environment; + _currencyNameTable = currencyNameTable; } protected override void SubscribeToEvents() @@ -90,7 +92,9 @@ public class StoreEmailRuleProcessorSender : EventHostedServiceBase //TODO: we should switch to https://dotnetfiddle.net/MoqJFk later return str.Replace("{Invoice.Id}", i.Id) .Replace("{Invoice.StoreId}", i.StoreId) - .Replace("{Invoice.Price}", i.Amount.ToString(CultureInfo.InvariantCulture)) + .Replace("{Invoice.Price}", + decimal.Round(i.Amount, _currencyNameTable.GetCurrencyData(i.Currency, true).Divisibility, + MidpointRounding.ToEven).ToString(CultureInfo.InvariantCulture)) .Replace("{Invoice.Currency}", i.Currency) .Replace("{Invoice.Status}", i.Status.ToString()) .Replace("{Invoice.AdditionalStatus}", i.AdditionalStatus.ToString())