POS: Account for custom amount in cart view (#5151)

* Add failing test

* Account for custom amount

* Test fix
This commit is contained in:
d11n
2023-07-05 10:23:15 +02:00
committed by GitHub
parent f6b27cc5f9
commit e998340387
4 changed files with 91 additions and 28 deletions

View File

@@ -133,6 +133,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
[ModelBinder(typeof(InvariantDecimalModelBinder))] decimal? amount = null,
[ModelBinder(typeof(InvariantDecimalModelBinder))] decimal? tip = null,
[ModelBinder(typeof(InvariantDecimalModelBinder))] decimal? discount = null,
[ModelBinder(typeof(InvariantDecimalModelBinder))] decimal? customAmount = null,
string email = null,
string orderId = null,
string notificationUrl = null,
@@ -232,9 +233,11 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
price += expectedCartItemPrice * cartItem.Value;
}
if (discount is decimal d)
if (customAmount is { } c)
price += c;
if (discount is { } d)
price -= price * d/100.0m;
if (tip is decimal t)
if (tip is { } t)
price += t;
}
}