Source code for cadrumo.domain.filing.software_identity
"""AEAT product-software identity carried by filing export envelopes."""from__future__importannotationsfromtypingimportAnnotatedfrompydanticimportBaseModel,Field,StringConstraints,model_validatorfromcadrumo.domain.calculations.registry.tax_id_formatimportSubjectTaxIdfrom...core.errors.hierarchyimportpydantic_validation_boundaryfrom...core.identity.digestimportContentDigestfrom...core.modelsimportSTRICT_FROZEN_CONFIGtypeAeatProgramIdentifier=Annotated[str,StringConstraints(min_length=4,max_length=4,pattern=r"^[A-Z0-9]{4}$"),]"""Exact four-byte AEAT-assigned program identifier for one export header."""
[docs]classAeatProductSoftwareEvidence(BaseModel):"""One immutable evidence item authorising an AEAT software identity. This is deliberately distinct from legal, taxpayer, presenter and filing producer evidence. A product developer must be explicitly authorised to emit its program and tax identifiers; neither identifier may be guessed from a filing participant. """model_config=STRICT_FROZEN_CONFIGreference:str=Field(min_length=1,max_length=512)digest:ContentDigest
[docs]classAeatProductSoftwareIdentity(BaseModel):"""Explicit product/software authority for an AEAT export header. No module-level instance is supplied. A caller must provide both the AEAT program identifier and the developer's validated Spanish tax identifier with reviewed evidence for every generated or emitted envelope. """model_config=STRICT_FROZEN_CONFIGprogram_identifier:AeatProgramIdentifierdeveloper_tax_id:SubjectTaxIdevidence:tuple[AeatProductSoftwareEvidence,...]=Field(min_length=1)@model_validator(mode="after")@pydantic_validation_boundarydef_require_exact_wire_widths(self)->AeatProductSoftwareIdentity:iflen(self.program_identifier.encode("ascii"))!=4:raiseValueError("AEAT program identifier must encode to exactly four ASCII bytes")iflen(self.developer_tax_id.encode("ascii"))!=9:raiseValueError("AEAT developer tax identifier must encode to exactly nine ASCII bytes")references=tuple(item.referenceforiteminself.evidence)iflen(set(references))!=len(references):raiseValueError("AEAT product software evidence must not repeat a reference")returnself