BR 1.11 — Warehouse Service

Миграция

  • Создать таблицу ingredients (id, franchise_id, name, description, unit_of_measure, status, timestamps)
  • Добавить ingredient_id (FK → ingredients, nullable) в recipe_items
  • Добавить semi_finished_product_id (nullable) в recipe_items
  • Мигрировать данные из старого ingredient_product_idingredient_id (создать ingredients из Catalog products type=ingredient)
  • Добавить CHECK constraint на recipe_items: ровно одно из ingredient_id / semi_finished_product_id NOT NULL
  • Удалить ingredient_product_id из recipe_items
  • Заменить ingredient_product_id на ingredient_id (FK, NOT NULL) в modifier_tech_card_items
  • Обновить unit_conversions: product_id → nullable, добавить ingredient_id с XOR constraint

Entity / DTO

  • Создать Ingredient entity
  • Создать IngredientResponse DTO
  • Создать CreateIngredientRequest DTO
  • Создать UpdateIngredientRequest DTO
  • Обновить RecipeItem entity: ingredient_id + semi_finished_product_id
  • Обновить ModifierTechCardItem entity: ingredient_id
  • Обновить RecipeItemResponse / request DTOs
  • Обновить UnitConversion entity: ingredient_id

Repository

  • Создать IngredientRepository (findByFranchiseId, findByFranchiseIdAndName, search)
  • Обновить RecipeItemRepository — новые поля
  • Обновить ModifierTechCardItemRepository
  • Обновить UnitConversionRepository

Service

  • Создать IngredientService (CRUD + валидация: INGREDIENT_IN_USE при удалении/смене unit)
  • Обновить RecipeItemService — ingredient_id / semi_finished_product_id логика
  • Обновить TechCardService — маппинг ответов с новыми полями
  • Обновить ModifierTechCardService — ingredient_id
  • Обновить CostCalculationService — ingredient_id + semi_finished_product_id
  • Обновить CatalogServiceClient — lookup semi_finished_product_name из Catalog

Controller

  • Создать IngredientController (GET/POST/PATCH/DELETE /ingredients)
  • Обновить TechCardController — новые поля в items
  • Обновить ModifierTechCardController — ingredient_id