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);
 }
Beispiel #2
0
 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)
                ));
 }
Beispiel #3
0
 private SalesInvoice(
     InvoiceInfo info,
     ISequenceStartingWithOne <NonNegativeRevenue> revenueItems,
     INonEmptyEnumerable <NonNegativePayment> payments,
     InvoiceParty counterpart)
 {
     Info         = info;
     RevenueItems = revenueItems;
     Payments     = payments;
     Counterpart  = counterpart;
 }
Beispiel #4
0
 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();
 }
Beispiel #5
0
 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));
        }
Beispiel #7
0
 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)
                ));
 }
Beispiel #8
0
 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;
 }