Refactor inventory commands and queries for improved clarity and consistency
Build and Deploy / build (push) Failing after 2m12s
Build and Deploy / build (push) Failing after 2m12s
- Updated ProductType enum values to be more descriptive (RegularProduct, DiscountProduct). - Removed unnecessary Success and Message properties from response DTOs in AddStock and AdjustStock commands. - Renamed Note property to Reason in AdjustStock and RecordLoss commands, and added ReferenceNumber. - Changed InventoryItemId to Id in UpdateInventorySettingsCommand for consistency. - Updated pagination properties in various queries (PageIndex to Page). - Enhanced GetAllInventoryItemsQuery and GetLowStockItemsQuery to include sorting options. - Updated InventoryProfile mappings to reflect changes in DTOs and Protobuf definitions. - Adjusted Protobuf definitions to align with new property names and structures.
This commit is contained in:
@@ -23,12 +23,13 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<BffProtos.GetAllWarehousesRequest, GetAllWarehousesQuery>()
|
||||
.MapWith(src => new GetAllWarehousesQuery
|
||||
{
|
||||
ActiveOnly = src.ActiveOnly != null ? src.ActiveOnly.Value : null
|
||||
IsActive = src.IsActive != null ? src.IsActive.Value : null
|
||||
});
|
||||
|
||||
config.NewConfig<GetAllWarehousesResponseDto, BffProtos.GetAllWarehousesResponse>()
|
||||
.MapWith(src => new BffProtos.GetAllWarehousesResponse
|
||||
{
|
||||
TotalCount = src.TotalCount,
|
||||
Warehouses = { src.Warehouses.Select(w => new BffProtos.WarehouseDto
|
||||
{
|
||||
Id = w.Id,
|
||||
@@ -36,7 +37,13 @@ public class InventoryProfile : IRegister
|
||||
Code = w.Code ?? string.Empty,
|
||||
Address = w.Address ?? string.Empty,
|
||||
IsDefault = w.IsDefault,
|
||||
IsActive = w.IsActive
|
||||
IsActive = w.IsActive,
|
||||
Created = w.Created.HasValue
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(w.Created.Value, DateTimeKind.Utc))
|
||||
: null,
|
||||
LastModified = w.LastModified.HasValue
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(w.LastModified.Value, DateTimeKind.Utc))
|
||||
: null
|
||||
}) }
|
||||
});
|
||||
|
||||
@@ -62,13 +69,15 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<BffProtos.GetAllInventoryItemsRequest, GetAllInventoryItemsQuery>()
|
||||
.MapWith(src => new GetAllInventoryItemsQuery
|
||||
{
|
||||
PageIndex = src.PageIndex > 0 ? src.PageIndex : 1,
|
||||
Page = src.Page > 0 ? src.Page : 1,
|
||||
PageSize = src.PageSize > 0 ? src.PageSize : 20,
|
||||
WarehouseId = src.WarehouseId,
|
||||
ProductType = src.ProductType != BffProtos.ProductType.Unspecified
|
||||
? (int)src.ProductType
|
||||
: null,
|
||||
SearchTerm = string.IsNullOrWhiteSpace(src.SearchTerm) ? null : src.SearchTerm
|
||||
Search = string.IsNullOrWhiteSpace(src.Search) ? null : src.Search,
|
||||
SortBy = string.IsNullOrWhiteSpace(src.SortBy) ? null : src.SortBy,
|
||||
SortDesc = src.SortDesc
|
||||
});
|
||||
|
||||
config.NewConfig<GetAllInventoryItemsResponseDto, BffProtos.GetAllInventoryItemsResponse>()
|
||||
@@ -88,7 +97,8 @@ public class InventoryProfile : IRegister
|
||||
ProductId = i.ProductId.HasValue ? i.ProductId.Value : null,
|
||||
DiscountProductId = i.DiscountProductId.HasValue ? i.DiscountProductId.Value : null,
|
||||
ProductType = (BffProtos.ProductType)i.ProductType,
|
||||
ProductName = i.ProductName ?? string.Empty,
|
||||
ProductTitle = i.ProductTitle ?? string.Empty,
|
||||
ProductPrice = i.ProductPrice,
|
||||
Quantity = i.Quantity,
|
||||
ReservedQuantity = i.ReservedQuantity,
|
||||
AvailableQuantity = i.AvailableQuantity,
|
||||
@@ -103,7 +113,10 @@ public class InventoryProfile : IRegister
|
||||
: null,
|
||||
WarehouseId = i.WarehouseId,
|
||||
WarehouseName = i.WarehouseName ?? string.Empty,
|
||||
IsLowStock = i.IsLowStock
|
||||
IsLowStock = i.IsLowStock,
|
||||
Created = i.Created.HasValue
|
||||
? Timestamp.FromDateTime(DateTime.SpecifyKind(i.Created.Value, DateTimeKind.Utc))
|
||||
: null
|
||||
}) }
|
||||
});
|
||||
|
||||
@@ -113,7 +126,8 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<BffProtos.GetLowStockItemsRequest, GetLowStockItemsQuery>()
|
||||
.MapWith(src => new GetLowStockItemsQuery
|
||||
{
|
||||
Count = src.Count > 0 ? src.Count : 10,
|
||||
Page = src.Page > 0 ? src.Page : 1,
|
||||
PageSize = src.PageSize > 0 ? src.PageSize : 20,
|
||||
WarehouseId = src.WarehouseId,
|
||||
ProductType = src.ProductType != BffProtos.ProductType.Unspecified
|
||||
? (int)src.ProductType
|
||||
@@ -124,20 +138,23 @@ public class InventoryProfile : IRegister
|
||||
.MapWith(src => new BffProtos.GetLowStockItemsResponse
|
||||
{
|
||||
TotalCount = src.TotalCount,
|
||||
Items = { src.Items.Select(i => new BffProtos.LowStockItemDto
|
||||
Items = { src.Items.Select(i => new BffProtos.InventoryItemDto
|
||||
{
|
||||
Id = i.Id,
|
||||
ProductId = i.ProductId.HasValue ? i.ProductId.Value : null,
|
||||
DiscountProductId = i.DiscountProductId.HasValue ? i.DiscountProductId.Value : null,
|
||||
ProductType = (BffProtos.ProductType)i.ProductType,
|
||||
ProductName = i.ProductName ?? string.Empty,
|
||||
ProductTitle = i.ProductTitle ?? string.Empty,
|
||||
ProductPrice = i.ProductPrice,
|
||||
Quantity = i.Quantity,
|
||||
ReservedQuantity = i.ReservedQuantity,
|
||||
AvailableQuantity = i.AvailableQuantity,
|
||||
LowStockThreshold = i.LowStockThreshold,
|
||||
ReorderPoint = i.ReorderPoint,
|
||||
MaxStockLevel = i.MaxStockLevel,
|
||||
WarehouseId = i.WarehouseId,
|
||||
WarehouseName = i.WarehouseName ?? string.Empty
|
||||
WarehouseName = i.WarehouseName ?? string.Empty,
|
||||
IsLowStock = i.IsLowStock
|
||||
}) }
|
||||
});
|
||||
|
||||
@@ -147,14 +164,14 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<BffProtos.GetStockMovementsRequest, GetStockMovementsQuery>()
|
||||
.MapWith(src => new GetStockMovementsQuery
|
||||
{
|
||||
PageIndex = src.PageIndex > 0 ? src.PageIndex : 1,
|
||||
Page = src.Page > 0 ? src.Page : 1,
|
||||
PageSize = src.PageSize > 0 ? src.PageSize : 20,
|
||||
InventoryItemId = src.InventoryItemId,
|
||||
ProductId = src.ProductId,
|
||||
ProductType = src.ProductType != BffProtos.ProductType.Unspecified
|
||||
? (int)src.ProductType
|
||||
: null,
|
||||
MovementType = src.MovementType != BffProtos.StockMovementType.Unspecified
|
||||
MovementType = src.MovementType != BffProtos.StockMovementType.MovementTypeUnspecified
|
||||
? (int)src.MovementType
|
||||
: null,
|
||||
FromDate = src.FromDate != null ? src.FromDate.ToDateTime() : null,
|
||||
@@ -176,9 +193,7 @@ public class InventoryProfile : IRegister
|
||||
{
|
||||
Id = m.Id,
|
||||
InventoryItemId = m.InventoryItemId,
|
||||
ProductName = m.ProductName ?? string.Empty,
|
||||
MovementType = (BffProtos.StockMovementType)m.MovementType,
|
||||
MovementTypeName = m.MovementTypeName ?? string.Empty,
|
||||
Quantity = m.Quantity,
|
||||
QuantityBefore = m.QuantityBefore,
|
||||
QuantityAfter = m.QuantityAfter,
|
||||
@@ -187,8 +202,8 @@ public class InventoryProfile : IRegister
|
||||
ReferenceNumber = m.ReferenceNumber ?? string.Empty,
|
||||
Note = m.Note ?? string.Empty,
|
||||
PerformedByUserId = m.PerformedByUserId.HasValue ? m.PerformedByUserId.Value : null,
|
||||
PerformedByUserName = m.PerformedByUserName ?? string.Empty,
|
||||
CreatedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.CreatedAt, DateTimeKind.Utc))
|
||||
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(m.Created, DateTimeKind.Utc)),
|
||||
ProductTitle = m.ProductTitle ?? string.Empty
|
||||
}) }
|
||||
});
|
||||
|
||||
@@ -209,10 +224,8 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<AddStockResponseDto, BffProtos.AddStockResponse>()
|
||||
.MapWith(src => new BffProtos.AddStockResponse
|
||||
{
|
||||
Success = src.Success,
|
||||
InventoryItemId = src.InventoryItemId,
|
||||
NewQuantity = src.NewQuantity,
|
||||
Message = src.Message ?? string.Empty
|
||||
NewQuantity = src.NewQuantity
|
||||
});
|
||||
|
||||
// =============================================
|
||||
@@ -224,17 +237,16 @@ public class InventoryProfile : IRegister
|
||||
ProductId = src.ProductId,
|
||||
ProductType = (int)src.ProductType,
|
||||
NewQuantity = src.NewQuantity,
|
||||
Note = src.Note
|
||||
Reason = src.Reason,
|
||||
ReferenceNumber = src.ReferenceNumber
|
||||
});
|
||||
|
||||
config.NewConfig<AdjustStockResponseDto, BffProtos.AdjustStockResponse>()
|
||||
.MapWith(src => new BffProtos.AdjustStockResponse
|
||||
{
|
||||
Success = src.Success,
|
||||
OldQuantity = src.OldQuantity,
|
||||
PreviousQuantity = src.PreviousQuantity,
|
||||
NewQuantity = src.NewQuantity,
|
||||
Difference = src.Difference,
|
||||
Message = src.Message ?? string.Empty
|
||||
Difference = src.Difference
|
||||
});
|
||||
|
||||
// =============================================
|
||||
@@ -246,8 +258,9 @@ public class InventoryProfile : IRegister
|
||||
ProductId = src.ProductId,
|
||||
ProductType = (int)src.ProductType,
|
||||
Quantity = src.Quantity,
|
||||
LossType = 40, // Loss type
|
||||
Note = src.Reason
|
||||
LossType = (int)src.LossType,
|
||||
Reason = src.Reason,
|
||||
ReferenceNumber = src.ReferenceNumber
|
||||
});
|
||||
|
||||
// =============================================
|
||||
@@ -256,7 +269,7 @@ public class InventoryProfile : IRegister
|
||||
config.NewConfig<BffProtos.UpdateInventorySettingsRequest, UpdateInventorySettingsCommand>()
|
||||
.MapWith(src => new UpdateInventorySettingsCommand
|
||||
{
|
||||
InventoryItemId = src.InventoryItemId,
|
||||
Id = src.Id,
|
||||
LowStockThreshold = src.LowStockThreshold,
|
||||
ReorderPoint = src.ReorderPoint,
|
||||
MaxStockLevel = src.MaxStockLevel
|
||||
|
||||
Reference in New Issue
Block a user