public async Task <IActionResult> OrderIncompleteReportList(DataSourceRequest command)
        {
            if (!await _permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(Content(""));
            }

            //a vendor does have access to this report
            if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff())
            {
                return(Content(""));
            }

            string storeId = "";

            if (_workContext.CurrentCustomer.IsStaff())
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }


            var model = new List <OrderIncompleteReportLineModel>();
            //not paid
            var psPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, ps : PaymentStatus.Pending, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalUnpaidOrders"),
                Count    = psPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(psPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { paymentStatusId = ((int)PaymentStatus.Pending).ToString() })
            });
            //not shipped
            var ssPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, ss : ShippingStatus.NotYetShipped, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalNotShippedOrders"),
                Count    = ssPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(ssPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { shippingStatusId = ((int)ShippingStatus.NotYetShipped).ToString() })
            });
            //pending
            var osPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, os : OrderStatus.Pending, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalIncompleteOrders"),
                Count    = osPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(osPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { orderStatusId = ((int)OrderStatus.Pending).ToString() })
            });

            var gridModel = new DataSourceResult {
                Data  = model,
                Total = model.Count
            };

            return(Json(gridModel));
        }
예제 #2
0
        public ActionResult GetOrderReportList(DataSourceRequest command, OrderReportModel model)
        {
            DateTime?startDateValue = (model.StartDate == null) ? null
                           : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);


            OrderStatus?orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null;

            orderStatus = OrderStatus.Complete;
            //load orders
            var orders = _orderService.SearchOrders(0, 0, 0, 0, 0,
                                                    startDateValue, endDateValue, orderStatus,
                                                    null, null, null, null,
                                                    command.Page - 1, command.PageSize);
            var gridModel = new DataSourceResult
            {
                Data = orders.Select(x =>
                {
                    return(new OrderModel()
                    {
                        Id = x.Id,
                        OrderTotal = _priceFormatter.FormatPrice(x.OrderTotal, true, false),
                        OrderStatus = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                        CustomerEmail = x.BillingAddress.Email,
                        CustomerFullName = string.Format("{0} {1}", x.BillingAddress.FirstName, x.BillingAddress.LastName),
                        CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)
                    });
                }),
                Total = orders.TotalCount,
            };

            //summary report
            var reportSummary = _orderReportService.GetOrderAverageReportLine(0,
                                                                              0, orderStatus, null, null,
                                                                              startDateValue, endDateValue, null);


            gridModel.ExtraData = new OrderAggreratorModel()
            {
                aggregatortotal = _priceFormatter.FormatPrice(reportSummary.SumOrders, true, false),
                avgOrderTotal   = _priceFormatter.FormatPrice(reportSummary.SumOrders / gridModel.Total, true, false)
            };

            return(Json(gridModel));
        }
예제 #3
0
        private async Task <DashboardActivityModel> PrepareActivityModel()
        {
            var    model    = new DashboardActivityModel();
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            var storeId = string.Empty;

            if (_workContext.CurrentCustomer.IsStaff())
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }

            model.OrdersPending  = (await _orderReportService.GetOrderAverageReportLine(storeId: storeId, os: OrderStatus.NewOrder)).CountOrders;
            model.AbandonedCarts = (await _customerService.GetAllCustomers(storeId: storeId, loadOnlyWithShoppingCart: true, pageSize: 1)).TotalCount;

            HttpContext.RequestServices.GetRequiredService <IProductService>().GetLowStockProducts(vendorId, storeId, out IList <Product> products, out IList <ProductAttributeCombination> combinations);

            model.LowStockProducts = products.Count + combinations.Count;

            model.ReturnRequests = await _mediator.Send(new GetReturnRequest()
            {
                RequestStatusId = 0, StoreId = storeId
            });

            model.TodayRegisteredCustomers = (await _customerService.GetAllCustomers(storeId: storeId, customerRoleIds: new string[] { (await _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered)).Id }, createdFromUtc: DateTime.UtcNow.Date, pageSize: 1)).TotalCount;
            return(model);
        }
예제 #4
0
        private DashboardActivityModel PrepareActivityModel()
        {
            var    model    = new DashboardActivityModel();
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            model.OrdersPending  = _orderReportService.GetOrderAverageReportLine(os: Core.Domain.Orders.OrderStatus.Pending).CountOrders;
            model.AbandonedCarts = _customerService.GetAllCustomers(loadOnlyWithShoppingCart: true, pageSize: 1).TotalCount;

            IList <Product> products;
            IList <ProductAttributeCombination> combinations;

            Grand.Core.Infrastructure.EngineContext.Current.Resolve <Grand.Services.Catalog.IProductService>()
            .GetLowStockProducts(vendorId, out products, out combinations);

            model.LowStockProducts = products.Count + combinations.Count;

            model.ReturnRequests           = (int)_returnRequestRepository.Collection.Count(new BsonDocument());
            model.TodayRegisteredCustomers = _customerService.GetAllCustomers(customerRoleIds: new string[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id }, createdFromUtc: DateTime.UtcNow.Date, pageSize: 1).TotalCount;
            return(model);
        }
