Skip to content

The open source simple and complete warehouse management system is derived from our many years of experience in implementing erp projects. We stripped the original commercial system wms function and opened it up for free, hoping to help the majority of small and medium-sized enterprises. At present, the system supports cross-platform。

add limit of delete when Inventory exists in the warehouse location

JawerZengf1d2c0b3db9f
diff --git a/backend/ModernWMS.Core/Models/MultiLanguage.en-us.resx b/backend/ModernWMS.Core/Models/MultiLanguage.en-us.resx
index 902a651..2bf7595 100644
--- a/backend/ModernWMS.Core/Models/MultiLanguage.en-us.resx
+++ b/backend/ModernWMS.Core/Models/MultiLanguage.en-us.resx
@@ -639,4 +639,7 @@
<data name="old_password" xml:space="preserve">
<value>old password</value>
</data>
+ <data name="location_exist_stock_not_delete" xml:space="preserve">
+ <value>Inventory exists in the warehouse location. Cannot delete the warehouse location</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/backend/ModernWMS.Core/Models/MultiLanguage.zh-cn.resx b/backend/ModernWMS.Core/Models/MultiLanguage.zh-cn.resx
index f4f1741..01370db 100644
--- a/backend/ModernWMS.Core/Models/MultiLanguage.zh-cn.resx
+++ b/backend/ModernWMS.Core/Models/MultiLanguage.zh-cn.resx
@@ -639,4 +639,7 @@
<data name="old_password" xml:space="preserve">
<value>旧密码</value>
</data>
+ <data name="location_exist_stock_not_delete" xml:space="preserve">
+ <value>库位存在库存,不能删除</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/backend/ModernWMS.WMS/Services/Goodslocation/GoodslocationService.cs b/backend/ModernWMS.WMS/Services/Goodslocation/GoodslocationService.cs
index 645de9b..1b7d32d 100644
--- a/backend/ModernWMS.WMS/Services/Goodslocation/GoodslocationService.cs
+++ b/backend/ModernWMS.WMS/Services/Goodslocation/GoodslocationService.cs
@@ -212,7 +212,12 @@
/// <returns></returns>
public async Task<(bool flag, string msg)> DeleteAsync(int id)
{
- var qty = await _dBContext.GetDbSet<GoodslocationEntity>().Where(t => t.id.Equals(id)).ExecuteDeleteAsync();
+ var exist_stock = await _dBContext.GetDbSet<StockEntity>().AsNoTracking().Where(t => t.qty > 0 && t.goods_location_id == id).AnyAsync();
+ if (exist_stock)
+ {
+ return (false, _stringLocalizer["location_exist_stock_not_delete"]);
+ }
+ var qty = await _dBContext.GetDbSet<GoodslocationEntity>().Where(t => t.id.Equals(id)).ExecuteDeleteAsync();
if (qty > 0)
{
return (true, _stringLocalizer["delete_success"]);