Skip to content
Closed
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 @@ -23,5 +23,7 @@ public class ComplianceSchemeMemberRequest

public int NumberOfSubsidiaries { get; set; }

public int NumberOfLateSubsidiaries { get; set; }

public int NoOfSubsidiariesOnlineMarketplace { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CsoMembershipDetailsDto
public bool IsOnlineMarketPlace { get; set; }
public bool IsLateFeeApplicable { get; set; }
public int NumberOfSubsidiaries { get; set; }
public int NumberOfLateSubsidiaries { get; set; }

[JsonPropertyName("NumberOfSubsidiariesOnlineMarketPlace")]
public int NoOfSubsidiariesOnlineMarketplace { get; set; }
Expand All @@ -23,6 +24,7 @@ public class CsoMembershipDetailsDto
IsOnlineMarketplace = dto.IsOnlineMarketPlace,
IsLateFeeApplicable = dto.IsLateFeeApplicable,
NoOfSubsidiariesOnlineMarketplace = dto.NoOfSubsidiariesOnlineMarketplace,
NumberOfSubsidiaries = dto.NumberOfSubsidiaries
NumberOfSubsidiaries = dto.NumberOfSubsidiaries,
NumberOfLateSubsidiaries = dto.NumberOfLateSubsidiaries
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ProducerDetailsDto

public int NoOfSubsidiaries { get; set; }

public int NoOfLateSubsidiaries { get; set; }

public bool IsLateFeeApplicable { get; set; }

public bool IsProducerOnlineMarketplace { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class RegistrationSubmissionOrganisationDetailsResponse
public bool IsOnlineMarketPlace { get; set; }
public int NumberOfSubsidiaries { get; set; }
public int NumberOfOnlineSubsidiaries { get; set; }
public int NumberOfLateSubsidiaries { get; set; }
public bool IsLateSubmission { get; set; }
public string OrganisationSize { get; set; }
public bool IsComplianceScheme { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ProducerPaymentRequest

public int NumberOfSubsidiaries { get; set; }

public int NoOfLateSubsidiaries { get; set; }

public bool IsLateFeeApplicable { get; set; }

public bool IsProducerOnlineMarketplace { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static implicit operator RegistrationSubmissionOrganisationDetails(Regist
IsProducerOnlineMarketplace = response.IsOnlineMarketPlace,
NoOfSubsidiaries = response.NumberOfSubsidiaries,
NoOfSubsidiariesOnlineMarketPlace = response.NumberOfOnlineSubsidiaries,
NoOfLateSubsidiaries = response.NumberOfLateSubsidiaries,
ProducerType = response.OrganisationSize
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public class PackagingProducerPaymentRequest
public required string Regulator { get; set; }

public required DateTime ResubmissionDate { get; set; }

public required int MemberCount { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using EPR.RegulatorService.Frontend.Core.Sessions;
using EPR.RegulatorService.Frontend.UnitTests.TestData;
using EPR.RegulatorService.Frontend.Web.Constants;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using EPR.RegulatorService.Frontend.Web.ViewModels.Submissions;
using EPR.RegulatorService.Frontend.UnitTests.TestData;
using EPR.RegulatorService.Frontend.Core.Models.Submissions;

using Microsoft.AspNetCore.Http;

namespace EPR.RegulatorService.Frontend.UnitTests.Web.Controllers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using EPR.RegulatorService.Frontend.Core.Models.Submissions;
using EPR.RegulatorService.Frontend.Core.Services;
using EPR.RegulatorService.Frontend.Web.Configs;
using EPR.RegulatorService.Frontend.Web.ViewComponents.Submissions;
using EPR.RegulatorService.Frontend.Web.ViewModels.Submissions;

using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.FeatureManagement;

namespace EPR.RegulatorService.Frontend.UnitTests.Web.ViewComponents;

Expand All @@ -18,6 +15,7 @@ public class PackagingProducerPaymentDetailsViewComponentTests : ViewComponentsT
private readonly Mock<IPaymentFacadeService> _paymentFacadeServiceMock = new();
private readonly Mock<ILogger<PackagingProducerPaymentDetailsViewComponent>> _loggerMock = new();
private readonly Mock<IOptions<PaymentDetailsOptions>> _paymentDetailsOptionsMock = new();
private readonly Mock<IFeatureManager> _mockFeatureManager = new();

[TestInitialize]
public void TestInitialize()
Expand All @@ -29,7 +27,15 @@ public void TestInitialize()
};
_loggerMock.Setup(x => x.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
_paymentDetailsOptionsMock.Setup(r => r.Value).Returns(new PaymentDetailsOptions());
_sut = new PackagingProducerPaymentDetailsViewComponent(_paymentDetailsOptionsMock.Object, _paymentFacadeServiceMock.Object, _loggerMock.Object);
_mockFeatureManager.Setup(fm =>
fm.IsEnabledAsync(FeatureFlags.IncludeSubsidiariesInFeeCalculationsForRegulators))
.ReturnsAsync(false);

_sut = new PackagingProducerPaymentDetailsViewComponent(
_paymentDetailsOptionsMock.Object,
_paymentFacadeServiceMock.Object,
_mockFeatureManager.Object,
_loggerMock.Object);
}

[TestMethod]
Expand Down Expand Up @@ -119,7 +125,7 @@ public async Task InvokeAsync_Returns_CorrectView_With_Model()
}

[TestMethod]
public async Task WhenpPoducerPaidInExcessOfTheAmountRequiredThenOutstandingPaymentShouldShowZero()
public async Task WhenProducerPaidInExcessOfTheAmountRequiredThenOutstandingPaymentShouldShowZero()
{
// Arrange
_paymentFacadeServiceMock.Setup(x => x.GetProducerPaymentDetailsForResubmissionAsync(
Expand All @@ -132,7 +138,11 @@ public async Task WhenpPoducerPaidInExcessOfTheAmountRequiredThenOutstandingPaym
});
_loggerMock.Setup(x => x.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
_paymentDetailsOptionsMock.Setup(r => r.Value).Returns(new PaymentDetailsOptions { ShowZeroFeeForTotalOutstanding = true });
_sut = new PackagingProducerPaymentDetailsViewComponent(_paymentDetailsOptionsMock.Object, _paymentFacadeServiceMock.Object, _loggerMock.Object);
_sut = new PackagingProducerPaymentDetailsViewComponent(
_paymentDetailsOptionsMock.Object,
_paymentFacadeServiceMock.Object,
_mockFeatureManager.Object,
_loggerMock.Object);

// Act
var result = await _sut.InvokeAsync(_submissionDetailsViewModel);
Expand Down Expand Up @@ -179,4 +189,54 @@ public async Task InvokeAsync_Logs_Error_And_Returns_CorrectView_With_DefaultMod
It.IsAny<Func<It.IsAnyType, Exception, string>>()),
Times.Once);
}

[TestMethod]
public async Task InvokeAsync_WhenFeatureFlagDisabled_PassesMemberCountAsOne()
{
// Arrange
_submissionDetailsViewModel.MemberCount = 25; // should be ignored when flag disabled
_paymentFacadeServiceMock
.Setup(s => s.GetProducerPaymentDetailsForResubmissionAsync(It.IsAny<PackagingProducerPaymentRequest>()))
.ReturnsAsync(new PackagingProducerPaymentResponse
{
ResubmissionFee = 0,
PreviousPaymentsReceived = 0,
TotalOutstanding = 0
});

// Act
await _sut.InvokeAsync(_submissionDetailsViewModel);

// Assert
_paymentFacadeServiceMock.Verify(s =>
s.GetProducerPaymentDetailsForResubmissionAsync(
It.Is<PackagingProducerPaymentRequest>(r => r.MemberCount == 1)), Times.Once);
}

[TestMethod]
public async Task InvokeAsync_WhenFeatureFlagEnabled_Passes_ViewModel_MemberCount()
{
// Arrange
_submissionDetailsViewModel.MemberCount = 37;
_mockFeatureManager.Setup(fm =>
fm.IsEnabledAsync(FeatureFlags.IncludeSubsidiariesInFeeCalculationsForRegulators))
.ReturnsAsync(true);

_paymentFacadeServiceMock
.Setup(s => s.GetProducerPaymentDetailsForResubmissionAsync(It.IsAny<PackagingProducerPaymentRequest>()))
.ReturnsAsync(new PackagingProducerPaymentResponse
{
ResubmissionFee = 0,
PreviousPaymentsReceived = 0,
TotalOutstanding = 0
});

// Act
await _sut.InvokeAsync(_submissionDetailsViewModel);

// Assert
_paymentFacadeServiceMock.Verify(s =>
s.GetProducerPaymentDetailsForResubmissionAsync(
It.Is<PackagingProducerPaymentRequest>(r => r.MemberCount == 37)), Times.Once);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public static class FeatureFlags

public const string ShowFeesWaiveButton = "ShowFeesWaiveButton";
public const string ShowComplianceSchemeMembership = "ShowComplianceSchemeMembership";

public const string IncludeSubsidiariesInFeeCalculationsForRegulators = "IncludeSubsidiariesInFeeCalculationsForRegulators";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async Task<ViewViewComponentResult> InvokeAsync(RegistrationSubmissionDet
ApplicationReferenceNumber = viewModel.ReferenceNumber,
NoOfSubsidiariesOnlineMarketplace = viewModel.ProducerDetails.NoOfSubsidiariesOnlineMarketPlace,
NumberOfSubsidiaries = viewModel.ProducerDetails.NoOfSubsidiaries,
NoOfLateSubsidiaries = viewModel.ProducerDetails.NoOfLateSubsidiaries,
IsLateFeeApplicable = viewModel.ProducerDetails.IsLateFeeApplicable,
IsProducerOnlineMarketplace = viewModel.ProducerDetails.IsProducerOnlineMarketplace,
ProducerType = viewModel.ProducerDetails.ProducerType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.Options;
using Microsoft.FeatureManagement;

namespace EPR.RegulatorService.Frontend.Web.ViewComponents.Submissions;

public class PackagingProducerPaymentDetailsViewComponent(IOptions<PaymentDetailsOptions> options, IPaymentFacadeService paymentFacadeService, ILogger<PackagingProducerPaymentDetailsViewComponent> logger) : ViewComponent
public class PackagingProducerPaymentDetailsViewComponent(
IOptions<PaymentDetailsOptions> options,
IPaymentFacadeService paymentFacadeService,
IFeatureManager featureManager,
ILogger<PackagingProducerPaymentDetailsViewComponent> logger) : ViewComponent
{
private static readonly Action<ILogger, string, Exception?> _logViewComponentError =
LoggerMessage.Define<string>(
Expand All @@ -34,11 +39,17 @@ public async Task<ViewViewComponentResult> InvokeAsync(SubmissionDetailsViewMode
return View(default(PackagingProducerPaymentDetailsViewModel));
}

int memberCount =
await featureManager.IsEnabledAsync(FeatureFlags.IncludeSubsidiariesInFeeCalculationsForRegulators)
? viewModel.MemberCount
: 1;

var producerPaymentResponse = await paymentFacadeService
.GetProducerPaymentDetailsForResubmissionAsync(new PackagingProducerPaymentRequest
{
ReferenceNumber = viewModel.ReferenceNumber,
Regulator = viewModel.NationCode,
MemberCount = memberCount,
ResubmissionDate = TimeZoneInfo.ConvertTimeToUtc(viewModel.SubmittedDate) //payment facade in utc format
});

Expand Down
3 changes: 2 additions & 1 deletion src/EPR.RegulatorService.Frontend.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@
"EnableCsvDownload": false,
"ReprocessorExporter": false,
"ShowYourFeedbackFooter": false,
"ShowFeesWaiveButton": false
"ShowFeesWaiveButton": false,
"IncludeSubsidiariesInFeeCalculationsForRegulators": false
},
"BehaviourManagement": {
"PomSubmissionFilters": {
Expand Down