public async Task Handle(ImportIncomingInvoiceCommand message) { var invoice = IncomingInvoice.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.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, message.LineItems .Select(i => new IncomingInvoice.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)) .ToArray(), false, message.PricesByVat .Select(i => new IncomingInvoice.InvoicePriceByVat(i.TaxableAmount, i.VatRate, i.VatAmount, i.TotalPrice)) .ToArray(), message.NonTaxableItems .Select(i => new IncomingInvoice.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 ImportIncomingInvoiceAsync(ImportIncomingInvoiceModel model) { var command = new ImportIncomingInvoiceCommand( 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 ImportIncomingInvoiceCommand.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 ImportIncomingInvoiceCommand.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 ImportIncomingInvoiceCommand.InvoiceLineItem(i.Code, i.Description, i.Quantity, i.UnitPrice, i.TotalPrice, i.Vat, i.VatDescription)).ToList(), model.PricesAreVatIncluded, model.PricesByVat.Select(p => new ImportIncomingInvoiceCommand.InvoicePriceByVat(p.TaxableAmount, p.VatRate, p.VatAmount, p.TotalPrice, p.ProvidenceFundAmount)).ToList(), model.NonTaxableItems.Select(i => new ImportIncomingInvoiceCommand.NonTaxableItem(i.Description, i.Amount)).ToList(), model.ProvidenceFundDescription, model.ProvidenceFundRate, model.ProvidenceFundAmount, model.WithholdingTaxDescription, model.WithholdingTaxRate, model.WithholdingTaxTaxableAmountRate, model.WithholdingTaxAmount ); await Bus.Send(command); }
public Task Handle(ImportIncomingInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = IncomingInvoice.Factory.Import( message.InvoiceId, 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; })); }