|
|
|
@ -694,9 +694,12 @@ async def update(
|
|
|
|
|
|
|
|
|
|
|
|
# Re-run generate_transaction for this equipment's assetnum.
|
|
|
|
# Re-run generate_transaction for this equipment's assetnum.
|
|
|
|
# Build an EquipmentCreate from the updated SQLAlchemy object and call the generator.
|
|
|
|
# Build an EquipmentCreate from the updated SQLAlchemy object and call the generator.
|
|
|
|
|
|
|
|
# Exclude fields not present in EquipmentCreate schema (e.g., id, equipment_master)
|
|
|
|
|
|
|
|
create_fields = set(EquipmentCreate.model_fields.keys())
|
|
|
|
|
|
|
|
create_data = {k: v for k, v in updated_data.items() if k in create_fields}
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
equipment_create = EquipmentCreate(**updated_data)
|
|
|
|
equipment_update = EquipmentUpdate(**update_data)
|
|
|
|
await generate_transaction(db_session=db_session, data_in=equipment_create, token=token)
|
|
|
|
await generate_transaction(db_session=db_session, data_in=equipment_update, token=token)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
# don't break the update if resimulation fails — log/print for visibility
|
|
|
|
# don't break the update if resimulation fails — log/print for visibility
|
|
|
|
print(f"Resimulation failed for assetnum {updated_data.get('assetnum')}: {e}")
|
|
|
|
print(f"Resimulation failed for assetnum {updated_data.get('assetnum')}: {e}")
|
|
|
|
|