mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Preventing entering of negative tips and discounts in POS
This commit is contained in:
parent
957fb09ffc
commit
8eabdab53a
@ -147,12 +147,17 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var app = await _appService.GetApp(appId, PointOfSaleAppType.AppType);
|
||||
if (string.IsNullOrEmpty(choiceKey) && amount <= 0)
|
||||
{
|
||||
|
||||
// not allowing negative tips or discounts
|
||||
if (tip < 0 || discount < 0)
|
||||
return RedirectToAction(nameof(ViewPointOfSale), new { appId });
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(choiceKey) && amount <= 0)
|
||||
return RedirectToAction(nameof(ViewPointOfSale), new { appId });
|
||||
|
||||
if (app == null)
|
||||
return NotFound();
|
||||
|
||||
var settings = app.GetSettings<PointOfSaleSettings>();
|
||||
settings.DefaultView = settings.EnableShoppingCart ? PosViewType.Cart : settings.DefaultView;
|
||||
var currentView = viewType ?? settings.DefaultView;
|
||||
|
@ -31,6 +31,9 @@ const posCommon = {
|
||||
if (this.tipPercent) {
|
||||
return parseFloat((this.amountMinusDiscountNumeric * (this.tipPercent / 100)).toFixed(this.currencyInfo.divisibility))
|
||||
} else {
|
||||
if (this.tip < 0) {
|
||||
this.tip = 0
|
||||
}
|
||||
const value = parseFloat(this.tip)
|
||||
return isNaN(value) ? 0.0 : parseFloat(value.toFixed(this.currencyInfo.divisibility))
|
||||
}
|
||||
@ -64,6 +67,7 @@ const posCommon = {
|
||||
discountPercent (val) {
|
||||
const value = parseFloat(val)
|
||||
if (isNaN(value)) this.discountPercent = null
|
||||
else if (value < 0) this.discountPercent = '0'
|
||||
else if (value > 100) this.discountPercent = '100'
|
||||
else this.discountPercent = value.toString()
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user