Notas débito de cliente¶
Recurso client.income_debit_notes (endpoint income-debit-notes). Ver Notas débito de cliente.
alegrapy.income_debit_notes.IncomeDebitNotes
¶
Bases: Actions
Operations related to customer debit notes (notas débito de venta) endpoint.
__init__(client=None)
¶
Initialize the resource.
list(start=0, limit=30, **kwargs)
¶
List customer debit notes.
start and limit follow the Alegra-wide pagination convention (not
explicitly documented for /income-debit-notes). Ordering is not documented,
so passing order_field or order_direction raises ValueError.
iter_all(max_items=None, page_size=30, **filters)
¶
Iterate lazily over customer debit notes, validating filters eagerly.
reconcile(dedup_key, *, date, client_id=None, max_pages=10)
¶
Return the matching debit note carrying dedup_key on date, or None.
GET /income-debit-notes returns records in ascending id order and does
not support order_field or client_id, so this scans pages of 30 records
filtered by date until a short page ends the day. When client_id is
given, records without a matching client.id are skipped. If several notes
match, the one with the highest id among the scanned pages is returned. A
match is returned even when max_pages stopped the scan early: finding the
marker already proves the note exists.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
AlegraLookupIncompleteError
|
If no match was found and |
create_once(params, dedup_key, *, on_unverified='retry', verify_window=30.0, max_pages=10, precheck=True, with_outcome=False)
¶
Create a customer debit note at most once per dedup_key.
Flow:
- With
precheck, look for the marker onparams["date"]; return the note if found. If the day exceedsmax_pages * 30notes, :class:AlegraLookupIncompleteErrorpropagates and nothing is posted. - POST the payload. A non-ambiguous failure is raised unchanged.
- On an ambiguous failure (timeout, 5xx, dropped connection), verify during
verify_windowseconds. - If not found and
on_unverified="retry", POST once more and verify again; otherwise raise :class:AlegraUnverifiedCreateError. Never more than 2 POSTs.
When with_outcome=True, returns a :class:CreateOnceResult
(record, outcome) instead of the bare record.
Limitations
The lookup only covers params["date"]: a note created on another day
(for example a retry after midnight with a new date) is not found. Alegra
may reuse ids after deleting drafts (identity is the marker, never the id).
Stamping via stamp.generateStamp follows AlegraStampError handling
(unverified live).
void(id)
¶
Void a customer debit note by ID (POST /income-debit-notes/{id}/void).