예제 #5
0
        private DashboardActivityModel PrepareActivityModel()
        {
            var model = new DashboardActivityModel();

            model.OrdersPending  = _orderReportService.GetOrderAverageReportLine(os: Core.Domain.Orders.OrderStatus.Pending).CountOrders;
            model.AbandonedCarts = _customerService.GetAllCustomers(loadOnlyWithShoppingCart: true, pageSize: 1).TotalCount;
            var doc = MongoDB.Bson.Serialization.BsonSerializer
                      .Deserialize <BsonDocument>
                          ("{$where: \" this.MinStockQuantity > this.StockQuantity && this.ProductTypeId == 5 && this.ManageInventoryMethodId != 0  \" }");

            model.LowStockProducts = _productRepository.Collection.Find(new CommandDocument(doc)).ToListAsync().Result.Count;

            model.ReturnRequests           = (int)_returnRequestRepository.Collection.Count(new BsonDocument());
            model.TodayRegisteredCustomers = _customerService.GetAllCustomers(customerRoleIds: new string[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id }, createdFromUtc: DateTime.UtcNow.Date, pageSize: 1).TotalCount;
            return(model);
        }
예제 #6
0
        private async Task <DashboardActivityModel> PrepareActivityModel()
        {
            var    model    = new DashboardActivityModel();
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            var storeId = string.Empty;

            if (await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }

            model.OrdersPending  = (await _orderReportService.GetOrderAverageReportLine(storeId: storeId, os: (int)OrderStatusSystem.Pending)).CountOrders;
            model.AbandonedCarts = (await _mediator.Send(new GetCustomerQuery()
            {
                StoreId = storeId, LoadOnlyWithShoppingCart = true
            })).Count();

            var lowStockProducts = await _productsReportService.LowStockProducts(vendorId, storeId);

            model.LowStockProducts = lowStockProducts.products.Count + lowStockProducts.combinations.Count;

            model.MerchandiseReturns = await _mediator.Send(new GetMerchandiseReturnCountQuery()
            {
                RequestStatusId = 0, StoreId = storeId
            });

            model.TodayRegisteredCustomers =
                (await _mediator.Send(new GetCustomerQuery()
            {
                StoreId = storeId,
                CustomerGroupIds = new string[] { (await _groupService.GetCustomerGroupBySystemName(SystemCustomerGroupNames.Registered)).Id },
                CreatedFromUtc = DateTime.UtcNow.Date
            })).Count();
            return(model);
        }
예제 #7
0
        private async Task <DashboardActivityModel> PrepareActivityModel()
        {
            var    model    = new DashboardActivityModel();
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            model.OrdersPending  = (await _orderReportService.GetOrderAverageReportLine(os: OrderStatus.Pending)).CountOrders;
            model.AbandonedCarts = (await _customerService.GetAllCustomers(loadOnlyWithShoppingCart: true, pageSize: 1)).TotalCount;

            _serviceProvider.GetRequiredService <IProductService>()
            .GetLowStockProducts(vendorId, out IList <Product> products, out IList <ProductAttributeCombination> combinations);

            model.LowStockProducts = products.Count + combinations.Count;

            model.ReturnRequests           = (int)_returnRequestRepository.Table.Where(x => x.ReturnRequestStatusId == 0).Count();
            model.TodayRegisteredCustomers = (await _customerService.GetAllCustomers(customerRoleIds: new string[] { (await _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered)).Id }, createdFromUtc: DateTime.UtcNow.Date, pageSize: 1)).TotalCount;
            return(model);
        }
예제 #8
0
        public virtual ActionResult OrderList(DataSourceRequest command, Admin.Models.Orders.OrderListModel model)
        {
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var amazonSettings = _settingService.LoadSetting<OrderAmazonSettings>(storeScope);
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedKendoGridJson();

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                model.VendorId = _workContext.CurrentVendor.Id;
            }

            DateTime? startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime? endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var orderStatusIds = !model.OrderStatusIds.Contains(0) ? model.OrderStatusIds : null;
            var paymentStatusIds = !model.PaymentStatusIds.Contains(0) ? model.PaymentStatusIds : null;
            var shippingStatusIds = !model.ShippingStatusIds.Contains(0) ? model.ShippingStatusIds : null;

            var filterByProductId = 0;
            var product = _productService.GetProductById(model.ProductId);
            if (product != null && HasAccessToProduct(product))
                filterByProductId = model.ProductId;

            //load orders
            var orders = _orderAmazonService.SearchOrders(storeId: model.StoreId,
                vendorId: model.VendorId,
                productId: filterByProductId,
                warehouseId: model.WarehouseId,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                createdFromUtc: startDateValue,
                createdToUtc: endDateValue,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize);
            var gridModel = new DataSourceResult
            {
                Data = orders.Select(x =>
                {
                    var store = _storeService.GetStoreById(x.StoreId);
                    return new OrderModel
                    {
                        Id = x.Id,
                        StoreName = store != null ? store.Name : "Unknown",
                        OrderTotal = _priceFormatter.FormatPrice(x.OrderTotal, true, false),
                        OrderStatus = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                        OrderStatusId = x.OrderStatusId,
                        PaymentStatus = x.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                        PaymentStatusId = x.PaymentStatusId,
                        ShippingStatus = x.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                        ShippingStatusId = x.ShippingStatusId,
                        CustomerEmail = x.BillingAddress.Email,
                        CustomerFullName = string.Format("{0} {1}", x.BillingAddress.FirstName, x.BillingAddress.LastName),
                        CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc),
                        CustomOrderNumber = x.CustomOrderNumber,

                        OrderAmazon = _orderAmazonService.GetOrderAmazonByOrderId(x.Id)
                    };
                }),
                Total = orders.TotalCount
            };

            //summary report
            //currently we do not support productId and warehouseId parameters for this report
            var reportSummary = _orderReportService.GetOrderAverageReportLine(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                orderId: 0,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes);

            var profit = _orderReportService.ProfitReport(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes);
            var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
            if (primaryStoreCurrency == null)
                throw new Exception("Cannot load primary store currency");

            gridModel.ExtraData = new Admin.Models.Orders.OrderAggreratorModel
            {
                aggregatorprofit = _priceFormatter.FormatPrice(profit, true, false),
                aggregatorshipping = _priceFormatter.FormatShippingPrice(reportSummary.SumShippingExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false),
                aggregatortax = _priceFormatter.FormatPrice(reportSummary.SumTax, true, false),
                aggregatortotal = _priceFormatter.FormatPrice(reportSummary.SumOrders, true, false)
            };

            return Json(gridModel);
        }
