public async Task ValidNegativeInvoiceWorks() { // Arrange var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); // Act // Step 1 - regular invoice var country = Countries.Greece; var invoices = SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(SalesInvoice.Create( info: AadeTestInvoicesData.CreateInvoiceInfo(invoiceSerialNumber: "50021"), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat13, RevenueType.Other)).Success.Get() )), payments: NonEmptyEnumerable.Create( NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.Cash).Success.Get(), NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.OnCredit).Success.Get(), NonNegativePayment.Create(NonNegativeAmount.Create(100m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get() ), counterpart: AadeTestInvoicesData.CreateInvoiceParty(country, "090701900") ).Success.Get()) )); var response = await client.SendInvoicesAsync(invoices); Assert.True(response.SendInvoiceResults.IsSuccess); Assert.All(response.SendInvoiceResults.Success.Get().Values, result => Assert.True(result.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.Success.Get().Values.First().Value.Success.InvoiceRegistrationNumber.Value; var negativeInvoice = SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(CreditInvoice.Create( correlatedInvoice: correlatedInvoice, info: AadeTestInvoicesData.CreateInvoiceInfo(invoiceSerialNumber: "50021"), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Products)).Success.Get(), NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Services)).Success.Get(), NegativeRevenue.Create(NegativeAmount.Create(-53.65m).Success.Get(), NonPositiveAmount.Create(-12.88m).Success.Get(), AadeTestInvoicesData.CreateRevenueInfo(TaxType.Vat6, RevenueType.Other)).Success.Get() )), payments: NonEmptyEnumerable.Create( NegativePayment.Create(NegativeAmount.Create(-133.06m).Success.Get(), PaymentType.Cash).Success.Get(), NegativePayment.Create(NegativeAmount.Create(-66.53m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get() ), counterPart: AadeTestInvoicesData.CreateInvoiceParty(country, "090701900", address: new Address(postalCode: NonEmptyString.CreateUnsafe("12"), city: NonEmptyString.CreateUnsafe("City"))) ).Success.Get()) )); var negativeInvoiceResponse = await client.SendInvoicesAsync(negativeInvoice); // Assert Assert.True(negativeInvoiceResponse.SendInvoiceResults.IsSuccess); Assert.All(negativeInvoiceResponse.SendInvoiceResults.Success.Get().Values, result => Assert.True(result.Value.IsSuccess)); }
public async Task InvalidInvoiceDocumentSendInvoicesGetsVidationError() { var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); var response = await client.SendInvoicesAsync(GetInvalidTestInvoiceDocument()); Assert.Null(response.SendInvoiceResults.Single().InvoiceIdentifier); Assert.Null(response.SendInvoiceResults.Single().InvoiceRegistrationNumber); Assert.NotNull(response.SendInvoiceResults.Single().Errors.Single()); }
public async Task ValidInvoiceDocumentSendInvoicesWorks() { var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); var response = await client.SendInvoicesAsync(GetValidTestInvoiceDocument()); Assert.NotEmpty(response.SendInvoiceResults.Single().InvoiceIdentifier); Assert.NotNull(response.SendInvoiceResults.Single().InvoiceRegistrationNumber); Assert.True(response.SendInvoiceResults.All(x => x.Errors == null)); }
public async Task ValidInvoicesWork(ISequenceStartingWithOne <Invoice> invoices) { // Arrange var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); // Act var response = await client.SendInvoicesAsync(invoices); // Assert Assert.True(response.SendInvoiceResults.IsSuccess); Assert.All(response.SendInvoiceResults.Success.Get().Values, result => Assert.True(result.Value.IsSuccess)); }
public async Task CheckUserCredentials() { // Arrange var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); // Act var response = await client.CheckUserCredentialsAsync(); // Assert Assert.True(response.IsSuccess); Assert.True(response.Success.IsAuthorized); }
public async Task ValidInvoiceDocumentWorks(InvoiceDocument invoiceDoc) { // Arrange var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); // Act var response = await client.SendInvoicesAsync(invoiceDoc); // Assert Assert.NotEmpty(response.SendInvoiceResults); Assert.True(response.SendInvoiceResults.Single().Item.IsSuccess); }
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); }
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); }