From bdf12aab0fa5147c81568da7a4db774c3a2fa3c4 Mon Sep 17 00:00:00 2001 From: d11n Date: Fri, 29 Nov 2024 08:23:53 +0100 Subject: [PATCH] App: Sales stats should only include paid invoices (#6444) Fixes btcpayserver/app#110 --- BTCPayServer/Services/Apps/AppService.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/BTCPayServer/Services/Apps/AppService.cs b/BTCPayServer/Services/Apps/AppService.cs index 71640e37c..7393aa17d 100644 --- a/BTCPayServer/Services/Apps/AppService.cs +++ b/BTCPayServer/Services/Apps/AppService.cs @@ -43,6 +43,10 @@ namespace BTCPayServer.Services.Apps private readonly DisplayFormatter _displayFormatter; private readonly StoreRepository _storeRepository; public CurrencyNameTable Currencies => _Currencies; + private readonly string[] _paidStatuses = [ + InvoiceStatus.Processing.ToString(), + InvoiceStatus.Settled.ToString() + ]; public AppService( IEnumerable apps, @@ -86,11 +90,7 @@ namespace BTCPayServer.Services.Apps { if (GetAppType(appData.AppType) is not IHasItemStatsAppType salesType) throw new InvalidOperationException("This app isn't a SalesAppBaseType"); - var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, appData, null, - [ - InvoiceStatus.Processing.ToString(), - InvoiceStatus.Settled.ToString() - ]); + var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, appData, null, _paidStatuses); return await salesType.GetItemStats(appData, paidInvoices); } @@ -132,8 +132,7 @@ namespace BTCPayServer.Services.Apps { if (GetAppType(app.AppType) is not IHasSaleStatsAppType salesType) throw new InvalidOperationException("This app isn't a SalesAppBaseType"); - var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, app, DateTimeOffset.UtcNow - TimeSpan.FromDays(numberOfDays)); - + var paidInvoices = await GetInvoicesForApp(_InvoiceRepository, app, DateTimeOffset.UtcNow - TimeSpan.FromDays(numberOfDays), _paidStatuses); return await salesType.GetSalesStats(app, paidInvoices, numberOfDays); }