diff --git a/internal/modules/inventory/product-stocks/dto/product-stock.dto.go b/internal/modules/inventory/product-stocks/dto/product-stock.dto.go index aa9f98c2..2bad7ae7 100644 --- a/internal/modules/inventory/product-stocks/dto/product-stock.dto.go +++ b/internal/modules/inventory/product-stocks/dto/product-stock.dto.go @@ -4,6 +4,7 @@ import ( "time" entity "gitlab.com/mbugroup/lti-api.git/internal/entities" + locationDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/locations/dto" productCategoryDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/product-categories/dto" uomDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/uoms/dto" userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto" @@ -47,13 +48,13 @@ type SupplierDTO struct { } type ProductWarehouseDTO struct { - Id uint `json:"id"` - ProductId uint `json:"product_id"` - WarehouseId uint `json:"warehouse_id"` - WarehouseName string `json:"warehouse_name"` - Location string `json:"location"` - CurrentStock float64 `json:"current_stock"` - StockLogs []StockLogDetailDTO `json:"stock_logs"` + Id uint `json:"id"` + ProductId uint `json:"product_id"` + WarehouseId uint `json:"warehouse_id"` + WarehouseName string `json:"warehouse_name"` + Location *locationDTO.LocationRelationDTO `json:"location"` + CurrentStock float64 `json:"current_stock"` + StockLogs []StockLogDetailDTO `json:"stock_logs"` } type StockLogDetailDTO struct { @@ -166,7 +167,8 @@ func mapProductWarehouseDTOs(src []entity.ProductWarehouse) []ProductWarehouseDT if pw.Warehouse.Id != 0 { dto.WarehouseName = pw.Warehouse.Name if pw.Warehouse.Location != nil { - dto.Location = pw.Warehouse.Location.Name + mapped := locationDTO.ToLocationRelationDTO(*pw.Warehouse.Location) + dto.Location = &mapped } } result = append(result, dto) diff --git a/internal/modules/inventory/product-stocks/services/product-stock.service.go b/internal/modules/inventory/product-stocks/services/product-stock.service.go index 5cf6ec17..4de4af67 100644 --- a/internal/modules/inventory/product-stocks/services/product-stock.service.go +++ b/internal/modules/inventory/product-stocks/services/product-stock.service.go @@ -45,6 +45,7 @@ func (s productStockService) withRelations(db *gorm.DB) *gorm.DB { Preload("ProductWarehouses"). Preload("ProductWarehouses.Warehouse"). Preload("ProductWarehouses.Warehouse.Location"). + Preload("ProductWarehouses.Warehouse.Location.Area"). Preload("ProductWarehouses.StockLogs", func(db *gorm.DB) *gorm.DB { return db.Order("created_at ASC") }).