Improve the frontend
This commit is contained in:
@@ -177,11 +177,33 @@ async def clone_demo_data(
|
||||
new_price_id = uuid.uuid4()
|
||||
price_list_map[price_list.id] = new_price_id
|
||||
|
||||
# Transform inventory_product_id to match virtual tenant's ingredient IDs
|
||||
# Using same formula as inventory service: tenant_int ^ base_int
|
||||
base_product_int = int(price_list.inventory_product_id.hex, 16)
|
||||
virtual_tenant_int = int(virtual_uuid.hex, 16)
|
||||
base_tenant_int = int(base_uuid.hex, 16)
|
||||
|
||||
# Reverse the original XOR to get the base ingredient ID
|
||||
# base_product = base_tenant ^ base_ingredient_id
|
||||
# So: base_ingredient_id = base_tenant ^ base_product
|
||||
base_ingredient_int = base_tenant_int ^ base_product_int
|
||||
|
||||
# Now apply virtual tenant XOR
|
||||
new_product_id = uuid.UUID(int=virtual_tenant_int ^ base_ingredient_int)
|
||||
|
||||
logger.debug(
|
||||
"Transforming price list product ID using XOR",
|
||||
supplier_name=supplier.name,
|
||||
base_product_id=str(price_list.inventory_product_id),
|
||||
new_product_id=str(new_product_id),
|
||||
product_code=price_list.product_code
|
||||
)
|
||||
|
||||
new_price_list = SupplierPriceList(
|
||||
id=new_price_id,
|
||||
tenant_id=virtual_uuid,
|
||||
supplier_id=new_supplier_id,
|
||||
inventory_product_id=price_list.inventory_product_id, # Keep product reference
|
||||
inventory_product_id=new_product_id, # Transformed for virtual tenant
|
||||
product_code=price_list.product_code,
|
||||
unit_price=price_list.unit_price,
|
||||
unit_of_measure=price_list.unit_of_measure,
|
||||
@@ -290,12 +312,20 @@ async def clone_demo_data(
|
||||
|
||||
new_price_list_id = price_list_map.get(item.price_list_item_id, item.price_list_item_id) if item.price_list_item_id else None
|
||||
|
||||
# Transform inventory_product_id to match virtual tenant's ingredient IDs
|
||||
if item.inventory_product_id:
|
||||
base_product_int = int(item.inventory_product_id.hex, 16)
|
||||
base_ingredient_int = base_tenant_int ^ base_product_int
|
||||
new_inventory_product_id = uuid.UUID(int=virtual_tenant_int ^ base_ingredient_int)
|
||||
else:
|
||||
new_inventory_product_id = None
|
||||
|
||||
new_item = PurchaseOrderItem(
|
||||
id=new_item_id,
|
||||
tenant_id=virtual_uuid,
|
||||
purchase_order_id=new_po_id,
|
||||
price_list_item_id=new_price_list_id,
|
||||
inventory_product_id=item.inventory_product_id, # Keep product reference
|
||||
inventory_product_id=new_inventory_product_id, # Transformed product reference
|
||||
product_code=item.product_code,
|
||||
ordered_quantity=item.ordered_quantity,
|
||||
unit_of_measure=item.unit_of_measure,
|
||||
@@ -377,12 +407,20 @@ async def clone_demo_data(
|
||||
for item in delivery_items:
|
||||
new_po_item_id = po_item_map.get(item.purchase_order_item_id, item.purchase_order_item_id)
|
||||
|
||||
# Transform inventory_product_id to match virtual tenant's ingredient IDs
|
||||
if item.inventory_product_id:
|
||||
base_product_int = int(item.inventory_product_id.hex, 16)
|
||||
base_ingredient_int = base_tenant_int ^ base_product_int
|
||||
new_inventory_product_id = uuid.UUID(int=virtual_tenant_int ^ base_ingredient_int)
|
||||
else:
|
||||
new_inventory_product_id = None
|
||||
|
||||
new_item = DeliveryItem(
|
||||
id=uuid.uuid4(),
|
||||
tenant_id=virtual_uuid,
|
||||
delivery_id=new_delivery_id,
|
||||
purchase_order_item_id=new_po_item_id,
|
||||
inventory_product_id=item.inventory_product_id, # Keep product reference
|
||||
inventory_product_id=new_inventory_product_id, # Transformed product reference
|
||||
ordered_quantity=item.ordered_quantity,
|
||||
delivered_quantity=item.delivered_quantity,
|
||||
accepted_quantity=item.accepted_quantity,
|
||||
|
||||
Reference in New Issue
Block a user