diff --git a/EstateReportingAPI.BusinessLogic/Queries/SettlementQueries.cs b/EstateReportingAPI.BusinessLogic/Queries/SettlementQueries.cs new file mode 100644 index 0000000..97527b6 --- /dev/null +++ b/EstateReportingAPI.BusinessLogic/Queries/SettlementQueries.cs @@ -0,0 +1,17 @@ +using System.Diagnostics.CodeAnalysis; +using EstateReportingAPI.Models; +using MediatR; +using SimpleResults; + +namespace EstateReportingAPI.BusinessLogic.Queries; + +[ExcludeFromCodeCoverage] +public record SettlementQueries { + public record TodaysSettlementQuery(Guid EstateId, DateTime ComparisonDate) : IRequest>; +} + +[ExcludeFromCodeCoverage] +public record FileImportLogQueries +{ + public record GetFileImportLogListQuery(Guid EstateId, Guid? MerchantId, DateTime StartDate, DateTime EndDate) : IRequest>>; +} \ No newline at end of file diff --git a/EstateReportingAPI.BusinessLogic/Queries/TransactionQueries.cs b/EstateReportingAPI.BusinessLogic/Queries/TransactionQueries.cs index 49f9358..f2873b8 100644 --- a/EstateReportingAPI.BusinessLogic/Queries/TransactionQueries.cs +++ b/EstateReportingAPI.BusinessLogic/Queries/TransactionQueries.cs @@ -14,9 +14,4 @@ public record TransactionSummaryByMerchantQuery(Guid EstateId, TransactionSummar public record TransactionSummaryByOperatorQuery(Guid EstateId, TransactionSummaryByOperatorRequest Request) : IRequest>; public record ProductPerformanceQuery(Guid EstateId, DateTime StartDate, DateTime EndDate) : IRequest>; public record TodaysSalesByHour(Guid estateId, DateTime comparisonDate) : IRequest>>; -} - -[ExcludeFromCodeCoverage] -public record SettlementQueries { - public record TodaysSettlementQuery(Guid EstateId, DateTime ComparisonDate) : IRequest>; } \ No newline at end of file diff --git a/EstateReportingAPI.BusinessLogic/ReportingManager.cs b/EstateReportingAPI.BusinessLogic/ReportingManager.cs index c6a8dfb..b444865 100644 --- a/EstateReportingAPI.BusinessLogic/ReportingManager.cs +++ b/EstateReportingAPI.BusinessLogic/ReportingManager.cs @@ -23,8 +23,7 @@ namespace EstateReportingAPI.BusinessLogic; using MerchantBalanceProjectionState = TransactionProcessor.ProjectionEngine.Database.Database.Entities.MerchantBalanceProjectionState; public interface IReportingManager -{ - #region Methods +{ Task>> GetCalendarComparisonDates(CalendarQueries.GetComparisonDatesQuery request, CancellationToken cancellationToken); Task>> GetCalendarDates(CalendarQueries.GetAllDatesQuery request, CancellationToken cancellationToken); Task>> GetCalendarYears(CalendarQueries.GetYearsQuery request, CancellationToken cancellationToken); @@ -57,11 +56,13 @@ Task> GetProductPerformanceReport(Transaction Task>> GetTodaysSalesByHour(TransactionQueries.TodaysSalesByHour request, CancellationToken cancellationToken); Task> GetTodaysSettlement(SettlementQueries.TodaysSettlementQuery request, - CancellationToken cancellationToken); - #endregion - + CancellationToken cancellationToken); + Task> GetMerchantSchedule(MerchantQueries.GetMerchantScheduleQuery request, CancellationToken cancellationToken); + + Task>> GetFileImportLogList(FileImportLogQueries.GetFileImportLogListQuery request, + CancellationToken cancellationToken); } public class ReportingManager : IReportingManager { @@ -70,16 +71,10 @@ public class ReportingManager : IReportingManager { private Guid Id; private static readonly String EstateManagementDatabaseName = "TransactionProcessorReadModel"; - #region Constructors - public ReportingManager(IDbContextResolver resolver) { this.Resolver = resolver; } - #endregion - - #region Methods - private static async Task> ExecuteQuerySafeSum(IQueryable query, CancellationToken cancellationToken, string contextMessage = null) { @@ -1390,6 +1385,70 @@ join d in context.MerchantScheduleMonths on s.MerchantScheduleId equals d.Mercha return response; } + public async Task>> GetFileImportLogList(FileImportLogQueries.GetFileImportLogListQuery request, + CancellationToken cancellationToken) { + using ResolvedDbContext? resolvedContext = this.Resolver.Resolve(EstateManagementDatabaseName, request.EstateId.ToString()); + await using EstateManagementContext context = resolvedContext.Context; + // Build flat projection of the required data then assemble into hierarchical models in-memory + var flatQuery = from fil in context.FileImportLogs + join f in context.Files on fil.FileImportLogId equals f.FileImportLogId + join esu in context.EstateSecurityUsers on f.UserId equals esu.SecurityUserId into esuJoin + from esu in esuJoin.DefaultIfEmpty() + join m in context.Merchants on f.MerchantId equals m.MerchantId into mJoin + from m in mJoin.DefaultIfEmpty() + join fl in context.FileLines on f.FileId equals fl.FileId + where fil.ImportLogDate >= request.StartDate && fil.ImportLogDate <= request.EndDate + && (request.MerchantId == null || f.MerchantId == request.MerchantId) + select new FileImportFlatData { + FileImportLogId = fil.FileImportLogId, + ImportLogDateTime = fil.ImportLogDateTime, + FileId = f.FileId, + FileName = f.FileLocation, + FileProfileId = f.FileProfileId, + DateTimeUploaded = f.FileReceivedDateTime, + UserId = f.UserId, + UploadedBy = esu != null ? esu.EmailAddress : null, + MerchantId = f.MerchantId, + MerchantName = m != null ? m.Name : null, + LineNumber = fl.LineNumber, + LineContents = fl.FileLineData, + LineStatus = fl.Status + }; + + var flatResult = await ExecuteQuerySafeToList(flatQuery, cancellationToken, "Error retrieving file import logs"); + + if (flatResult.IsFailed) + return ResultHelpers.CreateFailure(flatResult); + + var flatItems = flatResult.Data; + + // assemble hierarchical model + var fileImportLogs = flatItems + .GroupBy(x => new { x.FileImportLogId, x.ImportLogDateTime }) + .Select(g => new FileImportLog { + FileImportLogId = g.Key.FileImportLogId, + ImportLogDateTime = g.Key.ImportLogDateTime, + FileDetailsList = g.GroupBy(f => new { f.FileId, f.FileName, f.FileProfileId, f.DateTimeUploaded, f.UserId, f.UploadedBy, f.MerchantId, f.MerchantName }) + .Select(fg => new FileDetails { + FileId = fg.Key.FileId, + FileName = fg.Key.FileName, + FileProfile = fg.Key.FileProfileId != null ? fg.Key.FileProfileId.ToString() : null, + DateTimeUploaded = fg.Key.DateTimeUploaded, + UserId = fg.Key.UserId, + UploadedBy = fg.Key.UploadedBy, + MerchantId = fg.Key.MerchantId, + MerchantName = fg.Key.MerchantName, + FileLines = fg.Select(fl => new FileLine { + LineNumber = fl.LineNumber, + LineContents = fl.LineContents, + LineStatus = fl.LineStatus + }).ToList() + }).ToList() + }).ToList(); + + return Result.Success(fileImportLogs); + } + private async Task GetSettlementSummary(IQueryable query, CancellationToken cancellationToken) { // Get the settleed fees summary @@ -1637,5 +1696,19 @@ private sealed class ProductPerformanceItemData { public decimal PercentOfTotalAmount { get; init; } } - #endregion - } + private sealed class FileImportFlatData { + public Guid FileImportLogId { get; init; } + public DateTime ImportLogDateTime { get; init; } + public Guid FileId { get; init; } + public string? FileName { get; init; } + public Guid? FileProfileId { get; init; } + public DateTime DateTimeUploaded { get; init; } + public Guid UserId { get; init; } + public string? UploadedBy { get; init; } + public Guid MerchantId { get; init; } + public string? MerchantName { get; init; } + public int LineNumber { get; init; } + public string? LineContents { get; init; } + public string? LineStatus { get; init; } + } +} diff --git a/EstateReportingAPI.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs b/EstateReportingAPI.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs new file mode 100644 index 0000000..d813c19 --- /dev/null +++ b/EstateReportingAPI.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs @@ -0,0 +1,32 @@ +using EstateReportingAPI.BusinessLogic.Queries; +using EstateReportingAPI.Models; +using MediatR; +using SimpleResults; + +namespace EstateReportingAPI.BusinessLogic.RequestHandlers; + +public class SettlementRequestHandler : IRequestHandler> +{ + private readonly IReportingManager Manager; + public SettlementRequestHandler(IReportingManager manager) { + this.Manager = manager; + } + public async Task> Handle(SettlementQueries.TodaysSettlementQuery request, + CancellationToken cancellationToken) { + return await this.Manager.GetTodaysSettlement(request, cancellationToken); + } +} + +public class FileImportLogRequestHandler : IRequestHandler>> +{ + private readonly IReportingManager Manager; + public FileImportLogRequestHandler(IReportingManager manager) + { + this.Manager = manager; + } + + public async Task>> Handle(FileImportLogQueries.GetFileImportLogListQuery request, + CancellationToken cancellationToken) { + return await this.Manager.GetFileImportLogList(request, cancellationToken); + } +} \ No newline at end of file diff --git a/EstateReportingAPI.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs b/EstateReportingAPI.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs index 70e6477..04ae197 100644 --- a/EstateReportingAPI.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs +++ b/EstateReportingAPI.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs @@ -5,18 +5,6 @@ namespace EstateReportingAPI.BusinessLogic.RequestHandlers; -public class SettlementRequestHandler : IRequestHandler> -{ - private readonly IReportingManager Manager; - public SettlementRequestHandler(IReportingManager manager) { - this.Manager = manager; - } - public async Task> Handle(SettlementQueries.TodaysSettlementQuery request, - CancellationToken cancellationToken) { - return await this.Manager.GetTodaysSettlement(request, cancellationToken); - } -} - public class TransactionRequestHandler : IRequestHandler>, IRequestHandler>, IRequestHandler>, diff --git a/EstateReportingAPI.DataTrasferObjects/FileDetails.cs b/EstateReportingAPI.DataTrasferObjects/FileDetails.cs new file mode 100644 index 0000000..364e637 --- /dev/null +++ b/EstateReportingAPI.DataTrasferObjects/FileDetails.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace EstateReportingAPI.DataTransferObjects; + +public class FileDetails +{ + public Guid FileId { get; set; } + public string FileName { get; set; } + public string FileProfile { get; set; } + public DateTime DateTimeUploaded { get; set; } + public Guid UserId { get; set; } + public string UploadedBy { get; set; } + public Guid MerchantId { get; set; } + public string MerchantName { get; set; } + public List FileLines { get; set; } = new List(); +} \ No newline at end of file diff --git a/EstateReportingAPI.DataTrasferObjects/FileImportLog.cs b/EstateReportingAPI.DataTrasferObjects/FileImportLog.cs new file mode 100644 index 0000000..a4eb3c0 --- /dev/null +++ b/EstateReportingAPI.DataTrasferObjects/FileImportLog.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace EstateReportingAPI.DataTransferObjects; + +public class FileImportLog +{ + public Guid FileImportLogId { get; set; } + public DateTime ImportLogDateTime { get; set; } + public List FileDetailsList { get; set; } +} \ No newline at end of file diff --git a/EstateReportingAPI.DataTrasferObjects/FileLine.cs b/EstateReportingAPI.DataTrasferObjects/FileLine.cs new file mode 100644 index 0000000..ec86c6e --- /dev/null +++ b/EstateReportingAPI.DataTrasferObjects/FileLine.cs @@ -0,0 +1,10 @@ +using System; + +namespace EstateReportingAPI.DataTransferObjects; + +public sealed class FileLine +{ + public int LineNumber { get; set; } + public string LineContents { get; set; } + public String LineStatus { get; set; } +} \ No newline at end of file diff --git a/EstateReportingAPI.IntegrationTests/DatabaseHelper.cs b/EstateReportingAPI.IntegrationTests/DatabaseHelper.cs index b6018cb..bf7b5b5 100644 --- a/EstateReportingAPI.IntegrationTests/DatabaseHelper.cs +++ b/EstateReportingAPI.IntegrationTests/DatabaseHelper.cs @@ -24,6 +24,10 @@ using MerchantDevice = TransactionProcessor.Database.Entities.MerchantDevice; using MerchantOperator = TransactionProcessor.Database.Entities.MerchantOperator; using Operator = TransactionProcessor.Database.Entities.Operator; +using FileImportLog = TransactionProcessor.Database.Entities.FileImportLog; +using DbFile = TransactionProcessor.Database.Entities.File; +using FileLine = TransactionProcessor.Database.Entities.FileLine; +using EstateSecurityUser = TransactionProcessor.Database.Entities.EstateSecurityUser; namespace EstateReportingAPI.IntegrationTests; @@ -40,6 +44,65 @@ public DatabaseHelper(EstateManagementContext context, Guid estateId) { this.EstateId = estateId; } + public async Task AddEstateUser(String estateName, string name, string email){ + Estate? estate = await this.Context.Estates.SingleOrDefaultAsync(e => e.Name == estateName); + if (estate == null) throw new Exception($"No estate found with name {estateName}"); + + EstateSecurityUser user = new EstateSecurityUser { + EstateId = estate.EstateId, + SecurityUserId = Guid.NewGuid(), + EmailAddress = email + }; + + await this.Context.AddAsync(user); + await this.Context.SaveChangesAsync(CancellationToken.None); + + return user.SecurityUserId; + } + + public async Task AddFileImportLog(Guid estateId, DateTime importDate){ + FileImportLog fil = new FileImportLog { + FileImportLogId = Guid.NewGuid(), + EstateId = estateId, + ImportLogDateTime = importDate, + ImportLogDate = importDate.Date + }; + + await this.Context.AddAsync(fil); + await this.Context.SaveChangesAsync(CancellationToken.None); + + return fil.FileImportLogId; + } + + public async Task AddFile(Guid fileImportLogId, Guid merchantId, Guid userId, string fileLocation){ + DbFile file = new DbFile { + FileId = Guid.NewGuid(), + FileImportLogId = fileImportLogId, + FileLocation = fileLocation, + FileProfileId = Guid.NewGuid(), + FileReceivedDateTime = DateTime.Now, + UserId = userId, + MerchantId = merchantId + }; + + await this.Context.AddAsync(file); + await this.Context.SaveChangesAsync(CancellationToken.None); + + return file.FileId; + } + + public async Task AddFileLine(Guid fileId, int lineNumber, string data, string status){ + FileLine fl = new FileLine { + FileId = fileId, + LineNumber = lineNumber, + FileLineData = data, + Status = status + }; + + await this.Context.AddAsync(fl); + await this.Context.SaveChangesAsync(CancellationToken.None); + } + public async Task DeleteAllMerchants(){ List merchants = await this.Context.Merchants.ToListAsync(); this.Context.RemoveRange(merchants); diff --git a/EstateReportingAPI.IntegrationTests/FileImportLogsEndpointTests.cs b/EstateReportingAPI.IntegrationTests/FileImportLogsEndpointTests.cs new file mode 100644 index 0000000..6be3fea --- /dev/null +++ b/EstateReportingAPI.IntegrationTests/FileImportLogsEndpointTests.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using EstateReportingAPI.DataTransferObjects; +using Microsoft.EntityFrameworkCore; +using Shouldly; +using SimpleResults; +using Xunit; +using Xunit.Abstractions; + +namespace EstateReportingAPI.IntegrationTests +{ + public class FileImportLogsEndpointTests : ControllerTestsBase + { + public FileImportLogsEndpointTests(ITestOutputHelper output) + { + this.TestOutputHelper = output; + } + + private String BaseRoute = "api/fileimportlogs"; + + [Fact] + public async Task FileImportEndpoint_GetFileImportLogs_NoData_ReturnsEmptyList() + { + DateTime start = DateTime.Today.AddDays(-7); + DateTime end = DateTime.Today; + + Result> result = await this.CreateAndSendHttpRequestMessage>($"{this.BaseRoute}?startDate={start:yyyy-MM-dd}&endDate={end:yyyy-MM-dd}", CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + var list = result.Data; + list.ShouldNotBeNull(); + list.Count.ShouldBe(0); + } + + [Fact] + public async Task FileImportEndpoint_GetFileImportLogs_ReturnsInsertedData() + { + // create estate and user already created in SetupStandingData + var estate = await this.context.Estates.FirstAsync(); + + // create a user + var userId = await this.helper.AddEstateUser("Test Estate", "Api User", "apiuser@example.com"); + + // pick a merchant + var merchant = await this.context.Merchants.FirstAsync(); + + // create file import log, file and a line + var filId = await this.helper.AddFileImportLog(this.TestId, DateTime.Now); + var fileId = await this.helper.AddFile(filId, merchant.MerchantId, userId, "test/location/file1.csv"); + await this.helper.AddFileLine(fileId, 1, "line1data", "OK"); + + DateTime start = DateTime.Today.AddDays(-1); + DateTime end = DateTime.Today.AddDays(1); + + Result> result = await this.CreateAndSendHttpRequestMessage>($"{this.BaseRoute}?startDate={start:yyyy-MM-dd}&endDate={end:yyyy-MM-dd}", CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + var list = result.Data; + list.ShouldNotBeNull(); + list.Count.ShouldBeGreaterThan(0); + + var match = list.SelectMany(x => x.FileDetailsList).SelectMany(f => f.FileLines).SingleOrDefault(fl => fl.LineContents == "line1data"); + match.ShouldNotBeNull(); + match.LineStatus.ShouldBe("OK"); + } + + [Fact] + public async Task FileImportEndpoint_GetFileImportLogs_WithMerchantFilter_NoData_ReturnsEmptyList() + { + DateTime start = DateTime.Today.AddDays(-7); + DateTime end = DateTime.Today; + + // use one of the merchants created in SetupStandingData + var merchant = await this.context.Merchants.FirstAsync(); + + Result> result = await this.CreateAndSendHttpRequestMessage>($"{this.BaseRoute}?merchantId={merchant.MerchantId}&startDate={start:yyyy-MM-dd}&endDate={end:yyyy-MM-dd}", CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + var list = result.Data; + list.ShouldNotBeNull(); + list.Count.ShouldBe(0); + } + + protected override async Task ClearStandingData() { + + } + + protected override async Task SetupStandingData() { + Stopwatch sw = Stopwatch.StartNew(); + this.TestOutputHelper.WriteLine("Setting up standing data"); + + // Estates + await this.helper.AddEstate("Test Estate", "Ref1"); + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Estate {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // Estate Security User + //await this.helper.AddEstateUser("Test Estate User", "testuser@example.com", this.TestId); + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Estate User {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // Merchants + await this.helper.AddMerchant("Test Estate", "Test Merchant 1", 100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 2", 100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 3", 100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 4", 100, DateTime.MinValue, DateTime.MinValue, default, default); + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Merchants {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // File Profile (once the table is available at the RM) + } + } +} diff --git a/EstateReportingAPI.IntegrationTests/SettlmentsEndpointTests.cs b/EstateReportingAPI.IntegrationTests/SettlmentsEndpointTests.cs new file mode 100644 index 0000000..e4a1be1 --- /dev/null +++ b/EstateReportingAPI.IntegrationTests/SettlmentsEndpointTests.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Shouldly; +using Xunit; +using Xunit.Abstractions; + +namespace EstateReportingAPI.IntegrationTests; + +public class SettlmentsEndpointTests : ControllerTestsBase { + private String BaseRoute = "api/settlements"; + + public SettlmentsEndpointTests(ITestOutputHelper testOutputHelper) { + this.TestOutputHelper = testOutputHelper; + } + + + protected override async Task ClearStandingData() { + + } + + protected override async Task SetupStandingData() { + Stopwatch sw = Stopwatch.StartNew(); + this.TestOutputHelper.WriteLine("Setting up standing data"); + + // Estates + await this.helper.AddEstate("Test Estate", "Ref1"); + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Estate {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // Operators + await this.helper.AddOperator("Test Estate", "Safaricom"); + await this.helper.AddOperator("Test Estate", "Voucher"); + await this.helper.AddOperator("Test Estate", "PataPawa PostPay"); + await this.helper.AddOperator("Test Estate", "PataPawa PrePay"); + + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Operators {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + // Merchants + await this.helper.AddMerchant("Test Estate", "Test Merchant 1",100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 2",100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 3",100, DateTime.MinValue, DateTime.MinValue, default, default); + await this.helper.AddMerchant("Test Estate", "Test Merchant 4",100, DateTime.MinValue, DateTime.MinValue, default, default); + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Merchants {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // Contracts & Products + List<(string productName, int productType, decimal? value)> safaricomProductList = new() { ("200 KES Topup", 0, 200.00m), ("100 KES Topup", 0, 100.00m), ("50 KES Topup", 0, 50.00m), ("Custom", 0, null) }; + await this.helper.AddContractWithProducts("Test Estate", "Safaricom Contract", "Safaricom", safaricomProductList); + + List<(string productName, int productType, decimal? value)> voucherProductList = new() { ("10 KES Voucher", 0, 10.00m), ("Custom", 0, null) }; + await this.helper.AddContractWithProducts("Test Estate", "Healthcare Centre 1 Contract", "Voucher", voucherProductList); + + List<(string productName, int productType, decimal? value)> postPayProductList = new() { ("Post Pay Bill Pay", 0, null) }; + await this.helper.AddContractWithProducts("Test Estate", "PataPawa PostPay Contract", "PataPawa PostPay", postPayProductList); + + List<(string productName, int productType, decimal? value)> prePayProductList = new() { ("Pre Pay Bill Pay", 0, null) }; + await this.helper.AddContractWithProducts("Test Estate", "PataPawa PrePay Contract", "PataPawa PrePay", prePayProductList); + + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Contracts {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + // Response Codes + await this.helper.AddResponseCode(0, "Success"); + await this.helper.AddResponseCode(1000, "Unknown Device"); + await this.helper.AddResponseCode(1001, "Unknown Estate"); + await this.helper.AddResponseCode(1002, "Unknown Merchant"); + await this.helper.AddResponseCode(1003, "No Devices Configured"); + + sw.Stop(); + this.TestOutputHelper.WriteLine($"Setup Response Codes {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + + this.merchantsList = this.context.Merchants.Select(m => m).ToList(); + + this.contractList = this.context.Contracts.Join(this.context.Operators, c => c.OperatorId, o => o.OperatorId, (c, + o) => new { c.ContractId, c.Description, o.OperatorId, o.Name }).ToList().Select(x => (x.ContractId, x.Description, x.OperatorId, x.Name)).ToList(); + + var query1 = this.context.Contracts.GroupJoin(this.context.ContractProducts, c => c.ContractId, cp => cp.ContractId, (c, + productGroup) => new { c.ContractId, Products = productGroup.Select(p => new { p.ContractProductReportingId, p.ContractProductId, p.ProductName, p.Value }).OrderBy(p => p.ContractProductId).Select(p => new { p.ContractProductId, p.ProductName, p.Value, p.ContractProductReportingId }).ToList() }).ToList(); + + this.contractProducts = query1.ToDictionary(item => item.ContractId, item => item.Products.Select(i => (i.ContractProductId, i.ProductName, i.Value, i.ContractProductReportingId)).ToList()); + + this.operatorsList = this.context.Operators.ToList(); + + sw.Stop(); + this.TestOutputHelper.WriteLine($"Data Caching {sw.ElapsedMilliseconds}ms"); + sw.Restart(); + } + + [Fact] + public async Task SettlementEndpoints_TodaysSettlement_SettlementReturned() + { + int overallTodaysSettlementTransactionCount = 0; + int overallTodaysPendingSettlementTransactionCount = 0; + + int overallComparisonSettlementTransactionCount = 0; + int overallComparisonPendingSettlementTransactionCount = 0; + List<(decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees)> todayOverallTotals = new(); + List<(decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees)> comparisonOverallTotals = new(); + + DateTime todaysDate = DateTime.Now; + DateTime comparisonDate = DateTime.Now.AddDays(-1); + foreach (var merchant in this.merchantsList) + { + int todaysSettlementTransactionCount = 5; + int todaysPendingSettlementTransactionCount = 9; + var contract = this.contractList.Single(c => c.operatorName == "Safaricom"); + (decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees) todayTotals = await this.helper.AddSettlementRecord(merchant.EstateId, merchant.MerchantId, contract.operatorId, todaysDate, todaysSettlementTransactionCount, todaysPendingSettlementTransactionCount); + todayOverallTotals.Add(todayTotals); + + overallTodaysSettlementTransactionCount += todaysSettlementTransactionCount; + ; + overallTodaysPendingSettlementTransactionCount += todaysPendingSettlementTransactionCount; + + int comparisonSettlementTransactionCount = 12; + int comparisonPendingSettlementTransactionCount = 15; + var comparisonTotals = await this.helper.AddSettlementRecord(merchant.EstateId, merchant.MerchantId, contract.operatorId, comparisonDate, comparisonSettlementTransactionCount, comparisonPendingSettlementTransactionCount); + comparisonOverallTotals.Add(comparisonTotals); + + overallComparisonSettlementTransactionCount += comparisonSettlementTransactionCount; + overallComparisonPendingSettlementTransactionCount += comparisonPendingSettlementTransactionCount; + } + + await this.helper.RunTodaysTransactionsSummaryProcessing(comparisonDate.Date.AddDays(-1)); + await this.helper.RunHistoricTransactionsSummaryProcessing(comparisonDate.Date.AddDays(-1)); + await this.helper.RunTodaysTransactionsSummaryProcessing(todaysDate.Date.AddDays(-1)); + await this.helper.RunSettlementSummaryProcessing(comparisonDate.Date); + + + var result = await this.CreateAndSendHttpRequestMessage($"{this.BaseRoute}/todayssettlements?comparisondate={DateTime.Now.AddDays(-1):yyyy-MM-dd}", CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + var todaysSettlement = result.Data; + todaysSettlement.ShouldNotBeNull(); + todaysSettlement.ComparisonSettlementCount.ShouldBe(overallComparisonSettlementTransactionCount); + todaysSettlement.ComparisonSettlementValue.ShouldBe(comparisonOverallTotals.Sum(c => c.settlementFees)); + todaysSettlement.ComparisonPendingSettlementCount.ShouldBe(overallComparisonPendingSettlementTransactionCount); + todaysSettlement.ComparisonPendingSettlementValue.ShouldBe(comparisonOverallTotals.Sum(c => c.pendingSettlementFees)); + + todaysSettlement.TodaysSettlementCount.ShouldBe(overallTodaysSettlementTransactionCount); + todaysSettlement.TodaysSettlementValue.ShouldBe(todayOverallTotals.Sum(c => c.settlementFees)); + todaysSettlement.TodaysPendingSettlementCount.ShouldBe(overallTodaysPendingSettlementTransactionCount); + todaysSettlement.TodaysPendingSettlementValue.ShouldBe(todayOverallTotals.Sum(c => c.pendingSettlementFees)); + } +} \ No newline at end of file diff --git a/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs b/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs index f77b983..debc0ae 100644 --- a/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs +++ b/EstateReportingAPI.IntegrationTests/TransactionsEndpointTests.cs @@ -1072,146 +1072,4 @@ public async Task TransactionsEndpoint_TodaysSalesByHour_SummaryDataReturned() } } -} - - -public class SettlmentsEndpointTests : ControllerTestsBase { - private String BaseRoute = "api/settlements"; - - public SettlmentsEndpointTests(ITestOutputHelper testOutputHelper) { - this.TestOutputHelper = testOutputHelper; - } - - - protected override async Task ClearStandingData() { - - } - - protected override async Task SetupStandingData() { - Stopwatch sw = Stopwatch.StartNew(); - this.TestOutputHelper.WriteLine("Setting up standing data"); - - // Estates - await this.helper.AddEstate("Test Estate", "Ref1"); - sw.Stop(); - this.TestOutputHelper.WriteLine($"Setup Estate {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - - // Operators - await this.helper.AddOperator("Test Estate", "Safaricom"); - await this.helper.AddOperator("Test Estate", "Voucher"); - await this.helper.AddOperator("Test Estate", "PataPawa PostPay"); - await this.helper.AddOperator("Test Estate", "PataPawa PrePay"); - - sw.Stop(); - this.TestOutputHelper.WriteLine($"Setup Operators {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - // Merchants - await this.helper.AddMerchant("Test Estate", "Test Merchant 1",100, DateTime.MinValue, DateTime.MinValue, default, default); - await this.helper.AddMerchant("Test Estate", "Test Merchant 2",100, DateTime.MinValue, DateTime.MinValue, default, default); - await this.helper.AddMerchant("Test Estate", "Test Merchant 3",100, DateTime.MinValue, DateTime.MinValue, default, default); - await this.helper.AddMerchant("Test Estate", "Test Merchant 4",100, DateTime.MinValue, DateTime.MinValue, default, default); - sw.Stop(); - this.TestOutputHelper.WriteLine($"Setup Merchants {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - - // Contracts & Products - List<(string productName, int productType, decimal? value)> safaricomProductList = new() { ("200 KES Topup", 0, 200.00m), ("100 KES Topup", 0, 100.00m), ("50 KES Topup", 0, 50.00m), ("Custom", 0, null) }; - await this.helper.AddContractWithProducts("Test Estate", "Safaricom Contract", "Safaricom", safaricomProductList); - - List<(string productName, int productType, decimal? value)> voucherProductList = new() { ("10 KES Voucher", 0, 10.00m), ("Custom", 0, null) }; - await this.helper.AddContractWithProducts("Test Estate", "Healthcare Centre 1 Contract", "Voucher", voucherProductList); - - List<(string productName, int productType, decimal? value)> postPayProductList = new() { ("Post Pay Bill Pay", 0, null) }; - await this.helper.AddContractWithProducts("Test Estate", "PataPawa PostPay Contract", "PataPawa PostPay", postPayProductList); - - List<(string productName, int productType, decimal? value)> prePayProductList = new() { ("Pre Pay Bill Pay", 0, null) }; - await this.helper.AddContractWithProducts("Test Estate", "PataPawa PrePay Contract", "PataPawa PrePay", prePayProductList); - - sw.Stop(); - this.TestOutputHelper.WriteLine($"Setup Contracts {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - - // Response Codes - await this.helper.AddResponseCode(0, "Success"); - await this.helper.AddResponseCode(1000, "Unknown Device"); - await this.helper.AddResponseCode(1001, "Unknown Estate"); - await this.helper.AddResponseCode(1002, "Unknown Merchant"); - await this.helper.AddResponseCode(1003, "No Devices Configured"); - - sw.Stop(); - this.TestOutputHelper.WriteLine($"Setup Response Codes {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - - this.merchantsList = this.context.Merchants.Select(m => m).ToList(); - - this.contractList = this.context.Contracts.Join(this.context.Operators, c => c.OperatorId, o => o.OperatorId, (c, - o) => new { c.ContractId, c.Description, o.OperatorId, o.Name }).ToList().Select(x => (x.ContractId, x.Description, x.OperatorId, x.Name)).ToList(); - - var query1 = this.context.Contracts.GroupJoin(this.context.ContractProducts, c => c.ContractId, cp => cp.ContractId, (c, - productGroup) => new { c.ContractId, Products = productGroup.Select(p => new { p.ContractProductReportingId, p.ContractProductId, p.ProductName, p.Value }).OrderBy(p => p.ContractProductId).Select(p => new { p.ContractProductId, p.ProductName, p.Value, p.ContractProductReportingId }).ToList() }).ToList(); - - this.contractProducts = query1.ToDictionary(item => item.ContractId, item => item.Products.Select(i => (i.ContractProductId, i.ProductName, i.Value, i.ContractProductReportingId)).ToList()); - - this.operatorsList = this.context.Operators.ToList(); - - sw.Stop(); - this.TestOutputHelper.WriteLine($"Data Caching {sw.ElapsedMilliseconds}ms"); - sw.Restart(); - } - - [Fact] - public async Task SettlementEndpoints_TodaysSettlement_SettlementReturned() - { - int overallTodaysSettlementTransactionCount = 0; - int overallTodaysPendingSettlementTransactionCount = 0; - - int overallComparisonSettlementTransactionCount = 0; - int overallComparisonPendingSettlementTransactionCount = 0; - List<(decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees)> todayOverallTotals = new(); - List<(decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees)> comparisonOverallTotals = new(); - - DateTime todaysDate = DateTime.Now; - DateTime comparisonDate = DateTime.Now.AddDays(-1); - foreach (var merchant in merchantsList) - { - int todaysSettlementTransactionCount = 5; - int todaysPendingSettlementTransactionCount = 9; - var contract = this.contractList.Single(c => c.operatorName == "Safaricom"); - (decimal settledTransactions, decimal pendingSettlementTransactions, decimal settlementFees, decimal pendingSettlementFees) todayTotals = await helper.AddSettlementRecord(merchant.EstateId, merchant.MerchantId, contract.operatorId, todaysDate, todaysSettlementTransactionCount, todaysPendingSettlementTransactionCount); - todayOverallTotals.Add(todayTotals); - - overallTodaysSettlementTransactionCount += todaysSettlementTransactionCount; - ; - overallTodaysPendingSettlementTransactionCount += todaysPendingSettlementTransactionCount; - - int comparisonSettlementTransactionCount = 12; - int comparisonPendingSettlementTransactionCount = 15; - var comparisonTotals = await helper.AddSettlementRecord(merchant.EstateId, merchant.MerchantId, contract.operatorId, comparisonDate, comparisonSettlementTransactionCount, comparisonPendingSettlementTransactionCount); - comparisonOverallTotals.Add(comparisonTotals); - - overallComparisonSettlementTransactionCount += comparisonSettlementTransactionCount; - overallComparisonPendingSettlementTransactionCount += comparisonPendingSettlementTransactionCount; - } - - await helper.RunTodaysTransactionsSummaryProcessing(comparisonDate.Date.AddDays(-1)); - await helper.RunHistoricTransactionsSummaryProcessing(comparisonDate.Date.AddDays(-1)); - await helper.RunTodaysTransactionsSummaryProcessing(todaysDate.Date.AddDays(-1)); - await helper.RunSettlementSummaryProcessing(comparisonDate.Date); - - - var result = await this.CreateAndSendHttpRequestMessage($"{this.BaseRoute}/todayssettlements?comparisondate={DateTime.Now.AddDays(-1):yyyy-MM-dd}", CancellationToken.None); - result.IsSuccess.ShouldBeTrue(); - var todaysSettlement = result.Data; - todaysSettlement.ShouldNotBeNull(); - todaysSettlement.ComparisonSettlementCount.ShouldBe(overallComparisonSettlementTransactionCount); - todaysSettlement.ComparisonSettlementValue.ShouldBe(comparisonOverallTotals.Sum(c => c.settlementFees)); - todaysSettlement.ComparisonPendingSettlementCount.ShouldBe(overallComparisonPendingSettlementTransactionCount); - todaysSettlement.ComparisonPendingSettlementValue.ShouldBe(comparisonOverallTotals.Sum(c => c.pendingSettlementFees)); - - todaysSettlement.TodaysSettlementCount.ShouldBe(overallTodaysSettlementTransactionCount); - todaysSettlement.TodaysSettlementValue.ShouldBe(todayOverallTotals.Sum(c => c.settlementFees)); - todaysSettlement.TodaysPendingSettlementCount.ShouldBe(overallTodaysPendingSettlementTransactionCount); - todaysSettlement.TodaysPendingSettlementValue.ShouldBe(todayOverallTotals.Sum(c => c.pendingSettlementFees)); - } -} +} \ No newline at end of file diff --git a/EstateReportingAPI.Models/FileDetails.cs b/EstateReportingAPI.Models/FileDetails.cs new file mode 100644 index 0000000..5f502d1 --- /dev/null +++ b/EstateReportingAPI.Models/FileDetails.cs @@ -0,0 +1,14 @@ +namespace EstateReportingAPI.Models; + +public class FileDetails +{ + public Guid FileId { get; set; } + public string FileName { get; set; } + public string FileProfile { get; set; } + public DateTime DateTimeUploaded { get; set; } + public Guid UserId { get; set; } + public string UploadedBy { get; set; } + public Guid MerchantId { get; set; } + public string MerchantName { get; set; } + public List FileLines { get; set; } = new List(); +} \ No newline at end of file diff --git a/EstateReportingAPI.Models/FileImportLog.cs b/EstateReportingAPI.Models/FileImportLog.cs new file mode 100644 index 0000000..f25ebe9 --- /dev/null +++ b/EstateReportingAPI.Models/FileImportLog.cs @@ -0,0 +1,8 @@ +namespace EstateReportingAPI.Models; + +public class FileImportLog +{ + public Guid FileImportLogId { get; set; } + public DateTime ImportLogDateTime { get; set; } + public List FileDetailsList { get; set; } +} \ No newline at end of file diff --git a/EstateReportingAPI.Models/FileLine.cs b/EstateReportingAPI.Models/FileLine.cs new file mode 100644 index 0000000..19394fd --- /dev/null +++ b/EstateReportingAPI.Models/FileLine.cs @@ -0,0 +1,8 @@ +namespace EstateReportingAPI.Models; + +public sealed class FileLine +{ + public int LineNumber { get; set; } + public string LineContents { get; set; } + public String LineStatus { get; set; } +} \ No newline at end of file diff --git a/EstateReportingAPI.Models/TransactionSummaryByOperatorResponse.cs b/EstateReportingAPI.Models/TransactionSummaryByOperatorResponse.cs index 8144ab1..d7f096c 100644 --- a/EstateReportingAPI.Models/TransactionSummaryByOperatorResponse.cs +++ b/EstateReportingAPI.Models/TransactionSummaryByOperatorResponse.cs @@ -5,4 +5,3 @@ public class TransactionSummaryByOperatorResponse public List Operators { get; set; } public OperatorDetailSummary Summary { get; set; } } - diff --git a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs index d14363b..98741d7 100644 --- a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs +++ b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs @@ -20,7 +20,7 @@ public class MiddlewareRegistry : ServiceRegistry{ public MiddlewareRegistry() { this.ConfigureHealthChecks(); - this.ConfigureSwagger(); + //this.ConfigureSwagger(); this.ConfigureAuthentication(); this.ConfigureControllers(); this.ConfigureMiddlewareLogging(); diff --git a/EstateReportingAPI/Endpoints/FileImportLogEndpoints.cs b/EstateReportingAPI/Endpoints/FileImportLogEndpoints.cs new file mode 100644 index 0000000..84c78f2 --- /dev/null +++ b/EstateReportingAPI/Endpoints/FileImportLogEndpoints.cs @@ -0,0 +1,24 @@ +using EstateReportingAPI.DataTransferObjects; +using EstateReportingAPI.Handlers; +using Shared.Extensions; +using Shared.General; + +namespace EstateReportingAPI.Endpoints; + +public static class FileImportLogEndpoints +{ + private const string BaseRoute = "api/fileimportlogs"; + + public static void MapFileImportLogEndpoints(this IEndpointRouteBuilder app) + { + RouteGroupBuilder group = app.MapGroup(BaseRoute).WithTags("File Import Logs"); + + Boolean disableAuthorisation = ConfigurationReader.GetValueOrDefault("AppSettings", "DisableAuthorisation", false); + if (disableAuthorisation == false) + { + group = group.RequireAuthorization(); + } + + group.MapGet("", FileImportHandler.GetFileImportLogList).WithStandardProduces>(); + } +} \ No newline at end of file diff --git a/EstateReportingAPI/Endpoints/SettlementEndpoints.cs b/EstateReportingAPI/Endpoints/SettlementEndpoints.cs new file mode 100644 index 0000000..7860f4c --- /dev/null +++ b/EstateReportingAPI/Endpoints/SettlementEndpoints.cs @@ -0,0 +1,21 @@ +using EstateReportingAPI.DataTransferObjects; +using EstateReportingAPI.Handlers; +using Shared.Extensions; +using Shared.General; + +namespace EstateReportingAPI.Endpoints; + +public static class SettlementEndpoints { + private const string BaseRoute = "api/settlements"; + + public static void MapSettlementEndpoints(this IEndpointRouteBuilder app) { + RouteGroupBuilder group = app.MapGroup(BaseRoute).WithTags("Settlements"); + + Boolean disableAuthorisation = ConfigurationReader.GetValueOrDefault("AppSettings", "DisableAuthorisation", false); + if (disableAuthorisation == false) { + group = group.RequireAuthorization(); + } + + group.MapGet("todayssettlements", SettlementHandler.TodaysSettlements).WithStandardProduces(); + } +} \ No newline at end of file diff --git a/EstateReportingAPI/Endpoints/TransactionEndpoints.cs b/EstateReportingAPI/Endpoints/TransactionEndpoints.cs index e30d225..245cb21 100644 --- a/EstateReportingAPI/Endpoints/TransactionEndpoints.cs +++ b/EstateReportingAPI/Endpoints/TransactionEndpoints.cs @@ -5,21 +5,6 @@ namespace EstateReportingAPI.Endpoints; -public static class SettlementEndpoints { - private const string BaseRoute = "api/settlements"; - - public static void MapSettlementEndpoints(this IEndpointRouteBuilder app) { - RouteGroupBuilder group = app.MapGroup(BaseRoute).WithTags("Settlements"); - - Boolean disableAuthorisation = ConfigurationReader.GetValueOrDefault("AppSettings", "DisableAuthorisation", false); - if (disableAuthorisation == false) { - group = group.RequireAuthorization(); - } - - group.MapGet("todayssettlements", SettlementHandler.TodaysSettlements).WithStandardProduces(); - } -} - public static class TransactionEndpoints { private const string BaseRoute = "api/transactions"; diff --git a/EstateReportingAPI/Handlers/FileImportHandler.cs b/EstateReportingAPI/Handlers/FileImportHandler.cs new file mode 100644 index 0000000..4d79bbe --- /dev/null +++ b/EstateReportingAPI/Handlers/FileImportHandler.cs @@ -0,0 +1,43 @@ +using EstateReportingAPI.BusinessLogic.Queries; +using EstateReportingAPI.Models; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using Shared.Results.Web; +using SimpleResults; + +namespace EstateReportingAPI.Handlers; + +public static class FileImportHandler +{ + public static async Task GetFileImportLogList([FromHeader] Guid estateId, + [FromQuery] Guid? merchantId, + [FromQuery] DateTime startDate, + [FromQuery] DateTime endDate, + IMediator mediator, + CancellationToken cancellationToken) + { + FileImportLogQueries.GetFileImportLogListQuery query = new(estateId, merchantId, startDate, endDate); + Result> result = await mediator.Send(query, cancellationToken); + + return ResponseFactory.FromResult(result, r => r.Select(m => new DataTransferObjects.FileImportLog + { + FileImportLogId = m.FileImportLogId, + ImportLogDateTime = m.ImportLogDateTime, + FileDetailsList = m.FileDetailsList.Select(fd => new DataTransferObjects.FileDetails { + DateTimeUploaded = fd.DateTimeUploaded, + FileId = fd.FileId, + FileName = fd.FileName, + FileProfile = fd.FileProfile, + MerchantId = fd.MerchantId, + MerchantName = fd.MerchantName, + UploadedBy = fd.UploadedBy, + UserId = fd.UserId, + FileLines = fd.FileLines.Select(fl => new DataTransferObjects.FileLine { + LineContents = fl.LineContents, + LineNumber = fl.LineNumber, + LineStatus = fl.LineStatus + }).ToList() + }).ToList() + }).ToList()); + } +} \ No newline at end of file diff --git a/EstateReportingAPI/Handlers/SettlementHandler.cs b/EstateReportingAPI/Handlers/SettlementHandler.cs new file mode 100644 index 0000000..044fba6 --- /dev/null +++ b/EstateReportingAPI/Handlers/SettlementHandler.cs @@ -0,0 +1,28 @@ +using EstateReportingAPI.BusinessLogic.Queries; +using EstateReportingAPI.DataTransferObjects; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using Shared.Results.Web; + +namespace EstateReportingAPI.Handlers; + +public static class SettlementHandler { + public static async Task TodaysSettlements([FromHeader] Guid estateId, + [FromQuery] DateTime comparisonDate, + IMediator mediator, + CancellationToken cancellationToken) { + var query = new SettlementQueries.TodaysSettlementQuery(estateId, comparisonDate); + var result = await mediator.Send(query, cancellationToken); + + return ResponseFactory.FromResult(result, r => new TodaysSettlement() { + ComparisonPendingSettlementCount = r.ComparisonPendingSettlementCount, + ComparisonPendingSettlementValue = r.ComparisonPendingSettlementValue, + ComparisonSettlementCount = r.ComparisonSettlementCount, + ComparisonSettlementValue = r.ComparisonSettlementValue, + TodaysPendingSettlementCount = r.TodaysPendingSettlementCount, + TodaysPendingSettlementValue = r.TodaysPendingSettlementValue, + TodaysSettlementCount = r.TodaysSettlementCount, + TodaysSettlementValue = r.TodaysSettlementValue + }); + } +} \ No newline at end of file diff --git a/EstateReportingAPI/Handlers/TransactionHandler.cs b/EstateReportingAPI/Handlers/TransactionHandler.cs index 7037c6c..328ce9f 100644 --- a/EstateReportingAPI/Handlers/TransactionHandler.cs +++ b/EstateReportingAPI/Handlers/TransactionHandler.cs @@ -7,27 +7,6 @@ namespace EstateReportingAPI.Handlers; -public static class SettlementHandler { - public static async Task TodaysSettlements([FromHeader] Guid estateId, - [FromQuery] DateTime comparisonDate, - IMediator mediator, - CancellationToken cancellationToken) { - var query = new SettlementQueries.TodaysSettlementQuery(estateId, comparisonDate); - var result = await mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, r => new TodaysSettlement() { - ComparisonPendingSettlementCount = r.ComparisonPendingSettlementCount, - ComparisonPendingSettlementValue = r.ComparisonPendingSettlementValue, - ComparisonSettlementCount = r.ComparisonSettlementCount, - ComparisonSettlementValue = r.ComparisonSettlementValue, - TodaysPendingSettlementCount = r.TodaysPendingSettlementCount, - TodaysPendingSettlementValue = r.TodaysPendingSettlementValue, - TodaysSettlementCount = r.TodaysSettlementCount, - TodaysSettlementValue = r.TodaysSettlementValue - }); - } -} - public static class TransactionHandler { public static async Task TodaysSales([FromHeader] Guid estateId, [FromQuery] int? merchantReportingId, diff --git a/EstateReportingAPI/Properties/launchSettings.json b/EstateReportingAPI/Properties/launchSettings.json index 97e5211..54aaf46 100644 --- a/EstateReportingAPI/Properties/launchSettings.json +++ b/EstateReportingAPI/Properties/launchSettings.json @@ -2,18 +2,13 @@ "profiles": { "EstateReporting": { "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "dotnetRunMessages": true, - "applicationUrl": "http://localhost:5011" + "dotnetRunMessages": true, }, "Docker": { "commandName": "Docker", - "launchBrowser": true, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", "environmentVariables": { "ASPNETCORE_URLS": "https://+:443;http://+:80" }, diff --git a/EstateReportingAPI/Startup.cs b/EstateReportingAPI/Startup.cs index 5549428..86a09bf 100644 --- a/EstateReportingAPI/Startup.cs +++ b/EstateReportingAPI/Startup.cs @@ -71,6 +71,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF endpoints.MapContractEndpoints(); endpoints.MapTransactionEndpoints(); endpoints.MapSettlementEndpoints(); + endpoints.MapFileImportLogEndpoints(); endpoints.MapHealthChecks("health", new HealthCheckOptions() { @@ -83,9 +84,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); }); - app.UseSwagger(); + //app.UseSwagger(); - app.UseSwaggerUI(); + //app.UseSwaggerUI(); } } } \ No newline at end of file