mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-31 20:54:31 +01:00
Add InvoiceEntity.NetSettled property
This commit is contained in:
@@ -2252,17 +2252,21 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku
|
||||
PaymentMethodId = btcId
|
||||
});
|
||||
invoiceEntity.UpdateTotals();
|
||||
var prevNetSettled = invoiceEntity.NetSettled;
|
||||
Assert.Equal(invoiceEntity.PaidAmount.Net, invoiceEntity.NetSettled);
|
||||
accounting = btc.Calculate();
|
||||
invoiceEntity.Payments.Add(
|
||||
new PaymentEntity()
|
||||
{
|
||||
Status = PaymentStatus.Settled,
|
||||
Status = PaymentStatus.Processing,
|
||||
Currency = "BTC",
|
||||
Value = accounting.Due,
|
||||
PaymentMethodFee = 0.00000100m,
|
||||
PaymentMethodId = btcId
|
||||
});
|
||||
invoiceEntity.UpdateTotals();
|
||||
Assert.NotEqual(invoiceEntity.PaidAmount.Net, invoiceEntity.NetSettled);
|
||||
Assert.Equal(prevNetSettled, invoiceEntity.NetSettled);
|
||||
accounting = btc.Calculate();
|
||||
Assert.Equal(0.0m, accounting.Due);
|
||||
Assert.Equal(0.0m, accounting.DueUncapped);
|
||||
|
||||
@@ -416,6 +416,7 @@ namespace BTCPayServer.Services.Invoices
|
||||
{
|
||||
Currency = Currency
|
||||
};
|
||||
NetSettled = 0.0m;
|
||||
foreach (var payment in GetPayments(false))
|
||||
{
|
||||
payment.Rate = GetInvoiceRate(payment.Currency);
|
||||
@@ -425,6 +426,8 @@ namespace BTCPayServer.Services.Invoices
|
||||
{
|
||||
PaidAmount.Gross += payment.InvoicePaidAmount.Gross;
|
||||
PaidAmount.Net += payment.InvoicePaidAmount.Net;
|
||||
if (payment.Status == PaymentStatus.Settled)
|
||||
NetSettled += payment.InvoicePaidAmount.Net;
|
||||
}
|
||||
}
|
||||
NetDue = Price - PaidAmount.Net;
|
||||
@@ -772,6 +775,12 @@ namespace BTCPayServer.Services.Invoices
|
||||
}
|
||||
[JsonIgnore]
|
||||
public Amounts PaidAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Same as <see cref="Amounts.Net"/> of <see cref="PaidAmount"/>, but only counting payments in 'Settled' state
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public decimal NetSettled { get; private set; }
|
||||
}
|
||||
|
||||
public enum InvoiceStatusLegacy
|
||||
|
||||
Reference in New Issue
Block a user