Skip to content

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.

Extend warehouse entity - add new field Code

supportfc72ed23bd2e
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
index 480e73660..868096854 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
@@ -33,13 +33,15 @@ namespace Grand.Business.System.Services.Installation
{
new Warehouse
{
- Name = "Warehouse 1 (New York)",
+ Code = "WHS01",
+ Name = "Warehouse 1",
Address = warehouse1address,
DisplayOrder = 0,
},
new Warehouse
{
- Name = "Warehouse 2 (Los Angeles)",
+ Code = "WHS02",
+ Name = "Warehouse 2",
Address = warehouse2address,
DisplayOrder = 1,
}
diff --git a/src/Business/Grand.Business.System/Services/Migrations/2.1/MigrationUpdateResourceString.cs b/src/Business/Grand.Business.System/Services/Migrations/2.1/MigrationUpdateResourceString.cs
new file mode 100644
index 000000000..521e47fd0
--- /dev/null
+++ b/src/Business/Grand.Business.System/Services/Migrations/2.1/MigrationUpdateResourceString.cs
@@ -0,0 +1,24 @@
+using Grand.Domain.Data;
+using Grand.Infrastructure.Migrations;
+
+namespace Grand.Business.System.Services.Migrations._2._1
+{
+ public class MigrationUpdateResourceString : IMigration
+ {
+ public int Priority => 0;
+ public DbVersion Version => new(2, 1);
+ public Guid Identity => new("2803EE48-7875-4AB9-BDFA-3B1FBC7CC37E");
+ public string Name => "Update resource string for english language 2.1";
+
+ /// <summary>
+ /// Upgrade process
+ /// </summary>
+ /// <param name="database"></param>
+ /// <param name="serviceProvider"></param>
+ /// <returns></returns>
+ public bool UpgradeProcess(IDatabaseContext database, IServiceProvider serviceProvider)
+ {
+ return serviceProvider.ImportLanguageResourcesFromXml("App_Data/Resources/Upgrade/en_210.xml");
+ }
+ }
+}
diff --git a/src/Core/Grand.Domain/Shipping/Warehouse.cs b/src/Core/Grand.Domain/Shipping/Warehouse.cs
index 3a8f47019..2568a09c3 100644
--- a/src/Core/Grand.Domain/Shipping/Warehouse.cs
+++ b/src/Core/Grand.Domain/Shipping/Warehouse.cs
@@ -12,6 +12,10 @@ namespace Grand.Domain.Shipping
Address = new Address();
}
/// <summary>
+ /// Gets or sets the warehouse code
+ /// </summary>
+ public string Code { get; set; }
+ /// <summary>
/// Gets or sets the warehouse name
/// </summary>
public string Name { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Inventory.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Inventory.cshtml
index 2d7caa0aa..6bbc22a19 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Inventory.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/Partials/CreateOrUpdate.Inventory.cshtml
@@ -58,7 +58,7 @@
<tr>
<td style="width: 40%;">
<div style="padding-left: 10px; padding-right: 10px;">
- @item.WarehouseName
+ @item.WarehouseName (@item.WarehouseCode)
<input asp-for="@Model.ProductWarehouseInventoryModels[i].WarehouseId" type="hidden" />
</div>
</td>
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/EditWarehouse.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/EditWarehouse.cshtml
index 49a152889..7ead6bdd8 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/EditWarehouse.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/EditWarehouse.cshtml
@@ -11,7 +11,7 @@
<div class="x_title">
<div class="caption">
<i class="fa fa-list-alt"></i>
- @Loc["Admin.Configuration.Shipping.Warehouses.EditWarehouseDetails"] - @Model.Name
+ @Loc["Admin.Configuration.Shipping.Warehouses.EditWarehouseDetails"] - @Model.Name (@Model.Code)
<small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Admin.Configuration.Shipping.Warehouses.BackToList"], "Warehouses")</small>
</div>
<div class="actions">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Partials/CreateOrUpdateWarehouse.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Partials/CreateOrUpdateWarehouse.cshtml
index 9b7d26de2..41c7c9146 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Partials/CreateOrUpdateWarehouse.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Partials/CreateOrUpdateWarehouse.cshtml
@@ -5,6 +5,13 @@
<div class="form-horizontal">
<vc:admin-widget widget-zone="warehouse_details_top" additional-data="Model" />
<div class="form-body">
+ <div class="form-group">
+ <admin-label asp-for="Code" />
+ <div class="col-md-9 col-sm-9">
+ <admin-input asp-for="Code" />
+ <span asp-validation-for="Code"></span>
+ </div>
+ </div>
<div class="form-group">
<admin-label asp-for="Name" />
<div class="col-md-9 col-sm-9">
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Warehouses.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Warehouses.cshtml
index 4a8b8d517..0695402eb 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Warehouses.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shipping/Warehouses.cshtml
@@ -68,6 +68,11 @@
},
scrollable: false,
columns: [{
+ field: "Code",
+ title: "@Loc["Admin.Configuration.Shipping.Warehouses.Fields.Code"]",
+ template: '<a class="k-link" href="EditWarehouse/#=Id#">#=kendo.htmlEncode(Code)#</a>',
+ },
+ {
field: "Name",
title: "@Loc["Admin.Configuration.Shipping.Warehouses.Fields.Name"]",
template: '<a class="k-link" href="EditWarehouse/#=Id#">#=kendo.htmlEncode(Name)#</a>',
@@ -75,7 +80,6 @@
{
field: "DisplayOrder",
title: "@Loc["Admin.Configuration.Shipping.Warehouses.Fields.DisplayOrder"]",
- width: 120,
}]
});
});
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
index 0a9db90f1..59d18b3bd 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
@@ -726,15 +726,13 @@ namespace Grand.Web.Admin.Models.Catalog
{
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory.Fields.Warehouse")]
public string WarehouseId { get; set; }
+ public string WarehouseCode { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory.Fields.Warehouse")]
public string WarehouseName { get; set; }
-
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory.Fields.WarehouseUsed")]
public bool WarehouseUsed { get; set; }
-
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory.Fields.StockQuantity")]
public int StockQuantity { get; set; }
-
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory.Fields.ReservedQuantity")]
public int ReservedQuantity { get; set; }
@@ -782,8 +780,8 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Calendar.EndDate")]
[UIHint("DateNullable")]
public DateTime? EndDate { get; set; }
- [UIHint("Time")]
+ [UIHint("Time")]
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Calendar.EndTime")]
public DateTime EndTime { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
index 8615d9262..e86fe6674 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
@@ -94,6 +94,7 @@ namespace Grand.Web.Admin.Models.Orders
public class WarehouseInfo : BaseModel
{
public string WarehouseId { get; set; }
+ public string WarehouseCode { get; set; }
public string WarehouseName { get; set; }
public int StockQuantity { get; set; }
public int ReservedQuantity { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
index fa51408fe..ef11f507c 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
@@ -10,6 +10,8 @@ namespace Grand.Web.Admin.Models.Shipping
{
Address = new AddressModel();
}
+ [GrandResourceDisplayName("Admin.Configuration.Shipping.Warehouses.Fields.Code")]
+ public string Code { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.Warehouses.Fields.Name")]
public string Name { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
index ef3f99f11..08ae5b14b 100644
--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
@@ -545,7 +545,8 @@ namespace Grand.Web.Admin.Services
{
var pwiModel = new ProductModel.ProductWarehouseInventoryModel {
WarehouseId = warehouse.Id,
- WarehouseName = warehouse.Name
+ WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code
};
if (product != null)
{
diff --git a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
index 1927c1cc1..24684a9d4 100644
--- a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
@@ -402,6 +402,7 @@ namespace Grand.Web.Admin.Services
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code,
StockQuantity = pwi.StockQuantity,
ReservedQuantity = pwi.ReservedQuantity
});
@@ -417,6 +418,7 @@ namespace Grand.Web.Admin.Services
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code,
StockQuantity = product.StockQuantity
});
}
@@ -443,6 +445,7 @@ namespace Grand.Web.Admin.Services
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
StockQuantity = pwi.StockQuantity,
+ WarehouseCode = warehouse.Code,
ReservedQuantity = pwi.ReservedQuantity
});
}
@@ -458,6 +461,7 @@ namespace Grand.Web.Admin.Services
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code,
StockQuantity = product.StockQuantity
});
}
@@ -474,6 +478,7 @@ namespace Grand.Web.Admin.Services
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code,
StockQuantity = await GetStockQty(product, orderItem.WarehouseId),
ReservedQuantity = await GetReservedQty(product, orderItem.WarehouseId)
});
@@ -490,6 +495,7 @@ namespace Grand.Web.Admin.Services
shipmentItemModel.AvailableWarehouses.Add(new ShipmentModel.ShipmentItemModel.WarehouseInfo {
WarehouseId = warehouse.Id,
WarehouseName = warehouse.Name,
+ WarehouseCode = warehouse.Code,
StockQuantity = await GetStockQty(product, warehouse.Id),
ReservedQuantity = await GetReservedQty(product, warehouse.Id),
});
diff --git a/src/Web/Grand.Web.Admin/Validators/Shipping/WarehouseValidator.cs b/src/Web/Grand.Web.Admin/Validators/Shipping/WarehouseValidator.cs
index 396d486b0..d6888aaa5 100644
--- a/src/Web/Grand.Web.Admin/Validators/Shipping/WarehouseValidator.cs
+++ b/src/Web/Grand.Web.Admin/Validators/Shipping/WarehouseValidator.cs
@@ -13,6 +13,7 @@ namespace Grand.Web.Admin.Validators.Shipping
: base(validators)
{
RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Admin.Configuration.Shipping.Warehouses.Fields.Name.Required"));
+ RuleFor(x => x.Code).NotEmpty().WithMessage(translationService.GetResource("Admin.Configuration.Shipping.Warehouses.Fields.Code.Required"));
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index c311b334e..a64f39914 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -5037,6 +5037,12 @@
<Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.AdminComment" Area="Admin">
<Value>Admin comment</Value>
</Resource>
+ <Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.Code" Area="Admin">
+ <Value>Warehouse code</Value>
+ </Resource>
+ <Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.Code.Required" Area="Admin">
+ <Value>Please provide a warehouse code.</Value>
+ </Resource>
<Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.DisplayOrder" Area="Admin">
<Value>Display order</Value>
</Resource>
diff --git a/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_210.xml b/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_210.xml
new file mode 100644
index 000000000..bf6fb4c39
--- /dev/null
+++ b/src/Web/Grand.Web/App_Data/Resources/Upgrade/en_210.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Language Name="English">
+ <Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.Code" Area="Admin">
+ <Value>Warehouse code</Value>
+ </Resource>
+ <Resource Name="Admin.Configuration.Shipping.Warehouses.Fields.Code.Required" Area="Admin">
+ <Value>Please provide a warehouse code.</Value>
+ </Resource>
+</Language>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
index e83eb3bfa..23cc854aa 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
@@ -408,6 +408,7 @@ namespace Grand.Web.Features.Handlers.Products
ReservedQuantity = productwarehouse?.ReservedQuantity ?? 0,
WarehouseId = warehouse.Id,
Name = warehouse.Name,
+ Code = warehouse.Code,
Selected = updateCartItem != null && updateCartItem?.WarehouseId == warehouse.Id
});
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
index 5c3fb2433..efdf0a400 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
@@ -337,8 +337,11 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
//warehouse
if (!string.IsNullOrEmpty(cartItemModel.WarehouseId))
- cartItemModel.WarehouseName = (await _warehouseService.GetWarehouseById(cartItemModel.WarehouseId))?.Name;
-
+ {
+ var warehouse = await _warehouseService.GetWarehouseById(cartItemModel.WarehouseId);
+ cartItemModel.WarehouseName = warehouse?.Name;
+ cartItemModel.WarehouseCode = warehouse?.Code;
+ }
//vendor
if (!string.IsNullOrEmpty(product.VendorId))
{
diff --git a/src/Web/Grand.Web/Grand.Web.csproj b/src/Web/Grand.Web/Grand.Web.csproj
index 24af4d6c2..a0d83d3a7 100644
--- a/src/Web/Grand.Web/Grand.Web.csproj
+++ b/src/Web/Grand.Web/Grand.Web.csproj
@@ -57,6 +57,7 @@
<Compile Remove="Plugins\**" />
<EmbeddedResource Remove="Plugins\**" />
<None Remove="Plugins\**" />
+ <None Remove="App_Data\Resources\Upgrade\en_210.xml" />
<Content Update="Plugins\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
index ec643610f..faeacef08 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
@@ -300,6 +300,7 @@ namespace Grand.Web.Models.Catalog
{
public bool Use { get; set; }
public string WarehouseId { get; set; }
+ public string Code { get; set; }
public string Name { get; set; }
public int StockQuantity { get; set; }
public int ReservedQuantity { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
index 03874db7b..1390aeb91 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
@@ -53,6 +53,7 @@ namespace Grand.Web.Models.ShoppingCart
public string ProductUrl { get; set; }
public string WarehouseId { get; set; }
public string WarehouseName { get; set; }
+ public string WarehouseCode { get; set; }
public string VendorId { get; set; }
public string VendorName { get; set; }
public string VendorSeName { get; set; }