public Task Handle(ImportOutgoingInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = OutgoingInvoice.Factory.Import( message.InvoiceId, message.InvoiceNumber, message.InvoiceDate, message.DueDate, message.TaxableAmount, message.Taxes, message.TotalPrice, message.Description, message.PaymentTerms, message.PurchaseOrderNumber, message.Customer.Id, message.Customer.Name, message.Customer.StreetName, message.Customer.City, message.Customer.PostalCode, message.Customer.Country, message.Customer.VatIndex, message.Customer.NationalIdentificationNumber, message.Supplier.Name, message.Supplier.StreetName, message.Supplier.City, message.Supplier.PostalCode, message.Supplier.Country, message.Supplier.VatIndex, message.Supplier.NationalIdentificationNumber ); this.Repository.Save(invoice); this.Data.InvoiceId = invoice.Id; })); }
public async Task Handle(ImportOutgoingInvoiceCommand message) { var invoice = OutgoingInvoice.Factory.Import( message.InvoiceId, 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.StreetName, message.Customer.City, message.Customer.PostalCode, message.Customer.Country, message.Customer.VatIndex, message.Customer.NationalIdentificationNumber, message.Supplier.Name, message.Supplier.StreetName, message.Supplier.City, message.Supplier.PostalCode, message.Supplier.Country, message.Supplier.VatIndex, message.Supplier.NationalIdentificationNumber, message.LineItems .Select(i => new OutgoingInvoice.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)) .ToArray(), false, message.PricesByVat .Select(i => new OutgoingInvoice.InvoicePriceByVat(i.TaxableAmount, i.VatRate, i.VatAmount, i.TotalPrice)) .ToArray(), message.NonTaxableItems .Select(i => new OutgoingInvoice.NonTaxableItem(i.Description, i.Amount)) .ToArray(), message.ProvidenceFundDescription, message.ProvidenceFundRate, message.ProvidenceFundAmount, message.WithholdingTaxDescription, message.WithholdingTaxRate, message.WithholdingTaxTaxableAmountRate, message.WithholdingTaxAmount, message.UserId ); await this.Repository.SaveAsync(invoice); this.Data.InvoiceId = invoice.Id; }
public async Task ImportOutgoingInvoiceAsync(ImportOutgoingInvoiceModel model) { var command = new ImportOutgoingInvoiceCommand( model.UserId, model.InvoiceId, model.InvoiceNumber, model.InvoiceDate, model.DueDate, model.Currency, model.TaxableAmount, model.Taxes, model.TotalPrice, model.TotalToPay, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, new ImportOutgoingInvoiceCommand.PartyInfo( model.Customer.Id, model.Customer.Name, model.Customer.StreetName, model.Customer.City, model.Customer.PostalCode, model.Customer.Country, model.Customer.VatIndex, model.Customer.NationalIdentificationNumber ), new ImportOutgoingInvoiceCommand.PartyInfo( model.Supplier.Id, model.Supplier.Name, model.Supplier.StreetName, model.Supplier.City, model.Supplier.PostalCode, model.Supplier.Country, model.Supplier.VatIndex, model.Supplier.NationalIdentificationNumber ), model.LineItems.Select(i => new ImportOutgoingInvoiceCommand.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)).ToList(), model.PricesAreVatIncluded, model.PricesByVat.Select(p => new ImportOutgoingInvoiceCommand.InvoicePriceByVat(p.TaxableAmount, p.VatRate, p.VatAmount, p.TotalPrice, p.ProvidenceFundAmount)).ToList(), model.NonTaxableItems.Select(i => new ImportOutgoingInvoiceCommand.NonTaxableItem(i.Description, i.Amount)).ToList(), model.ProvidenceFundDescription, model.ProvidenceFundRate, model.ProvidenceFundAmount, model.WithholdingTaxDescription, model.WithholdingTaxRate, model.WithholdingTaxTaxableAmountRate, model.WithholdingTaxAmount ); await Bus.Send(command); }