コード例 #1
0
        public WeeeDeliveredAmount(ObligationType obligationType, WeeeCategory weeeCategory, decimal tonnage, AeDeliveryLocation aeDeliveryLocation) :
            base(obligationType, weeeCategory, tonnage)
        {
            Guard.ArgumentNotNull(() => aeDeliveryLocation, aeDeliveryLocation);

            AeDeliveryLocation = aeDeliveryLocation;
        }
コード例 #2
0
        private static IEnumerable <EeeOutputAmount> CreateEeeOutputAmounts(RegisteredProducer registeredProducer)
        {
            ObligationType            obligationType = registeredProducer.CurrentSubmission.ObligationType;
            IEnumerable <IReturnItem> returnItems    = CreateReturnItems(obligationType);

            return(returnItems.Select(x => new EeeOutputAmount(x.ObligationType, x.WeeeCategory, x.Tonnage, registeredProducer)));
        }
コード例 #3
0
 public WeeeDeliveredAmountBuilder()
 {
     obligationType       = ObligationType.B2C;
     tonnage              = 100;
     weeeCategory         = WeeeCategory.AutomaticDispensers;
     aatfDeliveryLocation = new AatfDeliveryLocation("ApprovalNumber", "FacilityName");
 }
コード例 #4
0
 public WeeeCollectedAmountBuilder()
 {
     obligationType = ObligationType.B2C;
     tonnage        = 100;
     weeeCategory   = WeeeCategory.AutomaticDispensers;
     sourceType     = WeeeCollectedAmountSourceType.Dcf;
 }
コード例 #5
0
ファイル: EeeOutputAmount.cs プロジェクト: DEFRA/prsd-weee
        public EeeOutputAmount(ObligationType obligationType, WeeeCategory weeeCategory, decimal tonnage, RegisteredProducer registeredProducer) :
            base(obligationType, weeeCategory, tonnage)
        {
            Guard.ArgumentNotNull(() => registeredProducer, registeredProducer);

            RegisteredProducer = registeredProducer;
        }
コード例 #6
0
 public EeeOutputAmountBuilder()
 {
     obligationType             = ObligationType.B2C;
     tonnage                    = 100;
     weeeCategory               = WeeeCategory.AutomaticDispensers;
     registeredProducerEquality = true;
 }
コード例 #7
0
        public CsvWriter <CsvResult> CreateWriter(ObligationType obligationType, IEnumerable <string> aatfLocations, IEnumerable <string> aaeLocations)
        {
            CsvWriter <CsvResult> writer = csvWriterFactory.Create <CsvResult>();

            writer.DefineColumn("Scheme name", x => x.SchemeName);
            writer.DefineColumn("Scheme approval No", x => x.SchemeApprovalNumber);
            writer.DefineColumn("Quarter", x => string.Format("Q{0}", x.QuarterType));
            writer.DefineColumn("Category", x => categories[x.Category]);
            writer.DefineColumn("DCF (t)", x => x.Dcf);

            if (obligationType == ObligationType.B2C)
            {
                writer.DefineColumn("Distributors (t)", x => x.Distributors);
                writer.DefineColumn("Final holders (t)", x => x.FinalHolders);
            }

            writer.DefineColumn("Total AATF/AE (t)", x => x.TotalDelivered);

            foreach (string aatfLocation in aatfLocations)
            {
                var columnTitle = string.Format("{0} (t)", aatfLocation);
                writer.DefineColumn(columnTitle, x => x.AatfTonnage[aatfLocation]);
            }

            foreach (string aaeLocation in aaeLocations)
            {
                var columnTitle = string.Format("{0} (t)", aaeLocation);
                writer.DefineColumn(columnTitle, x => x.AeTonnage[aaeLocation]);
            }

            return(writer);
        }
コード例 #8
0
            public static WeeeDeliveredAmount WithObligationType(ObligationType obligationType)
            {
                var builder = new WeeeDeliveredAmountBuilder();

                builder.obligationType = obligationType;

                return(builder.Build());
            }
