public void Issue(IssueViewModel model) { var command = new IssueInvoiceCommand( model.Date, model.Currency, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.Customer.OriginalId, model.Customer.Name, Settings.Address, Settings.City, Settings.PostalCode, Settings.Country, Settings.TaxId, Settings.TaxId, Settings.CompanyName, Settings.Address, Settings.City, Settings.PostalCode, Settings.Country, Settings.TaxId, string.Empty ); Bus.Send(command); }
public void Ctor_should_set_properties_according_to_parameters() { DateTime invoiceDate = new DateTime(1990, 11, 11); decimal amount = 101; decimal taxes = 42; decimal totalPrice = 143; string description = "fake"; string paymentTerms = "none"; string purchaseOrderNumber = "42"; Guid customerId = Guid.NewGuid(); string customerName = "Managed Designs S.r.l."; string streetName = "Via Torino 51"; string city = "Milan"; string postalCode = "20123"; string country = "Italy"; string vatIndex = "04358780965"; string nationalIdentificationNumber = "04358780965"; var sut = new IssueInvoiceCommand( invoiceDate, amount, taxes, totalPrice, description, paymentTerms, purchaseOrderNumber, customerId, customerName, streetName, city, postalCode, country, vatIndex, nationalIdentificationNumber); Assert.AreEqual <DateTime>(invoiceDate, sut.InvoiceDate); Assert.AreEqual <decimal>(amount, sut.Amount); Assert.AreEqual <decimal>(taxes, sut.Taxes); Assert.AreEqual <decimal>(totalPrice, sut.TotalPrice); Assert.AreEqual <string>(description, sut.Description); Assert.AreEqual <string>(paymentTerms, sut.PaymentTerms); Assert.AreEqual <string>(purchaseOrderNumber, sut.PurchaseOrderNumber); Assert.AreEqual <Guid>(customerId, sut.Customer.Id); Assert.AreEqual <string>(customerName, sut.Customer.Name); Assert.AreEqual <string>(streetName, sut.Customer.StreetName); Assert.AreEqual <string>(city, sut.Customer.City); Assert.AreEqual <string>(postalCode, sut.Customer.PostalCode); Assert.AreEqual <string>(country, sut.Customer.Country); Assert.AreEqual <string>(vatIndex, sut.Customer.VatIndex); Assert.AreEqual <string>(nationalIdentificationNumber, sut.Customer.NationalIdentificationNumber); }
public Task Handle(IssueInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = OutgoingInvoice.Factory.Create( this.InvoiceNumberGenerator, 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.InvoiceId = invoice.Id; })); }
public Task Handle(IssueInvoiceCommand message) { return(Task.Factory.StartNew(() => { var invoice = OutgoingInvoice.Factory.Issue( this.InvoiceNumberGenerator, message.InvoiceDate, message.Currency, 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; if (invoice.DueDate.HasValue) { var timeout = new OutgoingInvoiceExpiredTimeout(invoice.Id); Bus.Defer(invoice.DueDate.Value.Subtract(DateTime.Today), timeout); } })); }
public void Issue(IssueViewModel model) { var command = new IssueInvoiceCommand( model.Date, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.Customer.OriginalId, model.Customer.Name, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty ); Bus.Send(command); }
public async Task Handle(IssueInvoiceCommand 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 = OutgoingInvoice.Factory.Issue( this.InvoiceNumberGenerator, message.InvoiceDate, 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, 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 OutgoingInvoiceOverdueTimeout(invoice.Id, message.UserId); await Bus.Defer(invoice.DueDate.Value.Subtract(DateTime.Today), timeout); } }
public void Ctor_should_set_properties_according_to_parameters() { var userId = Guid.NewGuid(); DateTime invoiceDate = new DateTime(1990, 11, 11); string currency = "EUR"; decimal amount = 101; decimal taxes = 42; decimal totalPrice = 143; string description = "fake"; string paymentTerms = "none"; string purchaseOrderNumber = "42"; Guid customerId = Guid.NewGuid(); string customerName = "Managed Designs S.r.l."; string customerAddress = "Via Torino 51"; string customerCity = "Milan"; string customerPostalCode = "20123"; string customerCountry = "Italy"; string customerVatIndex = "04358780965"; string customerNationalIdentificationNumber = "04358780965"; string supplierName = "Mastreeno ltd"; string supplierAddress = "8, Leman street"; string supplierCity = "London"; string supplierPostalCode = ""; string supplierCountry = "England - United Kingdom"; string supplierVatIndex = "XYZ"; string supplierNationalIdentificationNumber = "04358780965"; var sut = new IssueInvoiceCommand( userId, invoiceDate, currency, amount, taxes, totalPrice, totalPrice, description, paymentTerms, purchaseOrderNumber, customerId, customerName, customerAddress, customerCity, customerPostalCode, customerCountry, customerVatIndex, customerNationalIdentificationNumber, supplierName, supplierAddress, supplierCity, supplierPostalCode, supplierCountry, supplierVatIndex, supplierNationalIdentificationNumber, null, false, null, null, null, null, null, null, null, null, null); Assert.Equal(invoiceDate, sut.InvoiceDate); Assert.Equal(currency, sut.Currency); Assert.Equal(amount, sut.TaxableAmount); Assert.Equal(taxes, sut.Taxes); Assert.Equal(totalPrice, sut.TotalPrice); Assert.Equal(description, sut.Description); Assert.Equal(paymentTerms, sut.PaymentTerms); Assert.Equal(purchaseOrderNumber, sut.PurchaseOrderNumber); Assert.Equal(customerId, sut.Customer.Id); Assert.Equal(customerName, sut.Customer.Name); Assert.Equal(customerAddress, sut.Customer.StreetName); Assert.Equal(customerCity, sut.Customer.City); Assert.Equal(customerPostalCode, sut.Customer.PostalCode); Assert.Equal(customerCountry, sut.Customer.Country); Assert.Equal(customerVatIndex, sut.Customer.VatIndex); Assert.Equal(customerNationalIdentificationNumber, sut.Customer.NationalIdentificationNumber); Assert.Equal(supplierName, sut.Supplier.Name); Assert.Equal(supplierAddress, sut.Supplier.StreetName); Assert.Equal(supplierCity, sut.Supplier.City); Assert.Equal(supplierPostalCode, sut.Supplier.PostalCode); Assert.Equal(supplierCountry, sut.Supplier.Country); Assert.Equal(supplierVatIndex, sut.Supplier.VatIndex); Assert.Equal(supplierNationalIdentificationNumber, sut.Supplier.NationalIdentificationNumber); }