mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
Add refund badge to invoice lists (#3918)
* Add refund badge to invoice lists * fix badge
This commit is contained in:
parent
4eabe91cee
commit
0970944ee4
9 changed files with 19 additions and 4 deletions
|
@ -38,6 +38,12 @@
|
||||||
@($"({invoice.Status.ExceptionStatus.ToString()})")
|
@($"({invoice.Status.ExceptionStatus.ToString()})")
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
@if (invoice.HasRefund)
|
||||||
|
{
|
||||||
|
<span class="badge bg-warning">
|
||||||
|
Refund
|
||||||
|
</span>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-end">@invoice.AmountCurrency</td>
|
<td class="text-end">@invoice.AmountCurrency</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -10,4 +10,5 @@ public class StoreRecentInvoiceViewModel
|
||||||
public string AmountCurrency { get; set; }
|
public string AmountCurrency { get; set; }
|
||||||
public InvoiceState Status { get; set; }
|
public InvoiceState Status { get; set; }
|
||||||
public DateTimeOffset Date { get; set; }
|
public DateTimeOffset Date { get; set; }
|
||||||
|
public bool HasRefund { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.Services.Invoices;
|
using BTCPayServer.Services.Invoices;
|
||||||
|
@ -39,6 +40,7 @@ public class StoreRecentInvoices : ViewComponent
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
StoreId = new [] { store.Id },
|
StoreId = new [] { store.Id },
|
||||||
IncludeArchived = false,
|
IncludeArchived = false,
|
||||||
|
IncludeRefunds = true,
|
||||||
Take = 5
|
Take = 5
|
||||||
});
|
});
|
||||||
var invoices = new List<StoreRecentInvoiceViewModel>();
|
var invoices = new List<StoreRecentInvoiceViewModel>();
|
||||||
|
@ -49,6 +51,7 @@ public class StoreRecentInvoices : ViewComponent
|
||||||
{
|
{
|
||||||
Date = invoice.InvoiceTime,
|
Date = invoice.InvoiceTime,
|
||||||
Status = state,
|
Status = state,
|
||||||
|
HasRefund = invoice.Refunds.Any(),
|
||||||
InvoiceId = invoice.Id,
|
InvoiceId = invoice.Id,
|
||||||
OrderId = invoice.Metadata.OrderId ?? string.Empty,
|
OrderId = invoice.Metadata.OrderId ?? string.Empty,
|
||||||
AmountCurrency = _currencyNameTable.DisplayFormatCurrency(invoice.Price, invoice.Currency),
|
AmountCurrency = _currencyNameTable.DisplayFormatCurrency(invoice.Price, invoice.Currency),
|
||||||
|
|
|
@ -826,6 +826,7 @@ namespace BTCPayServer.Controllers
|
||||||
invoiceQuery.StoreId = model.StoreIds;
|
invoiceQuery.StoreId = model.StoreIds;
|
||||||
invoiceQuery.Take = model.Count;
|
invoiceQuery.Take = model.Count;
|
||||||
invoiceQuery.Skip = model.Skip;
|
invoiceQuery.Skip = model.Skip;
|
||||||
|
invoiceQuery.IncludeRefunds = true;
|
||||||
var list = await _InvoiceRepository.GetInvoices(invoiceQuery);
|
var list = await _InvoiceRepository.GetInvoices(invoiceQuery);
|
||||||
|
|
||||||
model.IncludeArchived = invoiceQuery.IncludeArchived;
|
model.IncludeArchived = invoiceQuery.IncludeArchived;
|
||||||
|
@ -845,6 +846,7 @@ namespace BTCPayServer.Controllers
|
||||||
CanMarkInvalid = state.CanMarkInvalid(),
|
CanMarkInvalid = state.CanMarkInvalid(),
|
||||||
CanMarkSettled = state.CanMarkComplete(),
|
CanMarkSettled = state.CanMarkComplete(),
|
||||||
Details = InvoicePopulatePayments(invoice),
|
Details = InvoicePopulatePayments(invoice),
|
||||||
|
HasRefund = invoice.Refunds.Any(data => !data.PullPaymentData.Archived)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return View(model);
|
return View(model);
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike
|
||||||
|
|
||||||
public bool CanHandle(PaymentMethodId paymentMethod)
|
public bool CanHandle(PaymentMethodId paymentMethod)
|
||||||
{
|
{
|
||||||
return paymentMethod.PaymentType == LightningPaymentType.Instance &&
|
return (paymentMethod.PaymentType == LightningPaymentType.Instance || paymentMethod.PaymentType == LNURLPayPaymentType.Instance ) &&
|
||||||
_btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(paymentMethod.CryptoCode)?.SupportLightning is true;
|
_btcPayNetworkProvider.GetNetwork<BTCPayNetwork>(paymentMethod.CryptoCode)?.SupportLightning is true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,5 +31,6 @@ namespace BTCPayServer.Models.InvoicingModels
|
||||||
public string AmountCurrency { get; set; }
|
public string AmountCurrency { get; set; }
|
||||||
|
|
||||||
public InvoiceDetailsModel Details { get; set; }
|
public InvoiceDetailsModel Details { get; set; }
|
||||||
|
public bool HasRefund { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ namespace BTCPayServer.Services.Invoices
|
||||||
return GetPayments(network.CryptoCode, accountedOnly);
|
return GetPayments(network.CryptoCode, accountedOnly);
|
||||||
}
|
}
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
public bool Refundable { get; set; }
|
// public bool Refundable { get; set; }
|
||||||
public bool? RequiresRefundEmail { get; set; } = null;
|
public bool? RequiresRefundEmail { get; set; } = null;
|
||||||
public string RefundMail { get; set; }
|
public string RefundMail { get; set; }
|
||||||
[JsonProperty("redirectURL")]
|
[JsonProperty("redirectURL")]
|
||||||
|
@ -465,7 +465,6 @@ namespace BTCPayServer.Services.Invoices
|
||||||
ExceptionStatus = ExceptionStatus == InvoiceExceptionStatus.None ? new JValue(false) : new JValue(ExceptionStatusString),
|
ExceptionStatus = ExceptionStatus == InvoiceExceptionStatus.None ? new JValue(false) : new JValue(ExceptionStatusString),
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Currency = Currency,
|
Currency = Currency,
|
||||||
Flags = new Flags() { Refundable = Refundable },
|
|
||||||
PaymentSubtotals = new Dictionary<string, decimal>(),
|
PaymentSubtotals = new Dictionary<string, decimal>(),
|
||||||
PaymentTotals = new Dictionary<string, decimal>(),
|
PaymentTotals = new Dictionary<string, decimal>(),
|
||||||
SupportedTransactionCurrencies = new Dictionary<string, NBitpayClient.InvoiceSupportedTransactionCurrency>(),
|
SupportedTransactionCurrencies = new Dictionary<string, NBitpayClient.InvoiceSupportedTransactionCurrency>(),
|
||||||
|
|
|
@ -570,7 +570,6 @@ namespace BTCPayServer.Services.Invoices
|
||||||
entity.ExceptionStatus = state.ExceptionStatus;
|
entity.ExceptionStatus = state.ExceptionStatus;
|
||||||
entity.Status = state.Status;
|
entity.Status = state.Status;
|
||||||
entity.RefundMail = invoice.CustomerEmail;
|
entity.RefundMail = invoice.CustomerEmail;
|
||||||
entity.Refundable = false;
|
|
||||||
if (invoice.AddressInvoices != null)
|
if (invoice.AddressInvoices != null)
|
||||||
{
|
{
|
||||||
entity.AvailableAddressHashes = invoice.AddressInvoices.Select(a => a.GetAddress() + a.GetPaymentMethodId().ToString()).ToHashSet();
|
entity.AvailableAddressHashes = invoice.AddressInvoices.Select(a => a.GetAddress() + a.GetPaymentMethodId().ToString()).ToHashSet();
|
||||||
|
|
|
@ -352,6 +352,10 @@
|
||||||
{
|
{
|
||||||
<span class="badge">@paymentType.GetBadge()</span>
|
<span class="badge">@paymentType.GetBadge()</span>
|
||||||
}
|
}
|
||||||
|
@if (invoice.HasRefund)
|
||||||
|
{
|
||||||
|
<span class="badge bg-warning">Refund</span>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-end text-nowrap">@invoice.AmountCurrency</td>
|
<td class="text-end text-nowrap">@invoice.AmountCurrency</td>
|
||||||
<td class="text-end text-nowrap">
|
<td class="text-end text-nowrap">
|
||||||
|
|
Loading…
Add table
Reference in a new issue