diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommand.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommand.cs index 072db44..ef80683 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommand.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommand.cs @@ -3,7 +3,7 @@ namespace BackOffice.BFF.Application.InventoryCQ.Commands.AddStock; public record AddStockCommand : IRequest { public long ProductId { get; init; } - public int ProductType { get; init; } // 1=Regular, 2=Discount + public int ProductType { get; init; } // 1=RegularProduct, 2=DiscountProduct public int Quantity { get; init; } public string? ReferenceNumber { get; init; } public string? Note { get; init; } @@ -12,8 +12,6 @@ public record AddStockCommand : IRequest public class AddStockResponseDto { - public bool Success { get; set; } public long InventoryItemId { get; set; } public int NewQuantity { get; set; } - public string? Message { get; set; } } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommandHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommandHandler.cs index b5cad31..34eff58 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommandHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AddStock/AddStockCommandHandler.cs @@ -33,10 +33,8 @@ public class AddStockCommandHandler : IRequestHandler { public long ProductId { get; init; } - public int ProductType { get; init; } // 1=Regular, 2=Discount + public int ProductType { get; init; } // 1=RegularProduct, 2=DiscountProduct public int NewQuantity { get; init; } - public string? Note { get; init; } - public long? WarehouseId { get; init; } + public string? Reason { get; init; } + public string? ReferenceNumber { get; init; } } public class AdjustStockResponseDto { - public bool Success { get; set; } - public int OldQuantity { get; set; } + public int PreviousQuantity { get; set; } public int NewQuantity { get; set; } public int Difference { get; set; } - public string? Message { get; set; } } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AdjustStock/AdjustStockCommandHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AdjustStock/AdjustStockCommandHandler.cs index 7b03907..9983b98 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/AdjustStock/AdjustStockCommandHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/AdjustStock/AdjustStockCommandHandler.cs @@ -20,18 +20,19 @@ public class AdjustStockCommandHandler : IRequestHandler { public long ProductId { get; init; } - public int ProductType { get; init; } // 1=Regular, 2=Discount + public int ProductType { get; init; } // 1=RegularProduct, 2=DiscountProduct public int Quantity { get; init; } public int LossType { get; init; } // 40=Loss, 41=Damaged, 42=Expired - public string? Note { get; init; } - public long? WarehouseId { get; init; } + public string? Reason { get; init; } + public string? ReferenceNumber { get; init; } } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/RecordLoss/RecordLossCommandHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/RecordLoss/RecordLossCommandHandler.cs index 3de3229..147a8d8 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/RecordLoss/RecordLossCommandHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/RecordLoss/RecordLossCommandHandler.cs @@ -21,8 +21,11 @@ public class RecordLossCommandHandler : IRequestHandler LossType = (StockMovementType)request.LossType }; - if (!string.IsNullOrWhiteSpace(request.Note)) - protoRequest.Reason = request.Note; + if (!string.IsNullOrWhiteSpace(request.Reason)) + protoRequest.Reason = request.Reason; + + if (!string.IsNullOrWhiteSpace(request.ReferenceNumber)) + protoRequest.ReferenceNumber = request.ReferenceNumber; await _context.Inventory.RecordLossAsync(protoRequest, cancellationToken: cancellationToken); return true; diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommand.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommand.cs index 6805988..58f8861 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommand.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommand.cs @@ -2,7 +2,7 @@ namespace BackOffice.BFF.Application.InventoryCQ.Commands.UpdateInventorySetting public record UpdateInventorySettingsCommand : IRequest { - public long InventoryItemId { get; init; } + public long Id { get; init; } public int LowStockThreshold { get; init; } public int ReorderPoint { get; init; } public int MaxStockLevel { get; init; } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommandHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommandHandler.cs index c4b21d6..1bd4813 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommandHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Commands/UpdateInventorySettings/UpdateInventorySettingsCommandHandler.cs @@ -15,7 +15,7 @@ public class UpdateInventorySettingsCommandHandler : IRequestHandler { - public int PageIndex { get; init; } = 1; + public int Page { get; init; } = 1; public int PageSize { get; init; } = 20; public long? WarehouseId { get; init; } - public int? ProductType { get; init; } // 1=Regular, 2=Discount - public bool? LowStockOnly { get; init; } - public string? SearchTerm { get; init; } + public int? ProductType { get; init; } // 1=RegularProduct, 2=DiscountProduct + public string? Search { get; init; } + public string? SortBy { get; init; } + public bool SortDesc { get; init; } } public class GetAllInventoryItemsResponseDto @@ -23,7 +24,8 @@ public class InventoryItemDto public long? ProductId { get; set; } public long? DiscountProductId { get; set; } public int ProductType { get; set; } - public string ProductName { get; set; } = string.Empty; + public string ProductTitle { get; set; } = string.Empty; + public long ProductPrice { get; set; } public int Quantity { get; set; } public int ReservedQuantity { get; set; } public int AvailableQuantity { get; set; } @@ -34,5 +36,6 @@ public class InventoryItemDto public DateTime? LastSoldAt { get; set; } public long WarehouseId { get; set; } public string WarehouseName { get; set; } = string.Empty; - public bool IsLowStock => Quantity <= LowStockThreshold; + public bool IsLowStock { get; set; } + public DateTime? Created { get; set; } } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllInventoryItems/GetAllInventoryItemsQueryHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllInventoryItems/GetAllInventoryItemsQueryHandler.cs index 2a02396..3b1ca42 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllInventoryItems/GetAllInventoryItemsQueryHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllInventoryItems/GetAllInventoryItemsQueryHandler.cs @@ -16,7 +16,7 @@ public class GetAllInventoryItemsQueryHandler : IRequestHandler new InventoryItemDto @@ -47,7 +52,8 @@ public class GetAllInventoryItemsQueryHandler : IRequestHandler { - public bool? ActiveOnly { get; init; } + public bool? IsActive { get; init; } } public class GetAllWarehousesResponseDto @@ -19,4 +19,6 @@ public class WarehouseDto public string? Address { get; set; } public bool IsDefault { get; set; } public bool IsActive { get; set; } + public DateTime? Created { get; set; } + public DateTime? LastModified { get; set; } } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllWarehouses/GetAllWarehousesQueryHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllWarehouses/GetAllWarehousesQueryHandler.cs index e3b5d7b..2bec5cb 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllWarehouses/GetAllWarehousesQueryHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetAllWarehouses/GetAllWarehousesQueryHandler.cs @@ -15,9 +15,9 @@ public class GetAllWarehousesQueryHandler : IRequestHandler { - public int? Threshold { get; init; } public long? WarehouseId { get; init; } - public int? ProductType { get; init; } // 1=Regular, 2=Discount - public int Count { get; init; } = 50; + public int? ProductType { get; init; } // 1=RegularProduct, 2=DiscountProduct + public int Page { get; init; } = 1; + public int PageSize { get; init; } = 20; } public class GetLowStockItemsResponseDto { public int TotalCount { get; set; } - public List Items { get; set; } = new(); -} - -public class LowStockItemDto -{ - public long Id { get; set; } - public long? ProductId { get; set; } - public long? DiscountProductId { get; set; } - public int ProductType { get; set; } - public string ProductName { get; set; } = string.Empty; - public int Quantity { get; set; } - public int ReservedQuantity { get; set; } - public int AvailableQuantity { get; set; } - public int LowStockThreshold { get; set; } - public int ReorderPoint { get; set; } - public long WarehouseId { get; set; } - public string WarehouseName { get; set; } = string.Empty; - public int DeficitAmount => LowStockThreshold - Quantity; // چقدر کم داریم + public List Items { get; set; } = new(); } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetLowStockItems/GetLowStockItemsQueryHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetLowStockItems/GetLowStockItemsQueryHandler.cs index 787fb7b..760f180 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetLowStockItems/GetLowStockItemsQueryHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetLowStockItems/GetLowStockItemsQueryHandler.cs @@ -1,3 +1,4 @@ +using BackOffice.BFF.Application.InventoryCQ.Queries.GetAllInventoryItems; using CMSMicroservice.Protobuf.Protos.Inventory; namespace BackOffice.BFF.Application.InventoryCQ.Queries.GetLowStockItems; @@ -15,8 +16,8 @@ public class GetLowStockItemsQueryHandler : IRequestHandler new LowStockItemDto + Items = response.Items.Select(i => new GetAllInventoryItems.InventoryItemDto { Id = i.Id, ProductId = i.ProductId, DiscountProductId = i.DiscountProductId, ProductType = (int)i.ProductType, - ProductName = i.ProductTitle, + ProductTitle = i.ProductTitle, + 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 + WarehouseName = i.WarehouseName, + IsLowStock = true }).ToList() }; } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQuery.cs b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQuery.cs index 211e26c..ab85ea4 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQuery.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQuery.cs @@ -8,7 +8,7 @@ public record GetStockMovementsQuery : IRequest public int? MovementType { get; init; } public DateTime? FromDate { get; init; } public DateTime? ToDate { get; init; } - public int PageIndex { get; init; } = 1; + public int Page { get; init; } = 1; public int PageSize { get; init; } = 20; } @@ -23,9 +23,7 @@ public class StockMovementDto { public long Id { get; set; } public long InventoryItemId { get; set; } - public string ProductName { get; set; } = string.Empty; public int MovementType { get; set; } - public string MovementTypeName { get; set; } = string.Empty; public int Quantity { get; set; } public int QuantityBefore { get; set; } public int QuantityAfter { get; set; } @@ -34,6 +32,6 @@ public class StockMovementDto public string? ReferenceNumber { get; set; } public string? Note { get; set; } public long? PerformedByUserId { get; set; } - public string? PerformedByUserName { get; set; } - public DateTime CreatedAt { get; set; } + public DateTime Created { get; set; } + public string ProductTitle { get; set; } = string.Empty; } diff --git a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQueryHandler.cs b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQueryHandler.cs index 794bfa6..9f9e297 100644 --- a/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQueryHandler.cs +++ b/src/BackOffice.BFF.Application/InventoryCQ/Queries/GetStockMovements/GetStockMovementsQueryHandler.cs @@ -16,7 +16,7 @@ public class GetStockMovementsQueryHandler : IRequestHandler new StockMovementDto { Id = m.Id, InventoryItemId = m.InventoryItemId, - ProductName = m.ProductTitle, MovementType = (int)m.MovementType, - MovementTypeName = GetMovementTypeName(m.MovementType), Quantity = m.Quantity, QuantityBefore = m.QuantityBefore, QuantityAfter = m.QuantityAfter, @@ -65,8 +63,8 @@ public class GetStockMovementsQueryHandler : IRequestHandler() .MapWith(src => new GetAllWarehousesQuery { - ActiveOnly = src.ActiveOnly != null ? src.ActiveOnly.Value : null + IsActive = src.IsActive != null ? src.IsActive.Value : null }); config.NewConfig() .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() .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() @@ -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() .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() .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() .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() .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() .MapWith(src => new UpdateInventorySettingsCommand { - InventoryItemId = src.InventoryItemId, + Id = src.Id, LowStockThreshold = src.LowStockThreshold, ReorderPoint = src.ReorderPoint, MaxStockLevel = src.MaxStockLevel diff --git a/src/Protobufs/BackOffice.BFF.Inventory.Protobuf/Protos/inventory.proto b/src/Protobufs/BackOffice.BFF.Inventory.Protobuf/Protos/inventory.proto index 9c08a0c..28827c2 100644 --- a/src/Protobufs/BackOffice.BFF.Inventory.Protobuf/Protos/inventory.proto +++ b/src/Protobufs/BackOffice.BFF.Inventory.Protobuf/Protos/inventory.proto @@ -31,40 +31,41 @@ service InventoryBFFContract } // ============================================= -// Enums +// Enums (Aligned with CMS) // ============================================= enum ProductType { PRODUCT_TYPE_UNSPECIFIED = 0; - REGULAR = 1; - DISCOUNT = 2; + REGULAR_PRODUCT = 1; + DISCOUNT_PRODUCT = 2; } enum StockMovementType { - STOCK_MOVEMENT_TYPE_UNSPECIFIED = 0; + MOVEMENT_TYPE_UNSPECIFIED = 0; INITIAL_STOCK = 1; RESTOCK = 2; RETURN = 3; - SALE = 4; - ADJUSTMENT_INCREASE = 5; - ADJUSTMENT_DECREASE = 6; - RESERVED = 7; - RELEASED = 8; - LOSS = 9; - DAMAGED = 10; - EXPIRED = 11; - TRANSFER_OUT = 12; - TRANSFER_IN = 13; + SALE = 10; + ADJUSTMENT_INCREASE = 20; + ADJUSTMENT_DECREASE = 21; + RESERVED = 30; + RELEASED = 31; + LOSS = 40; + DAMAGED = 41; + EXPIRED = 42; + TRANSFER_OUT = 50; + TRANSFER_IN = 51; } // ============================================= // Warehouse Messages // ============================================= message GetAllWarehousesRequest { - google.protobuf.BoolValue active_only = 1; + google.protobuf.BoolValue is_active = 1; } message GetAllWarehousesResponse { repeated WarehouseDto warehouses = 1; + int32 total_count = 2; } message WarehouseDto { @@ -75,6 +76,7 @@ message WarehouseDto { bool is_default = 5; bool is_active = 6; google.protobuf.Timestamp created = 7; + google.protobuf.Timestamp last_modified = 8; } message CreateWarehouseRequest { @@ -92,17 +94,19 @@ message CreateWarehouseResponse { // Inventory Item Messages // ============================================= message GetAllInventoryItemsRequest { - int32 page_index = 1; - int32 page_size = 2; - google.protobuf.Int64Value warehouse_id = 3; - ProductType product_type = 4; - string search_term = 5; + google.protobuf.Int64Value warehouse_id = 1; + ProductType product_type = 2; + string search = 3; + int32 page = 4; + int32 page_size = 5; + string sort_by = 6; + bool sort_desc = 7; } message GetAllInventoryItemsResponse { - int32 total_count = 1; - messages.MetaData meta_data = 2; - repeated InventoryItemDto items = 3; + repeated InventoryItemDto items = 1; + int32 total_count = 2; + messages.MetaData meta_data = 3; } message InventoryItemDto { @@ -110,85 +114,71 @@ message InventoryItemDto { google.protobuf.Int64Value product_id = 2; google.protobuf.Int64Value discount_product_id = 3; ProductType product_type = 4; - string product_name = 5; - int32 quantity = 6; - int32 reserved_quantity = 7; - int32 available_quantity = 8; - int32 low_stock_threshold = 9; - int32 reorder_point = 10; - int32 max_stock_level = 11; - google.protobuf.Timestamp last_restocked_at = 12; - google.protobuf.Timestamp last_sold_at = 13; - int64 warehouse_id = 14; - string warehouse_name = 15; - bool is_low_stock = 16; + string product_title = 5; + int64 product_price = 6; + int32 quantity = 7; + int32 reserved_quantity = 8; + int32 available_quantity = 9; + int32 low_stock_threshold = 10; + int32 reorder_point = 11; + int32 max_stock_level = 12; + google.protobuf.Timestamp last_restocked_at = 13; + google.protobuf.Timestamp last_sold_at = 14; + int64 warehouse_id = 15; + string warehouse_name = 16; + bool is_low_stock = 17; + google.protobuf.Timestamp created = 18; } // ============================================= // Low Stock Messages // ============================================= message GetLowStockItemsRequest { - int32 count = 1; - google.protobuf.Int64Value warehouse_id = 2; - ProductType product_type = 3; + google.protobuf.Int64Value warehouse_id = 1; + ProductType product_type = 2; + int32 page = 3; + int32 page_size = 4; } message GetLowStockItemsResponse { - int32 total_count = 1; - repeated LowStockItemDto items = 2; -} - -message LowStockItemDto { - int64 id = 1; - google.protobuf.Int64Value product_id = 2; - google.protobuf.Int64Value discount_product_id = 3; - ProductType product_type = 4; - string product_name = 5; - int32 quantity = 6; - int32 reserved_quantity = 7; - int32 available_quantity = 8; - int32 low_stock_threshold = 9; - int32 reorder_point = 10; - int64 warehouse_id = 11; - string warehouse_name = 12; + repeated InventoryItemDto items = 1; + int32 total_count = 2; } // ============================================= // Stock Movement Messages // ============================================= message GetStockMovementsRequest { - int32 page_index = 1; - int32 page_size = 2; - google.protobuf.Int64Value inventory_item_id = 3; - google.protobuf.Int64Value product_id = 4; - ProductType product_type = 5; - StockMovementType movement_type = 6; - google.protobuf.Timestamp from_date = 7; - google.protobuf.Timestamp to_date = 8; + google.protobuf.Int64Value inventory_item_id = 1; + google.protobuf.Int64Value product_id = 2; + ProductType product_type = 3; + StockMovementType movement_type = 4; + google.protobuf.Timestamp from_date = 5; + google.protobuf.Timestamp to_date = 6; + int32 page = 7; + int32 page_size = 8; } message GetStockMovementsResponse { - int32 total_count = 1; - messages.MetaData meta_data = 2; - repeated StockMovementDto movements = 3; + repeated StockMovementDto movements = 1; + int32 total_count = 2; + messages.MetaData meta_data = 3; } message StockMovementDto { int64 id = 1; int64 inventory_item_id = 2; - string product_name = 3; - StockMovementType movement_type = 4; - string movement_type_name = 5; - int32 quantity = 6; - int32 quantity_before = 7; - int32 quantity_after = 8; - google.protobuf.Int64Value order_id = 9; - google.protobuf.Int64Value discount_order_id = 10; - string reference_number = 11; - string note = 12; - google.protobuf.Int64Value performed_by_user_id = 13; - string performed_by_user_name = 14; - google.protobuf.Timestamp created_at = 15; + StockMovementType movement_type = 3; + int32 quantity = 4; + int32 quantity_before = 5; + int32 quantity_after = 6; + google.protobuf.Int64Value order_id = 7; + google.protobuf.Int64Value discount_order_id = 8; + string reference_number = 9; + string note = 10; + google.protobuf.Int64Value performed_by_user_id = 11; + google.protobuf.Timestamp created = 12; + string product_title = 13; } // ============================================= @@ -204,37 +194,35 @@ message AddStockRequest { } message AddStockResponse { - bool success = 1; - int64 inventory_item_id = 2; - int32 new_quantity = 3; - string message = 4; + int64 inventory_item_id = 1; + int32 new_quantity = 2; } message AdjustStockRequest { int64 product_id = 1; ProductType product_type = 2; int32 new_quantity = 3; - string note = 4; + string reason = 4; + string reference_number = 5; } message AdjustStockResponse { - bool success = 1; - int32 old_quantity = 2; - int32 new_quantity = 3; - int32 difference = 4; - string message = 5; + int32 previous_quantity = 1; + int32 new_quantity = 2; + int32 difference = 3; } message RecordLossRequest { int64 product_id = 1; ProductType product_type = 2; int32 quantity = 3; - string reason = 4; - string reference_number = 5; + StockMovementType loss_type = 4; // LOSS, DAMAGED, or EXPIRED + string reason = 5; + string reference_number = 6; } message UpdateInventorySettingsRequest { - int64 inventory_item_id = 1; + int64 id = 1; int32 low_stock_threshold = 2; int32 reorder_point = 3; int32 max_stock_level = 4;