Ejemplo n.º 1
0
 public RetailSalesReceipt(
     InvoiceHeader header,
     LocalInvoiceParty issuer,
     ISequentialEnumerableStartingWithOne <NonNegativeRevenue> revenueItems,
     INonEmptyEnumerable <NonNegativePayment> payments)
     : base(header, issuer, revenueItems, payments)
 {
 }
Ejemplo n.º 2
0
 private SalesInvoice(
     InvoiceInfo info,
     ISequenceStartingWithOne <NonNegativeRevenue> revenueItems,
     INonEmptyEnumerable <NonNegativePayment> payments,
     InvoiceParty counterpart)
 {
     Info         = info;
     RevenueItems = revenueItems;
     Payments     = payments;
     Counterpart  = counterpart;
 }
Ejemplo n.º 3
0
        private async Task AssertNifLookup(INonEmptyEnumerable <NifInfoEntry> entries, NifSearchResult expectedResult)
        {
            var validator = new NifValidator(Certificate, httpTimeout: TimeSpan.FromSeconds(30));
            var response  = await validator.CheckNif(new Request(entries));

            Assert.AreEqual(response.Results.Count(), entries.Count());
            foreach (var result in response.Results)
            {
                Assert.AreEqual(expectedResult, result.Result);
            }
        }
 public SimplifiedInvoice(
     InvoiceHeader header,
     LocalInvoiceParty issuer,
     ISequentialEnumerableStartingWithOne <NonNegativeRevenue> revenueItems,
     INonEmptyEnumerable <NonNegativePayment> payments)
     : base(header, issuer, revenueItems, payments)
 {
     if (header.CurrencyCode.IsNull() || header.CurrencyCode.Value == "EUR")
     {
         Check.Condition(revenueItems.Sum(i => i.Value.NetValue.Value + i.Value.VatValue.Value) <= 100, "Simplified Invoice can only be below 100 EUR.");
     }
 }
Ejemplo n.º 5
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();
 }
Ejemplo n.º 6
0
 public SalesInvoice(
     InvoiceHeader header,
     LocalInvoiceParty issuer,
     ISequentialEnumerableStartingWithOne <NonNegativeRevenue> revenueItems,
     InvoiceParty counterpart,
     INonEmptyEnumerable <NonNegativePayment> payments)
     : base(header, issuer, revenueItems, payments, counterpart)
 {
     if (counterpart == null)
     {
         throw new ArgumentNullException(nameof(counterpart));
     }
 }
Ejemplo n.º 7
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)
                ));
 }
Ejemplo n.º 8
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)
                ));
 }
Ejemplo n.º 9
0
        public Invoice(
            InvoiceHeader header,
            LocalInvoiceParty issuer,
            ISequentialEnumerableStartingWithOne <Revenue> revenueItems,
            INonEmptyEnumerable <Payment> payments,
            InvoiceParty counterpart = null,
            long?correlatedInvoice   = null)
        {
            Header            = header ?? throw new ArgumentNullException(nameof(header));
            Issuer            = issuer ?? throw new ArgumentNullException(nameof(issuer));
            RevenueItems      = revenueItems ?? throw new ArgumentNullException(nameof(revenueItems));
            Payments          = payments ?? throw new ArgumentNullException(nameof(payments));
            Counterpart       = counterpart;
            CorrelatedInvoice = correlatedInvoice;

            if (!RevenueItems.Any())
            {
                throw new ArgumentException($"Minimal count of {nameof(revenueItems)} is 1.");
            }
        }
        public static ISequenceStartingWithZero <T> FromPreordered(INonEmptyEnumerable <T> values)
        {
            var sequence = Sequence <T> .FromPreordered(values, startIndex : 0);

            return(new SequenceStartingWithZero <T>(sequence));
        }
Ejemplo n.º 11
0
 private RetailSalesReceipt(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments)
 {
     Info         = info;
     RevenueItems = revenueItems;
     Payments     = payments;
 }
Ejemplo n.º 12
0
 private TaxSummary(INonEmptyEnumerable <TaxExemptItem> taxExempt = null, INonEmptyEnumerable <TaxRateSummary> taxed = null)
 {
     TaxExempt = taxExempt.ToOption();
     Taxed     = taxed.ToOption();
 }
 private SimplifiedInvoice(InvoiceInfo info, ISequenceStartingWithOne <NonNegativeRevenue> revenueItems, INonEmptyEnumerable <NonNegativePayment> payments)
 {
     Info         = info;
     RevenueItems = revenueItems;
     Payments     = payments;
 }
Ejemplo n.º 14
0
 public Request(INonEmptyEnumerable <NifInfoEntry> entries)
 {
     Entries = entries;
 }
Ejemplo n.º 15
0
        public static ISequence <T> FromPreordered(INonEmptyEnumerable <T> values, int startIndex)
        {
            var result = Create(values.Select((value, index) => new Indexed <T>(startIndex + index, value)));

            return(result.Get(e => throw new Exception($"{nameof(FromPreordered)} resulted in an invalid sequence.")));
        }
Ejemplo n.º 16
0
 private Sequence(INonEmptyEnumerable <Indexed <T> > values)
 {
     Values = values;
 }
Ejemplo n.º 17
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)
                ));
 }
        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));
        }