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
14 changes: 12 additions & 2 deletions EstateReportingAPI.BusinessLogic/ReportingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ from o in ops.DefaultIfEmpty()
CancellationToken cancellationToken) {
var productsQuery = context.ContractProducts.Where(cp => cp.ContractId == contractId).Select(cp => new {
cp.ContractProductId,
cp.ContractProductReportingId,
cp.ContractId,
cp.DisplayText,
cp.ProductName,
Expand All @@ -305,6 +306,7 @@ from o in ops.DefaultIfEmpty()
var feesQuery = context.ContractProductTransactionFees.Where(tf => productIds.Contains(tf.ContractProductId)).Select(tf => new {
tf.CalculationType,
tf.ContractProductTransactionFeeId,
tf.ContractProductTransactionFeeReportingId,
tf.FeeType,
tf.Value,
tf.ContractProductId,
Expand All @@ -326,12 +328,14 @@ from o in ops.DefaultIfEmpty()
ProductName = p.ProductName,
ProductType = p.ProductType,
Value = p.Value,
ContractProductReportingId = p.ContractProductReportingId,
TransactionFees = feesLookup[p.ContractProductId].Select(f => new ContractProductTransactionFee {
Description = f.Description,
Value = f.Value,
CalculationType = f.CalculationType,
FeeType = f.FeeType,
TransactionFeeId = f.ContractProductTransactionFeeId
TransactionFeeId = f.ContractProductTransactionFeeId,
ContractProductTransactionFeeReportingId = f.ContractProductTransactionFeeReportingId
}).ToList()
}).ToList());
}
Expand Down Expand Up @@ -1364,6 +1368,7 @@ private static async Task<Result<List<ContractProductData>>> LoadProductsAsync(E
string stepName) {
var query = context.ContractProducts.Where(cp => contractIds.Contains(cp.ContractId)).Select(cp => new ContractProductData {
ContractProductId = cp.ContractProductId,
ContractProductReportingId = cp.ContractProductReportingId,
ContractId = cp.ContractId,
DisplayText = cp.DisplayText,
ProductName = cp.ProductName,
Expand All @@ -1379,6 +1384,7 @@ private static async Task<Result<List<ContractFeeData>>> LoadFeesAsync(EstateMan
string stepName) {
var query = context.ContractProductTransactionFees.Where(tf => productIds.Contains(tf.ContractProductId)).Select(tf => new ContractFeeData {
ContractProductTransactionFeeId = tf.ContractProductTransactionFeeId,
ContractProducTransactionFeeReportingId = tf.ContractProductTransactionFeeReportingId,
ContractProductId = tf.ContractProductId,
Description = tf.Description,
CalculationType = tf.CalculationType,
Expand All @@ -1402,6 +1408,7 @@ private static List<Contract> BuildContracts(List<ContractBaseData> baseContract
Products = products.Where(p => p.ContractId == b.ContractId).Select(p => new Models.ContractProduct {
ContractId = p.ContractId,
ProductId = p.ContractProductId,
ContractProductReportingId = p.ContractProductReportingId,
DisplayText = p.DisplayText,
ProductName = p.ProductName,
ProductType = p.ProductType,
Expand All @@ -1411,7 +1418,8 @@ private static List<Contract> BuildContracts(List<ContractBaseData> baseContract
Value = f.Value,
CalculationType = f.CalculationType,
FeeType = f.FeeType,
TransactionFeeId = f.ContractProductTransactionFeeId
TransactionFeeId = f.ContractProductTransactionFeeId,
ContractProductTransactionFeeReportingId = f.ContractProducTransactionFeeReportingId
}).ToList()
}).ToList()
}).ToList();
Expand Down Expand Up @@ -1496,6 +1504,7 @@ private sealed class ContractBaseData {

private sealed class ContractProductData {
public Guid ContractProductId { get; init; }
public int ContractProductReportingId { get; init; }
public Guid ContractId { get; init; }
public string? DisplayText { get; init; }
public string? ProductName { get; init; }
Expand All @@ -1505,6 +1514,7 @@ private sealed class ContractProductData {

private sealed class ContractFeeData {
public Guid ContractProductTransactionFeeId { get; init; }
public int ContractProducTransactionFeeReportingId { get; init; }
public Guid ContractProductId { get; init; }
public string? Description { get; init; }
public int CalculationType { get; init; }
Expand Down
6 changes: 6 additions & 0 deletions EstateReportingAPI.DataTrasferObjects/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class ContractProduct
{
[JsonProperty("contract_id")]
public Guid ContractId { get; set; }
[JsonProperty("contract_product_reporting_id")]
public Int32 ContractProductReportingId { get; set; }

[JsonProperty("product_id")]
public Guid ProductId { get; set; }
[JsonProperty("product_name")]
Expand All @@ -49,6 +52,9 @@ public class ContractProduct
public class ContractProductTransactionFee {
[JsonProperty("transaction_fee_id")]
public Guid TransactionFeeId { get; set; }
[JsonProperty("contract_product_transaction_fee_reporting_id")]
public Int32 ContractProductTransactionFeeReportingId { get; set; }

[JsonProperty("description")]
public string? Description { get; set; }
[JsonProperty("calculation_type")]
Expand Down
9 changes: 7 additions & 2 deletions EstateReportingAPI.IntegrationTests/ContractEndPointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public async Task ContractEndpoint_GetContracts_ContractsReturned() {
contracts.SingleOrDefault(c => c.Description == "Healthcare Centre 1 Contract").ShouldNotBeNull();
contracts.SingleOrDefault(c => c.Description == "PataPawa PostPay Contract").ShouldNotBeNull();
contracts.SingleOrDefault(c => c.Description == "PataPawa PrePay Contract").ShouldNotBeNull();

foreach (Contract contract in contracts) {
contract.Products.Any(cp => cp.ContractProductReportingId != 0).ShouldBeTrue();
contract.Products.ToList().ForEach(cp => cp.TransactionFees.Any(t => t.ContractProductTransactionFeeReportingId != 0).ShouldBeTrue());
}
}

[Fact]
Expand Down Expand Up @@ -111,7 +114,9 @@ public async Task ContractEndpoint_GetContract_ContractReturned() {
Contract contract = result.Data;
contract.ShouldNotBeNull();
contract.Description.ShouldBe("PataPawa PrePay Contract");

contract.ContractReportingId.ShouldNotBe(0);
contract.Products.Any(cp => cp.ContractProductReportingId != 0).ShouldBeTrue();
contract.Products.ToList().ForEach(cp => cp.TransactionFees.Any(t => t.ContractProductTransactionFeeReportingId != 0).ShouldBeTrue());
}

protected override async Task ClearStandingData() {
Expand Down
1 change: 1 addition & 0 deletions EstateReportingAPI.Models/ContractProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class ContractProduct
{ public Guid ContractId { get; set; }
public Guid ProductId { get; set; }
public Int32 ContractProductReportingId { get; set; }
public String ProductName { get; set; }
public String DisplayText { get; set; }
public Int32 ProductType { get; set; }
Expand Down
1 change: 1 addition & 0 deletions EstateReportingAPI.Models/ContractProductTransactionFee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class ContractProductTransactionFee
{
public Int32 ContractProductTransactionFeeReportingId { get; set; }
public Guid TransactionFeeId { get; set; }
public string? Description { get; set; }
public Int32 CalculationType { get; set; }
Expand Down
8 changes: 6 additions & 2 deletions EstateReportingAPI/Handlers/ContractHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ public static async Task<IResult> GetContracts([FromHeader] Guid estateId,
ProductName = p.ProductName,
ProductType = p.ProductType,
Value = p.Value,
ContractProductReportingId = p.ContractProductReportingId,
TransactionFees = p.TransactionFees.Select(f => new DataTransferObjects.ContractProductTransactionFee {
Description = f.Description,
Value = f.Value,
CalculationType = f.CalculationType,
FeeType = f.FeeType,
TransactionFeeId = f.TransactionFeeId
TransactionFeeId = f.TransactionFeeId,
ContractProductTransactionFeeReportingId = f.ContractProductTransactionFeeReportingId
}).ToList()
}).ToList()
}).ToList());
Expand Down Expand Up @@ -87,13 +89,15 @@ public static async Task<IResult> GetContract([FromHeader] Guid estateId,
ProductName = p.ProductName,
ProductType = p.ProductType,
Value = p.Value,
ContractProductReportingId = p.ContractProductReportingId,
TransactionFees = p.TransactionFees.Select(f => new DataTransferObjects.ContractProductTransactionFee
{
Description = f.Description,
Value = f.Value,
CalculationType = f.CalculationType,
FeeType = f.FeeType,
TransactionFeeId = f.TransactionFeeId
TransactionFeeId = f.TransactionFeeId,
ContractProductTransactionFeeReportingId = f.ContractProductTransactionFeeReportingId
}).ToList()
}).ToList()
});
Expand Down
Loading