Source code for aeat.domain.calculations.registry._relation_aggregation
"""Single accessor for a registry relation's aggregation operator.The relation ``aggregation.op`` was re-parsed inline as``str((relation.aggregation or {}).get("op", "copy"))`` at the requirement-keying,resolve, and M390-partition sites — exactly the untyped re-parse the``binding-aggregation-is-typed`` rule forbids for bindings, on the relation half itskipped. ``RelationDefinition.aggregation`` is now the typed:class:`~core.aggregation.RelationAggregation` model (an unknown op is rejectedat registry-build by its strict ``op`` field). This module centralises the read intoone :func:`relation_aggregation_op` accessor returning the typed:class:`~core.aggregation.RelationAggregationOp`, applying the per-relationdefault in one place.The relation op axis is deliberately separate from the binding op axis(:func:`domain.calculations.registry.binding_aggregation_op`): relationscarry only ``copy`` / ``sum``, never the binding-only ``rows`` /``count_distinct`` / ``prior_pagos_fraccionados``.See Also: :mod:`domain.calculations.registry._relations` Requirement and resolve paths that call this accessor. :mod:`domain.calculations.registry._observation_fold` Shared ``copy`` / ``sum`` arithmetic applied after this accessor selects the relation op. :mod:`core.aggregation` Core enum/model definitions for relation and binding aggregation axes."""from__future__importannotationsfrom....core.aggregationimportRelationAggregationOpfrom._schemaimportRelationDefinition
[docs]defrelation_aggregation_op(relation:RelationDefinition)->RelationAggregationOp:"""Return the typed :class:`~core.aggregation.RelationAggregationOp` a relation declares. Reads the :class:`~domain.calculations.registry.RelationDefinition` aggregation field. Defaults to :attr:`~core.aggregation.RelationAggregationOp.COPY` when ``aggregation`` is absent, preserving the conformant single-period carry default used by relation source requirements. """ifrelation.aggregationisNone:returnRelationAggregationOp.COPYreturnrelation.aggregation.op