fix update ingredients
This commit is contained in:
parent
535e4c84f6
commit
3db4afbce6
@ -180,7 +180,10 @@ func (p *IngredientProcessorImpl) UpdateIngredient(ctx context.Context, id uuid.
|
||||
}
|
||||
|
||||
// Update fields
|
||||
existingIngredient.OutletID = req.OutletID
|
||||
if req.OutletID != nil {
|
||||
existingIngredient.OutletID = req.OutletID
|
||||
}
|
||||
|
||||
existingIngredient.Name = req.Name
|
||||
existingIngredient.UnitID = req.UnitID
|
||||
existingIngredient.Cost = req.Cost
|
||||
|
||||
@ -66,7 +66,11 @@ func (r *IngredientRepository) GetAll(ctx context.Context, organizationID uuid.U
|
||||
}
|
||||
|
||||
func (r *IngredientRepository) Update(ctx context.Context, ingredient *entities.Ingredient) error {
|
||||
result := r.db.WithContext(ctx).Where("id = ? AND organization_id = ?", ingredient.ID, ingredient.OrganizationID).Save(ingredient)
|
||||
result := r.db.WithContext(ctx).
|
||||
Model(&entities.Ingredient{}).
|
||||
Where("id = ? AND organization_id = ?", ingredient.ID, ingredient.OrganizationID).
|
||||
Select("outlet_id", "name", "unit_id", "cost", "stock", "is_semi_finished", "is_active", "metadata", "updated_at").
|
||||
Updates(ingredient)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user