Source code for cadrumo.domain.calculations.registry.ledger_binding_selector_support
"""Shared selector primitives for ledger aggregation binding families."""from__future__importannotationsfromcollections.abcimportMappingfromenumimportStrEnumfromtypingimportLiteralfrom....core.casilla_idimportCasillaId,validated_casilla_id
[docs]defmapping_lacks_fact(value:object)->bool:"""Whether *value* is a mapping with no ``fact`` key."""returnisinstance(value,Mapping)and"fact"notinvalue
[docs]defcasilla_id_set(surface:str,*values:object)->frozenset[CasillaId]:"""Validate a closed family of registry casilla identifiers."""returnfrozenset(validated_casilla_id(value,surface=surface)forvalueinvalues)
[docs]classLedgerIncomeFact(StrEnum):"""A figure a ledger-income binding can total out of matched rows."""INGRESOS_INTEGROS_SUM="ingresos_integros_sum"CASH_RECEIVED_SUM="cash_received_sum"TAXABLE_BASE_SUM="taxable_base_sum"WITHHELD_AMOUNT_SUM="withheld_amount_sum"
LedgerIncomeFactValue=Literal[LedgerIncomeFact.INGRESOS_INTEGROS_SUM,LedgerIncomeFact.CASH_RECEIVED_SUM,LedgerIncomeFact.TAXABLE_BASE_SUM,LedgerIncomeFact.WITHHELD_AMOUNT_SUM,]"""Every income fact, for a selector that can total any of them."""ImpatriadoLedgerIncomeFact=Literal[LedgerIncomeFact.INGRESOS_INTEGROS_SUM,LedgerIncomeFact.CASH_RECEIVED_SUM,]"""The income facts the impatriado regime's bindings actually total.A genuine narrowing, not a separate vocabulary: the two tokens mean exactly what theymean for renta income, and the impatriado selector simply has no binding that needs ataxable base or a withheld amount. Rooted here rather than spelled out in its ownmodule, where the pair looked unrelated to the four it is drawn from."""
[docs]classLedgerIvaFact(StrEnum):"""A figure an IVA ledger binding can total out of matched rows."""IVA_AMOUNT_SUM="iva_amount_sum"BASE_AMOUNT_SUM="base_amount_sum"RECARGO_AMOUNT_SUM="recargo_amount_sum"
LedgerIvaFactValue=Literal[LedgerIvaFact.IVA_AMOUNT_SUM,LedgerIvaFact.BASE_AMOUNT_SUM,LedgerIvaFact.RECARGO_AMOUNT_SUM,]"""Every IVA fact, for a selector that can total any of them."""OssIossLedgerFact=Literal[LedgerIvaFact.IVA_AMOUNT_SUM,LedgerIvaFact.BASE_AMOUNT_SUM,]"""The IVA facts an OSS/IOSS binding totals.Narrower because recargo de equivalencia does not arise in the one-stop-shop regimes,so a recargo total is not merely unused there -- it is not a thing that exists."""