aeat.domain.iva._lookup module

Lookup helpers for IVA registry data.

lookup_rate() resolves EUMemberState and IvaRateKind queries into IvaRateRecord records loaded by aeat.domain.iva.load_iva_rate_table(); cite() renders IvaCategory catalogue citations from an IvaCatalogue.

lookup_rate(member_state, kind, on_date)[source]

Return the aeat.domain.iva.IvaRateRecord matching the supplied query.

Iterates the rates registered for member_state in aeat.domain.iva.IVA_RATE_TABLE and returns the first record whose aeat.domain.iva.IvaRateRecord.kind matches kind and whose effective window covers on_date.

Parameters:
  • member_state (EUMemberState) – The EU member state whose rate is requested.

  • kind (IvaRateKind) – The rate tier (general / reduced / …).

  • on_date (date) – The effective date for the lookup.

Return type:

IvaRateRecord

Returns:

The matching aeat.domain.iva.IvaRateRecord.

Raises:

IvaRateNotFoundError – If no registered rate satisfies the query.

cite(category, *, on=None, catalogue=None)[source]

Return the canonical citation string for category.

Uses the first aeat.domain.iva.IvaCitation on the matching regulation as the canonical reference. The result includes a human-readable source label and the article reference so it is self-identifying when written to a log line.

Parameters:
  • category (IvaCategory) – The IVA category whose canonical citation is requested.

  • on (date | None) – Effective date used to resolve the committed catalogue.

  • catalogue (IvaCatalogue | None) – Optional catalogue override.

Return type:

str

Returns:

A canonical citation string such as "Ley 37/1992, Art. 90.Uno <quoted_text>".

Raises:

IvaCatalogueError – If both catalogue and on are None.