コード例 #9
0
            public static ProducerSubmission WithObligationType(ObligationType obligationType)
            {
                var builder = new ProducerBuilder();

                builder.obligationType = obligationType;

                return(builder.Build());
            }
コード例 #10
0
ファイル: ReturnItemTests.cs プロジェクト: DEFRA/prsd-weee
            public static ReturnItem WithObligationType(ObligationType obligationType)
            {
                var builder = new ReturnItemBuilder();

                builder.obligationType = obligationType;

                return(builder.Build());
            }
コード例 #11
0
            public static EeeOutputAmount WithObligationType(ObligationType obligationType)
            {
                var builder = new EeeOutputAmountBuilder();

                builder.obligationType = obligationType;

                return(builder.Build());
            }
コード例 #12
0
ファイル: ProducerSubmission.cs プロジェクト: DEFRA/prsd-weee
        public ProducerSubmission(
            RegisteredProducer registeredProducer,
            MemberUpload memberUpload,
            ProducerBusiness producerBusiness,
            AuthorisedRepresentative authorisedRepresentative,
            DateTime updatedDate,
            decimal?annualTurnover,
            bool vatRegistered,
            DateTime?ceaseToExist,
            string tradingName,
            EEEPlacedOnMarketBandType eeePlacedOnMarketBandType,
            SellingTechniqueType sellingTechniqueType,
            ObligationType obligationType,
            AnnualTurnOverBandType annualTurnOverBandType,
            List <BrandName> brandnames,
            List <SICCode> codes,
            ChargeBandAmount chargeBandAmount,
            decimal chargeThisUpdate,
            StatusType status)
        {
            Guard.ArgumentNotNull(() => registeredProducer, registeredProducer);
            Guard.ArgumentNotNull(() => memberUpload, memberUpload);
            Guard.ArgumentNotNull(() => producerBusiness, producerBusiness);
            Guard.ArgumentNotNull(() => chargeBandAmount, chargeBandAmount);

            if (registeredProducer.Scheme.Id != memberUpload.Scheme.Id)
            {
                string errorMessage = "A producer submission can only be associated "
                                      + "with a registered producer in the same scheme.";
                throw new InvalidOperationException(errorMessage);
            }

            if (registeredProducer.ComplianceYear != memberUpload.ComplianceYear)
            {
                string errorMessage = "A producer submission can only be associated "
                                      + "with a registered producer in the same compliance year.";
                throw new InvalidOperationException(errorMessage);
            }

            RegisteredProducer       = registeredProducer;
            ProducerBusiness         = producerBusiness;
            AuthorisedRepresentative = authorisedRepresentative;
            UpdatedDate               = updatedDate;
            AnnualTurnover            = annualTurnover;
            VATRegistered             = vatRegistered;
            CeaseToExist              = ceaseToExist;
            TradingName               = tradingName;
            EEEPlacedOnMarketBandType = eeePlacedOnMarketBandType.Value;
            SellingTechniqueType      = sellingTechniqueType.Value;
            ObligationType            = obligationType;
            AnnualTurnOverBandType    = annualTurnOverBandType.Value;
            BrandNames       = brandnames;
            SICCodes         = codes;
            MemberUpload     = memberUpload;
            ChargeBandAmount = chargeBandAmount;
            ChargeThisUpdate = chargeThisUpdate;
            StatusType       = status.Value;
        }
コード例 #13
0
        public void NoEeeInProducerEeeDetailsForOneCategory_TonnageShouldAlwaysBeEmpty(QuarterSelection quarter,
            WeeeCategory weeeCategory, ObligationType obligationType)
        {
            var producerDetails = new ProducerEeeDetails();

            var result = producerDetails.DisplayTonnage(quarter, weeeCategory, obligationType);

            Assert.Empty(result);
        }
コード例 #14
0
        private decimal?GetEeeDataTonnes(List <EeeOutputAmount> amounts, ObligationType obligationType, int category)
        {
            var amount = amounts
                         .Where(a => a.ObligationType == obligationType)
                         .Where(a => (int)a.WeeeCategory == category)
                         .SingleOrDefault();

            return(amount != null ? (decimal?)amount.Tonnage : null);
        }
コード例 #15
0
 public UpdateSchemeInformation(Guid schemeId, string schemeName, string approvalNumber, string ibisCustomerReference, ObligationType obligationType, Guid competentAuthorityId, SchemeStatus status)
 {
     SchemeId              = schemeId;
     SchemeName            = schemeName;
     ApprovalNumber        = approvalNumber;
     IbisCustomerReference = ibisCustomerReference;
     ObligationType        = obligationType;
     CompetentAuthorityId  = competentAuthorityId;
     Status = status;
 }
コード例 #16
0
ファイル: CreateScheme.cs プロジェクト: DEFRA/prsd-weee
 public CreateScheme(Guid organisationId, string schemeName, string approvalNumber, string ibisCustomerReference, ObligationType obligationType, Guid competentAuthorityId, SchemeStatus status)
 {
     OrganisationId        = organisationId;
     SchemeName            = schemeName;
     ApprovalNumber        = approvalNumber;
     IbisCustomerReference = ibisCustomerReference;
     ObligationType        = obligationType;
     CompetentAuthorityId  = competentAuthorityId;
     Status = status;
 }
コード例 #17
0
 public GetMissingProducerDataCsv(int complianceYear,
                                  ObligationType obligationType,
                                  int?quarter,
                                  Guid?schemeId)
 {
     ComplianceYear = complianceYear;
     ObligationType = obligationType;
     Quarter        = quarter;
     SchemeId       = schemeId;
 }
コード例 #18
0
        private static string ConvertEnumToDatabaseString(ObligationType obligationType)
        {
            switch (obligationType)
            {
            case ObligationType.B2B:
                return("B2B");

            case ObligationType.B2C:
                return("B2C");

            default:
                throw new NotSupportedException();
            }
        }
コード例 #19
0
        public WeeeCollectedAmount CreateWeeeCollectedAmount(ObligationType obligationType, decimal tonnage, WeeeCategory category)
        {
            var weeeCollectedAmount = new WeeeCollectedAmount
            {
                Id             = IntegerToGuid(GetNextId()),
                ObligationType = obligationType.ToString(),
                Tonnage        = tonnage,
                WeeeCategory   = (int)category
            };

            model.WeeeCollectedAmounts.Add(weeeCollectedAmount);

            return(weeeCollectedAmount);
        }
コード例 #20
0
        public static obligationTypeType ToDeserializedXmlObligationType(this ObligationType obligationType)
        {
            if (obligationType == ObligationType.B2B)
            {
                return(obligationTypeType.B2B);
            }

            if (obligationType == ObligationType.B2C)
            {
                return(obligationTypeType.B2C);
            }

            return(obligationTypeType.Both);
        }
コード例 #21
0
        public ProducerSubmission GetProducerForOtherSchemeAndObligationType(string registrationNo, string schemeComplianceYear, Guid organisationId, ObligationType obligationType)
        {
            int complianceYear = int.Parse(schemeComplianceYear);

            if (!currentProducersByRegistrationNumber.Run().ContainsKey(registrationNo))
            {
                return null;
            }

            return currentProducersByRegistrationNumber.Run()[registrationNo]
                .FirstOrDefault(p => p.RegisteredProducer.Scheme.OrganisationId != organisationId
                    && p.MemberUpload.ComplianceYear == complianceYear
                    && (p.ObligationType == obligationType || 
                    p.ObligationType == ObligationType.Both ||
                    obligationType == (obligationTypeType.Both.ToDomainObligationType())));
        }
コード例 #22
0
ファイル: Scheme.cs プロジェクト: EnvironmentAgency/prsd-weee
        public void UpdateScheme(
            string schemeName,
            string approvalNumber,
            string ibisCustomerReference,
            ObligationType? obligationType,
            Guid competentAuthorityId)
        {
            Guard.ArgumentNotNullOrEmpty(() => schemeName, schemeName);
            Guard.ArgumentNotNullOrEmpty(() => approvalNumber, approvalNumber);

            SchemeName = schemeName;
            ApprovalNumber = approvalNumber;
            IbisCustomerReference = ibisCustomerReference;
            ObligationType = obligationType;
            CompetentAuthorityId = competentAuthorityId;
        }
コード例 #23
0
ファイル: FakeProducer.cs プロジェクト: DEFRA/prsd-weee
        public static ProducerSubmission Create(
            ObligationType obligationType,
            string prn,
            Guid?schemeOrganisationId         = null,
            int?complianceYear                = null,
            ProducerBusiness producerBusiness = null,
            params string[] brandNames)
        {
            Scheme scheme = new Scheme(
                schemeOrganisationId ?? Guid.Empty);

            RegisteredProducer registeredProducer = new RegisteredProducer(
                prn,
                complianceYear ?? 2016,
                scheme);

            MemberUpload memberUpload = new MemberUpload(
                Guid.NewGuid(),
                "<xml>SomeData</xml>",
                new List <MemberUploadError>(),
                0,
                complianceYear ?? 2016,
                scheme,
                "File name");

            return(new ProducerSubmission(
                       registeredProducer,
                       memberUpload,
                       producerBusiness ?? new ProducerBusiness(),
                       new AuthorisedRepresentative("authrep"),
                       DateTime.Now,
                       0,
                       true,
                       null,
                       "trading name",
                       EEEPlacedOnMarketBandType.Lessthan5TEEEplacedonmarket,
                       SellingTechniqueType.Both,
                       obligationType,
                       AnnualTurnOverBandType.Greaterthanonemillionpounds,
                       brandNames.Select(bn => new BrandName(bn)).ToList(),
                       new List <SICCode>(),
                       new ChargeBandAmount(Guid.NewGuid(), ChargeBand.A, 123),
                       999,
                       A.Dummy <StatusType>()));
        }
コード例 #24
0
        public ReturnItem(ObligationType obligationType, WeeeCategory weeeCategory, decimal tonnage)
        {
            WeeeCategory   = weeeCategory;
            ObligationType = obligationType;

            if (tonnage < 0)
            {
                throw new ArgumentOutOfRangeException("amountInTonnes");
            }

            if (obligationType != ObligationType.B2B && obligationType != ObligationType.B2C)
            {
                string errorMessage = "The obligation type of a return item must be either B2B or B2C.";
                throw new InvalidOperationException(errorMessage);
            }

            Tonnage = tonnage;
        }
コード例 #25
0
        public static string DisplayTonnage(this ProducerEeeDetails producerEeeDetails, QuarterSelection quarter, WeeeCategory category,
                                            ObligationType obligationType)
        {
            switch (quarter)
            {
            case QuarterSelection.All:
                var totalEee = producerEeeDetails.TotalEee.SingleOrDefault(e => e.Category == category &&
                                                                           e.ObligationType == obligationType);
                return(totalEee != null
                        ? totalEee.Tonnage.ToString()
                        : string.Empty);

            case QuarterSelection.Q1:
                var quarter1Eee = producerEeeDetails.Q1EEE.SingleOrDefault(e => e.Category == category &&
                                                                           e.ObligationType == obligationType);
                return(quarter1Eee != null
                        ? quarter1Eee.Tonnage.ToString()
                        : string.Empty);

            case QuarterSelection.Q2:
                var quarter2Eee = producerEeeDetails.Q2EEE.SingleOrDefault(e => e.Category == category &&
                                                                           e.ObligationType == obligationType);
                return(quarter2Eee != null
                        ? quarter2Eee.Tonnage.ToString()
                        : string.Empty);

            case QuarterSelection.Q3:
                var quarter3Eee = producerEeeDetails.Q3EEE.SingleOrDefault(e => e.Category == category &&
                                                                           e.ObligationType == obligationType);
                return(quarter3Eee != null
                        ? quarter3Eee.Tonnage.ToString()
                        : string.Empty);

            case QuarterSelection.Q4:
                var quarter4Eee = producerEeeDetails.Q4EEE.SingleOrDefault(e => e.Category == category &&
                                                                           e.ObligationType == obligationType);
                return(quarter4Eee != null
                        ? quarter4Eee.Tonnage.ToString()
                        : string.Empty);

            default:
                return(string.Empty);
            }
        }
コード例 #26
0
        public static ProducerSubmission Create(
            ObligationType obligationType,
            string prn,
            Guid? schemeOrganisationId = null,
            int? complianceYear = null,
            ProducerBusiness producerBusiness = null,
            params string[] brandNames)
        {
            Scheme scheme = new Scheme(
                schemeOrganisationId ?? Guid.Empty);

            RegisteredProducer registeredProducer = new RegisteredProducer(
                prn,
                complianceYear ?? 2016,
                scheme);

            MemberUpload memberUpload = new MemberUpload(
                Guid.NewGuid(),
                "<xml>SomeData</xml>",
                new List<MemberUploadError>(),
                0,
                complianceYear ?? 2016,
                scheme,
                "File name");

            return new ProducerSubmission(
                registeredProducer,
                memberUpload,
                producerBusiness ?? new ProducerBusiness(),
                new AuthorisedRepresentative("authrep"),
                DateTime.Now,
                0,
                true,
                null,
                "trading name",
                EEEPlacedOnMarketBandType.Lessthan5TEEEplacedonmarket,
                SellingTechniqueType.Both,
                obligationType,
                AnnualTurnOverBandType.Greaterthanonemillionpounds,
                brandNames.Select(bn => new BrandName(bn)).ToList(),
                new List<SICCode>(),
                new ChargeBandAmount(Guid.NewGuid(), ChargeBand.A, 123),
                999);
        }
コード例 #27
0
        public void FirstAndSecondQuarterHasEeeDataForTheSameCategoryButDifferentObligationType_Q1ContainsTonnage_AndQ2ContainsTonnage_AndTotalEeeTonnageIsSeparatedIntoObligationTypes()
        {
            var map = new ProducerEeeMap();

            var                  scheme              = new Scheme(Guid.NewGuid());
            var                  producer            = new RegisteredProducer("ABC12345", 2016, scheme);
            const decimal        tonnageForQ1        = 10M;
            const decimal        tonnageForQ2        = 25.6M;
            const ObligationType obligationTypeForQ1 = ObligationType.B2B;
            const ObligationType obligationTypeForQ2 = ObligationType.B2C;

            var data = new List <ProducerEeeByQuarter>
            {
                new ProducerEeeByQuarter
                {
                    Eee = new List <EeeOutputAmount>
                    {
                        new EeeOutputAmount(obligationTypeForQ1, WeeeCategory.AutomaticDispensers, tonnageForQ1, producer)
                    },
                    Quarter = new Quarter(2016, QuarterType.Q1)
                },
                new ProducerEeeByQuarter
                {
                    Eee = new List <EeeOutputAmount>
                    {
                        new EeeOutputAmount(obligationTypeForQ2, WeeeCategory.AutomaticDispensers, tonnageForQ2, producer)
                    },
                    Quarter = new Quarter(2016, QuarterType.Q2)
                }
            };

            var result = map.Map(data);

            Assert.Single(result.Q1EEE);
            Assert.Equal(tonnageForQ1, result.Q1EEE.Single().Tonnage);

            Assert.Single(result.Q2EEE);
            Assert.Equal(tonnageForQ2, result.Q2EEE.Single().Tonnage);

            Assert.Equal(2, result.TotalEee.Count);
            Assert.Single(result.TotalEee.Where(eee => eee.Tonnage == tonnageForQ1 && (ObligationType)(int)eee.ObligationType == obligationTypeForQ1));
            Assert.Single(result.TotalEee.Where(eee => eee.Tonnage == tonnageForQ2 && (ObligationType)(int)eee.ObligationType == obligationTypeForQ2));
        }
