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)); }
private UserMessage( NonEmptyEnumerable <int> transactions, UniqueEnumerable <MessageProperty, string> properties) { _transactions = transactions; _properties = properties; }
public static ValidationResult <Party> Create(IEnumerable <string> ids) { return(NonEmptyEnumerable <string> .Create(ids) .Then(xs => xs.Traverse(NonWhiteSpaceString.Create)) .Then(xs => xs.AsUnique()) .Select(xs => new Party(xs))); }
public void Test1 <T>() { // Specification before the actual check of the base-uri. Spec <Uri> spec = Spec.Of <Uri>("uri") .NotNull("uri should not be 'null'") .Equal(uri => uri.Scheme, Uri.UriSchemeHttps, "@scheme should be 'https' scheme"); ValidationResult <Uri> validationResult = spec.Validate(new Uri("http://localhost", UriKind.Relative)); // Demonstration purposes, generic type could be anything. IObservable <T> obs = null; // Access controlled function with validation, revocation, limited amount of evaluations and time-based availability. Access <Uri, Uri> access = Access.OnlyUriFromBase(new Uri("https://localhost:9090/")) .Satisfy(spec) .Once() .DuringHours(9, 17) .RevokedWhen(obs); // Somewhere else... AccessResult <Uri> result = access.Eval(new Uri("http://localhost:9090/path")); if (result.TryGetValue(out Uri output)) { // use the now correct 'output' } int unknown = 5; Untrust <int> untrusted = unknown; ValidationResult <NonZeroInt> nonZeroIntValidationResult = Spec.Of <int>() .GreaterThan(0, "should not be zero") .CreateModel(untrusted, i => new NonZeroInt(i)); Outcome <EbmsString, IDictionary <string, string[]> > ebmsStringResult = EbmsString.Create("mycustomid"); var int100 = Valid <int> .Create(9, x => x > 0 && x < 100, "should be between 1-100"); Outcome <EbmsString, Exception> deserialize = Json.Deserialize <EbmsString>(new Valid <JObject>()); deserialize.Do(ex => throw ex); var nonEmptyResult = NonEmptyEnumerable <string> .Create(new[] { "test1", "test2", "test3" }); var uniqueResult = UniqueEnumerable <int> .Create(new[] { 1, 2, 3 }); }
private static ISequenceStartingWithOne <Invoice> RetailSalesReceiptForCustomer() { return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(RetailSalesReceipt.Create( info: CreateInvoiceInfo(), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NonNegativeRevenue.Create(NonNegativeAmount.Create(53.65m).Success.Get(), NonNegativeAmount.Create(12.88m).Success.Get(), CreateRevenueInfo(TaxType.Vat6, RevenueType.Products)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(53.65m).Success.Get(), NonNegativeAmount.Create(12.88m).Success.Get(), CreateRevenueInfo(TaxType.Vat6, RevenueType.Services)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(53.65m).Success.Get(), NonNegativeAmount.Create(12.88m).Success.Get(), CreateRevenueInfo(TaxType.Vat6, RevenueType.Other)).Success.Get() )), payments: NonEmptyEnumerable.Create( NonNegativePayment.Create(NonNegativeAmount.Create(133.06m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get(), NonNegativePayment.Create(NonNegativeAmount.Create(66.53m).Success.Get(), PaymentType.Cash).Success.Get() ) ).Success.Get()) ))); }
private static ISequenceStartingWithOne <Invoice> SimplifiedInvoiceForCustomer() { return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(SimplifiedInvoice.Create( info: CreateInvoiceInfo(), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NonNegativeRevenue.Create(NonNegativeAmount.Create(20.50m).Success.Get(), NonNegativeAmount.Create(10.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(20.50m).Success.Get(), NonNegativeAmount.Create(10.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(20.50m).Success.Get(), NonNegativeAmount.Create(10.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Other)).Success.Get() )), payments: NonEmptyEnumerable.Create( NonNegativePayment.Create(NonNegativeAmount.Create(31m).Success.Get(), PaymentType.Cash).Success.Get(), NonNegativePayment.Create(NonNegativeAmount.Create(31m).Success.Get(), PaymentType.OnCredit).Success.Get(), NonNegativePayment.Create(NonNegativeAmount.Create(31m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get() ) ).Success.Get()) ))); }
private static ISequenceStartingWithOne <Invoice> CreditInvoiceNonAssociatedForForeignCompany() { return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(CreditInvoice.Create( info: CreateInvoiceInfo(), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(), NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(), NegativeRevenue.Create(NegativeAmount.Create(-88.50m).Success.Get(), NonPositiveAmount.Create(-11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Other)).Success.Get() )), payments: NonEmptyEnumerable.Create( NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.Cash).Success.Get(), NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.OnCredit).Success.Get(), NegativePayment.Create(NegativeAmount.Create(-100m).Success.Get(), PaymentType.DomesticPaymentsAccountNumber).Success.Get() ), counterPart: CreateInvoiceParty(Countries.Greece, "090701900", address: new Address(postalCode: NonEmptyString.CreateUnsafe("12"), city: NonEmptyString.CreateUnsafe("City"))) ).Success.Get()) ))); }
private static ISequenceStartingWithOne <Invoice> InvoiceForForeignCompany() { return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(SalesInvoice.Create( info: CreateInvoiceInfo(), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NonNegativeRevenue.Create(NonNegativeAmount.Create(100m).Success.Get(), NonNegativeAmount.Create(0m).Success.Get(), CreateRevenueInfo(TaxType.Vat0, RevenueType.Products, VatExemptionType.VatIncludedArticle43)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(100m).Success.Get(), NonNegativeAmount.Create(0m).Success.Get(), CreateRevenueInfo(TaxType.Vat0, RevenueType.Services, VatExemptionType.VatIncludedArticle43)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(100m).Success.Get(), NonNegativeAmount.Create(0m).Success.Get(), CreateRevenueInfo(TaxType.Vat0, RevenueType.Other, VatExemptionType.VatIncludedArticle43)).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: CreateInvoiceParty(Countries.Greece, "090701900", address: new Address(postalCode: NonEmptyString.CreateUnsafe("12"), city: NonEmptyString.CreateUnsafe("City"))) ).Success.Get()) ))); }
private static ISequenceStartingWithOne <Invoice> SalesInvoiceForCompany() { return(SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( new Invoice(SalesInvoice.Create( info: CreateInvoiceInfo(), revenueItems: SequenceStartingWithOne.FromPreordered(NonEmptyEnumerable.Create( NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Products)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), CreateRevenueInfo(TaxType.Vat13, RevenueType.Services)).Success.Get(), NonNegativeRevenue.Create(NonNegativeAmount.Create(88.50m).Success.Get(), NonNegativeAmount.Create(11.50m).Success.Get(), 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: CreateInvoiceParty(Countries.Greece, "090701900") ).Success.Get()) ))); }
private static ValidationResult <UserMessage> Map(UserMessageXml userMessage) { ValidationResult <UserMessage> CreateModel(UserMessageXml validated) { var transactionsResult = NonEmptyEnumerable <int> .Create(validated.Transactions); var propertiesResult = validated.Properties.Traverse(MessageProperty.Create) .SelectMany(ids => ids.AsUnique(p => p.Name)); return(ValidationResult.Combine( transactionsResult, propertiesResult, (ts, ps) => new UserMessage(ts, ps))); } return(Spec.Of <UserMessageXml>() .NotNull("cannot create user message from 'null' input") .CreateModel(userMessage, CreateModel)); }
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) ) ) })); }
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) ) ) })); }
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"))) ) })); }
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"))) ) })); }
public async Task CheckNif() { var goodEntries = NonEmptyEnumerable.Create( new NifInfoEntry(IssuingCompany.TaxpayerIdentificationNumber, IssuingCompany.Name.Value), new NifInfoEntry(ReceivingCompany.TaxpayerIdentificationNumber, ReceivingCompany.Name.Value), new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Spain, "99999999R").Success.Get(), "ESPAÑOL ESPAÑOL JUAN"), new NifInfoEntry(IssuingCompany.TaxpayerIdentificationNumber, "Wrong company name") // surprisingly, good company ID with bad company name is found ); var badEntries = NonEmptyEnumerable.Create( new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Spain, "111111111").Success.Get(), IssuingCompany.Name.Value), new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Spain, "99999999R").Success.Get(), "Not Juan"), new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Spain, "12999999R").Success.Get(), "Non existent name for non existent ID."), new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Angola, "123456").Success.Get(), "Random tax id") ); await AssertNifLookup(goodEntries, NifSearchResult.Found); await AssertNifLookup(badEntries, NifSearchResult.NotFound); // Surprisingly, this works for some reason. var serverModifiedEntry = new NifInfoEntry(TaxpayerIdentificationNumber.Create(Countries.Spain, "A08433179").Success.Get(), "Microsoft test company"); await AssertNifLookup(serverModifiedEntry.ToEnumerable(), NifSearchResult.NotFoundBecauseNifModifiedByServer); }
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); }
private Deliver(string type, NonEmptyEnumerable <Parameter> parameters) { Type = type; Parameters = parameters; }