Ejemplo n.º 1
0
        public ActionResult SalesInvoice(int id = 0)
        {
            var model = new Web.Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);

            model.DocumentType = Core.Domain.DocumentTypes.SalesInvoice;

            if (id == 0)
            {
                return(View(model));
            }
            else
            {
                var invoice = _salesService.GetSalesInvoiceById(id);
                model.Id         = invoice.Id;
                model.CustomerId = invoice.CustomerId;
                model.Date       = invoice.Date;
                model.No         = invoice.No;
                foreach (var line in invoice.SalesInvoiceLines)
                {
                    var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                    lineItem.SetServiceHelpers(_financialService);
                    lineItem.Id              = line.Id;
                    lineItem.CustomerId      = invoice.CustomerId;
                    lineItem.ItemId          = line.ItemId;
                    lineItem.ItemNo          = line.Item.No;
                    lineItem.ItemDescription = line.Item.Description;
                    lineItem.Measurement     = line.Measurement.Description;
                    lineItem.Quantity        = line.Quantity;
                    lineItem.Discount        = line.Discount;
                    lineItem.Price           = line.Amount;
                    model.SalesLine.SalesLineItems.Add(lineItem);
                }
                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult SalesInvoice(int id)
        {
            var order = _salesService.GetSalesInvoiceById(id);
            var model = new Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);

            model.Id         = order.Id;
            model.CustomerId = order.CustomerId;
            model.Date       = order.Date;
            model.No         = order.No;

            foreach (var line in order.SalesInvoiceLines)
            {
                var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                lineItem.Id              = line.Id;
                lineItem.ItemId          = line.ItemId;
                lineItem.ItemNo          = line.Item.No;
                lineItem.ItemDescription = line.Item.Description;
                lineItem.Measurement     = line.Measurement.Description;
                lineItem.Quantity        = line.Quantity;
                lineItem.Discount        = line.Discount;
                lineItem.Price           = line.Amount;
                model.SalesLine.SalesLineItems.Add(lineItem);
            }

            HttpContext.Response.Clear();
            HttpContext.Response.AddHeader("Content-Type", "application/pdf");
            var html = base.RenderPartialViewToString("~/Views/Reports/SalesInvoice.cshtml", model);

            HttpContext.Response.Filter = new PdfFilter(HttpContext.Response.Filter, html);
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult SalesInvoice(int id)
        {
            var order = _salesService.GetSalesInvoiceById(id);
            var model = new Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);
            model.Id = order.Id;
            model.CustomerId = order.CustomerId;
            model.Date = order.Date;
            model.No = order.No;

            foreach (var line in order.SalesInvoiceLines)
            {
                var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                lineItem.Id = line.Id;
                lineItem.ItemId = line.ItemId;
                lineItem.ItemNo = line.Item.No;
                lineItem.ItemDescription = line.Item.Description;
                lineItem.Measurement = line.Measurement.Description;
                lineItem.Quantity = line.Quantity;
                lineItem.Discount = line.Discount;
                lineItem.Price = line.Amount;
                model.SalesLine.SalesLineItems.Add(lineItem);
            }

            HttpContext.Response.Clear();
            HttpContext.Response.AddHeader("Content-Type", "application/pdf");
            var html = base.RenderPartialViewToString("~/Views/Reports/SalesInvoice.cshtml", model);
            HttpContext.Response.Filter = new PdfFilter(HttpContext.Response.Filter, html);
            return View(model);
        }
Ejemplo n.º 4
0
        private void AddLineItem(Models.ViewModels.Sales.SalesHeaderViewModel model)
        {
            if (!model.CustomerId.HasValue)
            {
                throw new Exception("Please enter customer.");
            }

            var item    = _inventoryService.GetItemByNo(model.SalesLine.ItemNo);
            var newLine = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);

            newLine.CustomerId      = model.CustomerId.HasValue ? model.CustomerId.Value : 0;
            newLine.ItemId          = item.Id;
            newLine.ItemNo          = item.No;
            newLine.ItemDescription = item.Description;
            newLine.Measurement     = item.SellMeasurement.Description;
            newLine.Quantity        = model.SalesLine.Quantity;
            newLine.Price           = model.SalesLine.Price;
            newLine.Discount        = model.SalesLine.Discount;
            model.SalesLine.SalesLineItems.Add(newLine);

            foreach (var line in model.SalesLine.SalesLineItems)
            {
                line.SetServiceHelpers(_financialService);
            }
        }
Ejemplo n.º 5
0
        private void AddLineItem(Models.ViewModels.Sales.SalesHeaderViewModel model)
        {
            var item    = _inventoryService.GetItemByNo(model.SalesLine.ItemNo);
            var newLine = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);

            newLine.ItemId          = item.Id;
            newLine.ItemNo          = item.No;
            newLine.ItemDescription = item.Description;
            newLine.Measurement     = item.SellMeasurement.Description;
            newLine.Quantity        = model.SalesLine.Quantity;
            newLine.Price           = model.SalesLine.Price;
            newLine.Discount        = model.SalesLine.Discount;
            model.SalesLine.SalesLineItems.Add(newLine);

            foreach (var line in model.SalesLine.SalesLineItems)
            {
                line.SetServiceHelpers(_financialService);
            }
        }
