Improve receipt info display (#5350)

* Improve receipt info display

Displays the info in correct order and adds optional info if tip was given with a percentage.

* Test fix

---------

Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
d11n 2023-09-26 15:50:04 +02:00 committed by GitHub
parent 72a99bf9a6
commit 25af9c4227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 6 deletions

View File

@ -1892,6 +1892,7 @@ namespace BTCPayServer.Tests
});
s.GoToHome();
//offline/external payout test
var newStore = s.CreateNewStore();
s.GenerateWallet("BTC", "", true, true);
s.GoToStore(s.StoreId, StoreNavPages.PullPayments);

View File

@ -382,7 +382,8 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
}
if (appPosData.Tip > 0)
{
receiptData.Add("Tip", _displayFormatter.Currency(appPosData.Tip, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol));
var tipFormatted = _displayFormatter.Currency(appPosData.Tip, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol);
receiptData.Add("Tip", appPosData.TipPercentage > 0 ? $"{appPosData.TipPercentage}% = {tipFormatted}" : tipFormatted);
}
receiptData.Add("Total", _displayFormatter.Currency(appPosData.Total, settings.Currency, DisplayFormatter.CurrencyFormat.Symbol));
}

View File

@ -20,6 +20,9 @@ public class PosAppData
[JsonProperty(PropertyName = "discountAmount")]
public decimal DiscountAmount { get; set; }
[JsonProperty(PropertyName = "tipPercentage")]
public decimal TipPercentage { get; set; }
[JsonProperty(PropertyName = "tip")]
public decimal Tip { get; set; }

View File

@ -10,19 +10,23 @@
@if (Model.Items.Any())
{
var hasCart = Model.Items.ContainsKey("Cart");
<table class="table my-0" v-pre>
@if (Model.Items.ContainsKey("Cart"))
@if (hasCart || (Model.Items.ContainsKey("Subtotal") && Model.Items.ContainsKey("Total")))
{
<tbody>
@foreach (var (key, value) in (Dictionary <string, object>)Model.Items["Cart"])
@if (hasCart)
{
<tbody>
@foreach (var (key, value) in (Dictionary<string, object>)Model.Items["Cart"])
{
<tr>
<th>@key</th>
<td class="text-end">@value</td>
</tr>
}
</tbody>
<tfoot style="border-top-width:3px">
</tbody>
}
<tfoot style="border-top-width:@(hasCart ? "3px" : "0")">
@if (Model.Items.ContainsKey("Subtotal"))
{
<tr>

View File

@ -58,6 +58,7 @@ const posCommon = {
total: this.totalNumeric
}
if (this.tipNumeric > 0) data.tip = this.tipNumeric
if (this.tipPercent > 0) data.tipPercentage = this.tipPercent
if (this.discountNumeric > 0) data.discountAmount = this.discountNumeric
if (this.discountPercentNumeric > 0) data.discountPercentage = this.discountPercentNumeric
return JSON.stringify(data)