public static Dto.Xsd.InvoicesDoc GetInvoiceDoc(ISequenceStartingWithOne <Invoice> invoices) { return(new Dto.Xsd.InvoicesDoc { Invoices = invoices.Values.Select(invoice => GetInvoice(invoice.Value)).ToArray() }); }
private static bool IsValidSimplifiedInvoice(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems) { if (info.Header.CurrencyCode.IsNull() || info.Header.CurrencyCode.Value == "EUR") { return(revenueItems.Values.Sum(i => i.Value.NetValue.Value + i.Value.VatValue.Value) <= 100); } return(true); }
private SalesInvoice( InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments, InvoiceParty counterpart) { Info = info; RevenueItems = revenueItems; Payments = payments; Counterpart = counterpart; }
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)); }
private CreditInvoice( InvoiceInfo info, ISequenceStartingWithOne <NegativeRevenue> revenueItems, INonEmptyEnumerable <NegativePayment> payments, InvoiceParty counterpart, long?correlatedInvoice = null) { Info = info; RevenueItems = revenueItems; Payments = payments; Counterpart = counterpart; CorrelatedInvoice = correlatedInvoice.ToOption(); }
public static ITry <SalesInvoice, IEnumerable <Error> > Create( InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments, InvoiceParty counterpart) { return(Try.Aggregate( ObjectValidations.NotNull(info), ObjectValidations.NotNull(revenueItems), ObjectValidations.NotNull(payments), ObjectValidations.NotNull(counterpart), (i, r, p, c) => new SalesInvoice(i, r, p, c) )); }
public static ITry <CreditInvoice, IEnumerable <Error> > Create( InvoiceInfo info, ISequenceStartingWithOne <NegativeRevenue> revenueItems, INonEmptyEnumerable <NegativePayment> payments, InvoiceParty counterPart, long?correlatedInvoice = null) { return(Try.Aggregate( ObjectValidations.NotNull(info), ObjectValidations.NotNull(revenueItems), ObjectValidations.NotNull(payments), ObjectValidations.NotNull(counterPart), (i, r, p, c) => new CreditInvoice(i, r, p, c, correlatedInvoice) )); }
private RetailSalesReceipt(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments) { Info = info; RevenueItems = revenueItems; Payments = payments; }
public static ITry <RetailSalesReceipt, IEnumerable <Error> > Create(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments) { return(Try.Aggregate( ObjectValidations.NotNull(info), ObjectValidations.NotNull(revenueItems), ObjectValidations.NotNull(payments), (i, r, p) => new RetailSalesReceipt(i, r, p) )); }
private SimplifiedInvoice(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments) { Info = info; RevenueItems = revenueItems; Payments = payments; }
public static ITry <SimplifiedInvoice, IEnumerable <Error> > Create(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments) { var result = Try.Aggregate( ObjectValidations.NotNull(info), ObjectValidations.NotNull(revenueItems), ObjectValidations.NotNull(payments), (i, r, p) => IsValidSimplifiedInvoice(i, r).ToTry( t => new SimplifiedInvoice(i, r, p), f => new Error($"{nameof(SimplifiedInvoice)} can only be below or equal to 100 EUR.").ToEnumerable() ) ); return(result.FlatMap(r => r)); }
public async Task <SendInvoicesResult> SendInvoicesAsync(ISequenceStartingWithOne <Invoice> invoices) { var responseDoc = await RestClient.SendRequestAsync(InvoiceDocumentMapper.GetInvoiceDoc(invoices)); return(new SendInvoicesResult(responseDoc)); }