aeat.domain.manuals._rule_id module

Deterministic rule-id generation for aeat.domain.manuals.

Rule identifiers are locked at the schema layer so subsequent extraction runs cannot collide with each other. The generator is pure and fully deterministic given its inputs.

generate_rule_id(*, manual_id, year, part, chapter_id, section_id, ordinal)[source]

Return the deterministic identifier for a rule.

The shape is {manual_id}-{year}-[{part}-]{chapter_id}-{section_id}-rule{ordinal:04d}, where the part segment is collapsed for ManualPart.SINGLE so IVA rule IDs stay compact.

Parameters:
  • manual_id (ManualId) – Handbook identifier.

  • year (int) – Tax year the manual applies to.

  • part (ManualPart) – Volume split within the year.

  • chapter_id (str) – Stable kebab-case chapter identifier.

  • section_id (str) – Stable kebab-case section identifier.

  • ordinal (int) – 1-indexed position of the rule within its section.

Return type:

str

Returns:

A deterministic lower-case kebab-case rule identifier.

Raises:

ManualValidationError – If ordinal is not a positive integer or any of the identifier components is empty after slugging.