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); }
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 SalesInvoice( InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments, InvoiceParty counterpart) { Info = info; RevenueItems = revenueItems; Payments = payments; Counterpart = counterpart; }
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 <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 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; }
private SimplifiedInvoice(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments) { Info = info; RevenueItems = revenueItems; Payments = payments; }