cadrumo.domain.transactions.gross_validation module¶
Private gross-reconstitution diagnostic helpers for transactions.
- validate_gross_reconstitution(*, raw_amount, taxable_base, iva_amount, recargo_amount, iva_category, direction, category_id, irpf_category, effective_date)[source]¶
Validate the transaction’s gross/tax-substrate identity.
The model owns the fields, while this function owns the cohesive monetary invariant. Keeping the branches here makes the model validator a thin boundary adapter without changing the order or wording of any refusal.
- Return type:
- Parameters:
raw_amount (Decimal)
taxable_base (Decimal | None)
iva_amount (Decimal | None)
recargo_amount (Decimal | None)
iva_category (IvaCategory | None)
direction (TransactionDirection)
category_id (str | None)
irpf_category (str | None)
effective_date (date)
- gross_mismatch_detail(*, direction, category_id, recargo_amount, reconstituted, expected)[source]¶
Build the operator hint appended to a gross-reconstitution refusal.
Each branch names the one field that would legitimately explain the gap it sees, so the refusal is actionable rather than a bare arithmetic mismatch the operator has to decompose. The direction of the gap selects the vocabulary: a substrate above the cash is the withholding shape, and a substrate below it is the unrecorded-surcharge shape. Returns the empty string when no branch recognises the gap, which leaves the arithmetic to speak for itself rather than guessing.