Fix: invoice Price was not being rounded if no taxIncluded present

This commit is contained in:
nicolas.dorier
2019-02-21 21:58:49 +09:00
parent 2e1d623755
commit 2c7cc9a796
2 changed files with 10 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<Version>1.0.3.57</Version> <Version>1.0.3.58</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn> <NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -102,18 +102,17 @@ namespace BTCPayServer.Controllers
entity.RefundMail = entity.BuyerInformation.BuyerEmail; 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); invoice.Price = Math.Round(invoice.Price, currencyInfo.CurrencyDecimalDigits);
if (currencyInfo != null) invoice.TaxIncluded = Math.Round(taxIncluded, currencyInfo.CurrencyDecimalDigits);
{
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.Max(0.0m, invoice.Price);
invoice.TaxIncluded = Math.Max(0.0m, taxIncluded);
invoice.TaxIncluded = Math.Min(taxIncluded, invoice.Price);
entity.ProductInformation = Map<CreateInvoiceRequest, ProductInformation>(invoice); entity.ProductInformation = Map<CreateInvoiceRequest, ProductInformation>(invoice);