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:

None

Parameters:
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.

Return type:

str

Parameters: