diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 091a3a695..f467dc1af 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.1 - 1.0.3.57 + 1.0.3.58 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs index cd1dd5309..a13b4c1d9 100644 --- a/BTCPayServer/Controllers/InvoiceController.cs +++ b/BTCPayServer/Controllers/InvoiceController.cs @@ -102,18 +102,17 @@ namespace BTCPayServer.Controllers entity.RefundMail = entity.BuyerInformation.BuyerEmail; } - if (invoice.TaxIncluded is decimal taxIncluded) + var taxIncluded = invoice.TaxIncluded.HasValue ? invoice.TaxIncluded.Value : 0m; + + var currencyInfo = _CurrencyNameTable.GetNumberFormatInfo(invoice.Currency, false); + if (currencyInfo != null) { - var currencyInfo = _CurrencyNameTable.GetNumberFormatInfo(invoice.Currency, false); - if (currencyInfo != null) - { - invoice.Price = Math.Round(invoice.Price, currencyInfo.CurrencyDecimalDigits); - invoice.TaxIncluded = Math.Round(taxIncluded, currencyInfo.CurrencyDecimalDigits); - } - invoice.Price = Math.Max(0.0m, invoice.Price); - invoice.TaxIncluded = Math.Max(0.0m, taxIncluded); - invoice.TaxIncluded = Math.Min(taxIncluded, invoice.Price); + invoice.Price = Math.Round(invoice.Price, currencyInfo.CurrencyDecimalDigits); + invoice.TaxIncluded = Math.Round(taxIncluded, currencyInfo.CurrencyDecimalDigits); } + invoice.Price = Math.Max(0.0m, invoice.Price); + invoice.TaxIncluded = Math.Max(0.0m, taxIncluded); + invoice.TaxIncluded = Math.Min(taxIncluded, invoice.Price); entity.ProductInformation = Map(invoice);