예제 #9
0
        public ActionResult InvoiceList(DataSourceRequest command, InvoiceListModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            //    return AccessDeniedView();

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                model.VendorId = _workContext.CurrentVendor.Id;
            }

            DateTime?startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            OrderStatus?   orderStatus    = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null;
            PaymentStatus? paymentStatus  = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null;
            ShippingStatus?shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null;

            var filterByProductId = 0;
            var product           = _productService.GetProductById(model.ProductId);
            //if (product != null && HasAccessToProduct(product))
            //    filterByProductId = model.ProductId;

            //load invoices
            var invoices = _invoiceService.SearchInvoices(storeId: model.StoreId,
                                                          //vendorId: model.VendorId,
                                                          productId: filterByProductId,
                                                          warehouseId: model.WarehouseId,
                                                          billingCountryId: model.BillingCountryId,
                                                          paymentMethodSystemName: model.PaymentMethodSystemName,
                                                          createdFromUtc: startDateValue,
                                                          createdToUtc: endDateValue,
                                                          os: orderStatus,
                                                          ps: paymentStatus,
                                                          ss: shippingStatus,
                                                          billingEmail: model.CustomerEmail,
                                                          orderNotes: model.OrderNotes,
                                                          orderGuid: model.OrderGuid,
                                                          pageIndex: command.Page - 1,
                                                          pageSize: command.PageSize);

            foreach (var invoice in invoices)
            {
                var order = _orderService.GetOrderById(invoice.OrderId);
                invoice.OrderTotal = order.OrderTotal;
            }

            var gridModel = new DataSourceResult
            {
                Data = invoices.Select(x =>
                {
                    var store = _storeService.GetStoreById(x.StoreId);
                    return(new InvoiceModel
                    {
                        Id = x.Id,
                        StoreName = store != null ? store.Name : "Unknown",
                        OrderTotal = _priceFormatter.FormatPrice(x.OrderTotal, true, false),
                        OrderStatus = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                        PaymentStatus = x.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                        ShippingStatus = x.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                        //            CustomerEmail = x.BillingAddress.Email,
                        //            CustomerFullName = string.Format("{0} {1}", x.BillingAddress.FirstName, x.BillingAddress.LastName),
                        CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc),
                        Commission = x.Commission
                    });
                }),
                Total = invoices.TotalCount
            };

            //summary report
            //currently we do not support productId and warehouseId parameters for this report
            var reportSummary = _orderReportService.GetOrderAverageReportLine(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                billingCountryId: model.BillingCountryId,
                orderId: 0,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                os: orderStatus,
                ps: paymentStatus,
                ss: shippingStatus,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.CustomerEmail,
                orderNotes: model.OrderNotes);
            var profit = _orderReportService.ProfitReport(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                billingCountryId: model.BillingCountryId,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                os: orderStatus,
                ps: paymentStatus,
                ss: shippingStatus,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.CustomerEmail,
                orderNotes: model.OrderNotes);
            var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);

            if (primaryStoreCurrency == null)
            {
                throw new Exception("Cannot load primary store currency");
            }

            gridModel.ExtraData = new OrderAggreratorModel
            {
                aggregatorprofit   = _priceFormatter.FormatPrice(profit, true, false),
                aggregatorshipping = _priceFormatter.FormatShippingPrice(reportSummary.SumShippingExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false),
                aggregatortax      = _priceFormatter.FormatPrice(reportSummary.SumTax, true, false),
                aggregatortotal    = _priceFormatter.FormatPrice(reportSummary.SumOrders, true, false)
            };
            return(new JsonResult
            {
                Data = gridModel
            });
        }