예제 #1
0
        public void InitReport()
        {
            DateTime start = new DateTime(2016, 1, 1);
            DateTime end   = new DateTime(2017, 12, 31);

            result    = report.Report(customerId, start, end);
            resultGet = report.Report(customerIdGet);
        }
예제 #2
0
        public InvoiceReviewGetModel Report(int id)
        {
            InvoiceReviewGetModel result = new InvoiceReviewGetModel();

            var Invoices = _unitOfWork.Invoices.Get().Where(x => (x.Id == id)).ToList();
            var Items    = Invoices.SelectMany(x => x.Items).ToList();

            foreach (var invoice in Invoices)
            {
                result.InvoiceNo     = invoice.InvoiceNo;
                result.InvoiceDate   = invoice.Date;
                result.InvoiceStatus = (int)invoice.Status;
                result.VatAmount     = Math.Round(invoice.VatAmount, 2);
                result.Shipping      = invoice.Shipping;
                result.Subtotal      = invoice.SubTotal + result.VatAmount + result.Shipping;
                result.Shipper       = (invoice.Shipper == null) ? null : invoice.Shipper.Name;
                result.ShippedOn     = invoice.ShippedOn;
            }
            var query2 = Items
                         .GroupBy(
                x => new
            {
                ProductId   = x.Product.Id,
                ProductName = x.Product.Name,
                Quantity    = x.Quantity,
                Price       = x.Price,
                Unit        = x.Product.Unit,
                Subtotal    = x.SubTotal
            })
                         .Select(x => new
            {
                ProductId   = x.Key.ProductId,
                ProductName = x.Key.ProductName,
                Quantity    = x.Key.Quantity,
                Price       = x.Key.Price,
                Unit        = x.Key.Unit,
                Subtotal    = x.Key.Subtotal,
                Total       = x.Sum(y => y.SubTotal)
            }).ToList();
            var customer = Invoices.FirstOrDefault();

            result.CustomerName = customer.Customer.Name;

            foreach (var item in query2)
            {
                result.Items.Add(new InvoiceReviewItem()
                {
                    ProductId   = item.ProductId,
                    ProductName = item.ProductName,
                    Quantity    = item.Quantity,
                    Price       = item.Price,
                    Unit        = item.Unit,
                    Subtotal    = item.Subtotal
                });
            }

            return(result);
        }
예제 #3
0
        public InvoiceReviewGetModel Report(int id)
        {
            var Invoice = UnitOfWork.Invoices.Get().Where(x => x.Id == id).ToList();
            //double Subtotal = Invoice.Sum(x => x.SubTotal);
            Invoice invoice = UnitOfWork.Invoices.Get(id);

            InvoiceReviewGetModel result = new InvoiceReviewGetModel()
            {
                InvoiceNo     = invoice.InvoiceNo,
                CustomerName  = invoice.Customer.Name,
                InvoiceDate   = invoice.Date,
                InvoiceStatus = invoice.Status.ToString(),
                Subtotal      = invoice.SubTotal,
                VatAmount     = invoice.VatAmount,
                Shipping      = invoice.Shipping,
                Shipper       = invoice.Shipper.Name,
                ShippedOn     = invoice.ShippedOn
            };

            result.Products = UnitOfWork.Items.Get().Where(x => x.Invoice.Id == id).ToList()
                              .Select(x => Factory.Create(x.Product.Id, x.Product.Name, x.Quantity, x.Price, x.SubTotal)).ToList();

            return(result);
        }