public async Task <ProducerCharge> GetProducerChargeBand(schemeType schmemeType, producerType producerType)
        {
            var complianceYear = int.Parse(schmemeType.complianceYear);

            var previousProducerSubmission =
                await registeredProducerDataAccess.GetProducerRegistration(producerType.registrationNo, complianceYear, schmemeType.approvalNo);

            var previousAmendmentCharge = registeredProducerDataAccess.HasPreviousAmendmentCharge(producerType.registrationNo, complianceYear, schmemeType.approvalNo);

            var chargeband = await environmentAgencyProducerChargeBandCalculator.GetProducerChargeBand(schmemeType, producerType);

            if (previousProducerSubmission != null && previousProducerSubmission.CurrentSubmission != null)
            {
                if (!previousAmendmentCharge && (producerType.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                                                 previousProducerSubmission.CurrentSubmission.EEEPlacedOnMarketBandType == (int)eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket))
                {
                    return(chargeband);
                }
            }

            return(new ProducerCharge()
            {
                ChargeBandAmount = chargeband.ChargeBandAmount,
                Amount = 0
            });
        }
Ejemplo n.º 2
0
        public void IsMatch_Amendment_NoPreviousSubmission_TrueShouldBeReturned()
        {
            var scheme = new schemeType()
            {
                complianceYear = "2020"
            };
            var producerType = new producerType {
                status = statusType.A
            };

            A.CallTo(() => registeredProducerDataAccess.GetProducerRegistration(A <string> ._, A <int> ._, A <string> ._)).Returns((RegisteredProducer)null);

            var result = environmentAgencyProducerChargeBandCalculator.IsMatch(scheme, producerType);

            Assert.True(result);
        }
        public async void WhenUserIsUnauthorised_ShouldNotGetProducerRegistrations()
        {
            A.CallTo(() => weeeAuthorization.EnsureCanAccessInternalArea())
            .Throws <SecurityException>();

            var request = new IsProducerRegisteredForComplianceYear("ABC12345", 2016);

            await Assert.ThrowsAsync <SecurityException>(() => IsProducerRegisteredForComplianceYearHandler().HandleAsync(request));

            A.CallTo(() => registeredProducerDataAccess.GetProducerRegistration(A <Guid> ._))
            .MustNotHaveHappened();
        }
        public bool IsMatch(schemeType scheme, producerType producer)
        {
            var year = int.Parse(scheme.complianceYear);
            var previousProducerSubmission = Task.Run(() => registeredProducerDataAccess.GetProducerRegistration(producer.registrationNo, year, scheme.approvalNo)).Result;

            if (year > 2018)
            {
                if (producer.status == statusType.I)
                {
                    return(true);
                }
                if (producer.status == statusType.A && previousProducerSubmission == null)
                {
                    return(true);
                }
            }
            return(false);
        }
        public async void GetProducerChargeBand_GivenProducerSubmission_RegisteredProducerShouldBeRetrieved()
        {
            var schemeType = new schemeType()
            {
                approvalNo = "app", complianceYear = ComplianceYear.ToString()
            };
            var producerType = new producerType()
            {
                registrationNo = "no"
            };

            await calculator.GetProducerChargeBand(schemeType, producerType);

            A.CallTo(() => registeredProducerDataAccess.GetProducerRegistration(producerType.registrationNo, ComplianceYear, schemeType.approvalNo))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 6
0
 public async Task <RegisteredProducer> GetProducerRegistration(Guid registeredProducerId)
 {
     return(await registeredProducerDataAccess.GetProducerRegistration(registeredProducerId));
 }