Add refund badge to invoice lists (#3918)

* Add refund badge to invoice lists

* fix badge
This commit is contained in:
Andrew Camilleri 2022-07-01 06:26:00 +02:00 committed by GitHub
parent 4eabe91cee
commit 0970944ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 4 deletions

View file

@ -38,6 +38,12 @@
@($"({invoice.Status.ExceptionStatus.ToString()})")
}
</span>
@if (invoice.HasRefund)
{
<span class="badge bg-warning">
Refund
</span>
}
</td>
<td class="text-end">@invoice.AmountCurrency</td>
</tr>

View file

@ -10,4 +10,5 @@ public class StoreRecentInvoiceViewModel
public string AmountCurrency { get; set; }
public InvoiceState Status { get; set; }
public DateTimeOffset Date { get; set; }
public bool HasRefund { get; set; }
}

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Data;
using BTCPayServer.Services.Invoices;
@ -39,6 +40,7 @@ public class StoreRecentInvoices : ViewComponent
UserId = userId,
StoreId = new [] { store.Id },
IncludeArchived = false,
IncludeRefunds = true,
Take = 5
});
var invoices = new List<StoreRecentInvoiceViewModel>();
@ -49,6 +51,7 @@ public class StoreRecentInvoices : ViewComponent
{
Date = invoice.InvoiceTime,
Status = state,
HasRefund = invoice.Refunds.Any(),
InvoiceId = invoice.Id,
OrderId = invoice.Metadata.OrderId ?? string.Empty,
AmountCurrency = _currencyNameTable.DisplayFormatCurrency(invoice.Price, invoice.Currency),

View file

@ -826,6 +826,7 @@ namespace BTCPayServer.Controllers
invoiceQuery.StoreId = model.StoreIds;
invoiceQuery.Take = model.Count;
invoiceQuery.Skip = model.Skip;
invoiceQuery.IncludeRefunds = true;
var list = await _InvoiceRepository.GetInvoices(invoiceQuery);
model.IncludeArchived = invoiceQuery.IncludeArchived;
@ -845,6 +846,7 @@ namespace BTCPayServer.Controllers
CanMarkInvalid = state.CanMarkInvalid(),
CanMarkSettled = state.CanMarkComplete(),
Details = InvoicePopulatePayments(invoice),
HasRefund = invoice.Refunds.Any(data => !data.PullPaymentData.Archived)
});
}
return View(model);

View file

@ -41,7 +41,7 @@ namespace BTCPayServer.Data.Payouts.LightningLike
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;
}

View file

@ -31,5 +31,6 @@ namespace BTCPayServer.Models.InvoicingModels
public string AmountCurrency { get; set; }
public InvoiceDetailsModel Details { get; set; }
public bool HasRefund { get; set; }
}
}

View file

@ -392,7 +392,7 @@ namespace BTCPayServer.Services.Invoices
return GetPayments(network.CryptoCode, accountedOnly);
}
#pragma warning restore CS0618
public bool Refundable { get; set; }
// public bool Refundable { get; set; }
public bool? RequiresRefundEmail { get; set; } = null;
public string RefundMail { get; set; }
[JsonProperty("redirectURL")]
@ -465,7 +465,6 @@ namespace BTCPayServer.Services.Invoices
ExceptionStatus = ExceptionStatus == InvoiceExceptionStatus.None ? new JValue(false) : new JValue(ExceptionStatusString),
#pragma warning restore CS0618 // Type or member is obsolete
Currency = Currency,
Flags = new Flags() { Refundable = Refundable },
PaymentSubtotals = new Dictionary<string, decimal>(),
PaymentTotals = new Dictionary<string, decimal>(),
SupportedTransactionCurrencies = new Dictionary<string, NBitpayClient.InvoiceSupportedTransactionCurrency>(),

View file

@ -570,7 +570,6 @@ namespace BTCPayServer.Services.Invoices
entity.ExceptionStatus = state.ExceptionStatus;
entity.Status = state.Status;
entity.RefundMail = invoice.CustomerEmail;
entity.Refundable = false;
if (invoice.AddressInvoices != null)
{
entity.AvailableAddressHashes = invoice.AddressInvoices.Select(a => a.GetAddress() + a.GetPaymentMethodId().ToString()).ToHashSet();

View file

@ -352,6 +352,10 @@
{
<span class="badge">@paymentType.GetBadge()</span>
}
@if (invoice.HasRefund)
{
<span class="badge bg-warning">Refund</span>
}
</td>
<td class="text-end text-nowrap">@invoice.AmountCurrency</td>
<td class="text-end text-nowrap">