Refactor inventory commands and queries for improved clarity and consistency
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:
masoodafar-web
2026-01-03 15:38:22 +03:30
parent 989f4a799a
commit f027fd0b06
18 changed files with 196 additions and 197 deletions
@@ -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;