mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Prettify date on the invoice list, and add orderid
This commit is contained in:
parent
2d5a861df0
commit
9f734349da
4 changed files with 31 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>1.0.1.38</Version>
|
||||
<Version>1.0.1.39</Version>
|
||||
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<thead class="thead-inverse">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>OrderId</th>
|
||||
<th>InvoiceId</th>
|
||||
<th>Status</th>
|
||||
<th>Amount</th>
|
||||
|
@ -55,6 +56,7 @@
|
|||
{
|
||||
<tr>
|
||||
<td>@invoice.Date</td>
|
||||
<td>@invoice.OrderId</td>
|
||||
<td>@invoice.InvoiceId</td>
|
||||
@if(invoice.Status == "paid")
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue