Esempio n. 1
0
 internal SendInvoicesResult(ResponseDoc responseDoc)
 {
     SendInvoiceResults = SequentialEnumerableStartingWithOne.Create(responseDoc.Responses.Select(r => new IndexedItem <SendInvoiceResult>(r.Index, new SendInvoiceResult(
                                                                                                                                               invoiceIdentifier: r.InvoiceUid,
                                                                                                                                               invoiceRegistrationNumber: r.InvoiceMark,
                                                                                                                                               invoiceRegistrationNumberSpecified: r.InvoiceMarkSpecified,
                                                                                                                                               errors: r.Errors?.Select(error => new ResultError(MapErrorCode(error.Code, r.StatusCode), error.Message))
                                                                                                                                               ))));
 }
Esempio n. 2
0
        public async Task ValidInvoicesWork(SequentialEnumerableStartingWithOne <Invoice> invoices)
        {
            // Arrange
            var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox);

            // Act
            var response = await client.SendInvoicesAsync(invoices);

            // Assert
            Assert.NotEmpty(response.SendInvoiceResults);
            Assert.True(response.SendInvoiceResults.Single().Value.IsSuccess);
        }
Esempio n. 3
0
 private static ISequentialEnumerable <Invoice> RetailSalesReceiptForCustomer()
 {
     return(SequentialEnumerableStartingWithOne.FromPreordered(new List <Invoice>
     {
         new RetailSalesReceipt(
             issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
             header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50020"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
             revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NonNegativeRevenue>
         {
             new NonNegativeRevenue(new NonNegativeAmount(53.65m), new NonNegativeAmount(12.88m), TaxType.Vat6, RevenueType.Products),
             new NonNegativeRevenue(new NonNegativeAmount(53.65m), new NonNegativeAmount(12.88m), TaxType.Vat6, RevenueType.Services),
             new NonNegativeRevenue(new NonNegativeAmount(53.65m), new NonNegativeAmount(12.88m), TaxType.Vat6, RevenueType.Other)
         }),
             payments: NonEmptyEnumerable.Create(
                 new NonNegativePayment(new NonNegativeAmount(133.06m), PaymentType.DomesticPaymentsAccountNumber),
                 new NonNegativePayment(new NonNegativeAmount(66.53m), PaymentType.Cash)
                 )
             )
     }));
 }
Esempio n. 4
0
 private static ISequentialEnumerable <Invoice> SimplifiedInvoiceForCustomer()
 {
     return(SequentialEnumerableStartingWithOne.FromPreordered(new List <Invoice>
     {
         new SimplifiedInvoice(
             issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
             header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50020"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
             revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NonNegativeRevenue>
         {
             new NonNegativeRevenue(new NonNegativeAmount(20.50m), new NonNegativeAmount(10.50m), TaxType.Vat13, RevenueType.Products),
             new NonNegativeRevenue(new NonNegativeAmount(20.50m), new NonNegativeAmount(10.50m), TaxType.Vat13, RevenueType.Services),
             new NonNegativeRevenue(new NonNegativeAmount(20.50m), new NonNegativeAmount(10.50m), TaxType.Vat13, RevenueType.Other)
         }),
             payments: NonEmptyEnumerable.Create(
                 new NonNegativePayment(new NonNegativeAmount(31m), PaymentType.Cash),
                 new NonNegativePayment(new NonNegativeAmount(31m), PaymentType.OnCredit),
                 new NonNegativePayment(new NonNegativeAmount(31m), PaymentType.DomesticPaymentsAccountNumber)
                 )
             )
     }));
 }
Esempio n. 5
0
 private static ISequentialEnumerable <Invoice> InvoiceForForeignCompany(string countryCode, bool isWithinEU)
 {
     return(SequentialEnumerableStartingWithOne.FromPreordered(new List <Invoice>
     {
         new SalesInvoice(
             issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
             header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50020"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
             revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NonNegativeRevenue>
         {
             new NonNegativeRevenue(new NonNegativeAmount(100m), new NonNegativeAmount(0m), TaxType.WithoutVat, RevenueType.Products),
             new NonNegativeRevenue(new NonNegativeAmount(100m), new NonNegativeAmount(0m), TaxType.WithoutVat, RevenueType.Services),
             new NonNegativeRevenue(new NonNegativeAmount(100m), new NonNegativeAmount(0m), TaxType.WithoutVat, RevenueType.Other)
         }),
             payments: NonEmptyEnumerable.Create(
                 new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.Cash),
                 new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.OnCredit),
                 new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.DomesticPaymentsAccountNumber)
                 ),
             counterpart: new ForeignInvoiceParty(new Country(new CountryCode(countryCode), isWithinEU: isWithinEU), new NonEmptyString("12348765"), new NonNegativeInt(0), "Name", new Address(postalCode: new NonEmptyString("12"), city: new NonEmptyString("City")))
             )
     }));
 }
Esempio n. 6
0
 private static ISequentialEnumerable <Invoice> CreditInvoiceNonAssociated()
 {
     return(SequentialEnumerableStartingWithOne.FromPreordered(new List <Invoice>
     {
         new CreditInvoice(
             issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
             header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50020"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
             revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NegativeRevenue>
         {
             new NegativeRevenue(new NegativeAmount(-88.50m), new NonPositiveAmount(-11.50m), TaxType.Vat13, RevenueType.Products),
             new NegativeRevenue(new NegativeAmount(-88.50m), new NonPositiveAmount(-11.50m), TaxType.Vat13, RevenueType.Services),
             new NegativeRevenue(new NegativeAmount(-88.50m), new NonPositiveAmount(-11.50m), TaxType.Vat13, RevenueType.Other)
         }),
             payments: NonEmptyEnumerable.Create(
                 new NegativePayment(new NegativeAmount(-100m), PaymentType.Cash),
                 new NegativePayment(new NegativeAmount(-100m), PaymentType.OnCredit),
                 new NegativePayment(new NegativeAmount(-100m), PaymentType.DomesticPaymentsAccountNumber)
                 ),
             counterpart: new LocalInvoiceParty(new GreekTaxIdentifier("090701900"), address: new Address(postalCode: new NonEmptyString("12"), city: new NonEmptyString("City")))
             )
     }));
 }
Esempio n. 7
0
        public async Task ValidNegativeInvoiceWorks()
        {
            // Arrange
            var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox);

            // Act

            // Step 1 - regular invoice
            var invoices = SequentialEnumerableStartingWithOne.FromPreordered <Invoice>(new List <Invoice>
            {
                new SalesInvoice(
                    issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
                    header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50020"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
                    revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NonNegativeRevenue>
                {
                    new NonNegativeRevenue(new NonNegativeAmount(88.50m), new NonNegativeAmount(11.50m), TaxType.Vat13, RevenueType.Products),
                    new NonNegativeRevenue(new NonNegativeAmount(88.50m), new NonNegativeAmount(11.50m), TaxType.Vat13, RevenueType.Services),
                    new NonNegativeRevenue(new NonNegativeAmount(88.50m), new NonNegativeAmount(11.50m), TaxType.Vat13, RevenueType.Other)
                }),
                    payments: NonEmptyEnumerable.Create(
                        new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.Cash),
                        new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.OnCredit),
                        new NonNegativePayment(new NonNegativeAmount(100m), PaymentType.DomesticPaymentsAccountNumber)
                        ),
                    counterpart: new LocalInvoiceParty(new GreekTaxIdentifier("090701900"))
                    )
            });

            var response = await client.SendInvoicesAsync(invoices);

            Assert.NotEmpty(response.SendInvoiceResults);
            Assert.True(response.SendInvoiceResults.Single().Value.IsSuccess);

            // We need to wait some time to allow external system to store the mark from the first call
            await Task.Delay(1000);

            // Step 2 - negative invoice
            var correlatedInvoice = response.SendInvoiceResults.First().Value.Success.InvoiceRegistrationNumber.Value;

            var negativeInvoice = SequentialEnumerableStartingWithOne.FromPreordered <Invoice>(new List <Invoice>
            {
                new CreditInvoice(
                    issuer: new LocalInvoiceParty(new GreekTaxIdentifier(UserVatNumber)),
                    correlatedInvoice: correlatedInvoice,
                    header: new InvoiceHeader(new LimitedString1To50("0"), new LimitedString1To50("50021"), DateTime.Now, currencyCode: new CurrencyCode("EUR")),
                    revenueItems: SequentialEnumerableStartingWithOne.FromPreordered(new List <NegativeRevenue>
                {
                    new NegativeRevenue(new NegativeAmount(-53.65m), new NonPositiveAmount(-12.88m), TaxType.Vat6, RevenueType.Products),
                    new NegativeRevenue(new NegativeAmount(-53.65m), new NonPositiveAmount(-12.88m), TaxType.Vat6, RevenueType.Services),
                    new NegativeRevenue(new NegativeAmount(-53.65m), new NonPositiveAmount(-12.88m), TaxType.Vat6, RevenueType.Other)
                }),
                    payments: NonEmptyEnumerable.Create(
                        new NegativePayment(new NegativeAmount(-133.06m), PaymentType.Cash),
                        new NegativePayment(new NegativeAmount(-66.53m), PaymentType.DomesticPaymentsAccountNumber)
                        ),
                    counterpart: new LocalInvoiceParty(new GreekTaxIdentifier("090701900"), new NonNegativeInt(0), address: new Address(postalCode: new NonEmptyString("12"), city: new NonEmptyString("City")))
                    )
            });

            var negativeInvoiceResponse = await client.SendInvoicesAsync(negativeInvoice);

            // Assert
            Assert.NotEmpty(negativeInvoiceResponse.SendInvoiceResults);
            Assert.True(negativeInvoiceResponse.SendInvoiceResults.Single().Value.IsSuccess);
        }