Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.DynamicLinq" Version="8.3.10" />
<PackageReference Include="Shared" Version="2024.4.3" />
<PackageReference Include="EstateManagement.Database" Version="2024.5.1" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
909 changes: 491 additions & 418 deletions EstateReportingAPI.BusinessLogic/ReportingManager.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion EstateReportingAPI.Client/EstateReportingAPI.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2024.4.2" />
<PackageReference Include="ClientProxyBase" Version="2024.5.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion EstateReportingAPI.IntegrationTests/ControllerTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public virtual async Task InitializeAsync()
this.context = new EstateManagementSqlServerContext(GetLocalConnectionString($"EstateReportingReadModel{this.TestId.ToString()}"));

this.helper = new DatabaseHelper(context);

await this.helper.CreateStoredProcedures(CancellationToken.None);
await this.SetupStandingData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)

containerBuilder.AddAuthentication(TestAuthHandler.AuthenticationScheme)
.AddScheme<TestAuthHandlerOptions, TestAuthHandler>(TestAuthHandler.AuthenticationScheme, options => { });

bool b = context.Database.EnsureCreated();

b.ShouldBeTrue();
});

Expand Down
253 changes: 156 additions & 97 deletions EstateReportingAPI.IntegrationTests/DatabaseHelper.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,7 @@ public async Task DimensionsController_GetOperators_OperatorsReturned(ClientType
Int32 operator1ReportingId = await this.helper.AddOperator("Test Estate", "Operator1");
Int32 operator2ReportingId = await this.helper.AddOperator("Test Estate", "Operator2");
Int32 operator3ReportingId = await this.helper.AddOperator("Test Estate", "Operator3");

await helper.AddEstateOperator("Test Estate", operator1ReportingId);
await helper.AddEstateOperator("Test Estate", operator2ReportingId);
await helper.AddEstateOperator("Test Estate", operator3ReportingId);


Func<Task<List<Operator>?>> asyncFunction = async () =>
{
List<Operator>? result = clientType switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
Expand All @@ -23,12 +23,12 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Shared" Version="2024.4.3" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.4.2" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.5.1" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="SecurityService.Client" Version="2024.3.2-build59" />
<PackageReference Include="SecurityService.Client" Version="2024.5.1" />

</ItemGroup>

Expand All @@ -38,9 +38,22 @@
</ItemGroup>

<ItemGroup>
<None Update="StoredProcedures\spBuildHistoricTransactions.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="StoredProcedures\spBuildSettlementSummary.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="StoredProcedures\spBuildTodaysTransactions.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Folder Include="StoredProcedures\" />
</ItemGroup>

</Project>
139 changes: 69 additions & 70 deletions EstateReportingAPI.IntegrationTests/FactSettlementsControllerTests.cs

Large diffs are not rendered by default.

147 changes: 109 additions & 38 deletions EstateReportingAPI.IntegrationTests/FactTransactionsControllerTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CREATE OR ALTER PROCEDURE [dbo].[spBuildHistoricTransactions] @date date
AS

insert into TransactionHistory(MerchantReportingId, ContractProductReportingId,ContractReportingId,OperatorReportingId,
TransactionId,
AuthorisationCode,
DeviceIdentifier,
IsAuthorised,
IsCompleted,
ResponseCode,
ResponseMessage,
TransactionDate,
TransactionDateTime,
TransactionNumber,
TransactionReference,
TransactionTime,
TransactionSource,
TransactionType,
TransactionReportingId,
TransactionAmount,
Hour)
select t.MerchantReportingId,
t.ContractProductReportingId,
t.ContractReportingId,
t.OperatorReportingId,
t.TransactionId,
t.AuthorisationCode,
t.DeviceIdentifier,
t.IsAuthorised,
t.IsCompleted,
t.ResponseCode,
t.ResponseMessage,
t.TransactionDate,
t.TransactionDateTime,
t.TransactionNumber,
t.TransactionReference,
t.TransactionTime,
t.TransactionSource,
t.TransactionType,
t.TransactionReportingId,
t.TransactionAmount,
t.Hour
from TodayTransactions t
where t.TransactionDate = @date

delete from TodayTransactions where TransactionDate = @date
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE OR ALTER PROCEDURE [dbo].[spBuildSettlementSummary] @date date
AS

declare @weekNumber int
declare @yearnumber int
declare @startDate date
declare @enddate date

SELECT @weekNumber = WeekNumber, @yearnumber = year from calendar where date = @date

SELECT @startDate = min(date), @enddate = max(date) from calendar where WeekNumber = @weekNumber and Year = @yearnumber and date < convert(date,getdate())

delete from settlementsummary where settlementdate BETWEEN @startDate and @enddate

insert into settlementsummary(IsCompleted, IsSettled, SettlementDate, merchantreportingid, operatorreportingid, contractproductreportingid,
salesvalue,feevalue, salescount, feecount)
select settlement.IsCompleted, IsSettled, SettlementDate, merchant.merchantreportingid, operator.operatorreportingid, contractproduct.contractproductreportingid,
sum([transaction].TransactionAmount) as salesvalue,sum(merchantsettlementfee.CalculatedValue) as feevalue,
count([transaction].TransactionAmount) as salescount, count(merchantsettlementfee.CalculatedValue) as feecount
from settlement
inner join merchantsettlementfee on merchantsettlementfee.SettlementId = settlement.SettlementId
inner join [transaction] on [transaction].TransactionId = merchantsettlementfee.TransactionId
inner join contractproducttransactionfee on contractproducttransactionfee.ContractProductTransactionFeeId = merchantsettlementfee.ContractProductTransactionFeeId
inner join contractproduct on contractproducttransactionfee.ContractProductId = contractproduct.ContractProductId
inner join contract on contract.ContractId = contractproduct.ContractId
inner join merchant on merchant.MerchantId = merchantsettlementfee.MerchantId
inner join estate on estate.EstateId = merchant.EstateId
inner join operator on operator.OperatorId = contract.OperatorId
where settlementdate BETWEEN @startDate and @enddate
group by settlement.IsCompleted, IsSettled, SettlementDate, merchant.merchantreportingid, operator.operatorreportingid, contractproduct.contractproductreportingid
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
CREATE OR ALTER PROCEDURE [dbo].[spBuildTodaysTransactions] @date date
AS

insert into TodayTransactions(MerchantReportingId, ContractProductReportingId,ContractReportingId,OperatorReportingId,
TransactionId,
AuthorisationCode,
DeviceIdentifier,
IsAuthorised,
IsCompleted,
ResponseCode,
ResponseMessage,
TransactionDate,
TransactionDateTime,
TransactionNumber,
TransactionReference,
TransactionTime,
TransactionSource,
TransactionType,
TransactionReportingId,
TransactionAmount,
Hour)
select merchant.MerchantReportingId,
ISNULL(contractproduct.ContractProductReportingId,0) as ContractProductReportingId,
ISNULL(contract.ContractReportingId,0) as ContractReportingId,
ISNULL(operator.OperatorReportingId,0) as OperatorReportingId,
t.TransactionId,
ISNULL(t.AuthorisationCode,'') as AuthorisationCode,
t.DeviceIdentifier,
t.IsAuthorised,
t.IsCompleted,
t.ResponseCode,
t.ResponseMessage,
t.TransactionDate,
t.TransactionDateTime,
t.TransactionNumber,
t.TransactionReference,
t.TransactionTime,
t.TransactionSource,
t.TransactionType,
t.TransactionReportingId,
t.TransactionAmount,
DATEPART(HH, t.transactiondatetime) as Hour
from [transaction] t
inner join merchant on merchant.MerchantId = t.MerchantId
left outer join contractproduct on contractproduct.ContractProductId = t.ContractProductId
left outer join contract on contract.ContractId = t.ContractId
left outer join operator on operator.OperatorId= t.OperatorId
where transactiondate = @date
and TransactionReportingId not in (select distinct TransactionReportingId from TodayTransactions)
4 changes: 3 additions & 1 deletion EstateReportingAPI/Controllers/FactTransactionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public async Task<IActionResult> TodaysFailedSales([FromHeader] Guid estateId, G
ComparisonSalesCount = model.ComparisonSalesCount,
ComparisonSalesValue = model.ComparisonSalesValue,
TodaysSalesCount = model.TodaysSalesCount,
TodaysSalesValue = model.TodaysSalesValue
TodaysSalesValue = model.TodaysSalesValue,
ComparisonAverageSalesValue = model.ComparisonAverageSalesValue,
TodaysAverageSalesValue = model.TodaysAverageSalesValue
};

return this.Ok(response);
Expand Down
4 changes: 2 additions & 2 deletions EstateReportingAPI/EstateReportingAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
Expand All @@ -19,7 +19,7 @@
<PackageReference Include="Lamar" Version="13.0.3" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="13.0.3" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="Shared" Version="2024.4.3" />
<PackageReference Include="Shared" Version="2024.5.1" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
Expand Down