Receipts: Fix amount paid discrepancy (#4287)

Displays the actual amount paid instead of the total invoice price. Fixes #4242.
This commit is contained in:
d11n
2022-11-16 03:35:49 +01:00
committed by GitHub
parent 1d7dee8314
commit 324112b73b

View File

@@ -180,17 +180,8 @@ namespace BTCPayServer.Controllers
JToken? receiptData = null;
i.Metadata?.AdditionalData?.TryGetValue("receiptData", out receiptData);
return View(new InvoiceReceiptViewModel
{
StoreName = store.StoreName,
Status = i.Status.ToModernStatus(),
Amount = i.Price,
Currency = i.Currency,
Timestamp = i.InvoiceTime,
InvoiceId = i.Id,
OrderId = i.Metadata?.OrderId,
OrderUrl = i.Metadata?.OrderUrl,
Payments = receipt.ShowPayments is false ? null : i.GetPayments(true).Select(paymentEntity =>
var payments = i.GetPayments(true)
.Select(paymentEntity =>
{
var paymentData = paymentEntity.GetCryptoPaymentData();
var paymentMethodId = paymentEntity.GetPaymentMethodId();
@@ -220,7 +211,19 @@ namespace BTCPayServer.Controllers
};
})
.Where(payment => payment != null)
.ToList(),
.ToList();
return View(new InvoiceReceiptViewModel
{
StoreName = store.StoreName,
Status = i.Status.ToModernStatus(),
Amount = payments.Sum(p => p!.Paid),
Currency = i.Currency,
Timestamp = i.InvoiceTime,
InvoiceId = i.Id,
OrderId = i.Metadata?.OrderId,
OrderUrl = i.Metadata?.OrderUrl,
Payments = receipt.ShowPayments is false ? null : payments,
ReceiptOptions = receipt,
AdditionalData = receiptData is null
? new Dictionary<string, object>()