Disallow calling InvoiceEntity.UpdateTotals() on incomplete invoices (#6646)

This commit is contained in:
Nicolas Dorier
2025-04-02 08:35:52 +09:00
committed by GitHub
parent ec6c22f4bf
commit 81ede35fe4
2 changed files with 9 additions and 1 deletions

View File

@@ -412,6 +412,8 @@ namespace BTCPayServer.Services.Invoices
public void UpdateTotals()
{
if (DisableAccounting)
throw new InvalidOperationException("Accounting disabled, impossible to call UpdateTotals");
PaidAmount = new Amounts()
{
Currency = Currency
@@ -781,6 +783,8 @@ namespace BTCPayServer.Services.Invoices
/// </summary>
[JsonIgnore]
public decimal NetSettled { get; private set; }
[JsonIgnore]
public bool DisableAccounting { get; set; }
}
public enum InvoiceStatusLegacy

View File

@@ -151,7 +151,11 @@ namespace BTCPayServer.Services.Invoices
var paymentData = jobj.ToObject<PaymentData>();
invoiceData.Payments.Add(paymentData);
}
invoices.Add(ToEntity(invoiceData));
var entity = ToEntity(invoiceData);
// Disable accounting, as we don't have all the payments...
// only those related to this paymentMethodId
entity.DisableAccounting = true;
invoices.Add(entity);
}
return invoices.ToArray();
}