コード例 #28
0
        GetProducerForOtherSchemeAndObligationType_ProducerForAnotherSchemeHasMatchingObligationType_ReturnsProducer(
            ObligationType existingProducerObligationType, ObligationType obligationType)
        {
            const string prn = "ABC12345";
            var          schemeOrgansationId = Guid.NewGuid();

            var producer = FakeProducer.Create(existingProducerObligationType, prn, Guid.NewGuid());

            A.CallTo(() => currentProducersByRegistrationNumber.Run())
            .Returns(new Dictionary <string, List <ProducerSubmission> >
            {
                { prn, new List <ProducerSubmission> {
                      producer
                  } }
            });

            var result = ProducerQuerySet()
                         .GetProducerForOtherSchemeAndObligationType(prn, "2016", schemeOrgansationId, obligationType);

            Assert.NotNull(result);
        }
コード例 #29
0
 public WeeeDeliveredAmountBuilder()
 {
     obligationType = ObligationType.B2C;
     tonnage = 100;
     weeeCategory = WeeeCategory.AutomaticDispensers;
     aatfDeliveryLocation = new AatfDeliveryLocation("ApprovalNumber", "FacilityName");
 }
コード例 #30
0
        public async Task <ActionResult> DownloadMissingProducerDataCsv(int complianceYear,
                                                                        Guid?schemeId, ObligationType obligationType, int?quarter)
        {
            CSVFileData fileData;

            var request = new GetMissingProducerDataCsv(complianceYear, obligationType, quarter, schemeId);

            using (var client = apiClient())
            {
                fileData = await client.SendAsync(User.GetAccessToken(), request);
            }

            var data = new UTF8Encoding().GetBytes(fileData.FileContent);

            return(File(data, "text/csv", CsvFilenameFormat.FormatFileName(fileData.FileName)));
        }
コード例 #31
0
        public async Task <ActionResult> DownloadSchemeWeeeDataCsv(int complianceYear, Guid?schemeId, ObligationType obligationType)
        {
            FileInfo file;

            var request = new GetSchemeWeeeCsv(complianceYear, schemeId, obligationType);

            using (var client = apiClient())
            {
                file = await client.SendAsync(User.GetAccessToken(), request);
            }

            return(File(file.Data, "text/csv", file.FileName));
        }
コード例 #32
0
 public EeeOutputAmountBuilder()
 {
     obligationType = ObligationType.B2C;
     tonnage = 100;
     weeeCategory = WeeeCategory.AutomaticDispensers;
     registeredProducerEquality = true;
 }
コード例 #33
0
 public void ConstructsReturnItem_WithObligationTypeNotB2BOrB2C_ThrowsInvalidOperationException(ObligationType obligationType)
 {
     Assert.Throws<InvalidOperationException>(() => new ReturnItem(obligationType, A.Dummy<WeeeCategory>(), A.Dummy<decimal>()));
 }
コード例 #34
0
        public WeeeCollectedAmount CreateWeeeCollectedAmount(ObligationType obligationType, decimal tonnage, WeeeCategory category)
        {
            var weeeCollectedAmount = new WeeeCollectedAmount
            {
                Id = IntegerToGuid(GetNextId()),
                ObligationType = obligationType.ToString(),
                Tonnage = tonnage,
                WeeeCategory = (int)category
            };

            model.WeeeCollectedAmounts.Add(weeeCollectedAmount);

            return weeeCollectedAmount;
        }
