diff --git a/EstateReportingAPI.BusinessLogic/ReportingManager.cs b/EstateReportingAPI.BusinessLogic/ReportingManager.cs index 6d800c3..c40cb61 100644 --- a/EstateReportingAPI.BusinessLogic/ReportingManager.cs +++ b/EstateReportingAPI.BusinessLogic/ReportingManager.cs @@ -2064,14 +2064,14 @@ private static MerchantDailyPerformanceSummaryResponse BuildEmptyMerchantDailyPe private static List BuildMerchantDailyPerformanceBaseMetrics() { return new List { - new() { Title = "Total Sales Count", Value = 0, Description = "All sales transactions in the range", Category = 0 }, - new() { Title = "Total Sales Value", Value = 0, Description = "All sales value in the range", Category = 1 }, - new() { Title = "Successful Sales Count", Value = 0, Description = "Authorised sales count in the range", Category = 2 }, - new() { Title = "Successful Sales Value", Value = 0, Description = "Authorised sales value in the range", Category = 3 }, - new() { Title = "Failed Sales Count", Value = 0, Description = "Declined sales count in the range", Category = 4 }, - new() { Title = "Failed Sales Value", Value = 0, Description = "Declined sales value in the range", Category = 5 }, - new() { Title = "Average Sales Count", Value = 0, Description = "Average sales count per day in the range", Category = 6 }, - new() { Title = "Average Sales Value", Value = 0, Description = "Average value per sale in the range", Category = 7 } + new() { Title = "Total Sales Count", Value = 0, Description = "All sales transactions in the range", Category = 1, Type = 0 }, + new() { Title = "Total Sales Value", Value = 0, Description = "All sales value in the range", Category = 1, Type = 1 }, + new() { Title = "Successful Sales Count", Value = 0, Description = "Authorised sales count in the range", Category = 2, Type = 2 }, + new() { Title = "Successful Sales Value", Value = 0, Description = "Authorised sales value in the range", Category = 2, Type = 3 }, + new() { Title = "Failed Sales Count", Value = 0, Description = "Declined sales count in the range", Category = 3, Type = 4 }, + new() { Title = "Failed Sales Value", Value = 0, Description = "Declined sales value in the range", Category = 3, Type = 5 }, + new() { Title = "Average Sales Count", Value = 0, Description = "Average sales count per day in the range", Category = 4, Type = 6 }, + new() { Title = "Average Sales Value", Value = 0, Description = "Average value per sale in the range", Category = 4, Type = 7 } }; } diff --git a/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs b/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs index 9b039f7..6b69b79 100644 --- a/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs +++ b/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs @@ -1401,6 +1401,90 @@ public async Task TransactionsEndpoint_MerchantDailyPerformanceSummary_ReturnsMe } } + [Fact] + public async Task TransactionsEndpoint_MerchantDailyPerformanceSummary_NoSales_ReturnsStableMetricCategories() + { + TransactionProcessor.Database.Entities.Merchant merchant = this.merchantsList.Single(m => m.Name == "Test Merchant 1"); + DateTime startDate = DateTime.Now.Date.AddYears(1); + DateTime endDate = startDate.AddDays(6); + + MerchantDailyPerformanceSummaryRequest request = new() + { + StartDate = startDate, + EndDate = endDate, + MerchantReportingId = merchant.MerchantReportingId + }; + + var payload = JsonSerializer.Serialize(request); + var result = await this.CreateAndSendHttpRequestMessage( + $"{this.BaseRoute}/merchantdailyperformancesummary", + payload, + CancellationToken.None); + + result.IsFailed.ShouldBeFalse(result.ToString()); + + MerchantDailyPerformanceSummaryResponse response = result.Data; + response.Metrics.Count.ShouldBe(8); + response.DrillDownTransactions.Count.ShouldBe(0); + + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Total Sales Count"), + "Total Sales Count", + 0, + "All sales transactions in the range", + 1, + 0); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Total Sales Value"), + "Total Sales Value", + 0, + "All sales value in the range", + 1, + 1); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Successful Sales Count"), + "Successful Sales Count", + 0, + "Authorised sales count in the range", + 2, + 2); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Successful Sales Value"), + "Successful Sales Value", + 0, + "Authorised sales value in the range", + 2, + 3); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Failed Sales Count"), + "Failed Sales Count", + 0, + "Declined sales count in the range", + 3, + 4); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Failed Sales Value"), + "Failed Sales Value", + 0, + "Declined sales value in the range", + 3, + 5); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Average Sales Count"), + "Average Sales Count", + 0, + "Average sales count per day in the range", + 4, + 6); + AssertMerchantDailyPerformanceMetricMatches( + response.Metrics.Single(m => m.Title == "Average Sales Value"), + "Average Sales Value", + 0, + "Average value per sale in the range", + 4, + 7); + } + [Fact] public async Task TransactionsEndpoint_RecentActivityReceiptReport_MerchantFilter_ReturnsDescendingResults() { var reportDate = DateTime.Now.Date; diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +}