diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index fa9e1ba7a..4853ea32c 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1988,6 +1988,7 @@ donation: var invoice = user.BitPay.CreateInvoice(new Invoice() { Price = 5000.0m, + TaxIncluded = 1000.0m, Currency = "USD", PosData = "posData", OrderId = "orderId", @@ -2017,6 +2018,8 @@ donation: }); invoice = user.BitPay.GetInvoice(invoice.Id, Facade.Merchant); + Assert.Equal(1000.0m, invoice.TaxIncluded); + Assert.Equal(5000.0m, invoice.Price); Assert.Equal(Money.Coins(0), invoice.BtcPaid); Assert.Equal("new", invoice.Status); Assert.False((bool)((JValue)invoice.ExceptionStatus).Value); diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 2fff73736..739ffaff9 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -33,7 +33,7 @@ - + @@ -45,8 +45,8 @@ all runtime; build; native; contentfiles; analyzers - - + + diff --git a/BTCPayServer/Controllers/InvoiceController.cs b/BTCPayServer/Controllers/InvoiceController.cs index eea614f23..6f06573c0 100644 --- a/BTCPayServer/Controllers/InvoiceController.cs +++ b/BTCPayServer/Controllers/InvoiceController.cs @@ -99,8 +99,12 @@ namespace BTCPayServer.Controllers if (currencyInfo != null) { invoice.Price = Math.Round(invoice.Price, currencyInfo.CurrencyDecimalDigits); + invoice.TaxIncluded = Math.Round(invoice.TaxIncluded, currencyInfo.CurrencyDecimalDigits); } invoice.Price = Math.Max(0.0m, invoice.Price); + invoice.TaxIncluded = Math.Max(0.0m, invoice.TaxIncluded); + invoice.TaxIncluded = Math.Min(invoice.TaxIncluded, invoice.Price); + entity.ProductInformation = Map(invoice); diff --git a/BTCPayServer/Models/InvoiceResponse.cs b/BTCPayServer/Models/InvoiceResponse.cs index 486a3b906..d0c5c5dfe 100644 --- a/BTCPayServer/Models/InvoiceResponse.cs +++ b/BTCPayServer/Models/InvoiceResponse.cs @@ -90,6 +90,12 @@ namespace BTCPayServer.Models get; set; } + [JsonProperty("taxIncluded", DefaultValueHandling = DefaultValueHandling.Ignore)] + public decimal TaxIncluded + { + get; set; + } + //"currency":"USD" [JsonProperty("currency")] public string Currency diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 0bc8fa914..cb54640f1 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -91,6 +91,12 @@ namespace BTCPayServer.Services.Invoices get; set; } + [JsonProperty(PropertyName = "taxIncluded", DefaultValueHandling = DefaultValueHandling.Ignore)] + public decimal TaxIncluded + { + get; set; + } + [JsonProperty(PropertyName = "currency")] public string Currency { diff --git a/BTCPayServer/Views/Invoice/Invoice.cshtml b/BTCPayServer/Views/Invoice/Invoice.cshtml index 848216821..03fed5d38 100644 --- a/BTCPayServer/Views/Invoice/Invoice.cshtml +++ b/BTCPayServer/Views/Invoice/Invoice.cshtml @@ -157,6 +157,10 @@ Price @Model.ProductInformation.Price @Model.ProductInformation.Currency + + Tax included + @Model.ProductInformation.TaxIncluded @Model.ProductInformation.Currency + } @@ -180,6 +184,10 @@ Price @Model.ProductInformation.Price @Model.ProductInformation.Currency + + Tax included + @Model.ProductInformation.TaxIncluded @Model.ProductInformation.Currency +