コード例 #35
0
 public WeeeCollectedAmountBuilder()
 {
     obligationType = ObligationType.B2C;
     tonnage = 100;
     weeeCategory = WeeeCategory.AutomaticDispensers;
     sourceType = WeeeCollectedAmountSourceType.Dcf;
 }
コード例 #36
0
        public ProducerSubmission GetProducerForOtherSchemeAndObligationType(string registrationNo, string schemeComplianceYear, Guid organisationId, ObligationType obligationType)
        {
            int complianceYear = int.Parse(schemeComplianceYear);

            if (!currentProducersByRegistrationNumber.Run().ContainsKey(registrationNo))
            {
                return(null);
            }

            return(currentProducersByRegistrationNumber.Run()[registrationNo]
                   .FirstOrDefault(p => p.RegisteredProducer.Scheme.OrganisationId != organisationId &&
                                   p.MemberUpload.ComplianceYear == complianceYear &&
                                   (p.ObligationType == obligationType ||
                                    p.ObligationType == ObligationType.Both ||
                                    obligationType == (obligationTypeType.Both.ToDomainObligationType()))));
        }
コード例 #37
0
        GetProducerForOtherSchemeAndObligationType_ProducerExistsInOtherSchemesWithB2bAndB2cObligationTypes_ReturnsProducer(ObligationType obligationType)
        {
            const string prn = "ABC12345";

            var producer1 = FakeProducer.Create(ObligationType.B2B, prn, Guid.NewGuid());
            var producer2 = FakeProducer.Create(ObligationType.B2C, prn, Guid.NewGuid());

            A.CallTo(() => currentProducersByRegistrationNumber.Run())
            .Returns(new Dictionary <string, List <ProducerSubmission> >
            {
                { prn, new List <ProducerSubmission> {
                      producer1, producer2
                  } }
            });

            var result = ProducerQuerySet()
                         .GetProducerForOtherSchemeAndObligationType(prn, "2016", Guid.NewGuid(), obligationType);

            Assert.NotNull(result);
        }
コード例 #38
0
        public async Task<ActionResult> DownloadSchemeWeeeDataCsv(int complianceYear, Guid? schemeId, ObligationType obligationType)
        {
            FileInfo file;

            GetSchemeWeeeCsv request = new GetSchemeWeeeCsv(complianceYear, schemeId, obligationType);
            using (var client = apiClient())
            {
                file = await client.SendAsync(User.GetAccessToken(), request);
            }

            return File(file.Data, "text/csv", file.FileName);
        }
コード例 #39
0
            public static ProducerSubmission WithObligationType(ObligationType obligationType)
            {
                var builder = new ProducerBuilder();
                builder.obligationType = obligationType;

                return builder.Build();
            }
コード例 #40
0
 public GetProducerEeeDataCsv(int complianceYear, Guid?schemeId, ObligationType obligationType)
 {
     ComplianceYear = complianceYear;
     SchemeId       = schemeId;
     ObligationType = obligationType;
 }
コード例 #41
0
        private static IEnumerable<ReturnItem> CreateReturnItems(ObligationType? filter)
        {
            List<ReturnItem> returnItems = new List<ReturnItem>();
            foreach (WeeeCategory category in Enum.GetValues(typeof(WeeeCategory)))
            {
                switch (filter)
                {
                    case null:
                    case ObligationType.Both:
                        returnItems.Add(new ReturnItem(ObligationType.B2B, category, GetRandomReturnAmount()));
                        returnItems.Add(new ReturnItem(ObligationType.B2C, category, GetRandomReturnAmount()));
                        break;

                    case ObligationType.B2B:
                        returnItems.Add(new ReturnItem(ObligationType.B2B, category, GetRandomReturnAmount()));
                        break;

                    case ObligationType.B2C:
                        returnItems.Add(new ReturnItem(ObligationType.B2C, category, GetRandomReturnAmount()));
                        break;

                    default:
                        throw new NotSupportedException();
                }
            }

            int numberOfResults = 1 + r.Next(returnItems.Count - 1);

            return returnItems
                .Shuffle()
                .Take(numberOfResults)
                .OrderBy(ri => ri.ObligationType)
                .ThenBy(ri => ri.WeeeCategory);
        }
