public async Task CreateTransactionFile_WithFileID_CreatesFileWithCorrectFileID()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                123.45m,
                complianceYear,
                scheme,
                A.Dummy <string>());

            memberUpload.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            ByChargeValueTransactionFileGenerator generator = new ByChargeValueTransactionFileGenerator(transactionReferenceGenerator);

            ulong id = 12345;

            // Act
            var result = await generator.CreateAsync(id, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.Equal((ulong)12345, transactionFile.FileID);
        }
        public async Task CreateTransactionFile_WithExceptionThrown_ReturnsError_AndNoTransactionFile()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                123.45m,
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            memberUpload.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns((string)null); // A null value will cause the Ibis object to throw an exception.

            BySubmissionTransactionFileGenerator generator = new BySubmissionTransactionFileGenerator(transactionReferenceGenerator);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            // Assert
            Assert.Null(result.IbisFile);
            Assert.NotEmpty(result.Errors);
        }
        public async Task <IbisFileGeneratorResult <TransactionFile> > CreateAsync(ulong fileID, InvoiceRun invoiceRun)
        {
            TransactionFile transactionFile = new TransactionFile("WEE", fileID);
            var             errors          = new List <Exception>();

            foreach (MemberUpload memberUpload in invoiceRun.MemberUploads)
            {
                DateTime submittedDate = memberUpload.SubmittedDate.Value;

                string description = string.Format("Charge for producer registration submission made on {0:dd MMM yyyy}.",
                                                   submittedDate);
                try
                {
                    InvoiceLineItem lineItem = new InvoiceLineItem(
                        memberUpload.TotalCharges,
                        description);

                    string transactionReference = await transactionReferenceGenerator.GetNextTransactionReferenceAsync();

                    Invoice invoice = new Invoice(
                        memberUpload.Scheme.IbisCustomerReference,
                        invoiceRun.IssuedDate,
                        TransactionType.Invoice,
                        transactionReference,
                        new List <InvoiceLineItem>()
                    {
                        lineItem
                    });

                    transactionFile.AddInvoice(invoice);
                }
                catch (Exception ex)
                {
                    errors.Add(ex);
                }
            }

            return(new IbisFileGeneratorResult <TransactionFile>(errors.Count == 0 ? transactionFile : null, errors));
        }
        public async Task <IbisFileGeneratorResult <TransactionFile> > CreateAsync(ulong fileID, InvoiceRun invoiceRun)
        {
            TransactionFile transactionFile = new TransactionFile("WEE", fileID);

            var errors = new List <Exception>();
            var groups = invoiceRun.MemberUploads.GroupBy(mu => mu.Scheme);

            foreach (var group in groups)
            {
                List <InvoiceLineItem> lineItems = new List <InvoiceLineItem>();
                var lineItemErrors = new List <Exception>();

                foreach (MemberUpload memberUpload in group)
                {
                    var submittedDate = memberUpload.SubmittedDate.Value;
                    var competantAuthorityAnnualChargeAmount = memberUpload.Scheme.CompetentAuthority.AnnualChargeAmount;

                    var description = string.Format("{0}.", CommonMessage(submittedDate));

                    if (memberUpload.HasAnnualCharge && competantAuthorityAnnualChargeAmount > 0)
                    {
                        description = string.Format("{0} and the {1} annual charge.", CommonMessage(submittedDate), competantAuthorityAnnualChargeAmount.Value.ToString("#,##0.00"));
                    }

                    try
                    {
                        InvoiceLineItem lineItem = new InvoiceLineItem(
                            memberUpload.TotalCharges,
                            description);

                        lineItems.Add(lineItem);
                    }
                    catch (Exception ex)
                    {
                        lineItemErrors.Add(new SchemeFieldException(group.Key, ex));
                    }
                }

                errors.AddRange(lineItemErrors);

                string transactionReference = await transactionReferenceGenerator.GetNextTransactionReferenceAsync();

                if (lineItemErrors.Count == 0)
                {
                    try
                    {
                        Invoice invoice = new Invoice(
                            group.Key.IbisCustomerReference,
                            invoiceRun.IssuedDate,
                            TransactionType.Invoice,
                            transactionReference,
                            lineItems);

                        transactionFile.AddInvoice(invoice);
                    }
                    catch (Exception ex)
                    {
                        errors.Add(new SchemeFieldException(group.Key, ex));
                    }
                }
            }

            return(new IbisFileGeneratorResult <TransactionFile>(errors.Count == 0 ? transactionFile : null, errors));
        }
Exemple #5
0
        public async Task <IbisFileGeneratorResult <TransactionFile> > CreateAsync(ulong fileID, InvoiceRun invoiceRun)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

            var             errors          = new List <Exception>();
            TransactionFile transactionFile = new TransactionFile("WEE", fileID);

            foreach (MemberUpload memberUpload in invoiceRun.MemberUploads)
            {
                List <InvoiceLineItem> lineItems = new List <InvoiceLineItem>();

                var lineItemGroups = memberUpload.ProducerSubmissions
                                     .Where(ps => ps.ChargeThisUpdate != 0)
                                     .Where(ps => ps.Invoiced)
                                     .GroupBy(ps => ps.ChargeThisUpdate)
                                     .OrderBy(g => g.Key)
                                     .Select(g => new { Charge = g.Key, Quantity = g.Count() })
                                     .ToList();

                if (lineItemGroups.Count > 0)
                {
                    var lineItemErrors = new List <Exception>();

                    foreach (var lineItemGroup in lineItemGroups)
                    {
                        decimal amount = lineItemGroup.Charge * lineItemGroup.Quantity;

                        string description = string.Format("{0} producer registration charge{1} at {2:C}.",
                                                           lineItemGroup.Quantity,
                                                           lineItemGroup.Quantity != 1 ? "s" : string.Empty,
                                                           lineItemGroup.Charge);

                        InvoiceLineItem lineItem;
                        try
                        {
                            lineItem = new InvoiceLineItem(
                                amount,
                                description);

                            lineItems.Add(lineItem);
                        }
                        catch (Exception ex)
                        {
                            lineItemErrors.Add(ex);
                        }
                    }

                    errors.AddRange(lineItemErrors);

                    if (lineItemErrors.Count == 0)
                    {
                        string transactionReference = await transactionReferenceGenerator.GetNextTransactionReferenceAsync();

                        try
                        {
                            Invoice invoice = new Invoice(
                                memberUpload.Scheme.IbisCustomerReference,
                                invoiceRun.IssuedDate,
                                TransactionType.Invoice,
                                transactionReference,
                                lineItems);

                            transactionFile.AddInvoice(invoice);
                        }
                        catch (Exception ex)
                        {
                            errors.Add(ex);
                        }
                    }
                }
            }

            return(new IbisFileGeneratorResult <TransactionFile>(errors.Count == 0 ? transactionFile : null, errors));
        }
        public async Task CreateTransactionFile_WithExceptionThrown_ReturnsError_AndNoTransactionFile()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                A.Dummy <decimal>(),
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            RegisteredProducer registeredProducer = new RegisteredProducer("WEE/11AAAA11", complianceYear, scheme);

            ProducerSubmission producerSubmission = new ProducerSubmission(
                registeredProducer,
                memberUpload,
                A.Dummy <ProducerBusiness>(),
                A.Dummy <AuthorisedRepresentative>(),
                A.Dummy <DateTime>(),
                A.Dummy <decimal>(),
                A.Dummy <bool>(),
                A.Dummy <DateTime?>(),
                A.Dummy <string>(),
                A.Dummy <EEEPlacedOnMarketBandType>(),
                A.Dummy <SellingTechniqueType>(),
                A.Dummy <ObligationType>(),
                A.Dummy <AnnualTurnOverBandType>(),
                A.Dummy <List <BrandName> >(),
                A.Dummy <List <SICCode> >(),
                A.Dummy <Domain.Lookup.ChargeBandAmount>(),
                100M,
                A.Dummy <StatusType>());

            memberUpload.ProducerSubmissions.Add(producerSubmission);

            memberUpload.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns((string)null); // A null value will cause the Ibis object to throw an exception.

            ByChargeValueTransactionFileGenerator generator = new ByChargeValueTransactionFileGenerator(
                transactionReferenceGenerator);

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            // Assert
            Assert.Null(result.IbisFile);
            Assert.NotEmpty(result.Errors);
        }
        public async Task CreateTransactionFile_WithTwoMemberUploads_CreatesTwoInvoices()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload1 = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                A.Dummy <decimal>(),
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            RegisteredProducer registeredProducer1 = new RegisteredProducer("WEE/11AAAA11", complianceYear, scheme);

            ProducerSubmission producerSubmission1 = new ProducerSubmission(
                registeredProducer1,
                memberUpload1,
                A.Dummy <ProducerBusiness>(),
                A.Dummy <AuthorisedRepresentative>(),
                A.Dummy <DateTime>(),
                A.Dummy <decimal>(),
                A.Dummy <bool>(),
                A.Dummy <DateTime?>(),
                A.Dummy <string>(),
                A.Dummy <EEEPlacedOnMarketBandType>(),
                A.Dummy <SellingTechniqueType>(),
                A.Dummy <ObligationType>(),
                A.Dummy <AnnualTurnOverBandType>(),
                A.Dummy <List <BrandName> >(),
                A.Dummy <List <SICCode> >(),
                A.Dummy <Domain.Lookup.ChargeBandAmount>(),
                100m,
                A.Dummy <StatusType>());

            memberUpload1.ProducerSubmissions.Add(producerSubmission1);

            memberUpload1.Submit(A.Dummy <User>());

            MemberUpload memberUpload2 = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                A.Dummy <decimal>(),
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            RegisteredProducer registeredProducer2 = new RegisteredProducer("WEE/22BBBB22", complianceYear, scheme);

            ProducerSubmission producerSubmission2 = new ProducerSubmission(
                registeredProducer2,
                memberUpload2,
                A.Dummy <ProducerBusiness>(),
                A.Dummy <AuthorisedRepresentative>(),
                A.Dummy <DateTime>(),
                A.Dummy <decimal>(),
                A.Dummy <bool>(),
                A.Dummy <DateTime?>(),
                A.Dummy <string>(),
                A.Dummy <EEEPlacedOnMarketBandType>(),
                A.Dummy <SellingTechniqueType>(),
                A.Dummy <ObligationType>(),
                A.Dummy <AnnualTurnOverBandType>(),
                A.Dummy <List <BrandName> >(),
                A.Dummy <List <SICCode> >(),
                A.Dummy <Domain.Lookup.ChargeBandAmount>(),
                100m,
                A.Dummy <StatusType>());

            memberUpload2.ProducerSubmissions.Add(producerSubmission2);

            memberUpload2.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload1);
            memberUploads.Add(memberUpload2);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            ByChargeValueTransactionFileGenerator generator = new ByChargeValueTransactionFileGenerator(transactionReferenceGenerator);

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(2, transactionFile.Invoices.Count);

            Invoice invoice1 = transactionFile.Invoices[0];

            Assert.NotNull(invoice1);
            Assert.Equal(100m, invoice1.TransactionTotal);

            Invoice invoice2 = transactionFile.Invoices[1];

            Assert.NotNull(invoice2);
            Assert.Equal(100m, invoice2.TransactionTotal);
        }
        public async Task CreateTransactionFile_WithOneProducerSubmission_CreatesOneInvoiceWithOneLineItem()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                A.Dummy <decimal>(),
                complianceYear,
                scheme,
                A.Dummy <string>());

            RegisteredProducer registeredProducer = new RegisteredProducer("WEE/11AAAA11", complianceYear, scheme);

            ProducerSubmission producerSubmission = new ProducerSubmission(
                registeredProducer,
                memberUpload,
                A.Dummy <ProducerBusiness>(),
                A.Dummy <AuthorisedRepresentative>(),
                A.Dummy <DateTime>(),
                A.Dummy <decimal>(),
                A.Dummy <bool>(),
                A.Dummy <DateTime?>(),
                A.Dummy <string>(),
                A.Dummy <EEEPlacedOnMarketBandType>(),
                A.Dummy <SellingTechniqueType>(),
                A.Dummy <ObligationType>(),
                A.Dummy <AnnualTurnOverBandType>(),
                A.Dummy <List <BrandName> >(),
                A.Dummy <List <SICCode> >(),
                A.Dummy <Domain.Lookup.ChargeBandAmount>(),
                123.45m,
                A.Dummy <StatusType>());

            memberUpload.ProducerSubmissions.Add(producerSubmission);

            memberUpload.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            SystemTime.Freeze(new DateTime(2015, 12, 31));
            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            SystemTime.Unfreeze();

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            ByChargeValueTransactionFileGenerator generator = new ByChargeValueTransactionFileGenerator(transactionReferenceGenerator);

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(1, transactionFile.Invoices.Count);

            Invoice invoice = transactionFile.Invoices[0];

            Assert.NotNull(invoice);

            Assert.Equal(TransactionType.Invoice, invoice.TransactionType);
            Assert.Equal("WEE800001H", invoice.TransactionReference);
            Assert.Equal(123.45m, invoice.TransactionTotal);
            Assert.Equal(null, invoice.TransactionHeaderNarrative);
            Assert.Equal(new DateTime(2015, 12, 31), invoice.TransactionDate);
            Assert.Equal(null, invoice.RelatedTransactionReference);
            Assert.Equal(CurrencyCode.GBP, invoice.CurrencyCode);
            Assert.Equal("WEE00000001", invoice.CustomerReference);

            Assert.NotNull(invoice.LineItems);
            Assert.Equal(1, invoice.LineItems.Count);

            InvoiceLineItem lineItem = invoice.LineItems[0];

            Assert.NotNull(lineItem);

            Assert.Equal(123.45m, lineItem.AmountExcludingVAT);
            Assert.Equal("1 producer registration charge at £123.45.", lineItem.Description);
            Assert.Equal("H", lineItem.AreaCode);
            Assert.Equal("H", lineItem.ContextCode);
            Assert.Equal("W", lineItem.IncomeStreamCode);
            Assert.Equal((ulong)1, lineItem.Quantity);
            Assert.Equal(UnitOfMeasure.Each, lineItem.UnitOfMeasure);
            Assert.Equal(null, lineItem.VatCode);
        }
        public async Task CreateTransactionFile_WithOneMemberUpload_CreatesOneInvoiceWithOneLineItem()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                123.45m,
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            SystemTime.Freeze(new DateTime(2015, 1, 1));
            memberUpload.Submit(A.Dummy <User>());
            SystemTime.Unfreeze();

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload);

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            BySubmissionTransactionFileGenerator generator = new BySubmissionTransactionFileGenerator(transactionReferenceGenerator);

            SystemTime.Freeze(new DateTime(2015, 12, 31));
            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            SystemTime.Unfreeze();

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(1, transactionFile.Invoices.Count);

            Invoice invoice = transactionFile.Invoices[0];

            Assert.NotNull(invoice);

            Assert.Equal(TransactionType.Invoice, invoice.TransactionType);
            Assert.Equal("WEE800001H", invoice.TransactionReference);
            Assert.Equal(123.45m, invoice.TransactionTotal);
            Assert.Equal(null, invoice.TransactionHeaderNarrative);
            Assert.Equal(new DateTime(2015, 12, 31), invoice.TransactionDate);
            Assert.Equal(null, invoice.RelatedTransactionReference);
            Assert.Equal(CurrencyCode.GBP, invoice.CurrencyCode);
            Assert.Equal("WEE00000001", invoice.CustomerReference);

            Assert.NotNull(invoice.LineItems);
            Assert.Equal(1, invoice.LineItems.Count);

            InvoiceLineItem lineItem = invoice.LineItems[0];

            Assert.NotNull(lineItem);

            Assert.Equal(123.45m, lineItem.AmountExcludingVAT);
            Assert.Equal("Charge for producer registration submission made on 01 Jan 2015.", lineItem.Description);
            Assert.Equal("H", lineItem.AreaCode);
            Assert.Equal("H", lineItem.ContextCode);
            Assert.Equal("W", lineItem.IncomeStreamCode);
            Assert.Equal((ulong)1, lineItem.Quantity);
            Assert.Equal(UnitOfMeasure.Each, lineItem.UnitOfMeasure);
            Assert.Equal(null, lineItem.VatCode);
        }
        public async Task CreateTransactionFile_WithTwoMemberUploads_CreatesTwoInvoices()
        {
            // Arrange
            UKCompetentAuthority authority = A.Dummy <UKCompetentAuthority>();

            Organisation organisation = Organisation.CreateSoleTrader("Test organisation");

            Scheme scheme = new Scheme(organisation);

            scheme.UpdateScheme(
                "Test scheme",
                "WEE/AA1111AA/SCH",
                "WEE00000001",
                A.Dummy <ObligationType>(),
                authority);

            int complianceYear = A.Dummy <int>();

            MemberUpload memberUpload1 = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                100,
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            memberUpload1.Submit(A.Dummy <User>());

            MemberUpload memberUpload2 = new MemberUpload(
                A.Dummy <Guid>(),
                A.Dummy <string>(),
                A.Dummy <List <MemberUploadError> >(),
                200,
                complianceYear,
                scheme,
                A.Dummy <string>(),
                A.Dummy <string>(),
                false);

            memberUpload2.Submit(A.Dummy <User>());

            List <MemberUpload> memberUploads = new List <MemberUpload>();

            memberUploads.Add(memberUpload1);
            memberUploads.Add(memberUpload2);

            InvoiceRun invoiceRun = new InvoiceRun(authority, memberUploads, A.Dummy <User>());

            ITransactionReferenceGenerator transactionReferenceGenerator = A.Fake <ITransactionReferenceGenerator>();

            A.CallTo(() => transactionReferenceGenerator.GetNextTransactionReferenceAsync()).Returns("WEE800001H");

            BySubmissionTransactionFileGenerator generator = new BySubmissionTransactionFileGenerator(transactionReferenceGenerator);

            // Act
            var result = await generator.CreateAsync(0, invoiceRun);

            TransactionFile transactionFile = result.IbisFile;

            // Assert
            Assert.NotNull(transactionFile);
            Assert.Equal(2, transactionFile.Invoices.Count);

            Invoice invoice1 = transactionFile.Invoices[0];

            Assert.NotNull(invoice1);
            Assert.Equal(100m, invoice1.TransactionTotal);

            Invoice invoice2 = transactionFile.Invoices[1];

            Assert.NotNull(invoice2);
            Assert.Equal(200m, invoice2.TransactionTotal);
        }