Source code for aeat.domain.calculations.registry._applicability_modelo202
"""Modelo 202 applicability modality gate.The full-profile entry point reads :class:`TaxpayerProfile` entity type andINCN facts, then delegates to the raw-input modality rule used by calculation."""from__future__importannotationsfromdecimalimportDecimalfromenumimportStrEnumfromtypingimportAnnotatedfrompydanticimportBaseModel,Field,StringConstraintsfrom....coreimportSTRICT_FROZEN_CONFIGas_STRICT_FROZENfrom....core.external_constantsimportMODELO_202_ART_40_3_INCN_THRESHOLD_EURfrom...deadlines.taxpayer_modelimportEntityType,TaxpayerProfilefrom._idsimportLegalRefIdtype_OperatorReason=Annotated[str,StringConstraints(strip_whitespace=True,min_length=1)]_MODELO_202_MODALITY_LEGAL_REFS:tuple[LegalRefId,...]=("ley-27-2014:art-40","ley-27-2014:art-40-3",)"""Scoped registry citation keys grounding the Modelo 202 modality gate."""
[docs]classModelo202Modality(StrEnum):"""The pago-fraccionado modality available to a Modelo 202 filer."""ART_40_2_OPTIONAL="art_40_2_optional"ART_40_3_MANDATORY="art_40_3_mandatory"INCOMPLETE="incomplete"
[docs]classModelo202ModalityVerdict(BaseModel):"""The derived Modelo 202 modality verdict and its grounding."""model_config=_STRICT_FROZENmodality:Modelo202Modalityreason:_OperatorReasonlegal_refs:tuple[LegalRefId,...]=Field(min_length=1)
_MODELO_202_ART_40_3_MANDATORY_REASON=("Modelo 202 modalidad obligatoria: el artículo 40.3 de la LIS impone ""el método de la base imponible (3 / 9 / 11 primeros meses) cuando el ""importe neto de la cifra de negocios de los doce meses anteriores ha ""superado los 6.000.000 €. La modalidad del artículo 40.2 (cuota) no ""está disponible.")_MODELO_202_ART_40_2_OPTIONAL_REASON=("Modelo 202 modalidad por defecto: el artículo 40.2 de la LIS permite ""el método de la cuota (18 %) cuando el importe neto de la cifra de ""negocios de los doce meses anteriores no ha superado los 6.000.000 €. ""La modalidad del artículo 40.3 sigue siendo opcional.")_MODELO_202_INCOMPLETE_REASON=("No se puede determinar la modalidad del Modelo 202: el importe neto ""de la cifra de negocios de los doce meses anteriores no está ""declarado. Sin este dato el motor no infiere modalidad — un pago ""fraccionado equivocado es peor que una respuesta incompleta. Declare ""el INCN con 'aeat config profile edit'.")_MODELO_202_NOT_APPLICABLE_REASON=("Modalidad del Modelo 202 no aplicable: el perfil declarado no es un ""contribuyente del Impuesto sobre Sociedades. La modalidad solo se ""deriva para entidades jurídicas obligadas al pago fraccionado del IS.")
[docs]defmodelo_202_modality_from_inputs(*,entity_type:EntityType|None,incn_prior_12_months:Decimal|None,)->Modelo202ModalityVerdict:"""Derive the Modelo 202 modality from the two raw inputs (entity type + INCN). The SINGLE modality definition, callable WITHOUT a full :class:`TaxpayerProfile` so the calculation engine can evaluate it off the wizard-free profile projection (``record_to_path_values``) in a non-CLI context where the wizard ``SETUP_FLOW`` catalogue is not registered. No fork: :func:`derive_modelo_202_modality` delegates here. Returns: :class:`Modelo202ModalityVerdict`: Derived modality, explanation, and legal grounding. """ifentity_typeisNoneorentity_typeisnotEntityType.LEGAL_ENTITY:returnModelo202ModalityVerdict(modality=Modelo202Modality.INCOMPLETE,reason=_MODELO_202_NOT_APPLICABLE_REASON,legal_refs=_MODELO_202_MODALITY_LEGAL_REFS,)ifincn_prior_12_monthsisNone:returnModelo202ModalityVerdict(modality=Modelo202Modality.INCOMPLETE,reason=_MODELO_202_INCOMPLETE_REASON,legal_refs=_MODELO_202_MODALITY_LEGAL_REFS,)ifincn_prior_12_months>MODELO_202_ART_40_3_INCN_THRESHOLD_EUR:returnModelo202ModalityVerdict(modality=Modelo202Modality.ART_40_3_MANDATORY,reason=_MODELO_202_ART_40_3_MANDATORY_REASON,legal_refs=_MODELO_202_MODALITY_LEGAL_REFS,)returnModelo202ModalityVerdict(modality=Modelo202Modality.ART_40_2_OPTIONAL,reason=_MODELO_202_ART_40_2_OPTIONAL_REASON,legal_refs=_MODELO_202_MODALITY_LEGAL_REFS,)
[docs]defderive_modelo_202_modality(profile:TaxpayerProfile)->Modelo202ModalityVerdict:"""Derive the Modelo 202 pago-fraccionado modality and return a :class:`Modelo202ModalityVerdict`. Reads :class:`TaxpayerProfile` entity type and INCN, then delegates the rule to :func:`modelo_202_modality_from_inputs` (the single definition). """returnmodelo_202_modality_from_inputs(entity_type=profile.entity_type,incn_prior_12_months=profile.incn_prior_12_months,)