diff --git a/internal/modules/inventory/adjustments/dto/adjustment.dto.go b/internal/modules/inventory/adjustments/dto/adjustment.dto.go index f6753848..94cbd371 100644 --- a/internal/modules/inventory/adjustments/dto/adjustment.dto.go +++ b/internal/modules/inventory/adjustments/dto/adjustment.dto.go @@ -5,6 +5,7 @@ import ( entity "gitlab.com/mbugroup/lti-api.git/internal/entities" 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" ) @@ -14,6 +15,7 @@ type ProductRelationDTO struct { Id uint `json:"id"` Name string `json:"name"` SKU string `json:"sku"` + Uom *uomDTO.UomRelationDTO `json:"uom,omitempty"` ProductCategory *productCategoryDTO.ProductCategoryRelationDTO `json:"product_category,omitempty"` } @@ -89,11 +91,17 @@ func ToProductRelationDTO(e *entity.Product) *ProductRelationDTO { mapped := productCategoryDTO.ToProductCategoryRelationDTO(e.ProductCategory) category = &mapped } + var uom *uomDTO.UomRelationDTO + if e.Uom.Id != 0 { + mapped := uomDTO.ToUomRelationDTO(e.Uom) + uom = &mapped + } return &ProductRelationDTO{ Id: e.Id, Name: e.Name, SKU: sku, + Uom: uom, ProductCategory: category, } } diff --git a/internal/modules/production/recordings/repositories/recording.repository.go b/internal/modules/production/recordings/repositories/recording.repository.go index fae5740d..6ea4c473 100644 --- a/internal/modules/production/recordings/repositories/recording.repository.go +++ b/internal/modules/production/recordings/repositories/recording.repository.go @@ -115,18 +115,21 @@ func (r *RecordingRepositoryImpl) WithRelations(db *gorm.DB) *gorm.DB { Preload("Depletions"). Preload("Depletions.ProductWarehouse"). Preload("Depletions.ProductWarehouse.Product"). + Preload("Depletions.ProductWarehouse.Product.Uom"). Preload("Depletions.ProductWarehouse.Warehouse"). Preload("Depletions.ProductWarehouse.Warehouse.Area"). Preload("Depletions.ProductWarehouse.Warehouse.Location"). Preload("Stocks"). Preload("Stocks.ProductWarehouse"). Preload("Stocks.ProductWarehouse.Product"). + Preload("Stocks.ProductWarehouse.Product.Uom"). Preload("Stocks.ProductWarehouse.Warehouse"). Preload("Stocks.ProductWarehouse.Warehouse.Area"). Preload("Stocks.ProductWarehouse.Warehouse.Location"). Preload("Eggs"). Preload("Eggs.ProductWarehouse"). Preload("Eggs.ProductWarehouse.Product"). + Preload("Eggs.ProductWarehouse.Product.Uom"). Preload("Eggs.ProductWarehouse.Warehouse"). Preload("Eggs.ProductWarehouse.Warehouse.Area"). Preload("Eggs.ProductWarehouse.Warehouse.Location")