mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Can filter with "exceptionstatus:", show the exception status on invoice list page
This commit is contained in:
parent
3f4ec9ba80
commit
366490516e
4 changed files with 46 additions and 6 deletions
|
@ -371,13 +371,15 @@ namespace BTCPayServer.Controllers
|
|||
Skip = skip,
|
||||
UserId = GetUserId(),
|
||||
Status = filterString.Filters.ContainsKey("status") ? filterString.Filters["status"].ToArray() : null,
|
||||
ExceptionStatus = filterString.Filters.ContainsKey("exceptionstatus") ? filterString.Filters["exceptionstatus"].ToArray() : null,
|
||||
StoreId = filterString.Filters.ContainsKey("storeid") ? filterString.Filters["storeid"].ToArray() : null
|
||||
}))
|
||||
{
|
||||
model.SearchTerm = searchTerm;
|
||||
model.Invoices.Add(new InvoiceModel()
|
||||
{
|
||||
Status = invoice.Status,
|
||||
Status = invoice.Status + (invoice.ExceptionStatus == null ? string.Empty : $" ({invoice.ExceptionStatus})"),
|
||||
ShowCheckout = invoice.Status == "new",
|
||||
Date = (DateTimeOffset.UtcNow - invoice.InvoiceTime).Prettify() + " ago",
|
||||
InvoiceId = invoice.Id,
|
||||
OrderId = invoice.OrderId ?? string.Empty,
|
||||
|
|
|
@ -49,6 +49,8 @@ namespace BTCPayServer.Models.InvoicingModels
|
|||
{
|
||||
get; set;
|
||||
}
|
||||
public bool ShowCheckout { get; set; }
|
||||
public string ExceptionStatus { get; set; }
|
||||
public string AmountCurrency
|
||||
{
|
||||
get; set;
|
||||
|
|
|
@ -436,6 +436,12 @@ namespace BTCPayServer.Services.Invoices
|
|||
query = query.Where(i => statusSet.Contains(i.Status));
|
||||
}
|
||||
|
||||
if (queryObject.ExceptionStatus != null && queryObject.ExceptionStatus.Length > 0)
|
||||
{
|
||||
var exceptionStatusSet = queryObject.ExceptionStatus.Select(s => NormalizeExceptionStatus(s)).ToHashSet();
|
||||
query = query.Where(i => exceptionStatusSet.Contains(i.ExceptionStatus));
|
||||
}
|
||||
|
||||
query = query.OrderByDescending(q => q.Created);
|
||||
|
||||
if (queryObject.Skip != null)
|
||||
|
@ -451,6 +457,29 @@ namespace BTCPayServer.Services.Invoices
|
|||
|
||||
}
|
||||
|
||||
private string NormalizeExceptionStatus(string status)
|
||||
{
|
||||
status = status.ToLowerInvariant();
|
||||
switch (status)
|
||||
{
|
||||
case "paidover":
|
||||
case "over":
|
||||
case "overpaid":
|
||||
status = "paidOver";
|
||||
break;
|
||||
case "paidlate":
|
||||
case "late":
|
||||
status = "paidLate";
|
||||
break;
|
||||
case "paidpartial":
|
||||
case "underpaid":
|
||||
case "partial":
|
||||
status = "paidPartial";
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public async Task AddRefundsAsync(string invoiceId, TxOut[] outputs, Network network)
|
||||
{
|
||||
if (outputs.Length == 0)
|
||||
|
@ -618,6 +647,12 @@ namespace BTCPayServer.Services.Invoices
|
|||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string[] ExceptionStatus
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string InvoiceId
|
||||
{
|
||||
get;
|
||||
|
|
|
@ -20,14 +20,15 @@
|
|||
<div id="help" class="collapse text-left">
|
||||
<p>
|
||||
You can search for invoice Id, deposit address, price, order id, store id, any buyer information and any product information.<br />
|
||||
You can also apply filters to your search by searching for `filtername:value`, here is a list of supported filters
|
||||
You can also apply filters to your search by searching for <code>filtername:value</code>, here is a list of supported filters
|
||||
</p>
|
||||
<ul>
|
||||
<li><b>storeid:id</b> for filtering a specific store</li>
|
||||
<li><b>status:(expired|invalid|complete|confirmed|paid|new)</b> for filtering a specific status</li>
|
||||
<li><code>storeid:id</code> for filtering a specific store</li>
|
||||
<li><code>status:(expired|invalid|complete|confirmed|paid|new)</code> for filtering a specific status</li>
|
||||
<li><code>exceptionstatus:(paidover|paidlate|paidpartial)</code> for filtering a specific exception state</li>
|
||||
</ul>
|
||||
<p>
|
||||
If you want two confirmed and complete invoices, duplicate the filter: `status:confirmed status:complete`.
|
||||
If you want two confirmed and complete invoices, duplicate the filter: <code>status:confirmed status:complete</code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -95,7 +96,7 @@
|
|||
}
|
||||
<td style="text-align:right">@invoice.AmountCurrency</td>
|
||||
<td style="text-align:right">
|
||||
@if(invoice.Status == "new")
|
||||
@if(invoice.ShowCheckout)
|
||||
{
|
||||
<a asp-action="Checkout" asp-route-invoiceId="@invoice.InvoiceId">Checkout</a> <span>-</span>
|
||||
}<a asp-action="Invoice" asp-route-invoiceId="@invoice.InvoiceId">Details</a>
|
||||
|
|
Loading…
Add table
Reference in a new issue