mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 07:04:26 +01:00
Disallow calling InvoiceEntity.UpdateTotals() on incomplete invoices (#6646)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user