New enterprise feature
This commit is contained in:
@@ -33,8 +33,8 @@ from shared.utils.demo_dates import BASE_REFERENCE_DATE
|
||||
logger = structlog.get_logger()
|
||||
|
||||
# Base demo tenant IDs
|
||||
DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6") # Individual bakery
|
||||
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7") # Central bakery
|
||||
DEMO_TENANT_PROFESSIONAL = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6") # Individual bakery
|
||||
DEMO_TENANT_ENTERPRISE_CHAIN = uuid.UUID("c3d4e5f6-a7b8-49c0-d1e2-f3a4b5c6d7e8") # Enterprise parent (Obrador)
|
||||
|
||||
|
||||
def load_equipment_data():
|
||||
@@ -109,9 +109,14 @@ async def seed_equipment_for_tenant(
|
||||
}
|
||||
equipment_type = type_mapping.get(equip_data["type"], EquipmentType.OTHER)
|
||||
|
||||
# Generate tenant-specific equipment ID using XOR transformation
|
||||
base_equipment_id = uuid.UUID(equip_data["id"])
|
||||
tenant_int = int(tenant_id.hex, 16)
|
||||
equipment_id = uuid.UUID(int=tenant_int ^ int(base_equipment_id.hex, 16))
|
||||
|
||||
# Create equipment
|
||||
equipment = Equipment(
|
||||
id=uuid.UUID(equip_data["id"]),
|
||||
id=equipment_id,
|
||||
tenant_id=tenant_id,
|
||||
name=equip_data["name"],
|
||||
type=equipment_type,
|
||||
@@ -156,23 +161,25 @@ async def seed_all(db: AsyncSession):
|
||||
|
||||
results = []
|
||||
|
||||
# Seed San Pablo (Individual Bakery)
|
||||
result_san_pablo = await seed_equipment_for_tenant(
|
||||
# Seed Professional Bakery with equipment (single location)
|
||||
result_professional = await seed_equipment_for_tenant(
|
||||
db,
|
||||
DEMO_TENANT_SAN_PABLO,
|
||||
"San Pablo - Individual Bakery",
|
||||
DEMO_TENANT_PROFESSIONAL,
|
||||
"Panadería Artesana Madrid (Professional)",
|
||||
data["equipos_individual_bakery"]
|
||||
)
|
||||
results.append(result_san_pablo)
|
||||
results.append(result_professional)
|
||||
|
||||
# Seed La Espiga (Central Bakery)
|
||||
result_la_espiga = await seed_equipment_for_tenant(
|
||||
# Seed Enterprise Parent (central production - Obrador) with scaled-up equipment
|
||||
# Use enterprise equipment list if available, otherwise use individual bakery equipment
|
||||
enterprise_equipment_key = "equipos_enterprise_chain" if "equipos_enterprise_chain" in data else "equipos_individual_bakery"
|
||||
result_enterprise_parent = await seed_equipment_for_tenant(
|
||||
db,
|
||||
DEMO_TENANT_LA_ESPIGA,
|
||||
"La Espiga - Central Bakery",
|
||||
data["equipos_central_bakery"]
|
||||
DEMO_TENANT_ENTERPRISE_CHAIN,
|
||||
"Panadería Central - Obrador Madrid (Enterprise Parent)",
|
||||
data[enterprise_equipment_key]
|
||||
)
|
||||
results.append(result_la_espiga)
|
||||
results.append(result_enterprise_parent)
|
||||
|
||||
total_created = sum(r["equipment_created"] for r in results)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user