mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
f59751853a
* Resolve Additional Information from posData * code formatting * Minor adjustments * Update ChromeDriver * Revert and improve PosData partial --------- Co-authored-by: Dennis Reimann <mail@dennisreimann.de> Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
80 lines
3.0 KiB
Plaintext
80 lines
3.0 KiB
Plaintext
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
@model (Dictionary<string, object> Items, int Level)
|
|
|
|
@if (Model.Items.Any())
|
|
{
|
|
@* Use titlecase and lowercase versions for backwards-compatibility *@
|
|
string[] cartKeys = ["cart", "subtotal", "discount", "tip", "total"];
|
|
<table class="table my-0" v-pre>
|
|
@if (Model.Items.Keys.Any(key => cartKeys.Contains(key.ToLowerInvariant())))
|
|
{
|
|
_ = Model.Items.TryGetValue("cart", out var cart) || Model.Items.TryGetValue("Cart", out cart);
|
|
var hasTotal = Model.Items.TryGetValue("total", out var total) || Model.Items.TryGetValue("Total", out total);
|
|
var hasSubtotal = Model.Items.TryGetValue("subtotal", out var subtotal) || Model.Items.TryGetValue("subTotal", out subtotal) || Model.Items.TryGetValue("Subtotal", out subtotal);
|
|
var hasDiscount = Model.Items.TryGetValue("discount", out var discount) || Model.Items.TryGetValue("Discount", out discount);
|
|
var hasTip = Model.Items.TryGetValue("tip", out var tip) || Model.Items.TryGetValue("Tip", out tip);
|
|
if (cart is Dictionary<string, object> { Keys.Count: > 0 } cartDict)
|
|
{
|
|
<tbody>
|
|
@foreach (var (key, value) in cartDict)
|
|
{
|
|
<tr>
|
|
<partial name="PosDataEntry" model="(key, value, Model.Level)"/>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
}
|
|
else if (cart is ICollection<object> { Count: > 0 } cartCollection)
|
|
{
|
|
<tbody>
|
|
@foreach (var value in cartCollection)
|
|
{
|
|
<tr>
|
|
<partial name="PosDataEntry" model="(string.Empty, value, Model.Level)"/>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
}
|
|
<tfoot style="border-top-width:0">
|
|
@if (hasSubtotal && (hasDiscount || hasTip))
|
|
{
|
|
<tr style="border-top-width:3px">
|
|
<th>Subtotal</th>
|
|
<td class="text-end">@subtotal</td>
|
|
</tr>
|
|
}
|
|
@if (hasDiscount)
|
|
{
|
|
<tr>
|
|
<th>Discount</th>
|
|
<td class="text-end">@discount</td>
|
|
</tr>
|
|
}
|
|
@if (hasTip)
|
|
{
|
|
<tr>
|
|
<th>Tip</th>
|
|
<td class="text-end">@tip</td>
|
|
</tr>
|
|
}
|
|
@if (hasTotal)
|
|
{
|
|
<tr style="border-top-width:3px">
|
|
<th>Total</th>
|
|
<td class="text-end">@total</td>
|
|
</tr>
|
|
}
|
|
</tfoot>
|
|
}
|
|
else
|
|
{
|
|
foreach (var (key, value) in Model.Items)
|
|
{
|
|
<tr>
|
|
<partial name="PosDataEntry" model="(key, value, Model.Level)"/>
|
|
</tr>
|
|
}
|
|
}
|
|
</table>
|
|
}
|