api.services.catalog_reprise

Reprises as the source of receiving batches (product-creation spec §6A, rule 9).

An accepted reprise is an Opération reprise whose Units already exist in Toutes les unités (Équipement rachetés), created by the existing reprise process, usually without a Variation. The app seeds a receiving batch from it: one expected line per pre-created Unit, enriched with the equipment details of the linked Proposition de reprise when there is one. Equipment rows and Units have no direct link in Airtable: they are matched here by serial number.

The Unit’s Statut logistique reprise is a lookup of the operation’s Statut logistique: the received status is set on the operation.

Attributes

Functions

normalize_serial(value) → str

match_equipment_to_units(units, equipment) → tuple[dict[str, dict[str, Any]], list[dict[str, Any]]]

One-to-one by serial number, exact matches first; then, when exactly

equipment_view(record) → dict[str, Any]

unit_view(record) → dict[str, Any]

unit_snapshot(fields) → dict[str, Any]

Current values of the fields the intake flow writes, absent ones as

list_open_operations([query]) → list[dict[str, Any]]

Opérations reprise to receive, newest first, for the picker: the

get_operation(gateway, operation_id) → dict[str, Any]

The operation, its pre-created Units (each with its matched equipment

get_unit(gateway, unit_id) → dict[str, Any]

mark_received(gateway, operation_id[, today]) → dict[str, Any]

Set the operation to Appareils reçus (and its reception date when

restore_reception(gateway, operation_id, previous) → None

Undo mark_received(), unless someone changed the operation since.

Module Contents

api.services.catalog_reprise.OPERATION_TABLE_NAME = 'Opération reprise'
api.services.catalog_reprise.PROPOSITION_TABLE_NAME = 'Propositions de reprises'
api.services.catalog_reprise.OP_UNITS_FIELD = 'Équipement rachetés'
api.services.catalog_reprise.OP_STATUS_FIELD = 'Statut logistique'
api.services.catalog_reprise.OP_RECEPTION_DATE_FIELD = 'Date de réception'
api.services.catalog_reprise.OP_COMPANY_FIELD = 'Entreprise vendeuse'
api.services.catalog_reprise.OP_PROPOSITION_FIELD = 'Propositions de reprises'
api.services.catalog_reprise.OP_RECEIVED = 'Appareils reçus'
api.services.catalog_reprise.OP_OPERATIONAL_STATUS_FIELD = 'Statut opérationnel'
api.services.catalog_reprise.OP_INVENTORY_DONE = 'Inventaire terminé'
api.services.catalog_reprise.PROPOSITION_EQUIPMENT_FIELD = 'Équipements'
api.services.catalog_reprise.UNIT_SNAPSHOT_FIELDS
api.services.catalog_reprise.EQUIPMENT_FIELDS
api.services.catalog_reprise.MAX_OPEN_OPERATIONS = 100
api.services.catalog_reprise.normalize_serial(value: Any) → str
api.services.catalog_reprise.match_equipment_to_units(units: list[dict[str, Any]], equipment: list[dict[str, Any]]) → tuple[dict[str, dict[str, Any]], list[dict[str, Any]]]

One-to-one by serial number, exact matches first; then, when exactly one Unit and one equipment row are left and one of them has no serial (a Unit created without it, usually), they are the same item. Returns ({unit_id: equipment}, unmatched equipment).

api.services.catalog_reprise.equipment_view(record: dict[str, Any]) → dict[str, Any]
api.services.catalog_reprise.unit_view(record: dict[str, Any]) → dict[str, Any]
api.services.catalog_reprise.unit_snapshot(fields: dict[str, Any]) → dict[str, Any]

Current values of the fields the intake flow writes, absent ones as None (an update with None clears the field).

api.services.catalog_reprise.list_open_operations(query: str = '') → list[dict[str, Any]]

Opérations reprise to receive, newest first, for the picker: the operations team sets « Appareils reçus » when the equipment arrives; an operation whose inventory is finished (« Inventaire terminé ») is history (the app also hides those it already received).

api.services.catalog_reprise.get_operation(gateway: api.services.catalog_sync.AirtableGateway, operation_id: str) → dict[str, Any]

The operation, its pre-created Units (each with its matched equipment row, if any) and the equipment rows matching no Unit.

api.services.catalog_reprise.get_unit(gateway: api.services.catalog_sync.AirtableGateway, unit_id: str) → dict[str, Any]
api.services.catalog_reprise.mark_received(gateway: api.services.catalog_sync.AirtableGateway, operation_id: str, today: datetime.date | None = None) → dict[str, Any]

Set the operation to Appareils reçus (and its reception date when empty). Returns the previous values, for restore_reception().

api.services.catalog_reprise.restore_reception(gateway: api.services.catalog_sync.AirtableGateway, operation_id: str, previous: dict[str, Any]) → None

Undo mark_received(), unless someone changed the operation since.