diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 709351af0..9b5713ff4 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.38 + 1.0.1.39 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 6d8c559ea..cc1fe2c53 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -345,8 +345,9 @@ namespace BTCPayServer.Controllers model.Invoices.Add(new InvoiceModel() { Status = invoice.Status, - Date = invoice.InvoiceTime, + Date = Prettify(invoice.InvoiceTime), InvoiceId = invoice.Id, + OrderId = invoice.OrderId ?? string.Empty, AmountCurrency = $"{invoice.ProductInformation.Price.ToString(CultureInfo.InvariantCulture)} {invoice.ProductInformation.Currency}" }); } @@ -356,6 +357,30 @@ namespace BTCPayServer.Controllers return View(model); } + private string Prettify(DateTimeOffset invoiceTime) + { + var ago = DateTime.UtcNow - invoiceTime; + + if(ago.TotalMinutes < 1) + { + return $"{(int)ago.TotalSeconds} second{Plural((int)ago.TotalSeconds)} ago"; + } + if (ago.TotalHours < 1) + { + return $"{(int)ago.TotalMinutes} minute{Plural((int)ago.TotalMinutes)} ago"; + } + if (ago.Days < 1) + { + return $"{(int)ago.TotalHours} hour{Plural((int)ago.TotalHours)} ago"; + } + return $"{(int)ago.TotalDays} day{Plural((int)ago.TotalDays)} ago"; + } + + private string Plural(int totalDays) + { + return totalDays > 1 ? "s" : string.Empty; + } + [HttpGet] [Route("invoices/create")] [Authorize(AuthenticationSchemes = "Identity.Application")] diff --git a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs index ded7c45fd..8c21a1b2a 100644 --- a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs +++ b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs @@ -33,11 +33,12 @@ namespace BTCPayServer.Models.InvoicingModels public class InvoiceModel { - public DateTimeOffset Date + public string Date { get; set; } + public string OrderId { get; set; } public string InvoiceId { get; set; diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml index 00e7edadd..783f8c693 100644 --- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml @@ -44,6 +44,7 @@ Date + OrderId InvoiceId Status Amount @@ -55,6 +56,7 @@ { @invoice.Date + @invoice.OrderId @invoice.InvoiceId @if(invoice.Status == "paid") {