Example #1
0
            public static OutgoingInvoice Create(IOutgoingInvoiceNumberGenerator generator, DateTime invoiceDate, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId, string customerName)
            {
                var @event = new OutgoingInvoiceIssuedEvent(
                    Guid.NewGuid(),
                    generator.Generate(),
                    invoiceDate,
                    amount,
                    taxes,
                    totalPrice,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty
                    );
                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #2
0
 public static OutgoingInvoice Issue(IOutgoingInvoiceNumberGenerator generator, DateTime invoiceDate, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId, string customerName)
 {
     var @event = new OutgoingInvoiceIssuedEvent(
         Guid.NewGuid(),
         generator.Generate(),
         invoiceDate,
         amount,
         taxes,
         totalPrice,
         description,
         paymentTerms,
         purchaseOrderNumber,
         customerId,
         customerName,
         string.Empty,
         string.Empty,
         string.Empty,
         string.Empty,
         string.Empty,
         string.Empty
         );
     var invoice = new OutgoingInvoice();
     invoice.RaiseEvent(@event);
     return invoice;
 }
Example #3
0
            //public static OutgoingInvoice Import(Guid invoiceId, string invoiceNumber, DateTime invoiceDate, DateTime? dueDate, string currency, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId,
            //    string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber,
            //    string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber, Guid userId)
            public static OutgoingInvoice Import(Guid invoiceId, string invoiceNumber, DateTime invoiceDate, DateTime?dueDate, string currency, decimal amount, decimal taxes, decimal totalPrice, decimal totalToPay, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId, string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber, string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber, IEnumerable <InvoiceLineItem> lineItems, bool pricesAreVatIncluded, IEnumerable <InvoicePriceByVat> pricesByVat, IEnumerable <NonTaxableItem> nonTaxableItems,
                                                 string providenceFundDescription, decimal?providenceFundRate, decimal?providenceFundAmount, string withholdingTaxDescription, decimal?withholdingTaxRate, decimal?withholdingTaxTaxableAmountRate, decimal?withholdingTaxAmount, Guid userId)
            {
                var @event = new OutgoingInvoiceIssuedEvent(
                    invoiceId,
                    invoiceNumber,
                    invoiceDate,
                    dueDate,
                    currency,
                    amount,
                    taxes,
                    totalPrice,
                    totalPrice,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    customerAddress,
                    customerCity,
                    customerPostalCode,
                    customerCountry,
                    customerVatIndex,
                    customerNationalIdentificationNumber,
                    supplierName,
                    supplierAddress,
                    supplierCity,
                    supplierPostalCode,
                    supplierCountry,
                    supplierVatIndex,
                    supplierNationalIdentificationNumber,
                    lineItems
                    .Select(i => new OutgoingInvoiceIssuedEvent.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription))
                    .ToArray(),
                    pricesAreVatIncluded,
                    pricesByVat
                    .Select(i => new OutgoingInvoiceIssuedEvent.InvoicePriceByVat(i.TaxableAmount, i.VatRate, i.VatAmount, i.TotalPrice))
                    .ToArray(),
                    nonTaxableItems
                    .Select(i => new OutgoingInvoiceIssuedEvent.NonTaxableItem(i.Description, i.Amount))
                    .ToArray(),
                    providenceFundDescription,
                    providenceFundRate,
                    providenceFundAmount,
                    withholdingTaxDescription,
                    withholdingTaxRate,
                    withholdingTaxTaxableAmountRate,
                    withholdingTaxAmount,
                    userId);
                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #4
0
            public static OutgoingInvoice Issue(IOutgoingInvoiceNumberGenerator generator, DateTime invoiceDate, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId, string customerName)
            {
                var invoice = new OutgoingInvoice()
                {
                    Id                  = Guid.NewGuid(),
                    Number              = generator.Generate(),
                    Date                = invoiceDate,
                    Amount              = amount,
                    Taxes               = taxes,
                    TotalPrice          = totalPrice,
                    Description         = description,
                    PaymentTerms        = paymentTerms,
                    PurchaseOrderNumber = purchaseOrderNumber,
                    Customer            = new PartyInfo(customerId, customerName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty)
                };
                var @event = new OutgoingInvoiceIssuedEvent(
                    invoice.Id,
                    invoice.Number,
                    invoice.Date,
                    invoice.Amount,
                    invoice.Taxes,
                    invoice.TotalPrice,
                    invoice.Description,
                    invoice.PaymentTerms,
                    invoice.PurchaseOrderNumber,
                    invoice.Customer.Id,
                    invoice.Customer.Name,
                    invoice.Customer.StreetName,
                    invoice.Customer.City,
                    invoice.Customer.PostalCode,
                    invoice.Customer.Country,
                    invoice.Customer.VatIndex,
                    invoice.Customer.NationalIdentificationNumber
                    );

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #5
0
            public static OutgoingInvoice Import(Guid invoiceId, string invoiceNumber, DateTime invoiceDate, DateTime?dueDate, string currency, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId,
                                                 string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber,
                                                 string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber)
            {
                var @event = new OutgoingInvoiceIssuedEvent(
                    invoiceId,
                    invoiceNumber,
                    invoiceDate,
                    dueDate,
                    currency,
                    amount,
                    taxes,
                    totalPrice,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    customerAddress,
                    customerCity,
                    customerPostalCode,
                    customerCountry,
                    customerVatIndex,
                    customerNationalIdentificationNumber,
                    supplierName,
                    supplierAddress,
                    supplierCity,
                    supplierPostalCode,
                    supplierCountry,
                    supplierVatIndex,
                    supplierNationalIdentificationNumber,
                    null, false, null, null, Guid.Empty);
                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #6
0
            public static OutgoingInvoice Issue(IOutgoingInvoiceNumberGenerator generator, DateTime invoiceDate, string currency, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId,
                                                string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber,
                                                string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber)
            {
                var @event = new OutgoingInvoiceIssuedEvent(
                    Guid.NewGuid(),
                    generator.Generate(),
                    invoiceDate,
                    invoiceDate.AddMonths(1),
                    currency,
                    amount,
                    taxes,
                    totalPrice,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    customerAddress,
                    customerCity,
                    customerPostalCode,
                    customerCountry,
                    customerVatIndex,
                    customerNationalIdentificationNumber,
                    supplierName,
                    supplierAddress,
                    supplierCity,
                    supplierPostalCode,
                    supplierCountry,
                    supplierVatIndex,
                    supplierNationalIdentificationNumber
                    );
                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #7
0
            public static OutgoingInvoice Issue(IOutgoingInvoiceNumberGenerator generator, DateTime invoiceDate, string currency, decimal amount, decimal taxes, decimal totalPrice, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId,
                                                string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber,
                                                string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber, IEnumerable <InvoiceLineItem> lineItems, bool pricesAreVatIncluded, IEnumerable <InvoicePriceByVat> pricesByVat, IEnumerable <NonTaxableItem> nonTaxableItems, Guid userId)
            {
                if (generator == null)
                {
                    throw new ArgumentNullException(nameof(generator));
                }

                if (lineItems == null)
                {
                    throw new ArgumentNullException(nameof(lineItems));
                }

                if (pricesByVat == null)
                {
                    throw new ArgumentNullException(nameof(pricesByVat));
                }

                var _invoiceLineItems = new OutgoingInvoiceIssuedEvent.InvoiceLineItem[0];

                if (lineItems.Count() > 0)
                {
                    _invoiceLineItems = lineItems.Select(i => new OutgoingInvoiceIssuedEvent.InvoiceLineItem(
                                                             i.Code,
                                                             i.Description,
                                                             i.Quantity,
                                                             i.UnitPrice,
                                                             i.TotalPrice,
                                                             i.Vat)).ToArray();
                }

                var _invoicePricesByVat = new OutgoingInvoiceIssuedEvent.InvoicePriceByVat[0];

                if (pricesByVat.Count() > 0)
                {
                    _invoicePricesByVat = pricesByVat.Select(p => new OutgoingInvoiceIssuedEvent.InvoicePriceByVat(
                                                                 p.TaxableAmount,
                                                                 p.VatRate,
                                                                 p.VatAmount,
                                                                 p.TotalPrice)).ToArray();
                }

                var _nonTaxableItems = new OutgoingInvoiceIssuedEvent.NonTaxableItem[0];

                if (nonTaxableItems != null && nonTaxableItems.Count() > 0)
                {
                    _nonTaxableItems = nonTaxableItems.Select(t => new OutgoingInvoiceIssuedEvent.NonTaxableItem(t.Description, t.Amount)).ToArray();
                }

                var @event = new OutgoingInvoiceIssuedEvent(
                    Guid.NewGuid(),
                    generator.Generate(),
                    invoiceDate,
                    invoiceDate.AddMonths(1),
                    currency,
                    amount,
                    taxes,
                    totalPrice,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    customerAddress,
                    customerCity,
                    customerPostalCode,
                    customerCountry,
                    customerVatIndex,
                    customerNationalIdentificationNumber,
                    supplierName,
                    supplierAddress,
                    supplierCity,
                    supplierPostalCode,
                    supplierCountry,
                    supplierVatIndex,
                    supplierNationalIdentificationNumber,
                    _invoiceLineItems,
                    pricesAreVatIncluded,
                    _invoicePricesByVat,
                    _nonTaxableItems,
                    userId);
                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);
                return(invoice);
            }
Example #8
0
            public static OutgoingInvoice Register(string invoiceNumber, DateTime invoiceDate, DateTime?dueDate, string currency, decimal amount, decimal taxes, decimal totalPrice, decimal totalToPay, string description, string paymentTerms, string purchaseOrderNumber, Guid customerId,
                                                   string customerName, string customerAddress, string customerCity, string customerPostalCode, string customerCountry, string customerVatIndex, string customerNationalIdentificationNumber,
                                                   string supplierName, string supplierAddress, string supplierCity, string supplierPostalCode, string supplierCountry, string supplierVatIndex, string supplierNationalIdentificationNumber, IEnumerable <InvoiceLineItem> lineItems, bool pricesAreVatIncluded, IEnumerable <InvoicePriceByVat> pricesByVat, IEnumerable <NonTaxableItem> nonTaxableItems,
                                                   string providenceFundDescription, decimal?providenceFundRate, decimal?providenceFundAmount, string withholdingTaxDescription, decimal?withholdingTaxRate, decimal?withholdingTaxTaxableAmountRate, decimal?withholdingTaxAmount, Guid userId)
            {
                if (string.IsNullOrWhiteSpace(invoiceNumber))
                {
                    throw new ArgumentException("value cannot be empty", nameof(invoiceNumber));
                }

                if (lineItems == null)
                {
                    throw new ArgumentNullException(nameof(lineItems));
                }

                if (pricesByVat == null)
                {
                    throw new ArgumentNullException(nameof(pricesByVat));
                }

                var _invoiceLineItems = new OutgoingInvoiceIssuedEvent.InvoiceLineItem[0];

                if (lineItems.Count() > 0)
                {
                    _invoiceLineItems = lineItems.Select(i => new OutgoingInvoiceIssuedEvent.InvoiceLineItem(
                                                             i.Code,
                                                             i.Description,
                                                             i.Quantity,
                                                             i.UnitPrice,
                                                             i.TotalPrice,
                                                             i.Vat,
                                                             i.VatDescription)).ToArray();
                }

                var _invoicePricesByVat = new OutgoingInvoiceIssuedEvent.InvoicePriceByVat[0];

                if (pricesByVat.Count() > 0)
                {
                    _invoicePricesByVat = pricesByVat.Select(p => new OutgoingInvoiceIssuedEvent.InvoicePriceByVat(
                                                                 p.TaxableAmount,
                                                                 p.VatRate,
                                                                 p.VatAmount,
                                                                 p.TotalPrice)).ToArray();
                }

                var _nonTaxableItems = new OutgoingInvoiceIssuedEvent.NonTaxableItem[0];

                if (nonTaxableItems != null && nonTaxableItems.Count() > 0)
                {
                    _nonTaxableItems = nonTaxableItems.Select(t => new OutgoingInvoiceIssuedEvent.NonTaxableItem(t.Description, t.Amount)).ToArray();
                }

                var @event = new OutgoingInvoiceIssuedEvent(
                    Guid.NewGuid(),
                    invoiceNumber,
                    invoiceDate,
                    dueDate,
                    currency,
                    amount,
                    taxes,
                    totalPrice,
                    totalToPay,
                    description,
                    paymentTerms,
                    purchaseOrderNumber,
                    customerId,
                    customerName,
                    customerAddress,
                    customerCity,
                    customerPostalCode,
                    customerCountry,
                    customerVatIndex,
                    customerNationalIdentificationNumber,
                    supplierName,
                    supplierAddress,
                    supplierCity,
                    supplierPostalCode,
                    supplierCountry,
                    supplierVatIndex,
                    supplierNationalIdentificationNumber,
                    _invoiceLineItems,
                    pricesAreVatIncluded,
                    _invoicePricesByVat,
                    _nonTaxableItems,
                    providenceFundDescription,
                    providenceFundRate,
                    providenceFundAmount,
                    withholdingTaxDescription,
                    withholdingTaxRate,
                    withholdingTaxTaxableAmountRate,
                    withholdingTaxAmount,
                    userId);

                var invoice = new OutgoingInvoice();

                invoice.RaiseEvent(@event);

                return(invoice);
            }