Ajustes de inventario¶
Recurso client.inventory_adjustments (endpoint inventory-adjustments) y subrecurso numerations. Ver Ajustes de inventario.
alegrapy.inventory_adjustments.InventoryAdjustments
¶
Bases: Actions
Operations related to inventory adjustments (/inventory-adjustments).
numerations
property
¶
Access inventory adjustment numerations sub-resource.
__init__(client=None)
¶
Initialize the resource.
list(start=0, limit=30, **kwargs)
¶
List inventory adjustments with optional ordering and filters.
iter_all(max_items=None, page_size=30, **filters)
¶
Iterate lazily over inventory adjustments, validating filters eagerly.
create(params, **kwargs)
¶
Create an inventory adjustment after validating date and items.
update(id, params, **kwargs)
¶
Update an inventory adjustment after validating provided date/items.
reconcile(dedup_key, *, date, warehouse_id=None, max_pages=10)
¶
Return the newest adjustment carrying dedup_key on date, or None.
Scans date in descending id order (newest first) up to max_pages
pages of 30 records. When warehouse_id is given, it is sent as a server
filter and re-checked client-side. Raises :class:AlegraLookupIncompleteError
only if max_pages full pages were scanned without finding a match.
create_once(params, dedup_key, *, on_unverified='retry', verify_window=30.0, max_pages=10, precheck=True, with_outcome=False)
¶
Create an inventory adjustment at most once per dedup_key.
Flow:
- With
precheck, look for the marker onparams["date"]; return the adjustment if found. If the day exceedsmax_pages * 30adjustments, :class:AlegraLookupIncompleteErrorpropagates and nothing is posted. - POST the payload. A non-ambiguous failure is raised unchanged.
- On an ambiguous failure, verify during
verify_windowseconds. - If not found and
on_unverified="retry", POST once more and verify again; otherwise raise :class:AlegraUnverifiedCreateError.
When with_outcome=True, returns a :class:CreateOnceResult
(record, outcome) instead of the bare record.
Limitations
The lookup covers only params["date"]. Because an adjustment moves
real stock, prefer on_unverified="raise" and quarantine
:class:AlegraUnverifiedCreateError instead of retrying blindly. Ids may be
reused after deletes.
alegrapy.inventory_adjustments.InventoryAdjustmentNumerations
¶
Bases: Actions
Operations for inventory adjustment numerations (/inventory-adjustments/numerations).
__init__(client=None)
¶
Initialize the numerations sub-resource.
list(start=0, limit=20, **kwargs)
¶
List inventory adjustment numerations (limit defaults to 20, max 30).
iter_all(max_items=None, page_size=20, **filters)
¶
Iterate lazily over inventory adjustment numerations.
create(params, **kwargs)
¶
Create a numeration (requires name and autoIncrement).