コード例 #42
0
            public static ReturnItem WithObligationType(ObligationType obligationType)
            {
                var builder = new ReturnItemBuilder();
                builder.obligationType = obligationType;

                return builder.Build();
            }
コード例 #43
0
            GetProducerForOtherSchemeAndObligationType_ProducerForAnotherSchemeHasMatchingObligationType_ReturnsProducer(
            ObligationType existingProducerObligationType, ObligationType obligationType)
        {
            const string prn = "ABC12345";
            var schemeOrgansationId = Guid.NewGuid();

            var producer = FakeProducer.Create(existingProducerObligationType, prn, Guid.NewGuid());

            A.CallTo(() => currentProducersByRegistrationNumber.Run())
                .Returns(new Dictionary<string, List<ProducerSubmission>>
                {
                    { prn, new List<ProducerSubmission> { producer } }
                });

            var result = ProducerQuerySet()
                .GetProducerForOtherSchemeAndObligationType(prn, "2016", schemeOrgansationId, obligationType);

            Assert.NotNull(result);
        }
コード例 #44
0
 public ReturnItemBuilder()
 {
     obligationType = ObligationType.B2C;
     tonnage = 100;
     weeeCategory = WeeeCategory.AutomaticDispensers;
 }
コード例 #45
0
            public static WeeeDeliveredAmount WithObligationType(ObligationType obligationType)
            {
                var builder = new WeeeDeliveredAmountBuilder();
                builder.obligationType = obligationType;

                return builder.Build();
            }
コード例 #46
0
            GetProducerForOtherSchemeAndObligationType_ProducerExistsInOtherSchemesWithB2bAndB2cObligationTypes_ReturnsProducer(ObligationType obligationType)
        {
            const string prn = "ABC12345";

            var producer1 = FakeProducer.Create(ObligationType.B2B, prn, Guid.NewGuid());
            var producer2 = FakeProducer.Create(ObligationType.B2C, prn, Guid.NewGuid());

            A.CallTo(() => currentProducersByRegistrationNumber.Run())
                .Returns(new Dictionary<string, List<ProducerSubmission>>
                {
                    { prn, new List<ProducerSubmission> { producer1, producer2 } }
                });

            var result = ProducerQuerySet()
                .GetProducerForOtherSchemeAndObligationType(prn, "2016", Guid.NewGuid(), obligationType);

            Assert.NotNull(result);
        }
コード例 #47
0
        public async Task<ActionResult> DownloadMissingProducerDataCsv(int complianceYear,
            Guid? schemeId, ObligationType obligationType, int? quarter)
        {
            CSVFileData fileData;

            GetMissingProducerDataCsv request = new GetMissingProducerDataCsv(complianceYear, obligationType, quarter, schemeId);
            using (IWeeeClient client = apiClient())
            {
                fileData = await client.SendAsync(User.GetAccessToken(), request);
            }

            byte[] data = new UTF8Encoding().GetBytes(fileData.FileContent);
            return File(data, "text/csv", CsvFilenameFormat.FormatFileName(fileData.FileName));
        }
コード例 #48
0
            public static EeeOutputAmount WithObligationType(ObligationType obligationType)
            {
                var builder = new EeeOutputAmountBuilder();
                builder.obligationType = obligationType;

                return builder.Build();
            }
コード例 #49
0
        public void NoEeeInProducerEeeDetailsForOneCategory_TonnageShouldAlwaysBeEmpty(QuarterSelection quarter,
                                                                                       WeeeCategory weeeCategory, ObligationType obligationType)
        {
            var producerDetails = new ProducerEeeDetails();

            var result = producerDetails.DisplayTonnage(quarter, weeeCategory, obligationType);

            Assert.Empty(result);
        }