Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
ARCH-001 Phase 9: Reports controller/service consolidation (Admin/Store/Vendor) (#801)
Krzysztof Pajakb9f182caea36
diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/AdminReportDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/AdminReportDataScopeTests.csnew file mode 100644index 000000000..63b09eded--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/AdminReportDataScopeTests.cs@@ -0,0 +1,29 @@+using Grand.Domain.Catalog;+using Grand.Web.AdminShared.Services;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class AdminReportDataScopeTests+{+ [TestMethod]+ public void ScopeDefaults_UnscopedWithBothSelectorsShown()+ {+ var scope = new AdminReportDataScope();++ Assert.AreEqual("", scope.StoreId);+ Assert.AreEqual("", scope.VendorId);+ Assert.IsTrue(scope.ShowStoreSelector);+ Assert.IsTrue(scope.ShowVendorSelector);+ Assert.AreEqual("Admin", scope.ResourceKeyPrefix);+ }++ [TestMethod]+ public void CanIncludeProduct_NotOverridden_AlwaysTrue()+ {+ var scope = new AdminReportDataScope();+ Assert.IsTrue(scope.CanIncludeProduct(new Product { Id = "p1" }));+ Assert.IsTrue(scope.CanIncludeProduct(null));+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseFullReportsControllerTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseFullReportsControllerTests.csnew file mode 100644index 000000000..977bbd6e1--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseFullReportsControllerTests.cs@@ -0,0 +1,285 @@+#nullable enable++using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Products;+using Grand.Business.Core.Interfaces.Checkout.Orders;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Common.Security;+using Grand.Business.Core.Interfaces.Common.Stores;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Interfaces.System.Reports;+using Grand.Business.Core.Utilities.System;+using Grand.Domain;+using Grand.Domain.Directory;+using Grand.Domain.Orders;+using Grand.Domain.Permissions;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.AdminShared.Models.Orders;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Localization;+using Microsoft.AspNetCore.Http;+using Microsoft.AspNetCore.Mvc;+using Microsoft.AspNetCore.Mvc.Routing;+using Microsoft.AspNetCore.Routing;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class BaseFullReportsControllerTests+{+ private class TestFullReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope,+ IOrderService orderService,+ ICustomerReportService customerReportService,+ IPermissionService permissionService)+ : BaseFullReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService,+ orderStatusService, enumTranslationService, contextAccessor, scope, orderService,+ customerReportService, permissionService);++ private TestFullReportsController _controller = null!;+ private Mock<IOrderReportService> _orderReportServiceMock = null!;+ private Mock<IOrderService> _orderServiceMock = null!;+ private Mock<IPermissionService> _permissionServiceMock = null!;+ private Mock<IReportDataScope> _scopeMock = null!;+ private Mock<ICustomerReportViewModelService> _customerReportViewModelServiceMock = null!;+ private Mock<ICustomerReportService> _customerReportServiceMock = null!;++ [TestInitialize]+ public void Setup()+ {+ _orderReportServiceMock = new Mock<IOrderReportService>();+ var productsReportServiceMock = new Mock<IProductsReportService>();+ _customerReportViewModelServiceMock = new Mock<ICustomerReportViewModelService>();+ var priceFormatterMock = new Mock<IPriceFormatter>();+ priceFormatterMock.Setup(p => p.FormatPrice(It.IsAny<double>(), It.IsAny<Currency>())).Returns("$0.00");+ var currencyServiceMock = new Mock<ICurrencyService>();+ currencyServiceMock.Setup(c => c.GetPrimaryStoreCurrency()).ReturnsAsync(new Currency());+ var productServiceMock = new Mock<IProductService>();+ var productAttributeFormatterMock = new Mock<IProductAttributeFormatter>();+ var stockQuantityServiceMock = new Mock<IStockQuantityService>();+ var translationServiceMock = new Mock<ITranslationService>();+ translationServiceMock.Setup(t => t.GetResource(It.IsAny<string>())).Returns("resource");+ var storeServiceMock = new Mock<IStoreService>();+ var countryServiceMock = new Mock<ICountryService>();+ var vendorServiceMock = new Mock<IVendorService>();+ var dateTimeServiceMock = new Mock<IDateTimeService>();+ var orderStatusServiceMock = new Mock<IOrderStatusService>();+ orderStatusServiceMock.Setup(o => o.GetAll()).ReturnsAsync(new List<Grand.Domain.Orders.OrderStatus>());+ var enumTranslationServiceMock = new Mock<IEnumTranslationService>();+ var contextAccessorMock = new Mock<IContextAccessor>();+ _scopeMock = new Mock<IReportDataScope>();+ _scopeMock.Setup(s => s.StoreId).Returns("");+ _scopeMock.Setup(s => s.VendorId).Returns("");+ _orderServiceMock = new Mock<IOrderService>();+ _customerReportServiceMock = new Mock<ICustomerReportService>();+ _permissionServiceMock = new Mock<IPermissionService>();+ _permissionServiceMock.Setup(p => p.Authorize(StandardPermission.ManageOrders)).ReturnsAsync(true);++ _controller = new TestFullReportsController(_orderReportServiceMock.Object, productsReportServiceMock.Object,+ _customerReportViewModelServiceMock.Object, priceFormatterMock.Object, currencyServiceMock.Object,+ productServiceMock.Object, productAttributeFormatterMock.Object, stockQuantityServiceMock.Object,+ translationServiceMock.Object, storeServiceMock.Object, countryServiceMock.Object,+ vendorServiceMock.Object, dateTimeServiceMock.Object, orderStatusServiceMock.Object,+ enumTranslationServiceMock.Object, contextAccessorMock.Object, _scopeMock.Object,+ _orderServiceMock.Object, _customerReportServiceMock.Object, _permissionServiceMock.Object);++ var httpContext = new DefaultHttpContext();+ var urlHelperFactoryMock = new Mock<IUrlHelperFactory>();+ urlHelperFactoryMock.Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>())).Returns(new Mock<IUrlHelper>().Object);+ var requestServicesMock = new Mock<IServiceProvider>();+ requestServicesMock.Setup(s => s.GetService(typeof(IUrlHelperFactory))).Returns(urlHelperFactoryMock.Object);+ httpContext.RequestServices = requestServicesMock.Object;+ var routeData = new RouteData();+ routeData.Values["area"] = "Admin";+ _controller.ControllerContext = new ControllerContext { HttpContext = httpContext, RouteData = routeData };+ }++ [TestMethod]+ public async Task BestsellersBriefReportByQuantityList_ManageOrdersDenied_ReturnsEmptyContent()+ {+ _permissionServiceMock.Setup(p => p.Authorize(StandardPermission.ManageOrders)).ReturnsAsync(false);++ var result = await _controller.BestsellersBriefReportByQuantityList(new DataSourceRequest { Page = 1, PageSize = 10 }) as ContentResult;++ Assert.IsNotNull(result);+ Assert.AreEqual("", result!.Content);+ _orderReportServiceMock.Verify(o => o.BestSellersReport(It.IsAny<string>(), It.IsAny<string>(),+ It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int?>(), It.IsAny<Grand.Domain.Payments.PaymentStatus?>(),+ It.IsAny<Grand.Domain.Shipping.ShippingStatus?>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(),+ It.IsAny<int>(), It.IsAny<bool>()), Times.Never);+ }++ [TestMethod]+ public async Task BestsellersBriefReportByAmountList_ManageOrdersAllowed_DelegatesToBase()+ {+ _orderReportServiceMock.Setup(o => o.BestSellersReport("", "", null, null, null, null, null, "", 2, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 0));++ var result = await _controller.BestsellersBriefReportByAmountList(new DataSourceRequest { Page = 1, PageSize = 10 });++ Assert.IsInstanceOfType(result, typeof(JsonResult));+ }++ [TestMethod]+ public async Task BestsellersBriefReportByAmountList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _orderReportServiceMock.Setup(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 2, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 0));++ await _controller.BestsellersBriefReportByAmountList(new DataSourceRequest { Page = 1, PageSize = 10 });++ _orderReportServiceMock.Verify(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 2, 0, 10, true), Times.Once);+ }++ [TestMethod]+ public async Task BestsellersBriefReportByAmountList_CanIncludeProductFalse_DropsRow()+ {+ var line = new BestsellersReportLine { ProductId = "p1", TotalAmount = 1, TotalQuantity = 1 };+ _orderReportServiceMock.Setup(o => o.BestSellersReport("", "", null, null, null, null, null, "", 2, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine> { line }, 0, 1));+ _scopeMock.Setup(s => s.CanIncludeProduct(It.IsAny<Grand.Domain.Catalog.Product>())).Returns(false);++ var result = await _controller.BestsellersBriefReportByAmountList(new DataSourceRequest { Page = 1, PageSize = 10 }) as JsonResult;++ var gridModel = (DataSourceResult)result!.Value!;+ Assert.AreEqual(0, ((List<BestsellersReportLineModel>)gridModel.Data).Count);+ }++ [TestMethod]+ public async Task ReportOrderPeriodList_ManageOrdersDenied_ReturnsEmptyContent()+ {+ _permissionServiceMock.Setup(p => p.Authorize(StandardPermission.ManageOrders)).ReturnsAsync(false);++ var result = await _controller.ReportOrderPeriodList(new DataSourceRequest { Page = 1, PageSize = 10 }) as ContentResult;++ Assert.IsNotNull(result);+ Assert.AreEqual("", result!.Content);+ }++ [TestMethod]+ public async Task ReportOrderTimeChart_ManageOrdersAllowed_PassesScopeStoreId()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _orderReportServiceMock.Setup(o => o.GetOrderByTimeReport("store-1", null, null))+ .ReturnsAsync(new List<OrderByTimeReportLine>());++ await _controller.ReportOrderTimeChart(new DataSourceRequest { Page = 1, PageSize = 10 }, null, null);++ _orderReportServiceMock.Verify(o => o.GetOrderByTimeReport("store-1", null, null), Times.Once);+ }++ [TestMethod]+ public async Task OrderAverageReportList_ManageOrdersAllowed_UsesScopeStoreIdForAllFourStatuses()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _orderReportServiceMock.Setup(o => o.OrderAverageReport("store-1", It.IsAny<int>()))+ .ReturnsAsync(new OrderAverageReportLineSummary());++ var result = await _controller.OrderAverageReportList(new DataSourceRequest { Page = 1, PageSize = 10 });++ Assert.IsInstanceOfType(result, typeof(JsonResult));+ _orderReportServiceMock.Verify(o => o.OrderAverageReport("store-1", It.IsAny<int>()), Times.Exactly(4));+ }++ [TestMethod]+ public async Task ReportLatestOrder_ManageOrdersAllowed_PassesScopeStoreIdToSearchOrders()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _orderServiceMock.Setup(o => o.SearchOrders("store-1", "", "", "", "", "", "", "", "",+ null, null, null, null, null, null, null, "", null, null, 0, 10, ""))+ .ReturnsAsync(new PagedList<Order>(new List<Order>(), 0, 0));++ await _controller.ReportLatestOrder(new DataSourceRequest { Page = 1, PageSize = 10 }, null, null);++ _orderServiceMock.Verify(o => o.SearchOrders("store-1", "", "", "", "", "", "", "", "",+ null, null, null, null, null, null, null, "", null, null, 0, 10, ""), Times.Once);+ }++ [TestMethod]+ public async Task OrderIncompleteReportList_ManageOrdersAllowed_ReturnsThreeRows()+ {+ _orderReportServiceMock.Setup(o => o.GetOrderAverageReportLine(It.IsAny<string>(), It.IsAny<string>(),+ It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),+ It.IsAny<int?>(), It.IsAny<Grand.Domain.Payments.PaymentStatus?>(), It.IsAny<Grand.Domain.Shipping.ShippingStatus?>(),+ It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>(), true, It.IsAny<string>()))+ .ReturnsAsync(new OrderAverageReportLine());++ var result = await _controller.OrderIncompleteReportList(new DataSourceRequest { Page = 1, PageSize = 10 }) as JsonResult;++ var gridModel = (DataSourceResult)result!.Value!;+ Assert.AreEqual(3, ((List<OrderIncompleteReportLineModel>)gridModel.Data).Count);+ }++ [TestMethod]+ public async Task ReportBestCustomersByNumberOfOrdersList_PassesScopeVendorIdToService()+ {+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _customerReportViewModelServiceMock.Setup(s =>+ s.PrepareBestCustomerReportLineModel(It.IsAny<BestCustomersReportModel>(), 2, 1, 10, "vendor-1"))+ .ReturnsAsync((new List<BestCustomerReportLineModel>(), 0));++ await _controller.ReportBestCustomersByNumberOfOrdersList(new DataSourceRequest { Page = 1, PageSize = 10 },+ new BestCustomersReportModel());++ _customerReportViewModelServiceMock.Verify(s =>+ s.PrepareBestCustomerReportLineModel(It.IsAny<BestCustomersReportModel>(), 2, 1, 10, "vendor-1"), Times.Once);+ }++ /// <summary>Verifies both scope values are passed to the service call, not that vendorId changes+ /// behavior — GetReportRegisteredCustomersModel's vendorId parameter is a documented no-op today+ /// (see its XML doc / ICustomerReportViewModelService), kept for signature symmetry and+ /// forward-compatibility. scope.VendorId is always "" for this Full-tier-only action anyway.</summary>+ [TestMethod]+ public async Task ReportRegisteredCustomersList_ScopeStoreIdAndVendorIdAcceptedByServiceCall()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _customerReportViewModelServiceMock.Setup(s => s.GetReportRegisteredCustomersModel("store-1", "vendor-1"))+ .ReturnsAsync(new List<RegisteredCustomerReportLineModel>());++ await _controller.ReportRegisteredCustomersList(new DataSourceRequest { Page = 1, PageSize = 10 });++ _customerReportViewModelServiceMock.Verify(s => s.GetReportRegisteredCustomersModel("store-1", "vendor-1"), Times.Once);+ }++ [TestMethod]+ public async Task ReportCustomerTimeChart_PassesScopeStoreIdToService()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _customerReportServiceMock.Setup(s => s.GetCustomerByTimeReport("store-1", null, null))+ .ReturnsAsync(new List<CustomerByTimeReportLine>());++ await _controller.ReportCustomerTimeChart(new DataSourceRequest { Page = 1, PageSize = 10 }, null, null);++ _customerReportServiceMock.Verify(s => s.GetCustomerByTimeReport("store-1", null, null), Times.Once);+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseReportsControllerTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseReportsControllerTests.csnew file mode 100644index 000000000..dee78901a--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/BaseReportsControllerTests.cs@@ -0,0 +1,312 @@+#nullable enable++using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Products;+using Grand.Business.Core.Interfaces.Checkout.Orders;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Common.Stores;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Interfaces.System.Reports;+using Grand.Business.Core.Utilities.System;+using Grand.Domain;+using Grand.Domain.Catalog;+using Grand.Domain.Directory;+using Grand.Domain.Stores;+using Grand.Domain.Vendors;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.AdminShared.Models.Orders;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Localization;+using Microsoft.AspNetCore.Mvc;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class BaseReportsControllerTests+{+ private class TestReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope)+ : BaseReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService,+ orderStatusService, enumTranslationService, contextAccessor, scope);++ private TestReportsController _controller = null!;+ private Mock<IOrderReportService> _orderReportServiceMock = null!;+ private Mock<IProductsReportService> _productsReportServiceMock = null!;+ private Mock<ICustomerReportViewModelService> _customerReportViewModelServiceMock = null!;+ private Mock<IProductService> _productServiceMock = null!;+ private Mock<IStoreService> _storeServiceMock = null!;+ private Mock<IVendorService> _vendorServiceMock = null!;+ private Mock<IReportDataScope> _scopeMock = null!;++ [TestInitialize]+ public void Setup()+ {+ _orderReportServiceMock = new Mock<IOrderReportService>();+ _productsReportServiceMock = new Mock<IProductsReportService>();+ _customerReportViewModelServiceMock = new Mock<ICustomerReportViewModelService>();+ _customerReportViewModelServiceMock.Setup(s => s.PrepareCustomerReportsModel()).ReturnsAsync(new CustomerReportsModel());+ var priceFormatterMock = new Mock<IPriceFormatter>();+ priceFormatterMock.Setup(p => p.FormatPrice(It.IsAny<double>(), It.IsAny<Currency>())).Returns("$0.00");+ var currencyServiceMock = new Mock<ICurrencyService>();+ currencyServiceMock.Setup(c => c.GetPrimaryStoreCurrency()).ReturnsAsync(new Currency());+ _productServiceMock = new Mock<IProductService>();+ var productAttributeFormatterMock = new Mock<IProductAttributeFormatter>();+ var stockQuantityServiceMock = new Mock<IStockQuantityService>();+ var translationServiceMock = new Mock<ITranslationService>();+ translationServiceMock.Setup(t => t.GetResource(It.IsAny<string>())).Returns("resource");+ _storeServiceMock = new Mock<IStoreService>();+ _storeServiceMock.Setup(s => s.GetAllStores()).ReturnsAsync(new List<Store>());+ var countryServiceMock = new Mock<ICountryService>();+ countryServiceMock.Setup(c => c.GetAllCountriesForBilling("", "", true)).ReturnsAsync(new List<Country>());+ _vendorServiceMock = new Mock<IVendorService>();+ _vendorServiceMock.Setup(v => v.GetAllVendors("", 0, int.MaxValue, true))+ .ReturnsAsync(new PagedList<Vendor>(new List<Vendor>(), 0, int.MaxValue));+ var dateTimeServiceMock = new Mock<IDateTimeService>();+ var orderStatusServiceMock = new Mock<IOrderStatusService>();+ orderStatusServiceMock.Setup(o => o.GetAll()).ReturnsAsync(new List<Grand.Domain.Orders.OrderStatus>());+ var enumTranslationServiceMock = new Mock<IEnumTranslationService>();+ enumTranslationServiceMock.Setup(e => e.ToSelectList(Grand.Domain.Payments.PaymentStatus.Pending, false, null))+ .Returns(new Microsoft.AspNetCore.Mvc.Rendering.SelectList(new List<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>()));+ var contextAccessorMock = new Mock<IContextAccessor>();+ _scopeMock = new Mock<IReportDataScope>();+ _scopeMock.Setup(s => s.StoreId).Returns("");+ _scopeMock.Setup(s => s.VendorId).Returns("");+ _scopeMock.Setup(s => s.ShowStoreSelector).Returns(true);+ _scopeMock.Setup(s => s.ShowVendorSelector).Returns(true);+ _scopeMock.Setup(s => s.ResourceKeyPrefix).Returns("Admin");+ _scopeMock.Setup(s => s.CanIncludeProduct(It.IsAny<Product>())).Returns(true);++ _controller = new TestReportsController(_orderReportServiceMock.Object, _productsReportServiceMock.Object,+ _customerReportViewModelServiceMock.Object, priceFormatterMock.Object, currencyServiceMock.Object,+ _productServiceMock.Object, productAttributeFormatterMock.Object, stockQuantityServiceMock.Object,+ translationServiceMock.Object, _storeServiceMock.Object, countryServiceMock.Object,+ _vendorServiceMock.Object, dateTimeServiceMock.Object, orderStatusServiceMock.Object,+ enumTranslationServiceMock.Object, contextAccessorMock.Object, _scopeMock.Object);+ }++ [TestMethod]+ public async Task BestsellersBriefReportByQuantityList_NoPermissionCheck_AlwaysReturnsJson()+ {+ _orderReportServiceMock.Setup(o => o.BestSellersReport("", "", null, null, null, null, null, "", 1, 0,+ 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 10));++ var result = await _controller.BestsellersBriefReportByQuantityList(new DataSourceRequest { Page = 1, PageSize = 10 });++ Assert.IsInstanceOfType(result, typeof(JsonResult));+ }++ [TestMethod]+ public async Task BestsellersBriefReportByQuantityList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _orderReportServiceMock.Setup(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 1, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 0));++ await _controller.BestsellersBriefReportByQuantityList(new DataSourceRequest { Page = 1, PageSize = 10 });++ _orderReportServiceMock.Verify(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 1, 0, 10, true), Times.Once);+ }++ [TestMethod]+ public async Task BestsellersBriefReportByAmountList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _orderReportServiceMock.Setup(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 2, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 0));++ await _controller.BestsellersBriefReportByAmountList(new DataSourceRequest { Page = 1, PageSize = 10 });++ _orderReportServiceMock.Verify(o => o.BestSellersReport("store-1", "vendor-1", null, null, null, null, null,+ "", 2, 0, 10, true), Times.Once);+ }++ [TestMethod]+ public async Task BestsellersBriefReportByQuantityList_CanIncludeProductFalse_DropsRow()+ {+ var line = new BestsellersReportLine { ProductId = "p1", TotalAmount = 1, TotalQuantity = 1 };+ _orderReportServiceMock.Setup(o => o.BestSellersReport("", "", null, null, null, null, null, "", 1, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine> { line }, 0, 1));+ _productServiceMock.Setup(p => p.GetProductById("p1")).ReturnsAsync(new Product { Id = "p1" });+ _scopeMock.Setup(s => s.CanIncludeProduct(It.IsAny<Product>())).Returns(false);++ var result = await _controller.BestsellersBriefReportByQuantityList(new DataSourceRequest { Page = 1, PageSize = 10 }) as JsonResult;++ var gridModel = (DataSourceResult)result!.Value!;+ Assert.AreEqual(0, ((List<BestsellersReportLineModel>)gridModel.Data).Count);+ }++ [TestMethod]+ public async Task BestsellersReport_ShowStoreSelectorTrue_PopulatesAvailableStores()+ {+ var result = await _controller.BestsellersReport() as ViewResult;++ Assert.IsNotNull(result);+ var model = (BestsellersReportModel)result!.Model!;+ Assert.IsTrue(model.AvailableStores.Count > 0);+ Assert.IsTrue(model.AvailableVendors.Count > 0);+ }++ [TestMethod]+ public async Task BestsellersReport_ShowStoreSelectorFalse_SkipsAvailableStoresAndVendors()+ {+ _scopeMock.Setup(s => s.ShowStoreSelector).Returns(false);+ _scopeMock.Setup(s => s.ShowVendorSelector).Returns(false);++ var result = await _controller.BestsellersReport() as ViewResult;++ var model = (BestsellersReportModel)result!.Model!;+ Assert.AreEqual(0, model.AvailableStores.Count);+ Assert.AreEqual(0, model.AvailableVendors.Count);+ _storeServiceMock.Verify(s => s.GetAllStores(), Times.Never);+ _vendorServiceMock.Verify(v => v.GetAllVendors(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<bool>()), Times.Never);+ }++ [TestMethod]+ public async Task BestsellersReportList_ScopeStoreIdNonEmpty_OverwritesPostedStoreId()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _orderReportServiceMock.Setup(o => o.BestSellersReport("store-1", "", null, null, null, null, null, "", 2,+ 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine>(), 0, 0));++ var model = new BestsellersReportModel { StoreId = "posted-store-should-be-overwritten" };+ await _controller.BestsellersReportList(new DataSourceRequest { Page = 1, PageSize = 10 }, model);++ _orderReportServiceMock.Verify(o => o.BestSellersReport("store-1", "", null, null, null, null, null, "", 2,+ 0, 10, true), Times.Once);+ }++ [TestMethod]+ public async Task BestsellersReportList_CanIncludeProductFalse_DropsRow()+ {+ var line = new BestsellersReportLine { ProductId = "p1", TotalAmount = 1, TotalQuantity = 1 };+ _orderReportServiceMock.Setup(o => o.BestSellersReport("", "", null, null, null, null, null, "", 2, 0, 10, true))+ .ReturnsAsync(new PagedList<BestsellersReportLine>(new List<BestsellersReportLine> { line }, 0, 1));+ _productServiceMock.Setup(p => p.GetProductById("p1")).ReturnsAsync(new Product { Id = "p1" });+ _scopeMock.Setup(s => s.CanIncludeProduct(It.IsAny<Product>())).Returns(false);++ var result = await _controller.BestsellersReportList(new DataSourceRequest { Page = 1, PageSize = 10 },+ new BestsellersReportModel()) as JsonResult;++ var gridModel = (DataSourceResult)result!.Value!;+ Assert.AreEqual(0, ((List<BestsellersReportLineModel>)gridModel.Data).Count);+ }++ [TestMethod]+ public void NeverSoldReport_ReturnsViewWithModel()+ {+ var result = _controller.NeverSoldReport() as ViewResult;++ Assert.IsNotNull(result);+ Assert.IsInstanceOfType(result!.Model, typeof(NeverSoldReportModel));+ }++ [TestMethod]+ public async Task NeverSoldReportList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _orderReportServiceMock.Setup(o => o.ProductsNeverSold("store-1", "vendor-1", null, null, 0, 10, true))+ .ReturnsAsync(new PagedList<Product>(new List<Product>(), 0, 0));++ await _controller.NeverSoldReportList(new DataSourceRequest { Page = 1, PageSize = 10 }, new NeverSoldReportModel());++ _orderReportServiceMock.Verify(o => o.ProductsNeverSold("store-1", "vendor-1", null, null, 0, 10, true), Times.Once);+ }++ [TestMethod]+ public async Task CountryReport_NoPermissionCheck_ReturnsViewWithModel()+ {+ var result = await _controller.CountryReport() as ViewResult;++ Assert.IsNotNull(result);+ Assert.IsInstanceOfType(result!.Model, typeof(CountryReportModel));+ }++ [TestMethod]+ public async Task CountryReportList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _orderReportServiceMock.Setup(o => o.GetCountryReport("store-1", "vendor-1", null, null, null, null, null))+ .ReturnsAsync(new List<OrderByCountryReportLine>());++ await _controller.CountryReportList(new DataSourceRequest { Page = 1, PageSize = 10 }, new CountryReportModel());++ _orderReportServiceMock.Verify(o => o.GetCountryReport("store-1", "vendor-1", null, null, null, null, null), Times.Once);+ }++ [TestMethod]+ public void LowStockReport_ReturnsView()+ {+ var result = _controller.LowStockReport();+ Assert.IsInstanceOfType(result, typeof(ViewResult));+ }++ [TestMethod]+ public async Task LowStockReportList_ScopeValuesThreadedIntoQuery()+ {+ _scopeMock.Setup(s => s.StoreId).Returns("store-1");+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _productsReportServiceMock.Setup(p => p.LowStockProducts("vendor-1", "store-1"))+ .ReturnsAsync((new List<Product>(), new List<ProductsAttributeCombination>()));++ await _controller.LowStockReportList(new DataSourceRequest { Page = 1, PageSize = 10 });++ _productsReportServiceMock.Verify(p => p.LowStockProducts("vendor-1", "store-1"), Times.Once);+ }++ [TestMethod]+ public async Task Customer_NoPermissionCheck_ReturnsViewWithModel()+ {+ var result = await _controller.Customer() as ViewResult;++ Assert.IsNotNull(result);+ Assert.IsInstanceOfType(result!.Model, typeof(CustomerReportsModel));+ }++ [TestMethod]+ public async Task ReportBestCustomersByOrderTotalList_PassesScopeVendorIdToService()+ {+ _scopeMock.Setup(s => s.VendorId).Returns("vendor-1");+ _customerReportViewModelServiceMock.Setup(s => s.PrepareBestCustomerReportLineModel(It.IsAny<BestCustomersReportModel>(), 1, 1, 10, "vendor-1"))+ .ReturnsAsync((new List<BestCustomerReportLineModel>(), 0));++ await _controller.ReportBestCustomersByOrderTotalList(new DataSourceRequest { Page = 1, PageSize = 10 },+ new BestCustomersReportModel());++ _customerReportViewModelServiceMock.Verify(s => s.PrepareBestCustomerReportLineModel(It.IsAny<BestCustomersReportModel>(), 1, 1, 10, "vendor-1"),+ Times.Once);+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/CustomerReportViewModelServiceTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/CustomerReportViewModelServiceTests.csnew file mode 100644index 000000000..56a763548--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/CustomerReportViewModelServiceTests.cs@@ -0,0 +1,80 @@+using Grand.Business.Core.Interfaces.Checkout.Orders;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Interfaces.System.Reports;+using Grand.Business.Core.Utilities.System;+using Grand.Domain;+using Grand.Domain.Customers;+using Grand.Domain.Directory;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.AdminShared.Services;+using Grand.Web.Common.Localization;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class CustomerReportViewModelServiceTests+{+ private CustomerReportViewModelService _service = null!;+ private Mock<ICustomerReportService> _customerReportServiceMock = null!;++ [TestInitialize]+ public void Setup()+ {+ var customerServiceMock = new Mock<ICustomerService>();+ var translationServiceMock = new Mock<ITranslationService>();+ translationServiceMock.Setup(t => t.GetResource(It.IsAny<string>())).Returns("resource");+ _customerReportServiceMock = new Mock<ICustomerReportService>();+ var dateTimeServiceMock = new Mock<IDateTimeService>();+ var priceFormatterMock = new Mock<Grand.Business.Core.Interfaces.Catalog.Prices.IPriceFormatter>();+ var orderStatusServiceMock = new Mock<IOrderStatusService>();+ var currencyServiceMock = new Mock<ICurrencyService>();+ currencyServiceMock.Setup(c => c.GetPrimaryStoreCurrency()).ReturnsAsync(new Currency());+ var enumTranslationServiceMock = new Mock<IEnumTranslationService>();++ _service = new CustomerReportViewModelService(customerServiceMock.Object, translationServiceMock.Object,+ _customerReportServiceMock.Object, dateTimeServiceMock.Object, priceFormatterMock.Object,+ orderStatusServiceMock.Object, currencyServiceMock.Object, enumTranslationServiceMock.Object);+ }++ [TestMethod]+ public async Task PrepareBestCustomerReportLineModel_DefaultVendorId_PassesEmptyStringToService()+ {+ _customerReportServiceMock.Setup(s => s.GetBestCustomersReport(It.IsAny<string>(), "", null, null, null, null, null, 2, 0, 10))+ .ReturnsAsync(new PagedList<BestCustomerReportLine>(new List<BestCustomerReportLine>(), 0, 0));++ await _service.PrepareBestCustomerReportLineModel(new BestCustomersReportModel(), 1, 1, 10);++ _customerReportServiceMock.Verify(s => s.GetBestCustomersReport(It.IsAny<string>(), "", null, null, null, null, null, 2, 0, 10), Times.Once);+ }++ [TestMethod]+ public async Task PrepareBestCustomerReportLineModel_ExplicitVendorId_PassesItToService()+ {+ _customerReportServiceMock.Setup(s => s.GetBestCustomersReport(It.IsAny<string>(), "vendor-1", null, null, null, null, null, 2, 0, 10))+ .ReturnsAsync(new PagedList<BestCustomerReportLine>(new List<BestCustomerReportLine>(), 0, 0));++ await _service.PrepareBestCustomerReportLineModel(new BestCustomersReportModel(), 1, 1, 10, "vendor-1");++ _customerReportServiceMock.Verify(s => s.GetBestCustomersReport(It.IsAny<string>(), "vendor-1", null, null, null, null, null, 2, 0, 10), Times.Once);+ }++ [TestMethod]+ public async Task GetReportRegisteredCustomersModel_DefaultVendorId_DoesNotThrow()+ {+ // GetRegisteredCustomersReport itself has no vendorId parameter (confirmed on+ // ICustomerReportService — registered-customer counts are never vendor-scoped in the business+ // layer); the new vendorId parameter on GetReportRegisteredCustomersModel exists purely for+ // Global Constraint 8's "both methods" symmetry (Task 9's header note) and is accepted but+ // not yet forwarded anywhere further. This test documents that "not forwarded" is intentional,+ // not a missed wire-up.+ _customerReportServiceMock.Setup(s => s.GetRegisteredCustomersReport("store-1", It.IsAny<int>())).ReturnsAsync(5);++ var result = await _service.GetReportRegisteredCustomersModel("store-1", "vendor-1");++ Assert.AreEqual(4, result.Count);+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/ReportsControllerRoutingTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/ReportsControllerRoutingTests.csnew file mode 100644index 000000000..c51643b7c--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/ReportsControllerRoutingTests.cs@@ -0,0 +1,53 @@+using Grand.Web.Admin.Controllers;+using Grand.Web.Admin.Extensions;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Grand.Domain.Permissions;+using Microsoft.AspNetCore.Mvc;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class ReportsControllerRoutingTests+{+ [TestMethod]+ public void AdminReportsController_InheritsBaseFullReportsController() =>+ Assert.IsTrue(typeof(BaseFullReportsController).IsAssignableFrom(typeof(ReportsController)));++ [TestMethod]+ public void AdminReportsController_HasAreaAttributeWithAdminArea()+ {+ var areaAttr = (AreaAttribute)Attribute.GetCustomAttribute(typeof(ReportsController), typeof(AreaAttribute), false);+ Assert.IsNotNull(areaAttr, "Missing [Area].");+ Assert.AreEqual(Constants.AreaAdmin, areaAttr.RouteValue);+ }++ [TestMethod]+ public void AdminReportsController_HasAuthorizeAdminAttribute() =>+ Assert.IsTrue(typeof(ReportsController).IsDefined(typeof(AuthorizeAdminAttribute), false),+ "Missing [AuthorizeAdmin].");++ [TestMethod]+ public void AdminReportsController_HasPermissionAuthorizeReportsAttribute()+ {+ var attr = (PermissionAuthorizeAttribute)Attribute.GetCustomAttribute(typeof(ReportsController),+ typeof(PermissionAuthorizeAttribute), false);+ Assert.IsNotNull(attr, "Missing [PermissionAuthorize].");+ Assert.AreEqual(PermissionSystemName.Reports, attr!.Permission);+ }++ [TestMethod]+ public void AdminReportsController_DeclaresPopularSearchTermsReport_NotOnEitherSharedBase()+ {+ var declaredDirectly = typeof(ReportsController).GetMethod("PopularSearchTermsReport",+ System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);+ Assert.IsNotNull(declaredDirectly, "PopularSearchTermsReport must be declared directly on Admin's ReportsController.");+ Assert.IsNull(typeof(BaseReportsController).GetMethod("PopularSearchTermsReport"),+ "PopularSearchTermsReport must not exist on BaseReportsController.");+ Assert.IsNull(typeof(BaseFullReportsController).GetMethod("PopularSearchTermsReport",+ System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly),+ "PopularSearchTermsReport must not be (re)declared on BaseFullReportsController.");+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedReportDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedReportDataScopeTests.csnew file mode 100644index 000000000..ad009edbb--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/RoutedReportDataScopeTests.cs@@ -0,0 +1,81 @@+#nullable enable++using Grand.Domain.Customers;+using Grand.Domain.Vendors;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Services;+using Microsoft.AspNetCore.Http;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class RoutedReportDataScopeTests+{+ private AdminReportDataScope _adminScope = null!;+ private StoreReportDataScope _storeScope = null!;+ private VendorReportDataScope _vendorScope = null!;++ [TestInitialize]+ public void Setup()+ {+ var storeWorkContext = new Mock<IWorkContext>();+ storeWorkContext.Setup(w => w.CurrentCustomer).Returns(new Customer { StaffStoreId = "store-1" });+ var storeContextAccessor = new Mock<IContextAccessor>();+ storeContextAccessor.Setup(c => c.WorkContext).Returns(storeWorkContext.Object);++ var vendorWorkContext = new Mock<IWorkContext>();+ vendorWorkContext.Setup(w => w.CurrentVendor).Returns(new Vendor { Id = "vendor-A" });+ var vendorContextAccessor = new Mock<IContextAccessor>();+ vendorContextAccessor.Setup(c => c.WorkContext).Returns(vendorWorkContext.Object);++ _adminScope = new AdminReportDataScope();+ _storeScope = new StoreReportDataScope(storeContextAccessor.Object);+ _vendorScope = new VendorReportDataScope(vendorContextAccessor.Object);+ }++ private RoutedReportDataScope ResolverForArea(string? area)+ {+ var httpContext = new DefaultHttpContext();+ if (area is not null) httpContext.Request.RouteValues["area"] = area;+ var httpContextAccessor = new Mock<IHttpContextAccessor>();+ httpContextAccessor.Setup(x => x.HttpContext).Returns(httpContext);+ return new RoutedReportDataScope(httpContextAccessor.Object, _adminScope, _storeScope, _vendorScope);+ }++ [TestMethod]+ public void AdminArea_ResolvesToAdminScope()+ {+ var resolver = ResolverForArea("Admin");+ Assert.AreEqual("", resolver.StoreId);+ Assert.IsTrue(resolver.ShowStoreSelector);+ Assert.AreEqual("Admin", resolver.ResourceKeyPrefix);+ }++ [TestMethod]+ public void StoreArea_ResolvesToStoreScope()+ {+ var resolver = ResolverForArea("Store");+ Assert.AreEqual("store-1", resolver.StoreId);+ Assert.IsFalse(resolver.ShowStoreSelector);+ }++ [TestMethod]+ public void VendorArea_ResolvesToVendorScope()+ {+ var resolver = ResolverForArea("Vendor");+ Assert.AreEqual("vendor-A", resolver.VendorId);+ Assert.AreEqual("Vendor", resolver.ResourceKeyPrefix);+ }++ [TestMethod]+ public void UnrecognizedOrMissingArea_ThrowsFailClosed()+ {+ var typo = ResolverForArea("Vendorr");+ Assert.Throws<InvalidOperationException>(() => _ = typo.ResourceKeyPrefix);++ var missing = ResolverForArea(null);+ Assert.Throws<InvalidOperationException>(() => _ = missing.ResourceKeyPrefix);+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/StoreReportDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/StoreReportDataScopeTests.csnew file mode 100644index 000000000..05902bec4--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/StoreReportDataScopeTests.cs@@ -0,0 +1,59 @@+using Grand.Domain.Catalog;+using Grand.Domain.Customers;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Services;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class StoreReportDataScopeTests+{+ private static StoreReportDataScope Build(string staffStoreId)+ {+ var customer = new Customer { StaffStoreId = staffStoreId };+ var workContextMock = new Mock<IWorkContext>();+ workContextMock.Setup(w => w.CurrentCustomer).Returns(customer);+ var contextAccessorMock = new Mock<IContextAccessor>();+ contextAccessorMock.Setup(c => c.WorkContext).Returns(workContextMock.Object);+ return new StoreReportDataScope(contextAccessorMock.Object);+ }++ [TestMethod]+ public void StoreId_ReturnsCurrentStaffStoreId()+ {+ var scope = Build("store-1");+ Assert.AreEqual("store-1", scope.StoreId);+ }++ [TestMethod]+ public void VendorId_AlwaysEmpty()+ {+ var scope = Build("store-1");+ Assert.AreEqual("", scope.VendorId);+ }++ [TestMethod]+ public void Selectors_BothHidden()+ {+ var scope = Build("store-1");+ Assert.IsFalse(scope.ShowStoreSelector);+ Assert.IsFalse(scope.ShowVendorSelector);+ }++ [TestMethod]+ public void ResourceKeyPrefix_IsAdmin()+ {+ // Store reuses Admin's resource keys today — same precedent as every prior phase.+ var scope = Build("store-1");+ Assert.AreEqual("Admin", scope.ResourceKeyPrefix);+ }++ [TestMethod]+ public void CanIncludeProduct_NotOverridden_AlwaysTrue()+ {+ var scope = Build("store-1");+ Assert.IsTrue(scope.CanIncludeProduct(new Product { Id = "p1" }));+ }+}diff --git a/src/Tests/Grand.Web.Admin.Tests/Controllers/VendorReportDataScopeTests.cs b/src/Tests/Grand.Web.Admin.Tests/Controllers/VendorReportDataScopeTests.csnew file mode 100644index 000000000..9e40a1d07--- /dev/null+++ b/src/Tests/Grand.Web.Admin.Tests/Controllers/VendorReportDataScopeTests.cs@@ -0,0 +1,64 @@+using Grand.Domain.Catalog;+using Grand.Domain.Vendors;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Services;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;++namespace Grand.Web.Admin.Tests.Controllers;++[TestClass]+public class VendorReportDataScopeTests+{+ private static VendorReportDataScope Build(string currentVendorId)+ {+ var workContextMock = new Mock<IWorkContext>();+ workContextMock.Setup(w => w.CurrentVendor).Returns(new Vendor { Id = currentVendorId });+ var contextAccessorMock = new Mock<IContextAccessor>();+ contextAccessorMock.Setup(c => c.WorkContext).Returns(workContextMock.Object);+ return new VendorReportDataScope(contextAccessorMock.Object);+ }++ [TestMethod]+ public void StoreId_AlwaysEmpty()+ {+ var scope = Build("vendor-A");+ Assert.AreEqual("", scope.StoreId);+ }++ [TestMethod]+ public void VendorId_ReturnsCurrentVendorId()+ {+ var scope = Build("vendor-A");+ Assert.AreEqual("vendor-A", scope.VendorId);+ }++ [TestMethod]+ public void Selectors_BothHidden()+ {+ var scope = Build("vendor-A");+ Assert.IsFalse(scope.ShowStoreSelector);+ Assert.IsFalse(scope.ShowVendorSelector);+ }++ [TestMethod]+ public void ResourceKeyPrefix_IsVendor()+ {+ var scope = Build("vendor-A");+ Assert.AreEqual("Vendor", scope.ResourceKeyPrefix);+ }++ [TestMethod]+ public void CanIncludeProduct_MatchingVendorId_True()+ {+ var scope = Build("vendor-A");+ Assert.IsTrue(scope.CanIncludeProduct(new Product { Id = "p1", VendorId = "vendor-A" }));+ }++ [TestMethod]+ public void CanIncludeProduct_MismatchedVendorId_False()+ {+ var scope = Build("vendor-A");+ Assert.IsFalse(scope.CanIncludeProduct(new Product { Id = "p1", VendorId = "vendor-B" }));+ }+}diff --git a/src/Tests/Grand.Web.Store.Tests/Controllers/StoreReportsControllerRoutingTests.cs b/src/Tests/Grand.Web.Store.Tests/Controllers/StoreReportsControllerRoutingTests.csnew file mode 100644index 000000000..ce01d17e2--- /dev/null+++ b/src/Tests/Grand.Web.Store.Tests/Controllers/StoreReportsControllerRoutingTests.cs@@ -0,0 +1,45 @@+using Grand.Domain.Permissions;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Grand.Web.Store.Controllers;+using Microsoft.AspNetCore.Mvc;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using StoreReportsController = Grand.Web.Store.Controllers.ReportsController;++namespace Grand.Web.Store.Tests.Controllers;++[TestClass]+public class StoreReportsControllerRoutingTests+{+ [TestMethod]+ public void StoreReportsController_InheritsBaseFullReportsController() =>+ Assert.IsTrue(typeof(BaseFullReportsController).IsAssignableFrom(typeof(StoreReportsController)));++ [TestMethod]+ public void StoreReportsController_HasAreaAttributeWithStoreArea()+ {+ var areaAttr = (AreaAttribute)Attribute.GetCustomAttribute(typeof(StoreReportsController), typeof(AreaAttribute), false);+ Assert.IsNotNull(areaAttr, "Missing [Area].");+ Assert.AreEqual("Store", areaAttr.RouteValue);+ }++ [TestMethod]+ public void StoreReportsController_HasAuthorizeStoreAttribute() =>+ Assert.IsTrue(typeof(StoreReportsController).IsDefined(typeof(AuthorizeStoreAttribute), false),+ "Missing [AuthorizeStore].");++ [TestMethod]+ public void StoreReportsController_HasPermissionAuthorizeReportsAttribute()+ {+ var attr = (PermissionAuthorizeAttribute)Attribute.GetCustomAttribute(typeof(StoreReportsController),+ typeof(PermissionAuthorizeAttribute), false);+ Assert.IsNotNull(attr, "Missing [PermissionAuthorize].");+ Assert.AreEqual(PermissionSystemName.Reports, attr!.Permission);+ }++ [TestMethod]+ public void StoreReportsController_HasNoPopularSearchTermsReport() =>+ Assert.IsNull(typeof(StoreReportsController).GetMethod("PopularSearchTermsReport"),+ "PopularSearchTermsReport is Admin-only (Task 10) and must not exist on Store's controller.");+}diff --git a/src/Tests/Grand.Web.Vendor.Tests/Controllers/VendorReportsControllerRoutingTests.cs b/src/Tests/Grand.Web.Vendor.Tests/Controllers/VendorReportsControllerRoutingTests.csnew file mode 100644index 000000000..4f61883a8--- /dev/null+++ b/src/Tests/Grand.Web.Vendor.Tests/Controllers/VendorReportsControllerRoutingTests.cs@@ -0,0 +1,83 @@+using Grand.Domain.Permissions;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.Common.Filters;+using Grand.Web.Common.Security.Authorization;+using Grand.Web.Vendor.Controllers;+using Microsoft.AspNetCore.Mvc;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using VendorReportsController = Grand.Web.Vendor.Controllers.ReportsController;++namespace Grand.Web.Vendor.Tests.Controllers;++[TestClass]+public class VendorReportsControllerRoutingTests+{+ /// <summary>The core guard for this phase's one novel risk (spec §11, "the two-tier split+ /// leaking Admin/Store-only actions onto Vendor"): confirm Vendor's concrete type inherits+ /// BaseReportsController but NOT BaseFullReportsController, and therefore exposes none of the 8+ /// Admin/Store-only actions as public instance methods at all — not merely "hidden from Vendor's+ /// menu", genuinely absent from the type, so no route/Url.Action/reflection-based route dump can+ /// ever reach them on the Vendor host (Global Constraint 2/10, spec §4/§11).</summary>+ [TestMethod]+ public void VendorReportsController_InheritsBaseReportsController_NotBaseFullReportsController()+ {+ Assert.IsTrue(typeof(BaseReportsController).IsAssignableFrom(typeof(VendorReportsController)));+ Assert.IsFalse(typeof(BaseFullReportsController).IsAssignableFrom(typeof(VendorReportsController)),+ "Vendor must not inherit BaseFullReportsController — that would silently add the 8 " ++ "Admin/Store-only report routes to the Vendor host.");+ }++ /// <summary>These 8 actions are declared on BaseFullReportsController. They are absent from Vendor+ /// specifically because Vendor's concrete type inherits BaseReportsController directly, not+ /// BaseFullReportsController (asserted separately above). Do not lump PopularSearchTermsReport in+ /// here: it is absent from Vendor for an unrelated reason (see+ /// VendorReportsController_HasNoPopularSearchTermsReport below).</summary>+ [TestMethod]+ public void VendorReportsController_HasNoBaseFullReportsControllerActions()+ {+ string[] baseFullReportsControllerOnlyActions = [+ "ReportOrderPeriodList", "ReportOrderTimeChart", "OrderAverageReportList", "ReportLatestOrder",+ "OrderIncompleteReportList", "ReportBestCustomersByNumberOfOrdersList",+ "ReportRegisteredCustomersList", "ReportCustomerTimeChart"+ ];+ foreach (var actionName in baseFullReportsControllerOnlyActions)+ Assert.IsNull(typeof(VendorReportsController).GetMethod(actionName),+ $"{actionName} is declared on BaseFullReportsController and must not exist on Vendor's " ++ "ReportsController (or any of its base types), because Vendor does not inherit " ++ "BaseFullReportsController.");+ }++ /// <summary>Unlike the 8 actions above, PopularSearchTermsReport is never declared on either shared+ /// base (see AdminReportsController_DeclaresPopularSearchTermsReport_NotOnEitherSharedBase in+ /// ReportsControllerRoutingTests.cs) — it is written directly on Admin's own concrete controller+ /// only, and is Admin-only (also absent from Store's controller, not Admin/Store-shared). It is+ /// absent from Vendor for this distinct reason, not because of the BaseFullReportsController+ /// split.</summary>+ [TestMethod]+ public void VendorReportsController_HasNoPopularSearchTermsReport() =>+ Assert.IsNull(typeof(VendorReportsController).GetMethod("PopularSearchTermsReport"),+ "PopularSearchTermsReport is Admin-only (never declared on any shared base) and must not " ++ "exist on Vendor's ReportsController.");++ [TestMethod]+ public void VendorReportsController_HasAreaAttributeWithVendorArea()+ {+ var areaAttr = (AreaAttribute)Attribute.GetCustomAttribute(typeof(VendorReportsController), typeof(AreaAttribute), false);+ Assert.IsNotNull(areaAttr, "Missing [Area].");+ Assert.AreEqual("Vendor", areaAttr.RouteValue);+ }++ [TestMethod]+ public void VendorReportsController_HasAuthorizeVendorAttribute() =>+ Assert.IsTrue(typeof(VendorReportsController).IsDefined(typeof(AuthorizeVendorAttribute), false),+ "Missing [AuthorizeVendor].");++ [TestMethod]+ public void VendorReportsController_HasPermissionAuthorizeReportsAttribute()+ {+ var attr = (PermissionAuthorizeAttribute)Attribute.GetCustomAttribute(+ typeof(VendorReportsController), typeof(PermissionAuthorizeAttribute), false);+ Assert.IsNotNull(attr, "Missing [PermissionAuthorize].");+ Assert.AreEqual(PermissionSystemName.Reports, attr!.Permission);+ }+}diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/CountryReport.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/CountryReport.cshtmldeleted file mode 100644index b45930084..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/CountryReport.cshtml+++ /dev/null@@ -1,153 +0,0 @@-@model CountryReportModel-@{- //page title- ViewBag.Title = Loc["Admin.Reports.Country"];-}---<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit popup-window">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.Country"]- </div>-- </div>- <div class="x_content form">- <vc:admin-widget widget-zone="country_report" additional-data="Model"/>- <div class="form-horizontal">- <div class="form-body">- <div class="x_content">- <div class="form-horizontal">- <div class="form-body">- <div class="main-header col-12 px-0">- <div class="row align-items-end">- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="StartDate" class="control-label"/>- <admin-input asp-for="StartDate"/>- </div>- </div>- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="EndDate" class="control-label"/>- <admin-input asp-for="EndDate"/>- </div>- </div>- <div class="col-md-4 col-sm-12 col-12">- <div class="form-actions">- <div class="btn-group">- <button class="btn btn-success filter-submit" id="search-countryreport">- <i class="fa fa-search"></i> @Loc["Admin.Reports.Country.RunReport"]- </button>- <button class="btn btn-info" type="button" data-toggle="collapse" data-target="#filterCollapse" aria-expanded="false" aria-controls="filterCollapse">- <i class="fa fa-filter"></i> @Loc["Admin.Common.Filters"]- </button>- </div>- </div>- </div>- </div>- </div>- <div class="collapse" id="filterCollapse">- <div class="drop-filters-container w-100">- <div class="form-group">- <admin-label asp-for="OrderStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="OrderStatusId" asp-items="Model.AvailableOrderStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="PaymentStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses"/>- </div>- </div>- </div>- </div>- </div>- <div class="x_content">- <div id="countryreport-grid"></div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>-</div>---<script>- $(document).ready(function () {- $("#countryreport-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("CountryReportList", "Reports", new { area = Constants.AreaAdmin }))",- type: "POST",- dataType: "json",- data: additionalData- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- numeric: false,- previousNext: false,- info: false- },- scrollable: false,- columns: [{- field: "CountryName",- title: "@Loc["Admin.Reports.Country.Fields.CountryName"]"- }, {- field: "TotalOrders",- title: "@Loc["Admin.Reports.Country.Fields.TotalOrders"]"- },{- field: "SumOrders",- title: "@Loc["Admin.Reports.Country.Fields.SumOrders"]"- }]- });- });- </script>--<script>-- $(document).ready(function () {-- $('#search-countryreport').click(function () {- var grid = $('#countryreport-grid').data('kendoGrid');- grid.dataSource.read();- return false;- });-- });-- function additionalData() {- var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val(),- OrderStatusId: $('#OrderStatusId').val(),- PaymentStatusId: $('#PaymentStatusId').val()- };- addAntiForgeryToken(data);- return data;- }-- </script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Customer.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Customer.cshtmldeleted file mode 100644index 65d565978..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Customer.cshtml+++ /dev/null@@ -1,53 +0,0 @@-@model CustomerReportsModel--@{- //page title- ViewBag.Title = Loc["Admin.Reports.Customers"];-}--<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-bar-chart-o"></i>- @Loc["Admin.Reports.Customers"]- </div>- </div>- <div class="x_content form">- <div class="form-horizontal">- <div class="form-body">- <div class="x_content">- <admin-tabstrip name="customer-reports">- <items>- <tabstrip-item text="@Loc["Admin.Reports.Customers.BestBy.BestByOrderTotal"]" tab-index="0">- <content>- <div>- <partial name="Partials/Customer.TabBestByOrderTotal" model="Model"/>- </div>- </content>- </tabstrip-item>- <tabstrip-item text="@Loc["Admin.Reports.Customers.BestBy.BestByNumberOfOrders"]" tab-index="1">- <content>- <div>- <partial name="Partials/Customer.TabBestByNumberOfOrders" model="Model"/>- </div>- </content>- </tabstrip-item>- <tabstrip-item text="@Loc["Admin.Reports.Customers.RegisteredCustomers"]" tab-index="2">- <content>- <div>- <partial name="Partials/Customer.TabRegisteredCustomers" model="Model"/>- </div>- </content>- </tabstrip-item>- <vc:admin-widget widget-zone="reports_details_tabs" additional-data="Model"/>- </items>- </admin-tabstrip>- </div>- </div>- </div>- </div>- </div>- </div>-</div>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/LowStockReport.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/LowStockReport.cshtmldeleted file mode 100644index 82e6ec77a..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/LowStockReport.cshtml+++ /dev/null@@ -1,88 +0,0 @@-@inject AdminAreaSettings adminAreaSettings-@{- //page title- ViewBag.Title = Loc["Admin.Reports.LowStockReport"];-}--<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-cubes"></i>- @Loc["Admin.Reports.LowStockReport"]- </div>- </div>- <div class="x_content form">- <div class="form-horizontal">- <div class="x_content">- <div id="products-grid"></div>- </div>- </div>- </div>- </div>- </div>-</div>-<script>- $(document).ready(function() {- $("#products-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("LowStockReportList", "Reports", new { area = Constants.AreaAdmin }))",- type: "POST",- dataType: "json",- data: addAntiForgeryToken- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- pageSizes: [@(adminAreaSettings.GridPageSizes)]- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [- {- field: "Name",- title: "@Loc["Admin.Catalog.Products.Fields.Name"]",- width: 300,- //if not a grouped product, then display- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=Id#">#:Name# # if(Attributes !== null) {# <br /><i> #=Attributes# </i> #} #</a>',- }, {- field: "ManageInventoryMethod",- title: "@Loc["Admin.Catalog.Products.Fields.ManageInventoryMethod"]",- width: 150- }, {- field: "StockQuantity",- title: "@Loc["Admin.Catalog.Products.Fields.StockQuantity"]",- width: 100- }, {- field: "Published",- title: "@Loc["Admin.Catalog.Products.Fields.Published"]",- width: 100,- headerAttributes: { style: "text-align:center" },- attributes: { style: "text-align:center" },- template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'- }- ]- });- });-</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtmlsimilarity index 66%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtmlrename to src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtmlindex 5ddd9c3c9..99984ead8 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtml@@ -1,4 +1,3 @@-@model CustomerReportsModel@{@await Component.InvokeAsync("CustomerReportRegistered")-}\ No newline at end of file+}diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtmldeleted file mode 100644index 03e65dbc8..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtml+++ /dev/null@@ -1,135 +0,0 @@-@model BestCustomersReportModel-@inject AdminAreaSettings adminAreaSettings--<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_top" additional-data="Model"/>-<div class="popup-window">- <div class="form-horizontal">- <div class="form-body">- <div class="main-header col-12 px-0">- <div class="row align-items-end">- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="StartDate" class="control-label"/>- <admin-input asp-for="StartDate"/>- </div>- </div>- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="EndDate" class="control-label"/>- <admin-input asp-for="EndDate"/>- </div>- </div>- <div class="col-md-4 col-sm-12 col-12">- <div class="form-actions">- <div class="btn-group">- <button class="btn btn-success filter-submit" id="search-best-customers-numberoforders-grid">- <i class="fa fa-search"></i> @Loc["Admin.Reports.Customers.RunReport"]- </button>- <button class="btn btn-info" type="button" data-toggle="collapse" data-target="#filterCollapse" aria-expanded="false" aria-controls="filterCollapse">- <i class="fa fa-filter"></i> @Loc["Admin.Common.Filters"]- </button>- </div>- </div>- </div>- </div>- </div>- <div class="collapse" id="filterCollapse">- <div class="drop-filters-container w-100">- <div class="form-group">- <admin-label asp-for="OrderStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="OrderStatusId" asp-items="Model.AvailableOrderStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="PaymentStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="ShippingStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="ShippingStatusId" asp-items="Model.AvailableShippingStatuses"/>- </div>- </div>- </div>- </div>- </div>- </div>- <div id="best-customers-numberoforders-grid"></div>-</div>-<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_bottom" additional-data="Model"/>-<script>-$(document).ready(function () {- $("#best-customers-numberoforders-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("ReportBestCustomersByNumberOfOrdersList", "Reports", new { area = Constants.AreaAdmin }))",- type: "POST",- dataType: "json",- data: bestCustomersNumberOfOrdersAdditionalData- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function (e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- pageSizes: [@(adminAreaSettings.GridPageSizes)]- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "CustomerName",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.Customer"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaAdmin })/#=CustomerId#">#:CustomerName#</a>',- }, {- field: "OrderTotal",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderTotal"]"- }, {- field: "OrderCount",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderCount"]"- }]- });-});-</script>-<script>-$(document).ready(function () {-- $('#search-best-customers-numberoforders-grid').click(function () {- var grid = $('#best-customers-numberoforders-grid').data('kendoGrid');- grid.dataSource.page(1); //new search. Set page size to 1- //grid.dataSource.read(); we already loaded the grid above using "page" function- return false;- });--});-function bestCustomersNumberOfOrdersAdditionalData(e) {- var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val(),- OrderStatusId: $('#@Html.IdFor(model => model.OrderStatusId)').val(),- PaymentStatusId: $('#@Html.IdFor(model => model.PaymentStatusId)').val(),- ShippingStatusId: $('#@Html.IdFor(model => model.ShippingStatusId)').val()- };- addAntiForgeryToken(data);- return data;-}-</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Bestsellers.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Bestsellers.cshtmlnew file mode 100644index 000000000..b841151ed--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Bestsellers.cshtml@@ -0,0 +1,2 @@+@model BestsellersReportModel+<vc:admin-widget widget-zone="bestsellers_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Country.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Country.cshtmlnew file mode 100644index 000000000..9a759dba1--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.Country.cshtml@@ -0,0 +1,2 @@+@model CountryReportModel+<vc:admin-widget widget-zone="country_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtmlnew file mode 100644index 000000000..6c7cf1a0b--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtml@@ -0,0 +1,2 @@+@model BestCustomersReportModel+<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_bottom" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtmlnew file mode 100644index 000000000..224d0bf6e--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtml@@ -0,0 +1,2 @@+@model BestCustomersReportModel+<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_top" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtmlnew file mode 100644index 000000000..efbe51d77--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtml@@ -0,0 +1,2 @@+@model BestCustomersReportModel+<vc:admin-widget widget-zone="customer_details_report_by_order_total_bottom" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtmlnew file mode 100644index 000000000..7f71b1f82--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtml@@ -0,0 +1,2 @@+@model BestCustomersReportModel+<vc:admin-widget widget-zone="customer_details_report_by_order_total_top" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtmlnew file mode 100644index 000000000..1d55b260d--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtml@@ -0,0 +1,2 @@+@model CustomerReportsModel+<vc:admin-widget widget-zone="reports_details_tabs" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.NeverSold.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.NeverSold.cshtmlnew file mode 100644index 000000000..dd693bec3--- /dev/null+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/WidgetZone.NeverSold.cshtml@@ -0,0 +1,2 @@+@model NeverSoldReportModel+<vc:admin-widget widget-zone="never_sold_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Admin/Controllers/ReportsController.cs b/src/Web/Grand.Web.Admin/Controllers/ReportsController.csindex 58b0bcfa3..79ff93d9b 100644--- a/src/Web/Grand.Web.Admin/Controllers/ReportsController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ReportsController.cs@@ -1,4 +1,4 @@-using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Directory;using Grand.Business.Core.Interfaces.Catalog.Prices;using Grand.Business.Core.Interfaces.Catalog.Products;using Grand.Business.Core.Interfaces.Checkout.Orders;@@ -8,654 +8,90 @@ using Grand.Business.Core.Interfaces.Common.Security;using Grand.Business.Core.Interfaces.Common.Stores;using Grand.Business.Core.Interfaces.Customers;using Grand.Business.Core.Interfaces.System.Reports;-using Grand.Business.Core.Utilities.System;-using Grand.Domain.Orders;-using Grand.Domain.Payments;using Grand.Domain.Permissions;-using Grand.Domain.Shipping;using Grand.Infrastructure;using Grand.Web.Admin.Extensions;+using Grand.Web.AdminShared.Controllers;using Grand.Web.AdminShared.Interfaces;-using Grand.Web.AdminShared.Models.Catalog;using Grand.Web.AdminShared.Models.Common;-using Grand.Web.AdminShared.Models.Customers;-using Grand.Web.AdminShared.Models.Orders;using Grand.Web.Common.DataSource;-using Grand.Web.Common.Extensions;+using Grand.Web.Common.Filters;using Grand.Web.Common.Localization;using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;-using Microsoft.AspNetCore.Mvc.Rendering;namespace Grand.Web.Admin.Controllers;+// Reduced to a thin subclass of BaseFullReportsController (ARCH-001 Reports consolidation). All 12+// shared + 8 Admin/Store-only actions live in the shared bases; this class supplies Admin's DI wiring,+// its own [Area]/[Authorize*]/[PermissionAuthorize] attributes (BaseFullReportsController can't+// inherit any single host's base controller - see this task's header note), the ManageCustomers+// overrides on CountryReport/Customer neither shared base carries (Tasks 5/6), and+// PopularSearchTermsReport, which stays declared here only (Task 10) - not on either shared base.+[AuthorizeAdmin]+[AutoValidateAntiforgeryToken]+[Area(Constants.AreaAdmin)]+[AuthorizeMenu][PermissionAuthorize(PermissionSystemName.Reports)]-public class ReportsController : BaseAdminController+public class ReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope,+ IOrderService orderService,+ ICustomerReportService customerReportService,+ IPermissionService permissionService,+ ISearchTermService searchTermService)+ : BaseFullReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService, orderStatusService,+ enumTranslationService, contextAccessor, scope, orderService, customerReportService, permissionService){- private readonly ICountryService _countryService;- private readonly ICurrencyService _currencyService;- private readonly ICustomerReportService _customerReportService;- private readonly ICustomerReportViewModelService _customerReportViewModelService;- private readonly IDateTimeService _dateTimeService;- private readonly IOrderReportService _orderReportService;- private readonly IOrderService _orderService;- private readonly IOrderStatusService _orderStatusService;- private readonly IPermissionService _permissionService;- private readonly IPriceFormatter _priceFormatter;- private readonly IProductAttributeFormatter _productAttributeFormatter;- private readonly IProductService _productService;- private readonly IProductsReportService _productsReportService;- private readonly ISearchTermService _searchTermService;- private readonly IStockQuantityService _stockQuantityService;- private readonly IStoreService _storeService;- private readonly ITranslationService _translationService;- private readonly IVendorService _vendorService;- private readonly IContextAccessor _contextAccessor;- private readonly IEnumTranslationService _enumTranslationService;- public ReportsController(IOrderService orderService,- IOrderReportService orderReportService,- IProductsReportService productsReportService,- ICustomerReportService customerReportService,- ICustomerReportViewModelService customerReportViewModelService,- IPermissionService permissionService,- IContextAccessor contextAccessor,- IPriceFormatter priceFormatter,- IProductService productService,- IProductAttributeFormatter productAttributeFormatter,- IStockQuantityService stockQuantityService,- ITranslationService translationService,- IStoreService storeService,- ICountryService countryService,- IVendorService vendorService,- IDateTimeService dateTimeService,- ISearchTermService searchTermService,- IOrderStatusService orderStatusService,- ICurrencyService currencyService,- IEnumTranslationService enumTranslationService)+ /// <summary>Admin-only ManageCustomers gate — absent on Store/Vendor. Global Constraint 5 names+ /// this check explicitly.</summary>+ public override async Task<IActionResult> CountryReport(){- _orderService = orderService;- _orderReportService = orderReportService;- _productsReportService = productsReportService;- _customerReportService = customerReportService;- _customerReportViewModelService = customerReportViewModelService;- _permissionService = permissionService;- _contextAccessor = contextAccessor;- _priceFormatter = priceFormatter;- _productService = productService;- _productAttributeFormatter = productAttributeFormatter;- _stockQuantityService = stockQuantityService;- _translationService = translationService;- _storeService = storeService;- _countryService = countryService;- _vendorService = vendorService;- _dateTimeService = dateTimeService;- _searchTermService = searchTermService;- _orderStatusService = orderStatusService;- _currencyService = currencyService;- _enumTranslationService = enumTranslationService;- }-- [NonAction]- protected async Task<DataSourceResult> GetBestsellersBriefReportModel(int pageIndex,- int pageSize, int orderBy)- {- var items = await _orderReportService.BestSellersReport(- orderBy: orderBy,- pageIndex: pageIndex,- pageSize: pageSize,- showHidden: true);- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };- return gridModel;- }-- [NonAction]- protected virtual async Task<IList<OrderPeriodReportLineModel>> GetReportOrderPeriodModel()- {- var report = new List<OrderPeriodReportLineModel>();- var reportperiod7days =- await _orderReportService.GetOrderPeriodReport(7, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.7days"),- Count = reportperiod7days.Count,- Amount = reportperiod7days.Amount- });-- var reportperiod14days =- await _orderReportService.GetOrderPeriodReport(14, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.14days"),- Count = reportperiod14days.Count,- Amount = reportperiod14days.Amount- });-- var reportperiodmonth =- await _orderReportService.GetOrderPeriodReport(30, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.month"),- Count = reportperiodmonth.Count,- Amount = reportperiodmonth.Amount- });-- var reportperiodyear =- await _orderReportService.GetOrderPeriodReport(365, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.year"),- Count = reportperiodyear.Count,- Amount = reportperiodyear.Amount- });-- return report;- }--- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByQuantityList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 1);-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByAmountList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 2);-- return Json(gridModel);- }-- public async Task<IActionResult> BestsellersReport()- {- var model = new BestsellersReportModel();- //stores- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- foreach (var s in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });-- var status = await _orderStatusService.GetAll();- //order statuses- model.AvailableOrderStatuses =- status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();- model.AvailableOrderStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //payment statuses- model.AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //billing countries- foreach (var c in await _countryService.GetAllCountriesForBilling(showHidden: true))- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });- model.AvailableCountries.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //vendors- model.AvailableVendors.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- var vendors = await _vendorService.GetAllVendors(showHidden: true);- foreach (var v in vendors)- model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> BestsellersReportList(DataSourceRequest command, BestsellersReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _orderReportService.BestSellersReport(- createdFromUtc: startDateValue,- createdToUtc: endDateValue,- os: orderStatus,- ps: paymentStatus,- billingCountryId: model.BillingCountryId,- orderBy: 2,- vendorId: model.VendorId,- pageIndex: command.Page - 1,- pageSize: command.PageSize,- showHidden: true,- storeId: model.StoreId);-- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;-- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportOrderPeriodList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var model = await GetReportOrderPeriodModel();- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportOrderTimeChart(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var model = await _orderReportService.GetOrderByTimeReport("", startDate, endDate);- var gridModel = new DataSourceResult {- Data = model- };- return Json(gridModel);- }-- public IActionResult NeverSoldReport()- {- var model = new NeverSoldReportModel();- return View(model);- }-- [HttpPost]- public async Task<IActionResult> NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- var items = await _orderReportService.ProductsNeverSold("", "",- startDateValue, endDateValue,- command.Page - 1, command.PageSize, true);- var gridModel = new DataSourceResult {- Data = items.Select(x =>- new NeverSoldReportLineModel {- ProductId = x.Id,- ProductName = x.Name- }),- Total = items.TotalCount- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> OrderAverageReportList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var report = new List<OrderAverageReportLineSummary> {- await _orderReportService.OrderAverageReport("", (int)OrderStatusSystem.Pending),- await _orderReportService.OrderAverageReport("", (int)OrderStatusSystem.Processing),- await _orderReportService.OrderAverageReport("", (int)OrderStatusSystem.Complete),- await _orderReportService.OrderAverageReport("", (int)OrderStatusSystem.Cancelled)- };-- var statuses = await _orderStatusService.GetAll();- var model = new List<OrderAverageReportLineSummaryModel>();- foreach (var x in report.ToList())- model.Add(new OrderAverageReportLineSummaryModel {- OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatus)?.Name,- SumTodayOrders =- _priceFormatter.FormatPrice(x.SumTodayOrders, await _currencyService.GetPrimaryStoreCurrency()),- SumThisWeekOrders = _priceFormatter.FormatPrice(x.SumThisWeekOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumThisMonthOrders = _priceFormatter.FormatPrice(x.SumThisMonthOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumThisYearOrders = _priceFormatter.FormatPrice(x.SumThisYearOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumAllTimeOrders = _priceFormatter.FormatPrice(x.SumAllTimeOrders,- await _currencyService.GetPrimaryStoreCurrency())- });- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportLatestOrder(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- //load orders- var orders = await _orderService.SearchOrders(- createdFromUtc: startDate,- createdToUtc: endDate,- pageIndex: command.Page - 1,- pageSize: command.PageSize);-- var statuses = await _orderStatusService.GetAll();-- var items = new List<OrderModel>();- foreach (var x in orders)- {- var store = await _storeService.GetStoreById(x.StoreId);- items.Add(new OrderModel {- Id = x.Id,- OrderNumber = x.OrderNumber,- StoreName = store != null ? store.Shortcut : "Unknown",- OrderTotal =- _priceFormatter.FormatPrice(x.OrderTotal, await _currencyService.GetPrimaryStoreCurrency()),- OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatusId)?.Name,- PaymentStatus = _enumTranslationService.GetTranslationEnum(x.PaymentStatusId),- ShippingStatus = _enumTranslationService.GetTranslationEnum(x.ShippingStatusId),- CustomerEmail = x.BillingAddress.Email,- CustomerFullName = $"{x.BillingAddress.FirstName} {x.BillingAddress.LastName}",- CreatedOn = _dateTimeService.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)- });- }-- var gridModel = new DataSourceResult {- Data = items,- Total = orders.TotalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> OrderIncompleteReportList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var model = new List<OrderIncompleteReportLineModel>();- //not paid- var psPending =- await _orderReportService.GetOrderAverageReportLine("", ps: PaymentStatus.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalUnpaidOrders"),- Count = psPending.CountOrders,- Total = _priceFormatter.FormatPrice(psPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { paymentStatusId = ((int)PaymentStatus.Pending).ToString(), area = Constants.AreaAdmin })- });- //not shipped- var ssPending =- await _orderReportService.GetOrderAverageReportLine("", ss: ShippingStatus.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalNotShippedOrders"),- Count = ssPending.CountOrders,- Total = _priceFormatter.FormatPrice(ssPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { shippingStatusId = ((int)ShippingStatus.Pending).ToString(), area = Constants.AreaAdmin })- });- //pending- var osPending = await _orderReportService.GetOrderAverageReportLine("", os: (int)OrderStatusSystem.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalIncompleteOrders"),- Count = osPending.CountOrders,- Total = _priceFormatter.FormatPrice(osPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { orderStatusId = ((int)OrderStatusSystem.Pending).ToString(), area = Constants.AreaAdmin })- });-- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- public async Task<IActionResult> CountryReport()- {- if (!await _permissionService.Authorize(StandardPermission.ManageCustomers))+ if (!await permissionService.Authorize(StandardPermission.ManageCustomers))return AccessDeniedView();-- var status = await _orderStatusService.GetAll();- var model = new CountryReportModel {- //order statuses- AvailableOrderStatuses =- status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList()- };-- model.AvailableOrderStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //payment statuses- model.AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- return View(model);+ return await base.CountryReport();}- [HttpPost]- public async Task<IActionResult> CountryReportList(DataSourceRequest command, CountryReportModel model)+ /// <summary>Admin-only ManageCustomers gate — absent on Store/Vendor. Confirmed present on Admin's+ /// original Customer() action (Task 5's header note flags that the spec's own §2.2 table omits+ /// this one) but not on Store's or Vendor's.</summary>+ public override async Task<IActionResult> Customer(){- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _orderReportService.GetCountryReport(- os: orderStatus,- ps: paymentStatus,- startTimeUtc: startDateValue,- endTimeUtc: endDateValue);- var result = new List<CountryReportLineModel>();- foreach (var x in items)- {- var country = await _countryService.GetCountryById(!string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "");- var m = new CountryReportLineModel {- CountryName = country != null ? country.Name : "Unknown",- SumOrders = _priceFormatter.FormatPrice(x.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- TotalOrders = x.TotalOrders- };- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.Count- };-- return Json(gridModel);+ if (!await permissionService.Authorize(StandardPermission.ManageCustomers))+ return AccessDeniedView();+ return await base.Customer();}+ /// <summary>Admin-only, no Store/Vendor equivalent at all (Task 10) — not declared on either+ /// shared base.</summary>[HttpPost]public async Task<IActionResult> PopularSearchTermsReport(DataSourceRequest command){- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ if (!await permissionService.Authorize(StandardPermission.ManageProducts))return AccessDeniedView();- var searchTermRecordLines = await _searchTermService.GetStats(command.Page - 1, command.PageSize);+ var searchTermRecordLines = await searchTermService.GetStats(command.Page - 1, command.PageSize);var gridModel = new DataSourceResult {- Data = searchTermRecordLines.Select(x => new SearchTermReportLineModel {- Keyword = x.Keyword,- Count = x.Count- }),+ Data = searchTermRecordLines.Select(x => new SearchTermReportLineModel { Keyword = x.Keyword, Count = x.Count }),Total = searchTermRecordLines.TotalCount};return Json(gridModel);}-- #region Low stock reports-- public IActionResult LowStockReport()- {- return View();- }-- [HttpPost]- public async Task<IActionResult> LowStockReportList(DataSourceRequest command)- {- var lowStockProducts = await _productsReportService.LowStockProducts();-- var models = new List<LowStockProductModel>();- //products- foreach (var product in lowStockProducts.products)- {- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true),- Published = product.Published- };- models.Add(lowStockModel);- }-- //combinations- foreach (var combination in lowStockProducts.combinations)- {- var product = await _productService.GetProductById(combination.ProductId);- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- Attributes = await _productAttributeFormatter.FormatAttributes(product, combination.Attributes,- _contextAccessor.WorkContext.CurrentCustomer, "<br />", true, true, true, false),- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = combination.StockQuantity,- Published = product.Published- };- models.Add(lowStockModel);- }-- var gridModel = new DataSourceResult {- Data = models.PagedForCommand(command),- Total = models.Count- };-- return Json(gridModel);- }-- #endregion-- #region Customer Reports-- public async Task<IActionResult> Customer()- {- if (!await _permissionService.Authorize(StandardPermission.ManageCustomers))- return AccessDeniedView();-- var model = await _customerReportViewModelService.PrepareCustomerReportsModel();- return View(model);- }-- [HttpPost]- public async Task<IActionResult> ReportBestCustomersByOrderTotalList(DataSourceRequest command,- BestCustomersReportModel model)- {- var (bestCustomerReportLineModels, totalCount) =- await _customerReportViewModelService.PrepareBestCustomerReportLineModel(model, 1, command.Page,- command.PageSize);- var gridModel = new DataSourceResult {- Data = bestCustomerReportLineModels.ToList(),- Total = totalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportBestCustomersByNumberOfOrdersList(DataSourceRequest command,- BestCustomersReportModel model)- {- var (bestCustomerReportLineModels, totalCount) =- await _customerReportViewModelService.PrepareBestCustomerReportLineModel(model, 2, command.Page,- command.PageSize);- var gridModel = new DataSourceResult {- Data = bestCustomerReportLineModels.ToList(),- Total = totalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportRegisteredCustomersList(DataSourceRequest command)- {- var model = await _customerReportViewModelService.GetReportRegisteredCustomersModel("");- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportCustomerTimeChart(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- var model = await _customerReportService.GetCustomerByTimeReport("", startDate, endDate);- var gridModel = new DataSourceResult {- Data = model- };- return Json(gridModel);- }-- #endregion-}\ No newline at end of file+}diff --git a/src/Web/Grand.Web.AdminShared/Controllers/BaseFullReportsController.cs b/src/Web/Grand.Web.AdminShared/Controllers/BaseFullReportsController.csnew file mode 100644index 000000000..975fff310--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Controllers/BaseFullReportsController.cs@@ -0,0 +1,286 @@+#nullable enable++using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Products;+using Grand.Business.Core.Interfaces.Checkout.Orders;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Common.Security;+using Grand.Business.Core.Interfaces.Common.Stores;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Interfaces.System.Reports;+using Grand.Business.Core.Utilities.System;+using Grand.Domain.Orders;+using Grand.Domain.Payments;+using Grand.Domain.Permissions;+using Grand.Domain.Shipping;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.AdminShared.Models.Orders;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Localization;+using Microsoft.AspNetCore.Mvc;++namespace Grand.Web.AdminShared.Controllers;++/// <summary>+/// The 8 report actions unique to Admin/Store (see ARCH-001 Reports consolidation spec §4).+/// Only Admin's and Store's concrete controllers inherit this class (Task 12) — Vendor's inherits+/// <see cref="BaseReportsController" /> directly, so none of these 8 actions, and neither of this+/// class's two <c>ManageOrders</c>-gated overrides of the inherited Bestsellers-brief actions+/// (Task 5's header note), become routable on the Vendor host.+/// </summary>+/// <remarks>+/// <see cref="AutoValidateAntiforgeryTokenAttribute" /> is restated here for the same reason as on+/// <see cref="BaseReportsController" /> — see that class's remarks.+/// </remarks>+[AutoValidateAntiforgeryToken]+public abstract class BaseFullReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope,+ IOrderService orderService,+ ICustomerReportService customerReportService,+ IPermissionService permissionService)+ : BaseReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService, orderStatusService,+ enumTranslationService, contextAccessor, scope)+{+ protected IOrderService OrderService => orderService;+ protected ICustomerReportService CustomerReportService => customerReportService;+ protected IPermissionService PermissionService => permissionService;++ #region Bestsellers-brief ManageOrders overrides++ /// <summary>Adds the ManageOrders check Admin/Store both have (identical between the two, so it+ /// belongs here once rather than duplicated per-host — see Task 5's header note) on top of+ /// BaseReportsController's check-free implementation. Never reached on the Vendor host — Vendor's+ /// thin subclass (Task 12) inherits BaseReportsController directly, not this class.</summary>+ public override async Task<IActionResult> BestsellersBriefReportByQuantityList(DataSourceRequest command)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");+ return await base.BestsellersBriefReportByQuantityList(command);+ }++ /// <summary>Same as above.</summary>+ public override async Task<IActionResult> BestsellersBriefReportByAmountList(DataSourceRequest command)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");+ return await base.BestsellersBriefReportByAmountList(command);+ }++ #endregion++ #region Order reports++ [NonAction]+ protected virtual async Task<IList<OrderPeriodReportLineModel>> GetReportOrderPeriodModel()+ {+ var report = new List<OrderPeriodReportLineModel>();+ foreach (var (days, resourceKey) in new (int, string)[] {+ (7, "Admin.Reports.Period.7days"), (14, "Admin.Reports.Period.14days"),+ (30, "Admin.Reports.Period.month"), (365, "Admin.Reports.Period.year")+ })+ {+ var reportPeriod = await orderReportService.GetOrderPeriodReport(days, scope.StoreId);+ report.Add(new OrderPeriodReportLineModel {+ Period = translationService.GetResource(resourceKey),+ Count = reportPeriod.Count,+ Amount = reportPeriod.Amount+ });+ }++ return report;+ }++ [HttpPost]+ public virtual async Task<IActionResult> ReportOrderPeriodList(DataSourceRequest command)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");++ var model = await GetReportOrderPeriodModel();+ var gridModel = new DataSourceResult { Data = model, Total = model.Count };+ return Json(gridModel);+ }++ [HttpPost]+ public virtual async Task<IActionResult> ReportOrderTimeChart(DataSourceRequest command, DateTime? startDate,+ DateTime? endDate)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");++ var model = await orderReportService.GetOrderByTimeReport(scope.StoreId, startDate, endDate);+ return Json(new DataSourceResult { Data = model });+ }++ [HttpPost]+ public virtual async Task<IActionResult> OrderAverageReportList(DataSourceRequest command)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");++ var report = new List<OrderAverageReportLineSummary> {+ await orderReportService.OrderAverageReport(scope.StoreId, (int)OrderStatusSystem.Pending),+ await orderReportService.OrderAverageReport(scope.StoreId, (int)OrderStatusSystem.Processing),+ await orderReportService.OrderAverageReport(scope.StoreId, (int)OrderStatusSystem.Complete),+ await orderReportService.OrderAverageReport(scope.StoreId, (int)OrderStatusSystem.Cancelled)+ };++ var statuses = await orderStatusService.GetAll();+ var model = new List<OrderAverageReportLineSummaryModel>();+ foreach (var x in report)+ model.Add(new OrderAverageReportLineSummaryModel {+ OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatus)?.Name,+ SumTodayOrders = priceFormatter.FormatPrice(x.SumTodayOrders, await currencyService.GetPrimaryStoreCurrency()),+ SumThisWeekOrders = priceFormatter.FormatPrice(x.SumThisWeekOrders, await currencyService.GetPrimaryStoreCurrency()),+ SumThisMonthOrders = priceFormatter.FormatPrice(x.SumThisMonthOrders, await currencyService.GetPrimaryStoreCurrency()),+ SumThisYearOrders = priceFormatter.FormatPrice(x.SumThisYearOrders, await currencyService.GetPrimaryStoreCurrency()),+ SumAllTimeOrders = priceFormatter.FormatPrice(x.SumAllTimeOrders, await currencyService.GetPrimaryStoreCurrency())+ });++ var gridModel = new DataSourceResult { Data = model, Total = model.Count };+ return Json(gridModel);+ }++ [HttpPost]+ public virtual async Task<IActionResult> ReportLatestOrder(DataSourceRequest command, DateTime? startDate,+ DateTime? endDate)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");++ var orders = await orderService.SearchOrders(+ storeId: scope.StoreId,+ createdFromUtc: startDate,+ createdToUtc: endDate,+ pageIndex: command.Page - 1,+ pageSize: command.PageSize);++ var statuses = await orderStatusService.GetAll();+ var items = new List<OrderModel>();+ foreach (var x in orders)+ {+ var store = await storeService.GetStoreById(x.StoreId);+ items.Add(new OrderModel {+ Id = x.Id,+ OrderNumber = x.OrderNumber,+ StoreName = store != null ? store.Shortcut : "Unknown",+ OrderTotal = priceFormatter.FormatPrice(x.OrderTotal, await currencyService.GetPrimaryStoreCurrency()),+ OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatusId)?.Name,+ PaymentStatus = enumTranslationService.GetTranslationEnum(x.PaymentStatusId),+ ShippingStatus = enumTranslationService.GetTranslationEnum(x.ShippingStatusId),+ CustomerEmail = x.BillingAddress.Email,+ CustomerFullName = $"{x.BillingAddress.FirstName} {x.BillingAddress.LastName}",+ CreatedOn = dateTimeService.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)+ });+ }++ var gridModel = new DataSourceResult { Data = items, Total = orders.TotalCount };+ return Json(gridModel);+ }++ /// <summary>Area constant for the "View" link on each row: reproduces each host's original+ /// literal (Admin used Constants.AreaAdmin, Store used Constants.AreaStore) via+ /// scope.ResourceKeyPrefix, which happens to already equal "Admin" for both Admin and Store (Store+ /// reuses Admin's resource keys — Task 2's StoreReportDataScope) — but the *area* value must be+ /// the actual routing area, not the resource-key prefix, so this uses+ /// ViewContext.RouteData.Values["area"] directly instead, matching the same+ /// `ViewContext.RouteData.Values["area"]` pattern already used elsewhere in migrated AdminShared+ /// views/controllers (e.g. Grand.Web.AdminShared/Views/AdminShared/PaymentTransaction/Edit.cshtml)+ /// rather than introducing a third scope-object member just for this one Url.Action call.</summary>+ [HttpPost]+ public virtual async Task<IActionResult> OrderIncompleteReportList(DataSourceRequest command)+ {+ if (!await permissionService.Authorize(StandardPermission.ManageOrders))+ return Content("");++ var area = ControllerContext.RouteData.Values["area"]?.ToString();+ var model = new List<OrderIncompleteReportLineModel>();++ var psPending = await orderReportService.GetOrderAverageReportLine(scope.StoreId, ps: PaymentStatus.Pending,+ ignoreCancelledOrders: true);+ model.Add(new OrderIncompleteReportLineModel {+ Item = translationService.GetResource("Admin.Reports.Incomplete.TotalUnpaidOrders"),+ Count = psPending.CountOrders,+ Total = priceFormatter.FormatPrice(psPending.SumOrders, await currencyService.GetPrimaryStoreCurrency()),+ ViewLink = Url.Action("List", "Order", new { paymentStatusId = ((int)PaymentStatus.Pending).ToString(), area })+ });++ var ssPending = await orderReportService.GetOrderAverageReportLine(scope.StoreId, ss: ShippingStatus.Pending,+ ignoreCancelledOrders: true);+ model.Add(new OrderIncompleteReportLineModel {+ Item = translationService.GetResource("Admin.Reports.Incomplete.TotalNotShippedOrders"),+ Count = ssPending.CountOrders,+ Total = priceFormatter.FormatPrice(ssPending.SumOrders, await currencyService.GetPrimaryStoreCurrency()),+ ViewLink = Url.Action("List", "Order", new { shippingStatusId = ((int)ShippingStatus.Pending).ToString(), area })+ });++ var osPending = await orderReportService.GetOrderAverageReportLine(scope.StoreId, os: (int)OrderStatusSystem.Pending,+ ignoreCancelledOrders: true);+ model.Add(new OrderIncompleteReportLineModel {+ Item = translationService.GetResource("Admin.Reports.Incomplete.TotalIncompleteOrders"),+ Count = osPending.CountOrders,+ Total = priceFormatter.FormatPrice(osPending.SumOrders, await currencyService.GetPrimaryStoreCurrency()),+ ViewLink = Url.Action("List", "Order", new { orderStatusId = ((int)OrderStatusSystem.Pending).ToString(), area })+ });++ var gridModel = new DataSourceResult { Data = model, Total = model.Count };+ return Json(gridModel);+ }++ #endregion++ #region Customer reports++ [HttpPost]+ public virtual async Task<IActionResult> ReportBestCustomersByNumberOfOrdersList(DataSourceRequest command,+ BestCustomersReportModel model)+ {+ if (!string.IsNullOrEmpty(scope.StoreId)) model.StoreId = scope.StoreId;++ var (bestCustomerReportLineModels, totalCount) = await customerReportViewModelService+ .PrepareBestCustomerReportLineModel(model, 2, command.Page, command.PageSize, scope.VendorId);++ var gridModel = new DataSourceResult { Data = bestCustomerReportLineModels.ToList(), Total = totalCount };+ return Json(gridModel);+ }++ [HttpPost]+ public virtual async Task<IActionResult> ReportRegisteredCustomersList(DataSourceRequest command)+ {+ var model = await customerReportViewModelService.GetReportRegisteredCustomersModel(scope.StoreId, scope.VendorId);+ var gridModel = new DataSourceResult { Data = model, Total = model.Count };+ return Json(gridModel);+ }++ [HttpPost]+ public virtual async Task<IActionResult> ReportCustomerTimeChart(DataSourceRequest command, DateTime? startDate,+ DateTime? endDate)+ {+ var model = await customerReportService.GetCustomerByTimeReport(scope.StoreId, startDate, endDate);+ return Json(new DataSourceResult { Data = model });+ }++ #endregion+}diff --git a/src/Web/Grand.Web.AdminShared/Controllers/BaseReportsController.cs b/src/Web/Grand.Web.AdminShared/Controllers/BaseReportsController.csnew file mode 100644index 000000000..98320d500--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Controllers/BaseReportsController.cs@@ -0,0 +1,406 @@+#nullable enable++using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Products;+using Grand.Business.Core.Interfaces.Checkout.Orders;+using Grand.Business.Core.Interfaces.Common.Directory;+using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Common.Stores;+using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Interfaces.System.Reports;+using Grand.Business.Core.Utilities.System;+using Grand.Domain.Payments;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.AdminShared.Models.Catalog;+using Grand.Web.AdminShared.Models.Customers;+using Grand.Web.AdminShared.Models.Orders;+using Grand.Web.Common.Controllers;+using Grand.Web.Common.DataSource;+using Grand.Web.Common.Extensions;+using Grand.Web.Common.Localization;+using Microsoft.AspNetCore.Mvc;+using Microsoft.AspNetCore.Mvc.Rendering;++namespace Grand.Web.AdminShared.Controllers;++/// <summary>+/// The 12 report actions all three hosts (Admin, Store, Vendor) share. See ARCH-001 Reports+/// consolidation spec §4. <see cref="Controllers.BaseFullReportsController" /> adds the 8 actions+/// unique to Admin/Store; Vendor's concrete controller inherits this class directly so those 8+/// never become routable on the Vendor host at all.+/// </summary>+/// <remarks>+/// <see cref="AutoValidateAntiforgeryTokenAttribute" /> is restated here even though this class is+/// never directly routable (Admin/Store/Vendor's concrete controllers already restate it too, per+/// Task 12) — static analysis (CodeQL) doesn't follow the attribute across the base/derived,+/// cross-project boundary and flags every POST action here as missing CSRF validation. Runtime+/// behavior is unchanged; this closes the same class of false positive already hardened against on+/// <c>BaseProductController</c> (ARCH-001 Product phase).+/// </remarks>+[AutoValidateAntiforgeryToken]+public abstract class BaseReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope)+ : BaseController+{+ // Exposed for BaseFullReportsController (Task 8/9) and for host-specific concrete-controller+ // overrides (Task 12) — same accessor pattern as BasePaymentTransactionController.+ protected IOrderReportService OrderReportService => orderReportService;+ protected IProductsReportService ProductsReportService => productsReportService;+ protected ICustomerReportViewModelService CustomerReportViewModelService => customerReportViewModelService;+ protected IPriceFormatter PriceFormatter => priceFormatter;+ protected ICurrencyService CurrencyService => currencyService;+ protected IProductService ProductService => productService;+ protected IProductAttributeFormatter ProductAttributeFormatter => productAttributeFormatter;+ protected IStockQuantityService StockQuantityService => stockQuantityService;+ protected ITranslationService TranslationService => translationService;+ protected IStoreService StoreService => storeService;+ protected ICountryService CountryService => countryService;+ protected IVendorService VendorService => vendorService;+ protected IDateTimeService DateTimeService => dateTimeService;+ protected IOrderStatusService OrderStatusService => orderStatusService;+ protected IEnumTranslationService EnumTranslationService => enumTranslationService;+ protected IContextAccessor ContextAccessor => contextAccessor;+ protected IReportDataScope Scope => scope;++ #region Bestsellers++ [NonAction]+ protected virtual async Task<DataSourceResult> GetBestsellersBriefReportModel(int pageIndex, int pageSize,+ int orderBy)+ {+ var items = await orderReportService.BestSellersReport(+ storeId: scope.StoreId,+ vendorId: scope.VendorId,+ orderBy: orderBy,+ pageIndex: pageIndex,+ pageSize: pageSize,+ showHidden: true);+ var result = new List<BestsellersReportLineModel>();+ foreach (var x in items)+ {+ var m = new BestsellersReportLineModel {+ ProductId = x.ProductId,+ TotalAmount = priceFormatter.FormatPrice(x.TotalAmount, await currencyService.GetPrimaryStoreCurrency()),+ TotalQuantity = x.TotalQuantity+ };+ var product = await productService.GetProductById(x.ProductId);+ if (product != null)+ m.ProductName = product.Name;+ if (scope.CanIncludeProduct(product))+ result.Add(m);+ }++ return new DataSourceResult { Data = result, Total = items.TotalCount };+ }++ /// <summary>No inline permission check here — matches Vendor's actual current behavior exactly+ /// (Vendor never had a ManageOrders gate on this action; Admin/Store do). `virtual` so+ /// BaseFullReportsController (Task 8) can override and add the check for exactly the two hosts+ /// that have it, without leaking it onto Vendor. See this task's header note.</summary>+ [HttpPost]+ public virtual async Task<IActionResult> BestsellersBriefReportByQuantityList(DataSourceRequest command)+ {+ var gridModel = await GetBestsellersBriefReportModel(command.Page - 1, command.PageSize, 1);+ return Json(gridModel);+ }++ /// <summary>Same as <see cref="BestsellersBriefReportByQuantityList" /> — no inline check here.</summary>+ [HttpPost]+ public virtual async Task<IActionResult> BestsellersBriefReportByAmountList(DataSourceRequest command)+ {+ var gridModel = await GetBestsellersBriefReportModel(command.Page - 1, command.PageSize, 2);+ return Json(gridModel);+ }++ /// <summary>Store/vendor picker population gated on scope.ShowStoreSelector/ShowVendorSelector —+ /// true for Admin only. AvailableOrderStatuses/AvailablePaymentStatuses/AvailableCountries are+ /// populated unconditionally for all three hosts: Vendor's pre-consolidation model never carried+ /// AvailableOrderStatuses at all, but populating it here is the same accepted "unused select list"+ /// tolerance already established for Store's AvailableVendors (spec §2.4/§5) — Vendor's view+ /// simply never renders the field. scope.ResourceKeyPrefix ("Admin" vs "Vendor") reproduces each+ /// host's original resource-key choice for the "(all)" placeholder text exactly (Admin/Store used+ /// "Admin.Common.All", Vendor used "Vendor.Common.All" — confirmed in the three original+ /// controllers).</summary>+ public virtual async Task<IActionResult> BestsellersReport()+ {+ var model = new BestsellersReportModel();++ if (scope.ShowStoreSelector)+ {+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var s in await storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });+ }++ var status = await orderStatusService.GetAll();+ model.AvailableOrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();+ model.AvailableOrderStatuses.Insert(0,+ new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "" });++ model.AvailablePaymentStatuses = enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();+ model.AvailablePaymentStatuses.Insert(0,+ new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "" });++ foreach (var c in await countryService.GetAllCountriesForBilling(showHidden: true))+ model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });+ model.AvailableCountries.Insert(0,+ new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "" });++ if (scope.ShowVendorSelector)+ {+ model.AvailableVendors.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var v in await vendorService.GetAllVendors(showHidden: true))+ model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });+ }++ return View(model);+ }++ /// <summary>storeId/vendorId: scope value wins when non-empty (Store/Vendor force it), otherwise+ /// the posted model value is used unmodified (Admin, whose scope.StoreId/.VendorId are always "").+ /// Mirrors Store's original unconditional `model.StoreId = StaffStoreId` assignment exactly for+ /// Store, and Vendor's original explicit `vendorId: CurrentVendor.Id` argument exactly for Vendor,+ /// while leaving Admin's posted values untouched. Row filtering via scope.CanIncludeProduct+ /// reproduces Vendor's original `HasAccessToProduct` post-filter exactly (default-true for+ /// Admin/Store, including when product is null — same as the original "if CurrentVendor == null,+ /// always add" branch; VendorReportDataScope.CanIncludeProduct(null) is false, matching Vendor's+ /// original `product != null && HasAccessToProduct(product)` guard). model.StoreId/model.VendorId+ /// are normalized to "" when unposted (`null`, the default for an unbound `string` model property)+ /// because `IOrderReportService.BestSellersReport`'s storeId/vendorId parameters are non-nullable+ /// and default to "" — a `null` model value must not reach them as `null`.</summary>+ [HttpPost]+ public virtual async Task<IActionResult> BestsellersReportList(DataSourceRequest command, BestsellersReportModel model)+ {+ if (!string.IsNullOrEmpty(scope.StoreId)) model.StoreId = scope.StoreId;+ if (!string.IsNullOrEmpty(scope.VendorId)) model.VendorId = scope.VendorId;++ DateTime? startDateValue = model.StartDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.StartDate.Value, dateTimeService.CurrentTimeZone);++ DateTime? endDateValue = model.EndDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.EndDate.Value, dateTimeService.CurrentTimeZone).AddDays(1);++ int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;+ var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;++ var items = await orderReportService.BestSellersReport(+ storeId: model.StoreId ?? "",+ vendorId: model.VendorId ?? "",+ createdFromUtc: startDateValue,+ createdToUtc: endDateValue,+ os: orderStatus,+ ps: paymentStatus,+ billingCountryId: model.BillingCountryId ?? "",+ orderBy: 2,+ pageIndex: command.Page - 1,+ pageSize: command.PageSize,+ showHidden: true);++ var result = new List<BestsellersReportLineModel>();+ foreach (var x in items)+ {+ var m = new BestsellersReportLineModel {+ ProductId = x.ProductId,+ TotalAmount = priceFormatter.FormatPrice(x.TotalAmount, await currencyService.GetPrimaryStoreCurrency()),+ TotalQuantity = x.TotalQuantity+ };+ var product = await productService.GetProductById(x.ProductId);+ if (product != null)+ m.ProductName = product.Name;+ if (scope.CanIncludeProduct(product))+ result.Add(m);+ }++ var gridModel = new DataSourceResult { Data = result, Total = items.TotalCount };+ return Json(gridModel);+ }++ #endregion++ #region Never sold++ public virtual IActionResult NeverSoldReport() => View(new NeverSoldReportModel());++ /// <summary>storeId/vendorId: same "scope wins when non-empty, else posted model value" rule as+ /// BestsellersReportList — NeverSoldReportModel has no StoreId/VendorId fields of its own (none of+ /// the three original controllers ever posted one for this action), so the "posted value" side is+ /// always "" here; this reduces to "scope value, or '' for Admin", which is exactly each of the+ /// three originals' literal argument (Admin: "", ""; Store: storeId, ""; Vendor: "", vendorId).</summary>+ [HttpPost]+ public virtual async Task<IActionResult> NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)+ {+ DateTime? startDateValue = model.StartDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.StartDate.Value, dateTimeService.CurrentTimeZone);++ DateTime? endDateValue = model.EndDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.EndDate.Value, dateTimeService.CurrentTimeZone).AddDays(1);++ var items = await orderReportService.ProductsNeverSold(scope.StoreId, scope.VendorId,+ startDateValue, endDateValue, command.Page - 1, command.PageSize, true);++ var gridModel = new DataSourceResult {+ Data = items.Select(x => new NeverSoldReportLineModel { ProductId = x.Id, ProductName = x.Name }),+ Total = items.TotalCount+ };+ return Json(gridModel);+ }++ #endregion++ #region Country++ /// <summary>No inline permission check here — matches Store's/Vendor's actual current behavior+ /// (only Admin gates this GET on ManageCustomers; see this task's header note and Global+ /// Constraint 5). `virtual` so Admin's thin subclass (Task 12) can override and add the check.</summary>+ public virtual async Task<IActionResult> CountryReport()+ {+ var status = await orderStatusService.GetAll();+ var model = new CountryReportModel {+ AvailableOrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList()+ };+ model.AvailableOrderStatuses.Insert(0,+ new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "" });++ model.AvailablePaymentStatuses = enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();+ model.AvailablePaymentStatuses.Insert(0,+ new SelectListItem { Text = translationService.GetResource($"{scope.ResourceKeyPrefix}.Common.All"), Value = "" });++ return View(model);+ }++ [HttpPost]+ public virtual async Task<IActionResult> CountryReportList(DataSourceRequest command, CountryReportModel model)+ {+ DateTime? startDateValue = model.StartDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.StartDate.Value, dateTimeService.CurrentTimeZone);++ DateTime? endDateValue = model.EndDate == null+ ? null+ : dateTimeService.ConvertToUtcTime(model.EndDate.Value, dateTimeService.CurrentTimeZone).AddDays(1);++ int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;+ var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;++ var items = await orderReportService.GetCountryReport(+ storeId: scope.StoreId,+ vendorId: scope.VendorId,+ os: orderStatus,+ ps: paymentStatus,+ startTimeUtc: startDateValue,+ endTimeUtc: endDateValue);++ var result = new List<CountryReportLineModel>();+ foreach (var x in items)+ {+ var country = await countryService.GetCountryById(!string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "");+ result.Add(new CountryReportLineModel {+ CountryName = country != null ? country.Name : "Unknown",+ SumOrders = priceFormatter.FormatPrice(x.SumOrders, await currencyService.GetPrimaryStoreCurrency()),+ TotalOrders = x.TotalOrders+ });+ }++ var gridModel = new DataSourceResult { Data = result, Total = items.Count };+ return Json(gridModel);+ }++ #endregion++ #region Low stock reports++ public virtual IActionResult LowStockReport() => View();++ [HttpPost]+ public virtual async Task<IActionResult> LowStockReportList(DataSourceRequest command)+ {+ var lowStockProducts = await productsReportService.LowStockProducts(scope.VendorId, scope.StoreId);++ var models = new List<LowStockProductModel>();+ foreach (var product in lowStockProducts.products)+ models.Add(new LowStockProductModel {+ Id = product.Id,+ Name = product.Name,+ ManageInventoryMethod = enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),+ StockQuantity = stockQuantityService.GetTotalStockQuantity(product, total: true),+ Published = product.Published+ });++ foreach (var combination in lowStockProducts.combinations)+ {+ var product = await productService.GetProductById(combination.ProductId);+ models.Add(new LowStockProductModel {+ Id = product.Id,+ Name = product.Name,+ Attributes = await productAttributeFormatter.FormatAttributes(product, combination.Attributes,+ contextAccessor.WorkContext.CurrentCustomer, "<br />", true, true, true, false),+ ManageInventoryMethod = enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),+ StockQuantity = combination.StockQuantity,+ Published = product.Published+ });+ }++ var gridModel = new DataSourceResult { Data = models.PagedForCommand(command), Total = models.Count };+ return Json(gridModel);+ }++ #endregion++ #region Customer reports++ /// <summary>No inline permission check here — matches Store's/Vendor's actual current behavior+ /// (only Admin gates this GET on ManageCustomers; see Task 5's header note and Global Constraint+ /// 5, which names CountryReport's twin of this same check explicitly but not this one). `virtual`+ /// so Admin's thin subclass (Task 12) can override and add the check. Reuses+ /// PrepareCustomerReportsModel() as-is for all three hosts, including Vendor, accepting the+ /// unused-select-list over-population documented at spec §5/§2.4 as a disclosed, accepted+ /// tradeoff rather than adding a Vendor-specific thinner variant.</summary>+ public virtual async Task<IActionResult> Customer()+ {+ var model = await customerReportViewModelService.PrepareCustomerReportsModel();+ return View(model);+ }++ /// <summary>`scope.VendorId` is the new 5th argument added to+ /// `PrepareBestCustomerReportLineModel` by Task 11 (Global Constraint 8) — "" for Admin/Store+ /// (unchanged behavior), the current vendor's id for Vendor (replaces Vendor's original inline+ /// `GetBestCustomersReport("", vendorId, ...)` reimplementation entirely; see Task 11).+ /// model.StoreId is still threaded the same "scope wins when non-empty" way as every other action+ /// in this file, for the storeId half of the same call.</summary>+ [HttpPost]+ public virtual async Task<IActionResult> ReportBestCustomersByOrderTotalList(DataSourceRequest command,+ BestCustomersReportModel model)+ {+ if (!string.IsNullOrEmpty(scope.StoreId)) model.StoreId = scope.StoreId;++ var (bestCustomerReportLineModels, totalCount) = await customerReportViewModelService+ .PrepareBestCustomerReportLineModel(model, 1, command.Page, command.PageSize, scope.VendorId);++ var gridModel = new DataSourceResult { Data = bestCustomerReportLineModels.ToList(), Total = totalCount };+ return Json(gridModel);+ }++ #endregion+}diff --git a/src/Web/Grand.Web.AdminShared/Interfaces/ICustomerReportViewModelService.cs b/src/Web/Grand.Web.AdminShared/Interfaces/ICustomerReportViewModelService.csindex 9fc675faf..7d07a4a37 100644--- a/src/Web/Grand.Web.AdminShared/Interfaces/ICustomerReportViewModelService.cs+++ b/src/Web/Grand.Web.AdminShared/Interfaces/ICustomerReportViewModelService.cs@@ -5,8 +5,15 @@ namespace Grand.Web.AdminShared.Interfaces;public interface ICustomerReportViewModelService{Task<CustomerReportsModel> PrepareCustomerReportsModel();- Task<IList<RegisteredCustomerReportLineModel>> GetReportRegisteredCustomersModel(string storeId);++ /// <param name="storeId">Store scope applied to the underlying registered-customers report.</param>+ /// <param name="vendorId">Intentionally accepted but currently unused: the underlying report has no vendor+ /// dimension. Kept for signature symmetry with <see cref="PrepareBestCustomerReportLineModel" /> and for+ /// forward-compatibility should a vendor dimension ever be added.</param>+ Task<IList<RegisteredCustomerReportLineModel>> GetReportRegisteredCustomersModel(string storeId,+ string vendorId = "");Task<(IEnumerable<BestCustomerReportLineModel> bestCustomerReportLineModels, int totalCount)>- PrepareBestCustomerReportLineModel(BestCustomersReportModel model, int orderBy, int pageIndex, int pageSize);+ PrepareBestCustomerReportLineModel(BestCustomersReportModel model, int orderBy, int pageIndex,+ int pageSize, string vendorId = "");}\ No newline at end of filediff --git a/src/Web/Grand.Web.AdminShared/Interfaces/IReportDataScope.cs b/src/Web/Grand.Web.AdminShared/Interfaces/IReportDataScope.csnew file mode 100644index 000000000..9ac616e8f--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Interfaces/IReportDataScope.cs@@ -0,0 +1,44 @@+#nullable enable++namespace Grand.Web.AdminShared.Interfaces;++/// <summary>+/// Per-host data-access strategy for the read-only Reports screens. Deliberately separate from+/// IAdminDataScope<TEntity>: Reports has no entity to load and access-check — every report is+/// an aggregation query parameterized by storeId/vendorId at the business-service layer (see+/// ARCH-001 Reports consolidation spec §2.3). Forcing Reports through IAdminDataScope<TEntity>+/// would require a fake TEntity and leave HasAccess/CanView permanently unused — a worse fit than a+/// second, smaller interface.+/// </summary>+public interface IReportDataScope+{+ /// <summary>Store id to force into report queries. "" (all stores) for Admin when the caller+ /// supplies no explicit store filter; the current staff store for Store; "" (not store-scoped)+ /// for Vendor.</summary>+ string StoreId { get; }++ /// <summary>Vendor id to force into report queries. "" for Admin/Store (unless the caller+ /// supplies an explicit vendor filter — Admin only); the current vendor's id for Vendor.</summary>+ string VendorId { get; }++ /// <summary>Whether the host's Bestsellers/report screens should render a store-picker field.+ /// True for Admin only (Store is implicitly scoped to its own store with no picker; Vendor has+ /// no store concept on these screens).</summary>+ bool ShowStoreSelector { get; }++ /// <summary>Whether the host's Bestsellers screen should render a vendor-picker field. True for+ /// Admin only.</summary>+ bool ShowVendorSelector { get; }++ /// <summary>Prefix used to build host-specific localization keys ("Admin" or "Vendor"). Store+ /// uses "Admin" — same precedent as every prior phase's ResourceKeyPrefix, Store has no distinct+ /// Reports resource set.</summary>+ string ResourceKeyPrefix { get; }++ /// <summary>Post-filter applied to bestsellers/product-bearing report rows after the underlying+ /// query returns, beyond the storeId/vendorId already passed into the query. Identity (no+ /// filtering) for Admin and Store. Vendor overrides this to additionally drop rows whose product+ /// the current vendor sub-account has no access to (WorkContext.HasAccessToProduct) — preserves+ /// Vendor's existing BestsellersReportList behavior exactly (see spec §2.3).</summary>+ bool CanIncludeProduct(Grand.Domain.Catalog.Product product) => true;+}diff --git a/src/Web/Grand.Web.AdminShared/Services/AdminReportDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/AdminReportDataScope.csnew file mode 100644index 000000000..f3a9540a6--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Services/AdminReportDataScope.cs@@ -0,0 +1,23 @@+#nullable enable++using Grand.Domain.Catalog;+using Grand.Web.AdminShared.Interfaces;++namespace Grand.Web.AdminShared.Services;++/// <summary>+/// Admin's <see cref="IReportDataScope" />. Admin's report screens accept an explicit+/// storeId/vendorId filter from the posted grid model itself (or default to "" = unscoped) — the+/// scope object's job for Admin is purely to advertise the *capability* to filter+/// (<see cref="ShowStoreSelector" />/<see cref="ShowVendorSelector" /> = true), not to supply a+/// forced value the way Store/Vendor's scopes do. See ARCH-001 Reports consolidation spec §3.+/// </summary>+public class AdminReportDataScope : IReportDataScope+{+ public string StoreId => "";+ public string VendorId => "";+ public bool ShowStoreSelector => true;+ public bool ShowVendorSelector => true;+ public string ResourceKeyPrefix => "Admin";+ public bool CanIncludeProduct(Product product) => true;+}diff --git a/src/Web/Grand.Web.AdminShared/Services/CustomerReportViewModelService.cs b/src/Web/Grand.Web.AdminShared/Services/CustomerReportViewModelService.csindex 72813b9e3..2c67419ca 100644--- a/src/Web/Grand.Web.AdminShared/Services/CustomerReportViewModelService.cs+++ b/src/Web/Grand.Web.AdminShared/Services/CustomerReportViewModelService.cs@@ -77,8 +77,15 @@ public class CustomerReportViewModelService : ICustomerReportViewModelServicereturn model;}+ /// <param name="storeId">Store scope applied to <see cref="ICustomerReportService.GetRegisteredCustomersReport" />.</param>+ /// <param name="vendorId">Intentionally accepted but currently unused: <see cref="ICustomerReportService.GetRegisteredCustomersReport" />+ /// has no vendor dimension at all (registered customers aren't owned by a vendor), so there is nothing to filter by here.+ /// The parameter exists for signature symmetry with <see cref="PrepareBestCustomerReportLineModel" /> (which DOES use its+ /// own <c>vendorId</c>) and for forward-compatibility should a vendor dimension ever be added to the underlying report.+ /// The only caller (<see cref="Controllers.BaseFullReportsController.ReportRegisteredCustomersList" />) is Full-tier/Admin-Store+ /// only, where <c>scope.VendorId</c> is always "" anyway, so this is currently a documented no-op, not a bug.</param>public virtual async Task<IList<RegisteredCustomerReportLineModel>> GetReportRegisteredCustomersModel(- string storeId)+ string storeId, string vendorId = ""){var report = new List<RegisteredCustomerReportLineModel> {new() {@@ -108,7 +115,8 @@ public class CustomerReportViewModelService : ICustomerReportViewModelService}public virtual async Task<(IEnumerable<BestCustomerReportLineModel> bestCustomerReportLineModels, int totalCount)>- PrepareBestCustomerReportLineModel(BestCustomersReportModel model, int orderBy, int pageIndex, int pageSize)+ PrepareBestCustomerReportLineModel(BestCustomersReportModel model, int orderBy, int pageIndex, int pageSize,+ string vendorId = ""){DateTime? startDateValue = model.StartDate == null? null@@ -124,6 +132,7 @@ public class CustomerReportViewModelService : ICustomerReportViewModelServicevar items = await _customerReportService.GetBestCustomersReport(model.StoreId,+ vendorId,createdFromUtc: startDateValue,createdToUtc: endDateValue,os: orderStatus,diff --git a/src/Web/Grand.Web.AdminShared/Services/RoutedReportDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/RoutedReportDataScope.csnew file mode 100644index 000000000..4051f92db--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Services/RoutedReportDataScope.cs@@ -0,0 +1,47 @@+#nullable enable++using Grand.Domain.Catalog;+using Grand.Web.AdminShared.Interfaces;+using Microsoft.AspNetCore.Http;++namespace Grand.Web.AdminShared.Services;++/// <summary>+/// Resolves the correct per-host <see cref="IReportDataScope" /> implementation at request time,+/// based on the current request's "area" route value — same fix and same reason as+/// <see cref="RoutedOrderDataScope" />/<see cref="RoutedPaymentTransactionDataScope" />:+/// <c>Grand.Web</c> (the combined host) <c>ProjectReference</c>s Admin, Store, and Vendor+/// directly and loads all three <c>StartupApplication</c>s into one DI container, so a plain+/// per-host registration would let whichever host's StartupApplication ran last win for every+/// area in that process.+/// </summary>+public class RoutedReportDataScope(+ IHttpContextAccessor httpContextAccessor,+ AdminReportDataScope adminScope,+ StoreReportDataScope storeScope,+ VendorReportDataScope vendorScope) : IReportDataScope+{+ private IReportDataScope Resolved+ {+ get+ {+ var area = httpContextAccessor.HttpContext?.Request.RouteValues["area"] as string;+ return area switch {+ "Admin" => adminScope,+ "Store" => storeScope,+ "Vendor" => vendorScope,+ //fail closed: this object fronts store/vendor tenant isolation, so an unrecognized+ //or missing area must never silently resolve to any concrete scope+ _ => throw new InvalidOperationException(+ $"RoutedReportDataScope: unrecognized or missing area '{area}'.")+ };+ }+ }++ public string StoreId => Resolved.StoreId;+ public string VendorId => Resolved.VendorId;+ public bool ShowStoreSelector => Resolved.ShowStoreSelector;+ public bool ShowVendorSelector => Resolved.ShowVendorSelector;+ public string ResourceKeyPrefix => Resolved.ResourceKeyPrefix;+ public bool CanIncludeProduct(Product product) => Resolved.CanIncludeProduct(product);+}diff --git a/src/Web/Grand.Web.AdminShared/Services/StoreReportDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/StoreReportDataScope.csnew file mode 100644index 000000000..5c933dbce--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Services/StoreReportDataScope.cs@@ -0,0 +1,23 @@+#nullable enable++using Grand.Domain.Catalog;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Interfaces;++namespace Grand.Web.AdminShared.Services;++/// <summary>+/// Store's <see cref="IReportDataScope" />. Forces every report query to the current staff+/// store; never a vendor concept. No store/vendor picker (Store is implicitly scoped, same+/// shape as every prior phase's Store scope). Reuses Admin's resource keys ("Admin" prefix) —+/// Store has no distinct Reports resource set today.+/// </summary>+public class StoreReportDataScope(IContextAccessor contextAccessor) : IReportDataScope+{+ public string StoreId => contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;+ public string VendorId => "";+ public bool ShowStoreSelector => false;+ public bool ShowVendorSelector => false;+ public string ResourceKeyPrefix => "Admin";+ public bool CanIncludeProduct(Product product) => true;+}diff --git a/src/Web/Grand.Web.AdminShared/Services/VendorReportDataScope.cs b/src/Web/Grand.Web.AdminShared/Services/VendorReportDataScope.csnew file mode 100644index 000000000..115ed84f4--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Services/VendorReportDataScope.cs@@ -0,0 +1,29 @@+#nullable enable++using Grand.Domain.Catalog;+using Grand.Infrastructure;+using Grand.Web.AdminShared.Interfaces;++namespace Grand.Web.AdminShared.Services;++/// <summary>+/// Vendor's <see cref="IReportDataScope" />. Forces every report query to the current vendor;+/// never a store concept on these screens. <see cref="CanIncludeProduct" /> reimplements the+/// equivalent of <c>Grand.Web.Vendor/Extensions/HasAccess.cs</c>'s+/// <c>HasAccessToProduct(Product)</c> rather than calling it: <c>Grand.Web.AdminShared</c> has no+/// project reference to <c>Grand.Web.Vendor</c> (the reference direction is Vendor→AdminShared),+/// same constraint <c>VendorMerchandiseReturnDataScope</c>/<c>VendorOrderDataScope</c> already+/// work around. Preserves Vendor's existing <c>BestsellersReportList</c> product-ownership+/// post-filter verbatim (ARCH-001 Reports consolidation spec §2.3/§9).+/// </summary>+public class VendorReportDataScope(IContextAccessor contextAccessor) : IReportDataScope+{+ public string StoreId => "";+ public string VendorId => contextAccessor.WorkContext.CurrentVendor.Id;+ public bool ShowStoreSelector => false;+ public bool ShowVendorSelector => false;+ public string ResourceKeyPrefix => "Vendor";++ public bool CanIncludeProduct(Product product) =>+ product is not null && product.VendorId == contextAccessor.WorkContext.CurrentVendor.Id;+}diff --git a/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs b/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.csindex 8eaf3fdc9..6d67af6f5 100644--- a/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs+++ b/src/Web/Grand.Web.AdminShared/Startup/StartupApplication.cs@@ -115,6 +115,14 @@ public class StartupApplication : IStartupApplicationservices.AddScoped<StoreMerchandiseReturnDataScope>();services.AddScoped<VendorMerchandiseReturnDataScope>();services.AddScoped<IAdminDataScope<MerchandiseReturn>, RoutedMerchandiseReturnDataScope>();++ // IReportDataScope: NOT an IAdminDataScope<TEntity> registration (Reports has no entity —+ // see IReportDataScope's doc comment and ARCH-001 Reports consolidation spec §3). All three+ // hosts have a Reports screen, so all three concrete scopes are registered.+ services.AddScoped<AdminReportDataScope>();+ services.AddScoped<StoreReportDataScope>();+ services.AddScoped<VendorReportDataScope>();+ services.AddScoped<IReportDataScope, RoutedReportDataScope>();}public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByAmount.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByAmount.cshtmlsimilarity index 87%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByAmount.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByAmount.cshtmlindex fe9cc1edf..d4231128b 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByAmount.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByAmount.cshtml@@ -1,4 +1,5 @@-@{+@{+ var area = ViewContext.RouteData.Values["area"]?.ToString();var gridPageSize = 5;}<div id="bestsellers-byamount-grid"></div>@@ -8,7 +9,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("BestsellersBriefReportByAmountList", "Reports", new { area = Constants.AreaAdmin }))",+ url: "@Html.Raw(Url.Action("BestsellersBriefReportByAmountList", "Reports", new { area }))",type: "POST",dataType: "json",data: addAntiForgeryToken@@ -50,8 +51,8 @@field: "ProductId",title: "@Loc["Admin.Common.View"]",width: 100,- template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'+ template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'}]});});-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByQuantity.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByQuantity.cshtmlsimilarity index 87%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByQuantity.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByQuantity.cshtmlindex da6b5c12b..373b2a3fd 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersBriefReportByQuantity.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersBriefReportByQuantity.cshtml@@ -1,4 +1,5 @@-@{+@{+ var area = ViewContext.RouteData.Values["area"]?.ToString();var gridPageSize = 5;}<div id="bestsellers-byquantity-grid"></div>@@ -8,7 +9,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("BestsellersBriefReportByQuantityList", "Reports", new { area = Constants.AreaAdmin }))",+ url: "@Html.Raw(Url.Action("BestsellersBriefReportByQuantityList", "Reports", new { area }))",type: "POST",dataType: "json",data: addAntiForgeryToken@@ -50,8 +51,8 @@field: "ProductId",title: "@Loc["Admin.Common.View"]",width: 100,- template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'+ template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'}]});});-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersReport.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersReport.cshtmlsimilarity index 83%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersReport.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersReport.cshtmlindex 27d96a774..bfa067455 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/BestsellersReport.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/BestsellersReport.cshtml@@ -1,8 +1,10 @@-@model BestsellersReportModel+@model BestsellersReportModel@inject AdminAreaSettings adminAreaSettings+@inject IReportDataScope Scope@{//page title- ViewBag.Title = Loc["Admin.Reports.Bestsellers"];+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Reports.Bestsellers"];+ var area = ViewContext.RouteData.Values["area"]?.ToString();}<div class="row">@@ -11,12 +13,12 @@<div class="x_title"><div class="caption level-caption"><i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.Bestsellers"]+ @Loc[$"{Scope.ResourceKeyPrefix}.Reports.Bestsellers"]</div></div><div class="x_content form">- <vc:admin-widget widget-zone="bestsellers_report" additional-data="Model"/>+ <partial name="Partials/WidgetZone.Bestsellers" model="Model"/><div class="form-horizontal"><div class="form-body"><div class="x_content">@@ -24,12 +26,15 @@<div class="form-body"><div class="main-header col-12 px-0"><div class="row align-items-end">- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="StoreId" class="control-label"/>- <admin-select asp-for="StoreId" asp-items="Model.AvailableStores"/>+ @if (Scope.ShowStoreSelector)+ {+ <div class="col-md-4 col-ms-12 col-12">+ <div class="form-group mb-0">+ <admin-label asp-for="StoreId" class="control-label"/>+ <admin-select asp-for="StoreId" asp-items="Model.AvailableStores"/>+ </div></div>- </div>+ }<div class="col-md-4 col-ms-12 col-12"><div class="form-group mb-0"><admin-label asp-for="OrderStatusId" class="control-label"/>@@ -76,12 +81,15 @@<admin-select asp-for="BillingCountryId" asp-items="Model.AvailableCountries"/></div></div>- <div class="form-group">- <admin-label asp-for="VendorId" class="col-sm-3 control-label"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="VendorId" asp-items="Model.AvailableVendors"/>+ @if (Scope.ShowVendorSelector)+ {+ <div class="form-group">+ <admin-label asp-for="VendorId" class="col-sm-3 control-label"/>+ <div class="col-md-9 col-sm-9">+ <admin-select asp-for="VendorId" asp-items="Model.AvailableVendors"/>+ </div></div>- </div>+ }</div></div></div>@@ -104,7 +112,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("BestsellersReportList", "Reports", new { area = Constants.AreaAdmin }))",+ url: "@Html.Raw(Url.Action("BestsellersReportList", "Reports", new { area }))",type: "POST",dataType: "json",data: additionalData@@ -137,7 +145,7 @@columns: [{field: "ProductName",title: "@Loc["Admin.Reports.Bestsellers.Fields.Name"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'+ template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'}, {field: "TotalQuantity",title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalQuantity"]"@@ -175,4 +183,4 @@return data;}-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/CountryReport.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/CountryReport.cshtmlsimilarity index 94%rename from src/Web/Grand.Web.Store/Areas/Store/Views/Reports/CountryReport.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/CountryReport.cshtmlindex 59a405ff8..924457927 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/CountryReport.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/CountryReport.cshtml@@ -1,7 +1,9 @@-@model CountryReportModel+@model CountryReportModel+@inject IReportDataScope Scope@{//page title- ViewBag.Title = Loc["Admin.Reports.Country"];+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Reports.Country"];+ var area = ViewContext.RouteData.Values["area"]?.ToString();}@@ -11,12 +13,12 @@<div class="x_title"><div class="caption level-caption"><i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.Country"]+ @Loc[$"{Scope.ResourceKeyPrefix}.Reports.Country"]</div></div><div class="x_content form">- <vc:admin-widget widget-zone="country_report" additional-data="Model"/>+ <partial name="Partials/WidgetZone.Country" model="Model"/><div class="form-horizontal"><div class="form-body"><div class="x_content">@@ -86,7 +88,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("CountryReportList", "Reports", new { area = Constants.AreaStore }))",+ url: "@Html.Raw(Url.Action("CountryReportList", "Reports", new { area }))",type: "POST",dataType: "json",data: additionalData@@ -150,4 +152,4 @@return data;}- </script>\ No newline at end of file+ </script>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Customer.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Customer.cshtmlsimilarity index 88%rename from src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Customer.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Customer.cshtmlindex 65d565978..58b1c5f5c 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Customer.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Customer.cshtml@@ -1,8 +1,9 @@-@model CustomerReportsModel+@model CustomerReportsModel+@inject IReportDataScope Scope@{//page title- ViewBag.Title = Loc["Admin.Reports.Customers"];+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Reports.Customers"];}<div class="row">@@ -11,7 +12,7 @@<div class="x_title"><div class="caption level-caption"><i class="fa fa-bar-chart-o"></i>- @Loc["Admin.Reports.Customers"]+ @Loc[$"{Scope.ResourceKeyPrefix}.Reports.Customers"]</div></div><div class="x_content form">@@ -41,7 +42,7 @@</div></content></tabstrip-item>- <vc:admin-widget widget-zone="reports_details_tabs" additional-data="Model"/>+ <partial name="Partials/WidgetZone.DetailsTabs" model="Model"/></items></admin-tabstrip></div>@@ -50,4 +51,4 @@</div></div></div>-</div>\ No newline at end of file+</div>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/LowStockReport.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/LowStockReport.cshtmlsimilarity index 84%rename from src/Web/Grand.Web.Store/Areas/Store/Views/Reports/LowStockReport.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/LowStockReport.cshtmlindex b72473b8e..b7592ce6a 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/LowStockReport.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/LowStockReport.cshtml@@ -1,7 +1,9 @@-@inject AdminAreaSettings adminAreaSettings+@inject AdminAreaSettings adminAreaSettings+@inject IReportDataScope Scope@{//page title- ViewBag.Title = Loc["Admin.Reports.LowStockReport"];+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Reports.LowStockReport"];+ var area = ViewContext.RouteData.Values["area"]?.ToString();}<div class="row">@@ -10,7 +12,7 @@<div class="x_title"><div class="caption level-caption"><i class="fa fa-cubes"></i>- @Loc["Admin.Reports.LowStockReport"]+ @Loc[$"{Scope.ResourceKeyPrefix}.Reports.LowStockReport"]</div></div><div class="x_content form">@@ -29,7 +31,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("LowStockReportList", "Reports", new { area = Constants.AreaStore }))",+ url: "@Html.Raw(Url.Action("LowStockReportList", "Reports", new { area }))",type: "POST",dataType: "json",data: addAntiForgeryToken@@ -64,8 +66,8 @@field: "Name",title: "@Loc["Admin.Catalog.Products.Fields.Name"]",width: 300,- //if not a grouped product, then display- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=Id#">#:Name# # if(Attributes !== null) {# <br /><i> #=Attributes# </i> #} #</a>',+ //if not a grouped product, then display+ template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area })/#=Id#">#:Name# # if(Attributes !== null) {# <br /><i> #=Attributes# </i> #} #</a>',}, {field: "ManageInventoryMethod",title: "@Loc["Admin.Catalog.Products.Fields.ManageInventoryMethod"]",@@ -85,4 +87,4 @@]});});-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/NeverSoldReport.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/NeverSoldReport.cshtmlsimilarity index 90%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/NeverSoldReport.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/NeverSoldReport.cshtmlindex 0c36b4543..27684fb7b 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/NeverSoldReport.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/NeverSoldReport.cshtml@@ -1,8 +1,10 @@-@model NeverSoldReportModel+@model NeverSoldReportModel@inject AdminAreaSettings adminAreaSettings+@inject IReportDataScope Scope@{//page title- ViewBag.Title = Loc["Admin.Reports.NeverSold"];+ ViewBag.Title = Loc[$"{Scope.ResourceKeyPrefix}.Reports.NeverSold"];+ var area = ViewContext.RouteData.Values["area"]?.ToString();}<div class="row">@@ -11,11 +13,11 @@<div class="x_title"><div class="caption level-caption"><i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.NeverSold"]+ @Loc[$"{Scope.ResourceKeyPrefix}.Reports.NeverSold"]</div></div><div class="x_content form">- <vc:admin-widget widget-zone="never_sold_report" additional-data="Model"/>+ <partial name="Partials/WidgetZone.NeverSold" model="Model"/><div class="form-horizontal"><div class="form-body"><div class="x_content">@@ -62,7 +64,7 @@dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("NeverSoldReportList", "Reports", new { area = Constants.AreaAdmin }))",+ url: "@Html.Raw(Url.Action("NeverSoldReportList", "Reports", new { area }))",type: "POST",dataType: "json",data: additionalData@@ -95,7 +97,7 @@columns: [{field: "ProductName",title: "@Loc["Admin.Reports.NeverSold.Fields.Name"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaAdmin })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'+ template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'}]});});@@ -122,4 +124,4 @@return data;}-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtmlsimilarity index 90%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtmlindex bcf131ac1..a8f3b0487 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtml@@ -1,4 +1,4 @@-@model CustomerReportsModel+@model CustomerReportsModel@{var dataDictAttributes = new ViewDataDictionary(ViewData){@@ -8,4 +8,4 @@}};<partial name="Partials/ReportBestCustomersByNumberOfOrders" model="Model.BestCustomersByOrderTotal" view-data="dataDictAttributes"/>-}\ No newline at end of file+}diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByOrderTotal.cshtmlsimilarity index 90%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByOrderTotal.cshtmlindex 1cfd5ef1b..7955f124e 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabBestByOrderTotal.cshtml@@ -1,4 +1,4 @@-@model CustomerReportsModel+@model CustomerReportsModel@{var dataDictAttributes = new ViewDataDictionary(ViewData){@@ -8,4 +8,4 @@}};<partial name="Partials/ReportBestCustomersByOrderTotal" model="Model.BestCustomersByOrderTotal" view-data="dataDictAttributes"/>-}\ No newline at end of file+}diff --git a/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabRegisteredCustomers.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabRegisteredCustomers.cshtmlnew file mode 100644index 000000000..6ca8a9a83--- /dev/null+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/Customer.TabRegisteredCustomers.cshtml@@ -0,0 +1,4 @@+@model CustomerReportsModel+@{+ <partial name="Partials/CustomerReportRegisteredComponent"/>+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtmlsimilarity index 93%rename from src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtmlindex 81e9b0fc6..af70fca45 100644--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByNumberOfOrders.cshtml@@ -1,7 +1,10 @@-@model BestCustomersReportModel+@model BestCustomersReportModel@inject AdminAreaSettings adminAreaSettings+@{+ var area = ViewContext.RouteData.Values["area"]?.ToString();+}-<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_top" additional-data="Model"/>+<partial name="Partials/WidgetZone.CustomerByNumberOfOrdersTop" model="Model"/><div class="popup-window"><div class="form-horizontal"><div class="form-body">@@ -59,14 +62,14 @@</div><div id="best-customers-numberoforders-grid"></div></div>-<vc:admin-widget widget-zone="customer_details_report_by_number_of_orders_bottom" additional-data="Model"/>+<partial name="Partials/WidgetZone.CustomerByNumberOfOrdersBottom" model="Model"/><script>$(document).ready(function () {$("#best-customers-numberoforders-grid").kendoGrid({dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("ReportBestCustomersByNumberOfOrdersList", "Reports", new { area = Constants.AreaStore }))",+ url: "@Html.Raw(Url.Action("ReportBestCustomersByNumberOfOrdersList", "Reports", new { area }))",type: "POST",dataType: "json",data: bestCustomersNumberOfOrdersAdditionalData@@ -99,7 +102,7 @@ $(document).ready(function () {columns: [{field: "CustomerName",title: "@Loc["Admin.Reports.Customers.BestBy.Fields.Customer"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaStore })/#=CustomerId#">#:CustomerName#</a>',+ template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area })/#=CustomerId#">#:CustomerName#</a>',}, {field: "OrderTotal",title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderTotal"]"@@ -132,4 +135,4 @@ function bestCustomersNumberOfOrdersAdditionalData(e) {addAntiForgeryToken(data);return data;}-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByOrderTotal.cshtmlsimilarity index 93%rename from src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtmlrename to src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByOrderTotal.cshtmlindex 5f2842896..694a459b9 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/Reports/Partials/ReportBestCustomersByOrderTotal.cshtml@@ -1,6 +1,9 @@-@model BestCustomersReportModel+@model BestCustomersReportModel@inject AdminAreaSettings adminAreaSettings-<vc:admin-widget widget-zone="customer_details_report_by_order_total_top" additional-data="Model"/>+@{+ var area = ViewContext.RouteData.Values["area"]?.ToString();+}+<partial name="Partials/WidgetZone.CustomerByOrderTotalTop" model="Model"/><div class="popup-window"><div class="form-horizontal"><div class="form-body">@@ -58,14 +61,14 @@</div><div id="best-customers-ordertotal-grid"></div></div>-<vc:admin-widget widget-zone="customer_details_report_by_order_total_bottom" additional-data="Model"/>+<partial name="Partials/WidgetZone.CustomerByOrderTotalBottom" model="Model"/><script>$(document).ready(function () {$("#best-customers-ordertotal-grid").kendoGrid({dataSource: {transport: {read: {- url: "@Html.Raw(Url.Action("ReportBestCustomersByOrderTotalList", "Reports", new { area = Constants.AreaAdmin }))",+ url: "@Html.Raw(Url.Action("ReportBestCustomersByOrderTotalList", "Reports", new { area }))",type: "POST",dataType: "json",data: bestCustomersOrderTotalAdditionalData@@ -98,7 +101,7 @@columns: [{field: "CustomerName",title: "@Loc["Admin.Reports.Customers.BestBy.Fields.Customer"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaAdmin })/#=CustomerId#">#:CustomerName#</a>',+ template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area })/#=CustomerId#">#:CustomerName#</a>',}, {field: "OrderTotal",title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderTotal"]"@@ -131,4 +134,4 @@addAntiForgeryToken(data);return data;}-</script>\ No newline at end of file+</script>diff --git a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtmlindex 6f40614b8..7480ac5e6 100644--- a/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml+++ b/src/Web/Grand.Web.AdminShared/Views/AdminShared/_ViewImports.cshtml@@ -15,6 +15,7 @@@using Grand.Web.Common.Localization@using Grand.Web.AdminShared.Models.Catalog@using Grand.Web.AdminShared.Models.Orders+@using Grand.Web.AdminShared.Models.Customers@using Grand.Web.AdminShared.Interfaces@inject LocService Locdiff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByAmount.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByAmount.cshtmldeleted file mode 100644index 4d3c28e11..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByAmount.cshtml+++ /dev/null@@ -1,57 +0,0 @@-@{- var gridPageSize = 5;-}-<div id="bestsellers-byamount-grid"></div>-<script>- $(document).ready(function () {- $("#bestsellers-byamount-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("BestsellersBriefReportByAmountList", "Reports", new { area = Constants.AreaStore }))",- type: "POST",- dataType: "json",- data: addAntiForgeryToken- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(gridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "ProductName",- title: "@Loc["Admin.Reports.Bestsellers.Fields.Name"]"- }, {- field: "TotalQuantity",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalQuantity"]"- }, {- field: "TotalAmount",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalAmount"]"- }, {- field: "ProductId",- title: "@Loc["Admin.Common.View"]",- width: 100,- template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'- }]- });- });-</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByQuantity.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByQuantity.cshtmldeleted file mode 100644index 7c748dab2..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersBriefReportByQuantity.cshtml+++ /dev/null@@ -1,57 +0,0 @@-@{- var gridPageSize = 5;-}-<div id="bestsellers-byquantity-grid"></div>-<script>- $(document).ready(function () {- $("#bestsellers-byquantity-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("BestsellersBriefReportByQuantityList", "Reports", new { area = Constants.AreaStore }))",- type: "POST",- dataType: "json",- data: addAntiForgeryToken- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(gridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "ProductName",- title: "@Loc["Admin.Reports.Bestsellers.Fields.Name"]"- }, {- field: "TotalQuantity",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalQuantity"]"- }, {- field: "TotalAmount",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalAmount"]"- }, {- field: "ProductId",- title: "@Loc["Admin.Common.View"]",- width: 100,- template: '<a class="btn btn-sm btn-default" href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=ProductId#"><i class="fa fa-search"></i> @Loc["Admin.Common.View"]</a>'- }]- });- });-</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersReport.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersReport.cshtmldeleted file mode 100644index 70ee88585..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/BestsellersReport.cshtml+++ /dev/null@@ -1,164 +0,0 @@-@model BestsellersReportModel-@inject AdminAreaSettings adminAreaSettings-@{- //page title- ViewBag.Title = Loc["Admin.Reports.Bestsellers"];-}--<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit popup-window">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.Bestsellers"]- </div>-- </div>- <div class="x_content form">- <vc:admin-widget widget-zone="bestsellers_report" additional-data="Model"/>- <div class="form-horizontal">- <div class="form-body">- <div class="x_content">- <div class="form-horizontal">- <div class="form-body">- <div class="main-header col-12 px-0">- <div class="row align-items-end">- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="OrderStatusId" class="control-label"/>- <admin-select asp-for="OrderStatusId" asp-items="Model.AvailableOrderStatuses"/>- </div>- </div>- <div class="col-md-4 col-sm-12 col-12">- <div class="form-actions">- <div class="btn-group">- <button class="btn btn-success filter-submit" id="search-salesreport">- <i class="fa fa-search"></i> @Loc["Admin.Reports.Bestsellers.RunReport"]- </button>- <button class="btn btn-info" type="button" data-toggle="collapse" data-target="#filterCollapse" aria-expanded="false" aria-controls="filterCollapse">- <i class="fa fa-filter"></i> @Loc["Admin.Common.Filters"]- </button>- </div>- </div>- </div>- </div>- </div>- <div class="collapse" id="filterCollapse">- <div class="drop-filters-container w-100">- <div class="form-group">- <admin-label asp-for="StartDate" class="col-sm-3 control-label"/>- <div class="col-md-9 col-sm-9">- <admin-input asp-for="StartDate"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="EndDate" class="col-sm-3 control-label"/>- <div class="col-md-9 col-sm-9">- <admin-input asp-for="EndDate"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="PaymentStatusId" class="col-sm-3 control-label"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="BillingCountryId" class="col-sm-3 control-label"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="BillingCountryId" asp-items="Model.AvailableCountries"/>- </div>- </div>- </div>- </div>- </div>-- <div class="x_content">- <div id="salesreport-grid"></div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>-</div>--<script>- $(document).ready(function () {- $("#salesreport-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("BestsellersReportList", "Reports", new { area = Constants.AreaStore }))",- type: "POST",- dataType: "json",- data: additionalData- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- pageSizes: [@(adminAreaSettings.GridPageSizes)]- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "ProductName",- title: "@Loc["Admin.Reports.Bestsellers.Fields.Name"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'- }, {- field: "TotalQuantity",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalQuantity"]"- },{- field: "TotalAmount",- title: "@Loc["Admin.Reports.Bestsellers.Fields.TotalAmount"]"- }]- });- });-</script>-<script>-- $(document).ready(function () {-- $('#search-salesreport').click(function () {- var grid = $('#salesreport-grid').data('kendoGrid');- grid.dataSource.page(1); //new search. Set page size to 1- //grid.dataSource.read(); we already loaded the grid above using "page" function- return false;- });-- });-- function additionalData() {- var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val(),- OrderStatusId: $('#OrderStatusId').val(),- PaymentStatusId: $('#PaymentStatusId').val(),- BillingCountryId: $('#BillingCountryId').val(),- };- addAntiForgeryToken(data);- return data;- }--</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/NeverSoldReport.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/NeverSoldReport.cshtmldeleted file mode 100644index 6b36f72ce..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/NeverSoldReport.cshtml+++ /dev/null@@ -1,125 +0,0 @@-@model NeverSoldReportModel-@inject AdminAreaSettings adminAreaSettings-@{- //page title- ViewBag.Title = Loc["Admin.Reports.NeverSold"];-}--<div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit">- <div class="x_title">- <div class="caption level-caption">- <i class="fa fa-list-alt"></i>- @Loc["Admin.Reports.NeverSold"]- </div>- </div>- <div class="x_content form">- <vc:admin-widget widget-zone="never_sold_report" additional-data="Model"/>- <div class="form-horizontal">- <div class="form-body">- <div class="x_content">- <div class="form-horizontal">- <div class="form-body">- <div class="row align-items-end mb-3">- <div class="col-md-3 col-sm-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="StartDate" class="d-flex flex-column align-items-start mw-100 px-0 text-left"/>- <admin-input asp-for="StartDate" class="w-100"/>- </div>- </div>- <div class="col-md-3 col-sm-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="EndDate" class="d-flex flex-column align-items-start mw-100 px-0 text-left"/>- <admin-input asp-for="EndDate" class="w-100"/>- </div>- </div>- <div class="col-md-5 col-sm-12 col-12 mt-md-0 mt-3">- <div class="form-actions">- <button class="btn btn-success filter-submit" id="search-neversoldreport">- <i class="fa fa-search"></i> @Loc["Admin.Reports.NeverSold.RunReport"]- </button>- </div>- </div>- </div>- </div>- <div class="x_content">- <div id="neversoldreport-grid"></div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>-</div>---<script>- $(document).ready(function () {- $("#neversoldreport-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("NeverSoldReportList", "Reports", new { area = Constants.AreaStore }))",- type: "POST",- dataType: "json",- data: additionalData- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- pageSizes: [@(adminAreaSettings.GridPageSizes)]- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "ProductName",- title: "@Loc["Admin.Reports.NeverSold.Fields.Name"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Product", new { area = Constants.AreaStore })/#=ProductId#">#=kendo.htmlEncode(ProductName)#</a>'- }]- });- });-</script>-<script>-- $(document).ready(function () {-- $('#search-neversoldreport').click(function () {- var grid = $('#neversoldreport-grid').data('kendoGrid');- grid.dataSource.page(1); //new search. Set page size to 1- //grid.dataSource.read(); we already loaded the grid above using "page" function- return false;- });-- });-- function additionalData() {- var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val()- };- addAntiForgeryToken(data);- return data;- }--</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtmldeleted file mode 100644index bcf131ac1..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByNumberOfOrders.cshtml+++ /dev/null@@ -1,11 +0,0 @@-@model CustomerReportsModel-@{- var dataDictAttributes = new ViewDataDictionary(ViewData)- {- TemplateInfo =- {- HtmlFieldPrefix = "bestbynumberoforders"- }- };- <partial name="Partials/ReportBestCustomersByNumberOfOrders" model="Model.BestCustomersByOrderTotal" view-data="dataDictAttributes"/>-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtmldeleted file mode 100644index 1cfd5ef1b..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabBestByOrderTotal.cshtml+++ /dev/null@@ -1,11 +0,0 @@-@model CustomerReportsModel-@{- var dataDictAttributes = new ViewDataDictionary(ViewData)- {- TemplateInfo =- {- HtmlFieldPrefix = "bestbyordertotal"- }- };- <partial name="Partials/ReportBestCustomersByOrderTotal" model="Model.BestCustomersByOrderTotal" view-data="dataDictAttributes"/>-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtmldeleted file mode 100644index 283ad7c75..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/Customer.TabRegisteredCustomers.cshtml+++ /dev/null@@ -1,4 +0,0 @@-@model CustomerReportsModel-@{- @await Component.InvokeAsync("StoreCustomerReportRegistered")-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtmlnew file mode 100644index 000000000..d84d69878--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/CustomerReportRegisteredComponent.cshtml@@ -0,0 +1,8 @@+@* Store invokes its own StoreCustomerReportRegistered component (Grand.Web.Store/Components), not+ Admin's CustomerReportRegistered — the Admin component's base class (BaseAdminViewComponent) is+ not usable from the Store app. Both components are functionally identical (same permission check,+ same view). Extracted into a per-host satellite following the same pattern as this Reports+ migration's WidgetZone.*.cshtml partials. *@+@{+ @await Component.InvokeAsync("StoreCustomerReportRegistered")+}diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtmldeleted file mode 100644index 704730d7b..000000000--- a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/ReportBestCustomersByOrderTotal.cshtml+++ /dev/null@@ -1,134 +0,0 @@-@model BestCustomersReportModel-@inject AdminAreaSettings adminAreaSettings-<vc:admin-widget widget-zone="customer_details_report_by_order_total_top" additional-data="Model"/>-<div class="popup-window">- <div class="form-horizontal">- <div class="form-body">- <div class="main-header col-12 px-0">- <div class="row align-items-end">- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="StartDate" class="control-label"/>- <admin-input asp-for="StartDate"/>- </div>- </div>- <div class="col-md-4 col-ms-12 col-12">- <div class="form-group mb-0">- <admin-label asp-for="EndDate" class="control-label"/>- <admin-input asp-for="EndDate"/>- </div>- </div>- <div class="col-md-4 col-sm-12 col-12">- <div class="form-actions">- <div class="btn-group">- <button class="btn btn-success filter-submit" id="search-best-customers-ordertotal">- <i class="fa fa-search"></i> @Loc["Admin.Reports.Customers.RunReport"]- </button>- <button class="btn btn-info" type="button" data-toggle="collapse" data-target="#filterCollapse" aria-expanded="false" aria-controls="filterCollapse">- <i class="fa fa-filter"></i> @Loc["Admin.Common.Filters"]- </button>- </div>- </div>- </div>- </div>- </div>- <div class="collapse" id="filterCollapse">- <div class="drop-filters-container w-100">- <div class="form-group">- <admin-label asp-for="OrderStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="OrderStatusId" asp-items="Model.AvailableOrderStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="PaymentStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses"/>- </div>- </div>- <div class="form-group">- <admin-label asp-for="ShippingStatusId" class="control-label col-md-3 col-sm-3"/>- <div class="col-md-9 col-sm-9">- <admin-select asp-for="ShippingStatusId" asp-items="Model.AvailableShippingStatuses"/>- </div>- </div>- </div>- </div>- </div>- </div>- <div id="best-customers-ordertotal-grid"></div>-</div>-<vc:admin-widget widget-zone="customer_details_report_by_order_total_bottom" additional-data="Model"/>-<script>- $(document).ready(function () {- $("#best-customers-ordertotal-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("ReportBestCustomersByOrderTotalList", "Reports", new { area = Constants.AreaStore }))",- type: "POST",- dataType: "json",- data: bestCustomersOrderTotalAdditionalData- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors"- },- error: function (e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- pageSize: @(adminAreaSettings.DefaultGridPageSize),- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- pageSizes: [@(adminAreaSettings.GridPageSizes)]- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [{- field: "CustomerName",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.Customer"]",- template: '<a class="k-link" href="@Url.Action("Edit", "Customer", new { area = Constants.AreaStore })/#=CustomerId#">#:CustomerName#</a>',- }, {- field: "OrderTotal",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderTotal"]"- }, {- field: "OrderCount",- title: "@Loc["Admin.Reports.Customers.BestBy.Fields.OrderCount"]"- }]- });- });-</script>-<script>- $(document).ready(function () {-- $('#search-best-customers-ordertotal').click(function () {- var grid = $('#best-customers-ordertotal-grid').data('kendoGrid');- grid.dataSource.page(1); //new search. Set page size to 1- //grid.dataSource.read(); we already loaded the grid above using "page" function- return false;- });-- });- function bestCustomersOrderTotalAdditionalData(e) {- var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val(),- OrderStatusId: $('#@Html.IdFor(model => model.OrderStatusId)').val(),- PaymentStatusId: $('#@Html.IdFor(model => model.PaymentStatusId)').val(),- ShippingStatusId: $('#@Html.IdFor(model => model.ShippingStatusId)').val()- };- addAntiForgeryToken(data);- return data;- }-</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Bestsellers.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Bestsellers.cshtmlnew file mode 100644index 000000000..69756b73b--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Bestsellers.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model BestsellersReportModel+<vc:store-widget widget-zone="bestsellers_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Country.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Country.cshtmlnew file mode 100644index 000000000..868411b2f--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.Country.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model CountryReportModel+<vc:store-widget widget-zone="country_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtmlnew file mode 100644index 000000000..92e3562bd--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersBottom.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model BestCustomersReportModel+<vc:store-widget widget-zone="customer_details_report_by_number_of_orders_bottom" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtmlnew file mode 100644index 000000000..a2b1368cd--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByNumberOfOrdersTop.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model BestCustomersReportModel+<vc:store-widget widget-zone="customer_details_report_by_number_of_orders_top" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtmlnew file mode 100644index 000000000..fbcbe3660--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalBottom.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model BestCustomersReportModel+<vc:store-widget widget-zone="customer_details_report_by_order_total_bottom" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtmlnew file mode 100644index 000000000..25ecb0f4b--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.CustomerByOrderTotalTop.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model BestCustomersReportModel+<vc:store-widget widget-zone="customer_details_report_by_order_total_top" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtmlnew file mode 100644index 000000000..5b2e2e6b6--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.DetailsTabs.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model CustomerReportsModel+<vc:store-widget widget-zone="reports_details_tabs" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.NeverSold.cshtml b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.NeverSold.cshtmlnew file mode 100644index 000000000..a70e16e44--- /dev/null+++ b/src/Web/Grand.Web.Store/Areas/Store/Views/Reports/Partials/WidgetZone.NeverSold.cshtml@@ -0,0 +1,5 @@+@* vc:store-widget, not vc:admin-widget as the pre-consolidation Store views used — that tag helper+ is not registered in the Store app (no ProjectReference to Grand.Web.Admin); the original markup+ was inert and never rendered anything. Fixed during ARCH-001 Phase 9 consolidation. *@+@model NeverSoldReportModel+<vc:store-widget widget-zone="never_sold_report" additional-data="Model"/>diff --git a/src/Web/Grand.Web.Store/Controllers/ReportsController.cs b/src/Web/Grand.Web.Store/Controllers/ReportsController.csindex 2461ad3a1..8e988278f 100644--- a/src/Web/Grand.Web.Store/Controllers/ReportsController.cs+++ b/src/Web/Grand.Web.Store/Controllers/ReportsController.cs@@ -1,639 +1,55 @@-using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Prices;using Grand.Business.Core.Interfaces.Catalog.Products;using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Business.Core.Interfaces.Common.Security;using Grand.Business.Core.Interfaces.Common.Stores;+using Grand.Business.Core.Interfaces.Customers;using Grand.Business.Core.Interfaces.System.Reports;-using Grand.Business.Core.Utilities.System;-using Grand.Domain.Orders;-using Grand.Domain.Payments;using Grand.Domain.Permissions;-using Grand.Domain.Shipping;using Grand.Infrastructure;+using Grand.Web.AdminShared.Controllers;using Grand.Web.AdminShared.Interfaces;-using Grand.Web.AdminShared.Models.Catalog;-using Grand.Web.AdminShared.Models.Customers;-using Grand.Web.AdminShared.Models.Orders;-using Grand.Web.Common.DataSource;-using Grand.Web.Common.Extensions;+using Grand.Web.Common.Filters;using Grand.Web.Common.Localization;using Grand.Web.Common.Security.Authorization;using Grand.Web.Store.Extensions;using Microsoft.AspNetCore.Mvc;-using Microsoft.AspNetCore.Mvc.Rendering;namespace Grand.Web.Store.Controllers;+// Reduced to a thin subclass of BaseFullReportsController (ARCH-001 Reports consolidation). No+// overrides needed - Store has neither the CountryReport/Customer ManageCustomers gate nor+// PopularSearchTermsReport; every remaining Admin/Store difference is already expressed inside the+// shared bases via IReportDataScope. Same pattern as PaymentTransactionController/OrderController.+[AutoValidateAntiforgeryToken]+[Area(Constants.AreaStore)]+[AuthorizeStore]+[AuthorizeMenu][PermissionAuthorize(PermissionSystemName.Reports)]-public class ReportsController : BaseStoreController-{- private readonly ICountryService _countryService;- private readonly ICurrencyService _currencyService;- private readonly ICustomerReportService _customerReportService;- private readonly ICustomerReportViewModelService _customerReportViewModelService;- private readonly IDateTimeService _dateTimeService;- private readonly IOrderReportService _orderReportService;- private readonly IOrderService _orderService;- private readonly IOrderStatusService _orderStatusService;- private readonly IPermissionService _permissionService;- private readonly IPriceFormatter _priceFormatter;- private readonly IProductAttributeFormatter _productAttributeFormatter;- private readonly IProductService _productService;- private readonly IProductsReportService _productsReportService;- private readonly IStockQuantityService _stockQuantityService;- private readonly IStoreService _storeService;- private readonly ITranslationService _translationService;- private readonly IContextAccessor _contextAccessor;- private readonly IEnumTranslationService _enumTranslationService;- public ReportsController(IOrderService orderService,- IOrderReportService orderReportService,- IProductsReportService productsReportService,- ICustomerReportService customerReportService,- ICustomerReportViewModelService customerReportViewModelService,- IPermissionService permissionService,- IContextAccessor contextAccessor,- IPriceFormatter priceFormatter,- IProductService productService,- IProductAttributeFormatter productAttributeFormatter,- IStockQuantityService stockQuantityService,- ITranslationService translationService,- IStoreService storeService,- ICountryService countryService,- IDateTimeService dateTimeService,- IOrderStatusService orderStatusService,- ICurrencyService currencyService,- IEnumTranslationService enumTranslationService)- {- _orderService = orderService;- _orderReportService = orderReportService;- _productsReportService = productsReportService;- _customerReportService = customerReportService;- _customerReportViewModelService = customerReportViewModelService;- _permissionService = permissionService;- _contextAccessor = contextAccessor;- _priceFormatter = priceFormatter;- _productService = productService;- _productAttributeFormatter = productAttributeFormatter;- _stockQuantityService = stockQuantityService;- _translationService = translationService;- _storeService = storeService;- _countryService = countryService;- _dateTimeService = dateTimeService;- _orderStatusService = orderStatusService;- _currencyService = currencyService;- _enumTranslationService = enumTranslationService;- }-- [NonAction]- protected async Task<DataSourceResult> GetBestsellersBriefReportModel(int pageIndex,- int pageSize, int orderBy)- {- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;- var items = await _orderReportService.BestSellersReport(- storeId,- orderBy: orderBy,- pageIndex: pageIndex,- pageSize: pageSize,- showHidden: true);- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };- return gridModel;- }-- [NonAction]- protected virtual async Task<IList<OrderPeriodReportLineModel>> GetReportOrderPeriodModel()- {- var report = new List<OrderPeriodReportLineModel>();- var reportperiod7days = await _orderReportService.GetOrderPeriodReport(7, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.7days"),- Count = reportperiod7days.Count,- Amount = reportperiod7days.Amount- });-- var reportperiod14days = await _orderReportService.GetOrderPeriodReport(14, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.14days"),- Count = reportperiod14days.Count,- Amount = reportperiod14days.Amount- });-- var reportperiodmonth = await _orderReportService.GetOrderPeriodReport(30, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.month"),- Count = reportperiodmonth.Count,- Amount = reportperiodmonth.Amount- });-- var reportperiodyear = await _orderReportService.GetOrderPeriodReport(365, _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId);- report.Add(new OrderPeriodReportLineModel {- Period = _translationService.GetResource("Admin.Reports.Period.year"),- Count = reportperiodyear.Count,- Amount = reportperiodyear.Amount- });-- return report;- }--- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByQuantityList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 1);-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByAmountList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 2);-- return Json(gridModel);- }-- public async Task<IActionResult> BestsellersReport()- {- var model = new BestsellersReportModel();-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var status = await _orderStatusService.GetAll();- //order statuses- model.AvailableOrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();- model.AvailableOrderStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //payment statuses- model.AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();- model.AvailablePaymentStatuses.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //billing countries- foreach (var c in await _countryService.GetAllCountriesForBilling(showHidden: true))- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });- model.AvailableCountries.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> BestsellersReportList(DataSourceRequest command, BestsellersReportModel model)- {- model.StoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _orderReportService.BestSellersReport(- createdFromUtc: startDateValue,- createdToUtc: endDateValue,- os: orderStatus,- ps: paymentStatus,- billingCountryId: model.BillingCountryId,- orderBy: 2,- pageIndex: command.Page - 1,- pageSize: command.PageSize,- showHidden: true,- storeId: model.StoreId);-- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;-- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportOrderPeriodList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var model = await GetReportOrderPeriodModel();- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportOrderTimeChart(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;- var model = await _orderReportService.GetOrderByTimeReport(storeId, startDate, endDate);- var gridModel = new DataSourceResult {- Data = model- };- return Json(gridModel);- }-- public IActionResult NeverSoldReport()- {- var model = new NeverSoldReportModel();- return View(model);- }-- [HttpPost]- public async Task<IActionResult> NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var items = await _orderReportService.ProductsNeverSold(storeId, "",- startDateValue, endDateValue,- command.Page - 1, command.PageSize, true);- var gridModel = new DataSourceResult {- Data = items.Select(x =>- new NeverSoldReportLineModel {- ProductId = x.Id,- ProductName = x.Name- }),- Total = items.TotalCount- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> OrderAverageReportList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var report = new List<OrderAverageReportLineSummary> {- await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Pending),- await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Processing),- await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Complete),- await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Cancelled)- };-- var statuses = await _orderStatusService.GetAll();- var model = new List<OrderAverageReportLineSummaryModel>();- foreach (var x in report.ToList())- model.Add(new OrderAverageReportLineSummaryModel {- OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatus)?.Name,- SumTodayOrders =- _priceFormatter.FormatPrice(x.SumTodayOrders, await _currencyService.GetPrimaryStoreCurrency()),- SumThisWeekOrders = _priceFormatter.FormatPrice(x.SumThisWeekOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumThisMonthOrders = _priceFormatter.FormatPrice(x.SumThisMonthOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumThisYearOrders = _priceFormatter.FormatPrice(x.SumThisYearOrders,- await _currencyService.GetPrimaryStoreCurrency()),- SumAllTimeOrders = _priceFormatter.FormatPrice(x.SumAllTimeOrders,- await _currencyService.GetPrimaryStoreCurrency())- });- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportLatestOrder(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- //load orders- var orders = await _orderService.SearchOrders(- storeId,- createdFromUtc: startDate,- createdToUtc: endDate,- pageIndex: command.Page - 1,- pageSize: command.PageSize);-- var statuses = await _orderStatusService.GetAll();-- var items = new List<OrderModel>();- foreach (var x in orders)- {- var store = await _storeService.GetStoreById(x.StoreId);- items.Add(new OrderModel {- Id = x.Id,- OrderNumber = x.OrderNumber,- StoreName = store != null ? store.Shortcut : "Unknown",- OrderTotal =- _priceFormatter.FormatPrice(x.OrderTotal, await _currencyService.GetPrimaryStoreCurrency()),- OrderStatus = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatusId)?.Name,- PaymentStatus = _enumTranslationService.GetTranslationEnum(x.PaymentStatusId),- ShippingStatus = _enumTranslationService.GetTranslationEnum(x.ShippingStatusId),- CustomerEmail = x.BillingAddress.Email,- CustomerFullName = $"{x.BillingAddress.FirstName} {x.BillingAddress.LastName}",- CreatedOn = _dateTimeService.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)- });- }-- var gridModel = new DataSourceResult {- Data = items,- Total = orders.TotalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> OrderIncompleteReportList(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageOrders))- return Content("");-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var model = new List<OrderIncompleteReportLineModel>();- //not paid- var psPending =- await _orderReportService.GetOrderAverageReportLine(storeId, ps: PaymentStatus.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalUnpaidOrders"),- Count = psPending.CountOrders,- Total = _priceFormatter.FormatPrice(psPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { paymentStatusId = ((int)PaymentStatus.Pending).ToString(), area = Constants.AreaStore })- });- //not shipped- var ssPending =- await _orderReportService.GetOrderAverageReportLine(storeId, ss: ShippingStatus.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalNotShippedOrders"),- Count = ssPending.CountOrders,- Total = _priceFormatter.FormatPrice(ssPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { shippingStatusId = ((int)ShippingStatus.Pending).ToString(), area = Constants.AreaStore })- });- //pending- var osPending = await _orderReportService.GetOrderAverageReportLine(storeId, os: (int)OrderStatusSystem.Pending,- ignoreCancelledOrders: true);- model.Add(new OrderIncompleteReportLineModel {- Item = _translationService.GetResource("Admin.Reports.Incomplete.TotalIncompleteOrders"),- Count = osPending.CountOrders,- Total = _priceFormatter.FormatPrice(osPending.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- ViewLink = Url.Action("List", "Order",- new { orderStatusId = ((int)OrderStatusSystem.Pending).ToString(), area = Constants.AreaStore })- });-- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- public async Task<IActionResult> CountryReport()- {- var status = await _orderStatusService.GetAll();- var model = new CountryReportModel {- //order statuses- AvailableOrderStatuses =- status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList()- };-- model.AvailableOrderStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- //payment statuses- model.AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> CountryReportList(DataSourceRequest command, CountryReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null;- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var items = await _orderReportService.GetCountryReport(- storeId,- os: orderStatus,- ps: paymentStatus,- startTimeUtc: startDateValue,- endTimeUtc: endDateValue);- var result = new List<CountryReportLineModel>();- foreach (var x in items)- {- var country = await _countryService.GetCountryById(!string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "");- var m = new CountryReportLineModel {- CountryName = country != null ? country.Name : "Unknown",- SumOrders = _priceFormatter.FormatPrice(x.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- TotalOrders = x.TotalOrders- };- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.Count- };-- return Json(gridModel);- }-- #region Low stock reports-- public IActionResult LowStockReport()- {- return View();- }-- [HttpPost]- public async Task<IActionResult> LowStockReportList(DataSourceRequest command)- {- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var lowStockProducts = await _productsReportService.LowStockProducts(storeId: storeId);-- var models = new List<LowStockProductModel>();- //products- foreach (var product in lowStockProducts.products)- {- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true),- Published = product.Published- };- models.Add(lowStockModel);- }-- //combinations- foreach (var combination in lowStockProducts.combinations)- {- var product = await _productService.GetProductById(combination.ProductId);- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- Attributes = await _productAttributeFormatter.FormatAttributes(product, combination.Attributes,- _contextAccessor.WorkContext.CurrentCustomer, "<br />", true, true, true, false),- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = combination.StockQuantity,- Published = product.Published- };- models.Add(lowStockModel);- }-- var gridModel = new DataSourceResult {- Data = models.PagedForCommand(command),- Total = models.Count- };-- return Json(gridModel);- }-- #endregion-- #region Customer Reports-- public async Task<IActionResult> Customer()- {- var model = await _customerReportViewModelService.PrepareCustomerReportsModel();- return View(model);- }-- [HttpPost]- public async Task<IActionResult> ReportBestCustomersByOrderTotalList(DataSourceRequest command,- BestCustomersReportModel model)- {- model.StoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;- var (bestCustomerReportLineModels, totalCount) =- await _customerReportViewModelService.PrepareBestCustomerReportLineModel(model, 1, command.Page,- command.PageSize);- var gridModel = new DataSourceResult {- Data = bestCustomerReportLineModels.ToList(),- Total = totalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportBestCustomersByNumberOfOrdersList(DataSourceRequest command,- BestCustomersReportModel model)- {- model.StoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var (bestCustomerReportLineModels, totalCount) =- await _customerReportViewModelService.PrepareBestCustomerReportLineModel(model, 2, command.Page,- command.PageSize);- var gridModel = new DataSourceResult {- Data = bestCustomerReportLineModels.ToList(),- Total = totalCount- };- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportRegisteredCustomersList(DataSourceRequest command)- {- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var model = await _customerReportViewModelService.GetReportRegisteredCustomersModel(storeId);- var gridModel = new DataSourceResult {- Data = model,- Total = model.Count- };-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> ReportCustomerTimeChart(DataSourceRequest command, DateTime? startDate,- DateTime? endDate)- {- var storeId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;-- var model = await _customerReportService.GetCustomerByTimeReport(storeId, startDate, endDate);- var gridModel = new DataSourceResult {- Data = model- };- return Json(gridModel);- }-- #endregion-}\ No newline at end of file+public class ReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope,+ IOrderService orderService,+ ICustomerReportService customerReportService,+ IPermissionService permissionService)+ : BaseFullReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService, orderStatusService,+ enumTranslationService, contextAccessor, scope, orderService, customerReportService, permissionService);diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Reports/Customer.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Reports/Customer.cshtmlindex e6703b655..52d355653 100644--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Reports/Customer.cshtml+++ b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Reports/Customer.cshtml@@ -28,14 +28,14 @@<div class="row align-items-end"><div class="col-md-4 col-ms-12 col-12"><div class="form-group mb-0">- <admin-label asp-for="StartDate" class="control-label"/>- <admin-input asp-for="StartDate"/>+ <admin-label asp-for="BestCustomersByOrderTotal.StartDate" class="control-label"/>+ <admin-input asp-for="BestCustomersByOrderTotal.StartDate"/></div></div><div class="col-md-4 col-ms-12 col-12"><div class="form-group mb-0">- <admin-label asp-for="EndDate" class="control-label"/>- <admin-input asp-for="EndDate"/>+ <admin-label asp-for="BestCustomersByOrderTotal.EndDate" class="control-label"/>+ <admin-input asp-for="BestCustomersByOrderTotal.EndDate"/></div></div><div class="col-md-4 col-sm-12 col-12">@@ -55,9 +55,9 @@<div class="collapse" id="filterCollapse"><div class="drop-filters-container w-100"><div class="form-group">- <admin-label asp-for="PaymentStatusId" class="control-label col-md-3 col-sm-3"/>+ <admin-label asp-for="BestCustomersByOrderTotal.PaymentStatusId" class="control-label col-md-3 col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="PaymentStatusId" asp-items="Model.AvailablePaymentStatuses"/>+ <admin-select asp-for="BestCustomersByOrderTotal.PaymentStatusId" asp-items="Model.BestCustomersByOrderTotal.AvailablePaymentStatuses"/></div></div></div>@@ -138,9 +138,9 @@function additionalData() {var data = {- StartDate: $('#@Html.IdFor(model => model.StartDate)').val(),- EndDate: $('#@Html.IdFor(model => model.EndDate)').val(),- PaymentStatusId: $('#PaymentStatusId').val()+ StartDate: $('#@Html.IdFor(model => model.BestCustomersByOrderTotal.StartDate)').val(),+ EndDate: $('#@Html.IdFor(model => model.BestCustomersByOrderTotal.EndDate)').val(),+ PaymentStatusId: $('#@Html.IdFor(model => model.BestCustomersByOrderTotal.PaymentStatusId)').val()};addAntiForgeryToken(data);return data;diff --git a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/_ViewImports.cshtml b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/_ViewImports.cshtmlindex 8210e1d57..9e98a146b 100644--- a/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/_ViewImports.cshtml+++ b/src/Web/Grand.Web.Vendor/Areas/Vendor/Views/_ViewImports.cshtml@@ -33,10 +33,10 @@@* Order/Shipment/MerchandiseReturn views bind to Grand.Web.AdminShared's model families (ARCH-001Order, Shipment, and MerchandiseReturn consolidation) - Grand.Web.Vendor.Models.Orders/Shipment/MerchandiseReturn's own equivalents are no longer used by any controller/view. This can't be a- blanket "@using Grand.Web.AdminShared.Models.Orders" - that namespace also holds *ReportModel etc.,- which Vendor's Reports views still bind to their own Grand.Web.Vendor.Models.* equivalents (not yet- consolidated), so a wildcard import here would make those bare names ambiguous instead. Alias just- the types that are actually consolidated. *@+ blanket "@using Grand.Web.AdminShared.Models.Orders" - that namespace also holds *ReportModel etc.+ (see the Reports block below, itself alias-only for the identical reason), so a wildcard import+ here would make those bare names ambiguous too. Alias just the types that are actually+ consolidated. *@@using OrderModel = Grand.Web.AdminShared.Models.Orders.OrderModel;@using OrderListModel = Grand.Web.AdminShared.Models.Orders.OrderListModel;@using ShipmentModel = Grand.Web.AdminShared.Models.Orders.ShipmentModel;@@ -50,6 +50,16 @@@using MerchandiseReturnListModel = Grand.Web.AdminShared.Models.Orders.MerchandiseReturnListModel;@using Grand.Web.Vendor.Models.Vendor;@using Grand.Web.Vendor.Models.VendorReview;-@using Grand.Web.Vendor.Models.Report;+@* Reports views bind to Grand.Web.AdminShared's report model families (ARCH-001 Reports+ consolidation, Task 11/12) - Grand.Web.Vendor.Models.Report is deleted entirely, so alias just+ the 4 types Vendor's 5 Reports views actually reference (same alias-not-blanket-import rationale+ as the Order/Shipment/MerchandiseReturn block above - Models.Orders also holds+ MerchandiseReturnModel, which is itself only aliased above rather than blanket-imported, for the+ same reason: a wildcard "@using Grand.Web.AdminShared.Models.Orders" would make every one of+ these Reports model names ambiguous too). *@+@using BestsellersReportModel = Grand.Web.AdminShared.Models.Orders.BestsellersReportModel;+@using CountryReportModel = Grand.Web.AdminShared.Models.Orders.CountryReportModel;+@using NeverSoldReportModel = Grand.Web.AdminShared.Models.Orders.NeverSoldReportModel;+@using CustomerReportsModel = Grand.Web.AdminShared.Models.Customers.CustomerReportsModel;@inject LocService Loc@inject IEnumTranslationService EnumTranslationService\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Controllers/ReportsController.cs b/src/Web/Grand.Web.Vendor/Controllers/ReportsController.csindex 5bc4b57b8..1c31382b6 100644--- a/src/Web/Grand.Web.Vendor/Controllers/ReportsController.cs+++ b/src/Web/Grand.Web.Vendor/Controllers/ReportsController.cs@@ -1,391 +1,57 @@-using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Interfaces.Catalog.Directory;+using Grand.Business.Core.Interfaces.Catalog.Prices;using Grand.Business.Core.Interfaces.Catalog.Products;using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Interfaces.Common.Stores;using Grand.Business.Core.Interfaces.Customers;using Grand.Business.Core.Interfaces.System.Reports;using Grand.Domain.Permissions;-using Grand.Domain.Payments;using Grand.Infrastructure;-using Grand.Web.Common.DataSource;-using Grand.Web.Common.Extensions;+using Grand.Web.AdminShared.Controllers;+using Grand.Web.AdminShared.Interfaces;+using Grand.Web.Common.Filters;using Grand.Web.Common.Localization;using Grand.Web.Common.Security.Authorization;using Grand.Web.Vendor.Extensions;-using Grand.Web.Vendor.Models.Report;using Microsoft.AspNetCore.Mvc;-using Microsoft.AspNetCore.Mvc.Rendering;namespace Grand.Web.Vendor.Controllers;+// Reduced to a thin subclass of BaseReportsController — deliberately NOT BaseFullReportsController+// (ARCH-001 Reports consolidation; Global Constraint 2/3). Vendor's action surface is exactly the+// 12 shared actions on BaseReportsController (see that class's own doc comment, the source of truth)+// and NONE of the 8 Full-tier actions (ReportOrderPeriodList/ReportOrderTimeChart/OrderAverageReportList/+// ReportLatestOrder/OrderIncompleteReportList/ReportBestCustomersByNumberOfOrdersList/+// ReportRegisteredCustomersList/ReportCustomerTimeChart), which live only on BaseFullReportsController+// and are never inherited here — confirmed against the original controller's 12 actions read during+// plan research. No overrides needed: Vendor never had the ManageCustomers/ManageOrders inline checks on+// any of the 12 shared actions, which is exactly BaseReportsController's own check-free default.+[AutoValidateAntiforgeryToken]+[Area(Constants.AreaVendor)]+[AuthorizeVendor]+[AuthorizeMenu][PermissionAuthorize(PermissionSystemName.Reports)]-public class ReportsController : BaseVendorController-{- private readonly ICountryService _countryService;- private readonly ICurrencyService _currencyService;- private readonly ICustomerReportService _customerReportService;- private readonly ICustomerService _customerService;- private readonly IDateTimeService _dateTimeService;- private readonly IOrderReportService _orderReportService;- private readonly IOrderStatusService _orderStatusService;- private readonly IPriceFormatter _priceFormatter;- private readonly IProductAttributeFormatter _productAttributeFormatter;- private readonly IProductService _productService;- private readonly IProductsReportService _productsReportService;- private readonly IStockQuantityService _stockQuantityService;- private readonly ITranslationService _translationService;- private readonly IContextAccessor _contextAccessor;- private readonly IEnumTranslationService _enumTranslationService;- public ReportsController(IOrderReportService orderReportService,- IProductsReportService productsReportService,- ICustomerReportService customerReportService,- IContextAccessor contextAccessor,- IPriceFormatter priceFormatter,- IProductService productService,- IProductAttributeFormatter productAttributeFormatter,- IStockQuantityService stockQuantityService,- ITranslationService translationService,- ICountryService countryService,- IDateTimeService dateTimeService,- IOrderStatusService orderStatusService,- ICurrencyService currencyService,- ICustomerService customerService,- IEnumTranslationService enumTranslationService)- {- _orderReportService = orderReportService;- _productsReportService = productsReportService;- _customerReportService = customerReportService;- _contextAccessor = contextAccessor;- _priceFormatter = priceFormatter;- _productService = productService;- _productAttributeFormatter = productAttributeFormatter;- _stockQuantityService = stockQuantityService;- _translationService = translationService;- _countryService = countryService;- _dateTimeService = dateTimeService;- _orderStatusService = orderStatusService;- _currencyService = currencyService;- _customerService = customerService;- _enumTranslationService = enumTranslationService;- }-- [NonAction]- private async Task<DataSourceResult> GetBestsellersBriefReportModel(int pageIndex,- int pageSize, int orderBy)- {- var items = await _orderReportService.BestSellersReport(- vendorId: _contextAccessor.WorkContext.CurrentVendor.Id,- orderBy: orderBy,- pageIndex: pageIndex,- pageSize: pageSize,- showHidden: true);- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };- return gridModel;- }-- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByQuantityList(DataSourceRequest command)- {- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 1);-- return Json(gridModel);- }-- [HttpPost]- public async Task<IActionResult> BestsellersBriefReportByAmountList(DataSourceRequest command)- {- var gridModel = await GetBestsellersBriefReportModel(command.Page - 1,- command.PageSize, 2);-- return Json(gridModel);- }-- public async Task<IActionResult> BestsellersReport()- {- var model = new BestsellersReportModel {- //payment statuses- AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList()- };- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Vendor.Common.All"), Value = "" });-- //billing countries- foreach (var c in await _countryService.GetAllCountriesForBilling(showHidden: true))- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });- model.AvailableCountries.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Vendor.Common.All"), Value = "" });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> BestsellersReportList(DataSourceRequest command, BestsellersReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _orderReportService.BestSellersReport(- createdFromUtc: startDateValue,- createdToUtc: endDateValue,- ps: paymentStatus,- billingCountryId: model.BillingCountryId,- orderBy: 2,- vendorId: _contextAccessor.WorkContext.CurrentVendor.Id,- pageIndex: command.Page - 1,- pageSize: command.PageSize,- showHidden: true,- storeId: model.StoreId);-- var result = new List<BestsellersReportLineModel>();- foreach (var x in items)- {- var m = new BestsellersReportLineModel {- ProductId = x.ProductId,- TotalAmount =- _priceFormatter.FormatPrice(x.TotalAmount, await _currencyService.GetPrimaryStoreCurrency()),- TotalQuantity = x.TotalQuantity- };- var product = await _productService.GetProductById(x.ProductId);- if (product != null)- m.ProductName = product.Name;- if (_contextAccessor.WorkContext.CurrentVendor != null)- {- if (product != null && _contextAccessor.WorkContext.HasAccessToProduct(product))- result.Add(m);- }- else- {- result.Add(m);- }- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.TotalCount- };-- return Json(gridModel);- }-- public IActionResult NeverSoldReport()- {- var model = new NeverSoldReportModel();- return View(model);- }-- [HttpPost]- public async Task<IActionResult> NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);--- var items = await _orderReportService.ProductsNeverSold("", _contextAccessor.WorkContext.CurrentVendor.Id,- startDateValue, endDateValue,- command.Page - 1, command.PageSize, true);- var gridModel = new DataSourceResult {- Data = items.Select(x =>- new NeverSoldReportLineModel {- ProductId = x.Id,- ProductName = x.Name- }),- Total = items.TotalCount- };-- return Json(gridModel);- }-- public IActionResult CountryReport()- {- var model = new CountryReportModel {- //payment statuses- AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList()- };-- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Vendor.Common.All"), Value = "" });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> CountryReportList(CountryReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _orderReportService.GetCountryReport(- vendorId: _contextAccessor.WorkContext.CurrentVendor.Id,- ps: paymentStatus,- startTimeUtc: startDateValue,- endTimeUtc: endDateValue);- var result = new List<CountryReportLineModel>();- foreach (var x in items)- {- var country = await _countryService.GetCountryById(!string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "");- var m = new CountryReportLineModel {- CountryName = country != null ? country.Name : "Unknown",- SumOrders = _priceFormatter.FormatPrice(x.SumOrders, await _currencyService.GetPrimaryStoreCurrency()),- TotalOrders = x.TotalOrders- };- result.Add(m);- }-- var gridModel = new DataSourceResult {- Data = result,- Total = items.Count- };-- return Json(gridModel);- }-- #region Low stock reports-- public IActionResult LowStockReport()- {- return View();- }-- [HttpPost]- public async Task<IActionResult> LowStockReportList(DataSourceRequest command)- {- var lowStockProducts = await _productsReportService.LowStockProducts(_contextAccessor.WorkContext.CurrentVendor.Id);-- var models = new List<LowStockProductModel>();- //products- foreach (var product in lowStockProducts.products)- {- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true),- Published = product.Published- };- models.Add(lowStockModel);- }-- //combinations- foreach (var combination in lowStockProducts.combinations)- {- var product = await _productService.GetProductById(combination.ProductId);- var lowStockModel = new LowStockProductModel {- Id = product.Id,- Name = product.Name,- Attributes = await _productAttributeFormatter.FormatAttributes(product, combination.Attributes,- _contextAccessor.WorkContext.CurrentCustomer, "<br />", true, true, true, false),- ManageInventoryMethod = _enumTranslationService.GetTranslationEnum(product.ManageInventoryMethodId),- StockQuantity = combination.StockQuantity,- Published = product.Published- };- models.Add(lowStockModel);- }-- var gridModel = new DataSourceResult {- Data = models.PagedForCommand(command),- Total = models.Count- };-- return Json(gridModel);- }-- #endregion-- #region Customer Reports-- public async Task<IActionResult> Customer()- {- var model = new CustomerReportsModel();- var status = await _orderStatusService.GetAll();-- model.AvailablePaymentStatuses = _enumTranslationService.ToSelectList(PaymentStatus.Pending, false).ToList();- model.AvailablePaymentStatuses.Insert(0,- new SelectListItem { Text = _translationService.GetResource("Vendor.Common.All"), Value = "" });-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> ReportBestCustomersByOrderTotalList(DataSourceRequest command,- BestCustomersReportModel model)- {- DateTime? startDateValue = model.StartDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);-- DateTime? endDateValue = model.EndDate == null- ? null- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1);-- var paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)model.PaymentStatusId : null;-- var items = await _customerReportService.GetBestCustomersReport("", _contextAccessor.WorkContext.CurrentVendor.Id, startDateValue,- endDateValue,- null, paymentStatus, null, 2, command.Page - 1, command.PageSize);-- var report = new List<BestCustomerReportLineModel>();- foreach (var x in items)- {- var m = new BestCustomerReportLineModel {- CustomerId = x.CustomerId,- OrderTotal =- _priceFormatter.FormatPrice(x.OrderTotal, await _currencyService.GetPrimaryStoreCurrency()),- OrderCount = x.OrderCount- };- var customer = await _customerService.GetCustomerById(x.CustomerId);- if (customer != null)- m.CustomerName = !string.IsNullOrEmpty(customer.Email)- ? customer.Email- : _translationService.GetResource("Vendor.Customers.Guest");- report.Add(m);- }-- var gridModel = new DataSourceResult {- Data = report,- Total = items.TotalCount- };-- return Json(gridModel);- }-- #endregion-}\ No newline at end of file+public class ReportsController(+ IOrderReportService orderReportService,+ IProductsReportService productsReportService,+ ICustomerReportViewModelService customerReportViewModelService,+ IPriceFormatter priceFormatter,+ ICurrencyService currencyService,+ IProductService productService,+ IProductAttributeFormatter productAttributeFormatter,+ IStockQuantityService stockQuantityService,+ ITranslationService translationService,+ IStoreService storeService,+ ICountryService countryService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ IOrderStatusService orderStatusService,+ IEnumTranslationService enumTranslationService,+ IContextAccessor contextAccessor,+ IReportDataScope scope)+ : BaseReportsController(orderReportService, productsReportService, customerReportViewModelService,+ priceFormatter, currencyService, productService, productAttributeFormatter, stockQuantityService,+ translationService, storeService, countryService, vendorService, dateTimeService, orderStatusService,+ enumTranslationService, contextAccessor, scope);diff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomerReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestCustomerReportLineModel.csdeleted file mode 100644index e54b20ecd..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomerReportLineModel.cs+++ /dev/null@@ -1,18 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class BestCustomerReportLineModel : BaseModel-{- public string CustomerId { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customers.BestBy.Fields.Customer")]- public string CustomerName { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customers.BestBy.Fields.OrderTotal")]- public string OrderTotal { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customers.BestBy.Fields.OrderCount")]- public double OrderCount { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.csdeleted file mode 100644index 883b52633..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs+++ /dev/null@@ -1,22 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;-using Microsoft.AspNetCore.Mvc.Rendering;-using System.ComponentModel.DataAnnotations;--namespace Grand.Web.Vendor.Models.Report;--public class BestCustomersReportModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.StartDate")]- [UIHint("DateNullable")]- public DateTime? StartDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.EndDate")]- [UIHint("DateNullable")]- public DateTime? EndDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.PaymentStatus")]- public int PaymentStatusId { get; set; }-- public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportLineModel.csdeleted file mode 100644index fdafce6fa..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportLineModel.cs+++ /dev/null@@ -1,18 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class BestsellersReportLineModel : BaseModel-{- public string ProductId { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.Fields.Name")]- public string ProductName { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.Fields.TotalAmount")]- public string TotalAmount { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.Fields.TotalQuantity")]- public double TotalQuantity { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.csdeleted file mode 100644index a844f8352..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs+++ /dev/null@@ -1,29 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;-using Microsoft.AspNetCore.Mvc.Rendering;-using System.ComponentModel.DataAnnotations;--namespace Grand.Web.Vendor.Models.Report;--public class BestsellersReportModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.Store")]- public string StoreId { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.StartDate")]- [UIHint("DateNullable")]- public DateTime? StartDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.EndDate")]- [UIHint("DateNullable")]- public DateTime? EndDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.PaymentStatus")]- public int PaymentStatusId { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Bestsellers.BillingCountry")]- public string BillingCountryId { get; set; }-- public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/CountryReportLineModel.csdeleted file mode 100644index 4f7c58db4..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportLineModel.cs+++ /dev/null@@ -1,16 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class CountryReportLineModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Country.Fields.CountryName")]- public string CountryName { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Country.Fields.TotalOrders")]- public int TotalOrders { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Country.Fields.SumOrders")]- public string SumOrders { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.csdeleted file mode 100644index 94deed08f..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs+++ /dev/null@@ -1,22 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;-using Microsoft.AspNetCore.Mvc.Rendering;-using System.ComponentModel.DataAnnotations;--namespace Grand.Web.Vendor.Models.Report;--public class CountryReportModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Country.StartDate")]- [UIHint("DateNullable")]- public DateTime? StartDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Country.EndDate")]- [UIHint("DateNullable")]- public DateTime? EndDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Country.PaymentStatus")]- public int PaymentStatusId { get; set; }-- public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.csdeleted file mode 100644index bdea6ab9f..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs+++ /dev/null@@ -1,22 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;-using Microsoft.AspNetCore.Mvc.Rendering;-using System.ComponentModel.DataAnnotations;--namespace Grand.Web.Vendor.Models.Report;--public class CustomerReportsModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.StartDate")]- [UIHint("DateNullable")]- public DateTime? StartDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.EndDate")]- [UIHint("DateNullable")]- public DateTime? EndDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.PaymentStatus")]- public int PaymentStatusId { get; set; }-- public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/LowStockProductModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/LowStockProductModel.csdeleted file mode 100644index 450118c8b..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/LowStockProductModel.cs+++ /dev/null@@ -1,21 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class LowStockProductModel : BaseEntityModel-{- [GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Name")]- public string Name { get; set; }-- public string Attributes { get; set; }-- [GrandResourceDisplayName("Vendor.Catalog.Products.Fields.ManageInventoryMethod")]- public string ManageInventoryMethod { get; set; }-- [GrandResourceDisplayName("Vendor.Catalog.Products.Fields.StockQuantity")]- public int StockQuantity { get; set; }-- [GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Published")]- public bool Published { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportLineModel.csdeleted file mode 100644index 10b87ce77..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportLineModel.cs+++ /dev/null@@ -1,12 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class NeverSoldReportLineModel : BaseModel-{- public string ProductId { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.NeverSold.Fields.Name")]- public string ProductName { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportModel.csdeleted file mode 100644index d61ed979c..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/NeverSoldReportModel.cs+++ /dev/null@@ -1,16 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;-using System.ComponentModel.DataAnnotations;--namespace Grand.Web.Vendor.Models.Report;--public class NeverSoldReportModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.NeverSold.StartDate")]- [UIHint("DateNullable")]- public DateTime? StartDate { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.NeverSold.EndDate")]- [UIHint("DateNullable")]- public DateTime? EndDate { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/OrderAverageReportLineSummaryModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/OrderAverageReportLineSummaryModel.csdeleted file mode 100644index 0cc738515..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/OrderAverageReportLineSummaryModel.cs+++ /dev/null@@ -1,22 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class OrderAverageReportLineSummaryModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Average.SumTodayOrders")]- public string SumTodayOrders { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Average.SumThisWeekOrders")]- public string SumThisWeekOrders { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Average.SumThisMonthOrders")]- public string SumThisMonthOrders { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Average.SumThisYearOrders")]- public string SumThisYearOrders { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Average.SumAllTimeOrders")]- public string SumAllTimeOrders { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/OrderIncompleteReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/OrderIncompleteReportLineModel.csdeleted file mode 100644index e6e6cf176..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/OrderIncompleteReportLineModel.cs+++ /dev/null@@ -1,19 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class OrderIncompleteReportLineModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Incomplete.Item")]- public string Item { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Incomplete.Total")]- public string Total { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Incomplete.Count")]- public int Count { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Incomplete.View")]- public string ViewLink { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/OrderPeriodReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/OrderPeriodReportLineModel.csdeleted file mode 100644index d918288d3..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/OrderPeriodReportLineModel.cs+++ /dev/null@@ -1,16 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class OrderPeriodReportLineModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Period.Name")]- public string Period { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Period.Count")]- public int Count { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Period.Amount")]- public double Amount { get; set; }-}\ No newline at end of filediff --git a/src/Web/Grand.Web.Vendor/Models/Report/RegisteredCustomerReportLineModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/RegisteredCustomerReportLineModel.csdeleted file mode 100644index 973cbf057..000000000--- a/src/Web/Grand.Web.Vendor/Models/Report/RegisteredCustomerReportLineModel.cs+++ /dev/null@@ -1,13 +0,0 @@-using Grand.Infrastructure.ModelBinding;-using Grand.Infrastructure.Models;--namespace Grand.Web.Vendor.Models.Report;--public class RegisteredCustomerReportLineModel : BaseModel-{- [GrandResourceDisplayName("Vendor.Reports.Customers.RegisteredCustomers.Fields.Period")]- public string Period { get; set; }-- [GrandResourceDisplayName("Vendor.Reports.Customers.RegisteredCustomers.Fields.Customers")]- public int Customers { get; set; }-}\ No newline at end of file