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;

            return(producer.status == statusType.A && (previousProducerSubmission != null));
        }
        public async Task <ProducerCharge> GetProducerChargeBand(schemeType scheme, producerType producer)
        {
            var calculator = chargeChargeBandCalculators.FirstOrDefault(c => c.IsMatch(scheme, producer));

            if (calculator == null)
            {
                throw new ApplicationException(string.Format("No charge band calculator found for scheme {0} and producer {1}", scheme.approvalNo, producer.tradingName));
            }

            return(await calculator.GetProducerChargeBand(scheme, producer));
        }
Beispiel #3
0
        public static string GetProducerName(this producerType producer)
        {
            if (producer.producerBusiness != null && producer.producerBusiness.Item != null)
            {
                var producerItem = producer.producerBusiness.Item;

                if (producerItem.GetType() == typeof(companyType))
                {
                    return(((companyType)producerItem).companyName ?? producer.tradingName);
                }

                if (producerItem.GetType() == typeof(partnershipType))
                {
                    return(((partnershipType)producerItem).partnershipName ?? producer.tradingName);
                }
            }

            return(producer.tradingName);
        }
Beispiel #4
0
        public static countryType GetProducerCountry(this producerType producer)
        {
            countryType countryType = new countryType();

            if (producer.producerBusiness != null && producer.producerBusiness.Item != null)
            {
                var producerItem = producer.producerBusiness.Item;

                if (producerItem.GetType() == typeof(companyType))
                {
                    var producerRegisteredOffice = ((companyType)producerItem).registeredOffice;
                    return(countryType = producerRegisteredOffice.contactDetails.address.country);
                }

                if (producerItem.GetType() == typeof(partnershipType))
                {
                    var producerPrincipalBusiness = ((partnershipType)producerItem).principalPlaceOfBusiness;
                    return(countryType = producerPrincipalBusiness.contactDetails.address.country);
                }
            }
            return(countryType);
        }
        public async Task <ProducerCharge> GetProducerChargeBand(schemeType scheme, producerType producer)
        {
            ChargeBand band;

            if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket)
            {
                band = ChargeBand.E;
            }
            else
            {
                if (producer.annualTurnoverBand == annualTurnoverBandType.Greaterthanonemillionpounds &&
                    producer.VATRegistered &&
                    producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket)
                {
                    band = ChargeBand.A;
                }
                else if (producer.annualTurnoverBand == annualTurnoverBandType.Lessthanorequaltoonemillionpounds &&
                         producer.VATRegistered &&
                         producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket)
                {
                    band = ChargeBand.B;
                }
                else if (producer.annualTurnoverBand == annualTurnoverBandType.Greaterthanonemillionpounds &&
                         !producer.VATRegistered &&
                         producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket)
                {
                    band = ChargeBand.D;
                }
                else
                {
                    band = ChargeBand.C;
                }
            }

            return(await fetchProducerCharge.GetCharge(band));
        }
        public async Task <ProducerCharge> GetProducerChargeBand(schemeType scheme, producerType producer)
        {
            var        producerCountry = producer.GetProducerCountry();
            ChargeBand band;

            if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Lessthan5TEEEplacedonmarket)
            {
                band = ChargeBand.E;
            }
            else
            {
                if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                    producer.VATRegistered && producerCountry == countryType.UKENGLAND)
                {
                    band = ChargeBand.A2;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         producer.VATRegistered &&
                         (producerCountry != countryType.UKENGLAND &&
                          producerCountry != countryType.UKSCOTLAND &&
                          producerCountry != countryType.UKWALES &&
                          producerCountry != countryType.UKNORTHERNIRELAND))
                {
                    band = ChargeBand.D3;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         producer.VATRegistered &&
                         (producerCountry == countryType.UKSCOTLAND ||
                          producerCountry == countryType.UKWALES ||
                          producerCountry == countryType.UKNORTHERNIRELAND) &&
                         producer.annualTurnoverBand == annualTurnoverBandType.Greaterthanonemillionpounds)
                {
                    band = ChargeBand.A;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         producer.VATRegistered &&
                         (producerCountry == countryType.UKSCOTLAND ||
                          producerCountry == countryType.UKWALES ||
                          producerCountry == countryType.UKNORTHERNIRELAND) &&
                         producer.annualTurnoverBand == annualTurnoverBandType.Lessthanorequaltoonemillionpounds)
                {
                    band = ChargeBand.B;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         producerCountry == countryType.UKENGLAND &&
                         !producer.VATRegistered)
                {
                    band = ChargeBand.C2;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         !producer.VATRegistered &&
                         (producerCountry != countryType.UKENGLAND &&
                          producerCountry != countryType.UKSCOTLAND &&
                          producerCountry != countryType.UKWALES &&
                          producerCountry != countryType.UKNORTHERNIRELAND))
                {
                    band = ChargeBand.D2;
                }
                else if (producer.eeePlacedOnMarketBand == eeePlacedOnMarketBandType.Morethanorequalto5TEEEplacedonmarket &&
                         !producer.VATRegistered &&
                         (producerCountry == countryType.UKSCOTLAND ||
                          producerCountry == countryType.UKWALES ||
                          producerCountry == countryType.UKNORTHERNIRELAND) &&
                         producer.annualTurnoverBand == annualTurnoverBandType.Greaterthanonemillionpounds)
                {
                    band = ChargeBand.D;
                }
                else
                {
                    band = ChargeBand.C;
                }
            }

            return(await fetchProducerCharge.GetCharge(band));
        }
        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
            });
        }