cadrumo.application.aggregation.foreign_assets module¶
Modelo 720 foreign-assets aggregation and source-mesh resolver.
Modelo 720 is an informativa declaration for assets and rights abroad. This
module groups per-asset observations by (source_kind, asset_class) and
returns ForeignAssetsAggregation for
application.aggregation.service; the repository-free
ForeignAssetsAggregationSourceResolver adapts the same observations to
the calculation source-mesh envelope when a caller supplies them.
Declarability is per regulatory obligation block. The aggregate keeps raw class
rollups, and declarable_asset_classes_720() applies each block’s threshold
to the sum of every present class in that block. Observation construction accepts
only the four canonical source-kind values ledger_transaction,
purchase_invoice_evidence, payable_invoice, and
collectible_invoice; bare invoice is rejected.
- class ForeignAssetIngestObservation(**data)[source]¶
Bases:
BaseModelOne asset observation for a Modelo 720 aggregator pass.
acquisition_dateis admitted by the canonical date authority at ingestion, before aggregation. Bounding its length alone let an impossible calendar date through –2026-99-99and2026-02-30are both ten characters – so the aggregate totals, the declarability decision, and the operator’s rollups were all computed from a row no date authority had ever approved, and the refusal only surfaced later at the registry adapter that finally parses it.- Parameters:
data (Any)
- source_kind: BindingSourceKind¶
- source_object_id: str¶
- asset_class: ForeignAssetClass¶
- asset_external_id: str¶
- country: CountryCodeAlpha2¶
- issuer_or_institution: str¶
- valuation_eur: Decimal¶
- acquisition_date: IsoDateString¶
- held_at_year_end: bool¶
- class ForeignAssetClassRollup(**data)[source]¶
Bases:
BaseModelPer-source-kind and per-asset-class rollup row.
- Parameters:
data (Any)
- source_kind: BindingSourceKind¶
- asset_class: ForeignAssetClass¶
- assets_count: NonNegativeInt¶
- held_at_year_end_count: NonNegativeInt¶
- total_valuation_eur: Decimal¶
- countries: tuple[str, ...]¶
- class ForeignAssetsAggregation(**data)[source]¶
Bases:
BaseModel720 aggregation output: per-class rollups + cross-class totals.
- Parameters:
data (Any)
- modelo: str¶
- period: InstanceOf[Period]¶
- rollups: tuple[ForeignAssetClassRollup, ...]¶
- total_assets: NonNegativeInt¶
- total_valuation_eur: Decimal¶
- declarable_asset_classes_720(aggregation, *, thresholds=None, operation=None)[source]¶
Return present asset classes whose obligation block exceeds its 720 declaration floor.
Returns a frozenset of
ForeignAssetClassmembers.- Return type:
- Parameters:
aggregation (ForeignAssetsAggregation)
thresholds (Mapping[ForeignAssetObligationGroup, ForeignAssetDeclarationThreshold] | None)
operation (PinnedAuthorityOperation | None)
- aggregate_foreign_assets_720(observations, *, period)[source]¶
Aggregate Modelo 720 observations into per-class rollups.
Returns a
ForeignAssetsAggregationgrouping observations by asset class. Pure function: identical observation input + period yields identical output. Rollups are sorted by asset_class.value so two equal aggregations serialise to identical bytes.No threshold gate is applied here; callers use
declarable_asset_classes_720()to filter rollups by obligation block before binding to Modelo 720 casillas.- Return type:
- Parameters:
observations (tuple[ForeignAssetIngestObservation, ...])
period (Period)
- class ForeignAssetsAggregationSourceResolver(*, observations=(), row_observations=())[source]¶
Bases:
objectResolve Modelo 720 foreign-asset rows from operator-supplied observations.
The resolver is deliberately repository-free, mirroring the existing
aggregate_foreign_assets_720shape-C surface: callers supply typed observations, the resolver delegates to the aggregate function for threshold semantics, then validates the declarable rows against the live M720 registry row-producer bindings.- Parameters:
observations (Iterable[ForeignAssetIngestObservation])
row_observations (Iterable[Modelo720RowObservation])
-
owned_sources:
ClassVar[tuple[BindingSourceKind,...]]¶
- resolve(context)[source]¶
Resolve the owned foreign-assets bindings for the calculation context.
- Return type:
- Parameters:
context (CalculationSourceContext)