public IHttpActionResult Post(AddInvoiceModel model) { var order = ordersManager.GetById(model.orderId); double taxValue = CalculationHelper.CalculateTaxes(taxesManager); var invoice = new ProfiCraftsman.Contracts.Entities.Invoices() { Orders = order, TaxValue = taxValue, WithTaxes = order.Customers.WithTaxes, Discount = order.Discount ?? 0, CreateDate = DateTime.Now, ChangeDate = DateTime.Now, IsSellInvoice = model.isSell, PayInDays = 10, InvoicePositions = new List<InvoicePositions>() }; if (AddInvoicePositions(order, invoice)) { invoice.InvoiceNumber = numberProvider.GetNextInvoiceNumber(); invoicesManager.AddEntity(invoice); invoicesManager.SaveChanges(); } model.Id = invoice.Id; return Ok(model); }
public IHttpActionResult Post(AddInvoiceModel model) { var order = ordersManager.GetById(model.orderId); double taxValue = CalculationHelper.CalculateTaxes(taxesManager); var invoice = new ProfiCraftsman.Contracts.Entities.Invoices() { Orders = order, TaxValue = taxValue, WithTaxes = order.Customers.WithTaxes, Discount = order.Discount ?? 0, CreateDate = DateTime.Now, ChangeDate = DateTime.Now, IsSellInvoice = model.isSell, PayInDays = 10, InvoicePositions = new List <InvoicePositions>() }; if (AddInvoicePositions(order, invoice)) { invoice.InvoiceNumber = numberProvider.GetNextInvoiceNumber(); invoicesManager.AddEntity(invoice); invoicesManager.SaveChanges(); } model.Id = invoice.Id; return(Ok(model)); }
public HttpResponseMessage Get() { double taxValue = CalculationHelper.CalculateTaxes(taxesManager); var invoicesForCurrentMonth = new List <ProfiCraftsman.Contracts.Entities.Invoices>(); var orders = ordersManager.GetEntities(o => !o.DeleteDate.HasValue && o.OrderStatus == OrderStatusTypes.Open && !o.IsOffer && o.AutoBill).ToList(); foreach (var order in orders) { var isSell = false;//TODO need generate for Sell positions monthly orders var invoice = new ProfiCraftsman.Contracts.Entities.Invoices() { Orders = order, TaxValue = taxValue, WithTaxes = order.Customers.WithTaxes, Discount = order.Discount ?? 0, CreateDate = DateTime.Now, ChangeDate = DateTime.Now, IsSellInvoice = isSell, InvoicePositions = new List <InvoicePositions>() }; if (AddInvoicePositions(/*todo true, isSell, */ order, invoice)) { invoice.InvoiceNumber = numberProvider.GetNextInvoiceNumber(); invoicesManager.AddEntity(invoice); invoicesManager.SaveChanges(); } invoicesForCurrentMonth.AddRange(order.Invoices. Where(o => o.CreateDate.Month == DateTime.Now.Month && o.CreateDate.Year == DateTime.Now.Year).ToList()); } var response = new HttpResponseMessage(HttpStatusCode.OK); var dataDirectory = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data"); string path = Path.Combine(dataDirectory, Contracts.Configuration.InvoiceFileName); var stream = printerManager.PrepareMonthInvoicePrintData(invoicesForCurrentMonth, path, invoicesManager, taxesManager, ordersManager); response.Content = new StreamContent(stream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); return(response); }
public HttpResponseMessage Get() { double taxValue = CalculationHelper.CalculateTaxes(taxesManager); var invoicesForCurrentMonth = new List<ProfiCraftsman.Contracts.Entities.Invoices>(); var orders = ordersManager.GetEntities(o => !o.DeleteDate.HasValue && o.OrderStatus == OrderStatusTypes.Open && !o.IsOffer && o.AutoBill).ToList(); foreach (var order in orders) { var isSell = false;//TODO need generate for Sell positions monthly orders var invoice = new ProfiCraftsman.Contracts.Entities.Invoices() { Orders = order, TaxValue = taxValue, WithTaxes = order.Customers.WithTaxes, Discount = order.Discount ?? 0, CreateDate = DateTime.Now, ChangeDate = DateTime.Now, IsSellInvoice = isSell, InvoicePositions = new List<InvoicePositions>() }; if (AddInvoicePositions(/*todo true, isSell, */order, invoice)) { invoice.InvoiceNumber = numberProvider.GetNextInvoiceNumber(); invoicesManager.AddEntity(invoice); invoicesManager.SaveChanges(); } invoicesForCurrentMonth.AddRange(order.Invoices. Where(o => o.CreateDate.Month == DateTime.Now.Month && o.CreateDate.Year == DateTime.Now.Year).ToList()); } var response = new HttpResponseMessage(HttpStatusCode.OK); var dataDirectory = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data"); string path = Path.Combine(dataDirectory, Contracts.Configuration.InvoiceFileName); var stream = printerManager.PrepareMonthInvoicePrintData(invoicesForCurrentMonth, path, invoicesManager, taxesManager, ordersManager); response.Content = new StreamContent(stream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); return response; }