Ejemplo n.º 6
0
        public ActionResult SalesOrder(int id = 0)
        {
            var model = new Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);

            model.DocumentType = Core.Domain.DocumentTypes.SalesOrder;

            if (id == 0)
            {
                return(View(model));
            }
            else
            {
                var order = _salesService.GetSalesOrderById(id);
                model.Id            = order.Id;
                model.CustomerId    = order.CustomerId;
                model.PaymentTermId = order.PaymentTermId;
                model.Date          = order.Date;
                model.Reference     = order.ReferenceNo;
                model.No            = order.No;

                foreach (var line in order.SalesOrderLines)
                {
                    var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                    lineItem.Id              = line.Id;
                    lineItem.ItemId          = line.ItemId;
                    lineItem.ItemNo          = line.Item.No;
                    lineItem.ItemDescription = line.Item.Description;
                    lineItem.Measurement     = line.Measurement.Description;
                    lineItem.Quantity        = line.Quantity;
                    lineItem.Discount        = line.Discount;
                    lineItem.Price           = line.Amount;
                    model.SalesLine.SalesLineItems.Add(lineItem);
                }
                return(View(model));
            }
        }
Ejemplo n.º 7
0
        private void AddLineItem(Models.ViewModels.Sales.SalesHeaderViewModel model)
        {
            var item = _inventoryService.GetItemByNo(model.SalesLine.ItemNo);
            var newLine = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
            newLine.ItemId = item.Id;
            newLine.ItemNo = item.No;
            newLine.ItemDescription = item.Description;
            newLine.Measurement = item.SellMeasurement.Description;
            newLine.Quantity = model.SalesLine.Quantity;
            newLine.Price = model.SalesLine.Price;
            newLine.Discount = model.SalesLine.Discount;            
            model.SalesLine.SalesLineItems.Add(newLine);

            foreach (var line in model.SalesLine.SalesLineItems)
                line.SetServiceHelpers(_financialService);
        }
Ejemplo n.º 8
0
        public ActionResult SalesOrder(int id = 0)
        {
            var model = new Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);
            model.DocumentType = Core.Domain.DocumentTypes.SalesOrder;

            if (id == 0)
            {
                return View(model);
            }
            else
            {
                var order = _salesService.GetSalesOrderById(id);
                model.Id = order.Id;
                model.CustomerId = order.CustomerId;
                model.PaymentTermId = order.PaymentTermId;
                model.Date = order.Date;
                model.Reference = order.ReferenceNo;
                model.No = order.No;

                foreach (var line in order.SalesOrderLines)
                {
                    var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                    lineItem.Id = line.Id;
                    lineItem.ItemId = line.ItemId;
                    lineItem.ItemNo = line.Item.No;
                    lineItem.ItemDescription = line.Item.Description;
                    lineItem.Measurement = line.Measurement.Description;
                    lineItem.Quantity = line.Quantity;
                    lineItem.Discount = line.Discount;
                    lineItem.Price = line.Amount;
                    model.SalesLine.SalesLineItems.Add(lineItem);
                }
                return View(model);
            }
        }
Ejemplo n.º 9
0
        public ActionResult SalesInvoice(int id = 0)
        {
            var model = new Web.Models.ViewModels.Sales.SalesHeaderViewModel(_inventoryService, _financialService);
            model.DocumentType = Core.Domain.DocumentTypes.SalesInvoice;

            if (id == 0)
            {   
                return View(model);
            }
            else
            {
                var invoice = _salesService.GetSalesInvoiceById(id);
                model.Id = invoice.Id;
                model.CustomerId = invoice.CustomerId;
                model.Date = invoice.Date;
                model.No = invoice.No;
                foreach (var line in invoice.SalesInvoiceLines)
                {
                    var lineItem = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
                    lineItem.SetServiceHelpers(_financialService);
                    lineItem.Id = line.Id;
                    lineItem.ItemId = line.ItemId;
                    lineItem.ItemNo = line.Item.No;
                    lineItem.ItemDescription = line.Item.Description;
                    lineItem.Measurement = line.Measurement.Description;
                    lineItem.Quantity = line.Quantity;
                    lineItem.Discount = line.Discount;
                    lineItem.Price = line.Amount;
                    model.SalesLine.SalesLineItems.Add(lineItem);
                }
                return View(model);
            }
        }
Ejemplo n.º 10
0
        private void AddLineItem(Models.ViewModels.Sales.SalesHeaderViewModel model)
        {
            if (!model.CustomerId.HasValue)
                throw new Exception("Please enter customer.");

            var item = _inventoryService.GetItemByNo(model.SalesLine.ItemNo);
            var newLine = new Models.ViewModels.Sales.SalesLineItemViewModel(_financialService);
            newLine.CustomerId = model.CustomerId.HasValue ? model.CustomerId.Value : 0;
            newLine.ItemId = item.Id;
            newLine.ItemNo = item.No;
            newLine.ItemDescription = item.Description;
            newLine.Measurement = item.SellMeasurement.Description;
            newLine.Quantity = model.SalesLine.Quantity;
            newLine.Price = model.SalesLine.Price;
            newLine.Discount = model.SalesLine.Discount;            
            model.SalesLine.SalesLineItems.Add(newLine);

            foreach (var line in model.SalesLine.SalesLineItems)
                line.SetServiceHelpers(_financialService);
        }