from tools.doc_generator.logic.calculations.legacy_legal import apply_legacy_legal_calculations CALCULATION_HANDLERS = { "legacy_legal": apply_legacy_legal_calculations, } def apply_calculations(document_type: dict, data: dict) -> dict: calculated = dict(data) for calculation in document_type.get("calculations", []): script = calculation.get("script") handler = CALCULATION_HANDLERS.get(script) if handler: calculated = handler(calculated, calculation) return calculated