aeat.application.review._edit module¶
Typed --set KEY=VALUE parser for record-edit commands.
The CLI exposes --set KEY=VALUE on ledger / invoice review-edit
commands. The canonical grammar:
ledger:
--set category=software,--set business.share=1.0,--set reference=invoice-1,--set comments=…,--set document.path=…invoice:
--set base=120.00,--set iva.rate=21,--set iva.amount=25.20,--set iva.category=…,--set retention.rate=15,--set retention.amount=18.00,--set payment.id=row_…,--set reference=…,--set comments=…,--set document.path=…
The CLI argv layer parses the raw strings; this module turns them
into typed EditClause records and binds them to per-scope
LedgerEditSpec / InvoiceEditSpec records. Each spec
validates its closed
key catalogue, coerces each value to its typed shape (Decimal,
Path, free text, foreign-key id), and exposes typed accessors the
orchestration layer reads instead of re-parsing strings at every
edit-application call site.
The orchestration that applies an EditSpec to a stored
aeat.domain.transactions.Transaction /
aeat.domain.invoices.Invoice /
aeat.domain.filing.ModeloDraft lives in the
application/workflow state overlay.
- class EditClause(**data)[source]¶
Bases:
BaseModelOne typed
KEY=VALUEclause from a--setflag.The
raw_valueis the trimmed string before per-key coercion; typed coercion happens on the owning scope’s spec.- Variables:
key – Lowercase, dotted-or-flat identifier.
raw_value – Trimmed value string.
- Parameters:
- key: str¶
- raw_value: str¶
- parse_edit_clause(raw)[source]¶
Parse one raw
KEY=VALUEstring into anEditClause.- Parameters:
raw (
str) – The rawKEY=VALUEtoken supplied by the operator.- Return type:
- Returns:
A validated
EditClausewith the parsed key and value.- Raises:
EditParseError – When the token is missing
=, has an empty key, or has an empty value.
- parse_edit_clauses(raw)[source]¶
Parse a sequence of
--setstrings intoEditClauserecords, preserving input order.- Return type:
- Parameters:
- class LedgerEditKey(*values)[source]¶
Bases:
StrEnumClosed catalogue of
aeat app ledger update --setkeys.- Variables:
CATEGORY – Spending / income category foreign-key id.
BUSINESS_SHARE – Decimal share in
[0, 1]of the row that is business-related (mixed-use accounting).REFERENCE – Free-text user reference (invoice number, ticket id, contract id).
COMMENTS – Free-text operator note.
DOCUMENT_PATH – Filesystem path to a supporting document.
- CATEGORY¶
- TREATMENT¶
- BUSINESS_SHARE¶
- REFERENCE¶
- COMMENTS¶
- DOCUMENT_PATH¶
- class InvoiceEditKey(*values)[source]¶
Bases:
StrEnumClosed catalogue of invoice-evidence edit keys.
- Variables:
BASE – Decimal taxable base amount.
IVA_RATE – Decimal IVA percentage (
21/10/4/0are the supported rates; the parser accepts any non-negative decimal so the grammar is not tied to a fixed rate table).IVA_AMOUNT – Decimal IVA amount.
IVA_CATEGORY – Free-text IVA category.
RETENTION_RATE – Decimal IRPF retention percentage.
RETENTION_AMOUNT – Decimal IRPF retention amount.
PAYMENT_ID – Foreign-key transaction id linked as the payment.
REFERENCE – Free-text invoice reference.
COMMENTS – Free-text operator note.
DOCUMENT_PATH – Filesystem path to the invoice file.
- BASE¶
- IVA_RATE¶
- IVA_AMOUNT¶
- IVA_CATEGORY¶
- RETENTION_RATE¶
- RETENTION_AMOUNT¶
- PAYMENT_ID¶
- REFERENCE¶
- COMMENTS¶
- DOCUMENT_PATH¶
- class LedgerEditSpec(**data)[source]¶
Bases:
BaseModelTyped
aeat app ledger update --setspec.- Variables:
clauses – Raw clauses in input order.
category – Resolved spending / income category id.
business_share – Resolved business share (0..1).
reference – Resolved free-text reference.
comments – Resolved free-text comments.
document_path – Resolved supporting-document path.
- Parameters:
- clauses: tuple[EditClause, ...]¶
- category: str | None¶
- reference: str | None¶
- comments: str | None¶
- document_path: Path | None¶
- classmethod from_strings(raw)[source]¶
Parse
--setarguments into a typed ledger spec.Returns a
LedgerEditSpecwith fields populated from the parsedkey=valueclause strings.- Return type:
- Parameters:
- class InvoiceEditSpec(**data)[source]¶
Bases:
BaseModelTyped invoice-evidence edit spec.
- Variables:
clauses – Raw clauses in input order.
base – Decimal taxable base.
iva_rate – Decimal IVA percentage.
iva_amount – Decimal IVA amount.
iva_category – Free-text IVA category.
retention_rate – Decimal IRPF retention percentage.
retention_amount – Decimal IRPF retention amount.
payment_id – Foreign-key transaction id.
reference – Free-text invoice reference.
comments – Free-text operator note.
document_path – Path to the invoice file.
- Parameters:
- clauses: tuple[EditClause, ...]¶
- base: Decimal | None¶
- iva_rate: Decimal | None¶
- iva_amount: Decimal | None¶
- iva_category: str | None¶
- retention_rate: Decimal | None¶
- retention_amount: Decimal | None¶
- payment_id: str | None¶
- reference: str | None¶
- comments: str | None¶
- document_path: Path | None¶
- classmethod from_strings(raw)[source]¶
Parse
--setarguments into a typedInvoiceEditSpec.- Return type:
- Parameters: