From 40c85d6104b12f35de331edf8f2a8119ee008879 Mon Sep 17 00:00:00 2001
From: Kukks
Date: Sun, 6 Jan 2019 10:00:55 +0100
Subject: [PATCH] Expand Invoice Searching
---
.../Controllers/InvoiceController.API.cs | 4 ++--
.../Services/Invoices/InvoiceRepository.cs | 19 ++++++++++++-------
.../Views/Invoice/ListInvoices.cshtml | 2 ++
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/BTCPayServer/Controllers/InvoiceController.API.cs b/BTCPayServer/Controllers/InvoiceController.API.cs
index 58c637a9d..b5b706fa5 100644
--- a/BTCPayServer/Controllers/InvoiceController.API.cs
+++ b/BTCPayServer/Controllers/InvoiceController.API.cs
@@ -73,8 +73,8 @@ namespace BTCPayServer.Controllers
Skip = offset,
EndDate = dateEnd,
StartDate = dateStart,
- OrderId = orderId,
- ItemCode = itemCode,
+ OrderId = orderId == null ? null : new[] { orderId },
+ ItemCode = itemCode == null ? null : new[] { itemCode },
Status = status == null ? null : new[] { status },
StoreId = new[] { this.HttpContext.GetStoreData().Id }
};
diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs
index 1ae4befc7..ba9f5bd19 100644
--- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs
+++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs
@@ -463,11 +463,16 @@ retry:
if (queryObject.EndDate != null)
query = query.Where(i => i.Created <= queryObject.EndDate.Value);
- if (queryObject.ItemCode != null)
- query = query.Where(i => i.ItemCode == queryObject.ItemCode);
-
- if (queryObject.OrderId != null)
- query = query.Where(i => i.OrderId == queryObject.OrderId);
+ if (queryObject.OrderId != null && queryObject.OrderId.Length > 0)
+ {
+ var statusSet = queryObject.OrderId.ToHashSet();
+ query = query.Where(i => statusSet.Contains(i.OrderId));
+ }
+ if (queryObject.ItemCode != null && queryObject.ItemCode.Length > 0)
+ {
+ var statusSet = queryObject.ItemCode.ToHashSet();
+ query = query.Where(i => statusSet.Contains(i.ItemCode));
+ }
if (queryObject.Status != null && queryObject.Status.Length > 0)
{
@@ -694,12 +699,12 @@ retry:
get; set;
}
- public string OrderId
+ public string[] OrderId
{
get; set;
}
- public string ItemCode
+ public string[] ItemCode
{
get; set;
}
diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml
index a415e5706..c3a877d1b 100644
--- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml
+++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml
@@ -29,6 +29,8 @@
storeid:id for filtering a specific store
+ orderid:id for filtering a specific order
+ itemcode:code for filtering a specific type of item purchased through the pos or crowdfund apps
status:(expired|invalid|complete|confirmed|paid|new) for filtering a specific status
exceptionstatus:(paidover|paidlate|paidpartial) for filtering a specific exception state
unusual:(true|false) for filtering invoices which might requires merchant attention (those invalid or with an exceptionstatus)