public void Register(RegisterViewModel model) { var command = new RegisterIncomingInvoiceCommand( model.InvoiceNumber, model.Date, model.DueDate, model.Currency, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, Guid.Empty, Settings.CompanyName, Settings.Address, Settings.City, Settings.PostalCode, Settings.Country, Settings.TaxId, string.Empty, model.Supplier.OriginalId, model.Supplier.Name, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty ); Bus.Send(command); }
public Task Handle(RegisterIncomingInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = IncomingInvoice.Factory.Register( message.InvoiceNumber, message.InvoiceDate, message.DueDate, message.Currency, message.TaxableAmount, message.Taxes, message.TotalPrice, message.Description, message.PaymentTerms, message.PurchaseOrderNumber, message.Customer.Id, message.Customer.Name, message.Customer.Address, message.Customer.City, message.Customer.PostalCode, message.Customer.Country, message.Customer.VatIndex, message.Customer.NationalIdentificationNumber, message.Supplier.Id, message.Supplier.Name, message.Supplier.Address, message.Supplier.City, message.Supplier.PostalCode, message.Supplier.Country, message.Supplier.VatIndex, message.Supplier.NationalIdentificationNumber ); this.Repository.Save(invoice); this.Data.InvoiceId = invoice.Id; if (invoice.DueDate.HasValue) { var timeout = new IncomingInvoiceExpiredTimeout(invoice.Id); Bus.Defer(invoice.DueDate.Value.Subtract(DateTime.Today), timeout); } })); }
public Task Handle(RegisterIncomingInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = IncomingInvoice.Factory.Create( message.InvoiceNumber, message.InvoiceDate, message.Amount, message.Taxes, message.TotalPrice, message.Description, message.PaymentTerms, message.PurchaseOrderNumber, message.Customer.Id, message.Customer.Name ); this._repository.Save(invoice); this.Data.Id = invoice.Id; })); }
public void Register(RegisterViewModel model) { var command = new RegisterIncomingInvoiceCommand( model.InvoiceNumber, model.Date, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.Supplier.OriginalId, model.Supplier.Name, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty ); Bus.Send(command); }
public async Task Handle(RegisterIncomingInvoiceCommand message) { var invoiceLineItems = new Invoice.InvoiceLineItem[0]; if (message.LineItems != null) { invoiceLineItems = message.LineItems .Select(i => new Invoice.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)) .ToArray(); } var invoicePricesByVat = new Invoice.InvoicePriceByVat[0]; if (message.PricesByVat != null) { invoicePricesByVat = message.PricesByVat .Select(p => new Invoice.InvoicePriceByVat(p.TaxableAmount, p.VatRate, p.VatAmount, p.TotalPrice)) .ToArray(); } var nonTaxableItems = new Invoice.NonTaxableItem[0]; if (message.NonTaxableItems != null) { nonTaxableItems = message.NonTaxableItems .Select(t => new Invoice.NonTaxableItem(t.Description, t.Amount)) .ToArray(); } var invoice = IncomingInvoice.Factory.Register( message.InvoiceNumber, message.InvoiceDate, message.DueDate, message.Currency, message.TaxableAmount, message.Taxes, message.TotalPrice, message.TotalToPay, message.Description, message.PaymentTerms, message.PurchaseOrderNumber, message.Customer.Id, message.Customer.Name, message.Customer.Address, message.Customer.City, message.Customer.PostalCode, message.Customer.Country, message.Customer.VatIndex, message.Customer.NationalIdentificationNumber, message.Supplier.Id, message.Supplier.Name, message.Supplier.Address, message.Supplier.City, message.Supplier.PostalCode, message.Supplier.Country, message.Supplier.VatIndex, message.Supplier.NationalIdentificationNumber, invoiceLineItems, message.PricesAreVatIncluded, invoicePricesByVat, nonTaxableItems, message.ProvidenceFundDescription, message.ProvidenceFundRate, message.ProvidenceFundAmount, message.WithholdingTaxDescription, message.WithholdingTaxRate, message.WithholdingTaxTaxableAmountRate, message.WithholdingTaxAmount, message.UserId ); this.Repository.Save(invoice); this.Data.InvoiceId = invoice.Id; if (invoice.DueDate.HasValue) { var timeout = new IncomingInvoiceOverdueTimeout(invoice.Id, message.UserId); await Bus.Defer(invoice.DueDate.Value.Subtract(DateTime.Today), timeout); } }