api.services.catalog_reprise ============================ .. py:module:: api.services.catalog_reprise .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: api.services.catalog_reprise.OPERATION_TABLE_NAME api.services.catalog_reprise.PROPOSITION_TABLE_NAME api.services.catalog_reprise.OP_UNITS_FIELD api.services.catalog_reprise.OP_STATUS_FIELD api.services.catalog_reprise.OP_RECEPTION_DATE_FIELD api.services.catalog_reprise.OP_COMPANY_FIELD api.services.catalog_reprise.OP_PROPOSITION_FIELD api.services.catalog_reprise.OP_RECEIVED api.services.catalog_reprise.OP_OPERATIONAL_STATUS_FIELD api.services.catalog_reprise.OP_INVENTORY_DONE api.services.catalog_reprise.PROPOSITION_EQUIPMENT_FIELD api.services.catalog_reprise.UNIT_SNAPSHOT_FIELDS api.services.catalog_reprise.EQUIPMENT_FIELDS api.services.catalog_reprise.MAX_OPEN_OPERATIONS Functions --------- .. autoapisummary:: api.services.catalog_reprise.normalize_serial api.services.catalog_reprise.match_equipment_to_units api.services.catalog_reprise.equipment_view api.services.catalog_reprise.unit_view api.services.catalog_reprise.unit_snapshot api.services.catalog_reprise.list_open_operations api.services.catalog_reprise.get_operation api.services.catalog_reprise.get_unit api.services.catalog_reprise.mark_received api.services.catalog_reprise.restore_reception Module Contents --------------- .. py:data:: OPERATION_TABLE_NAME :value: 'Opération reprise' .. py:data:: PROPOSITION_TABLE_NAME :value: 'Propositions de reprises' .. py:data:: OP_UNITS_FIELD :value: 'Équipement rachetés' .. py:data:: OP_STATUS_FIELD :value: 'Statut logistique' .. py:data:: OP_RECEPTION_DATE_FIELD :value: 'Date de réception' .. py:data:: OP_COMPANY_FIELD :value: 'Entreprise vendeuse' .. py:data:: OP_PROPOSITION_FIELD :value: 'Propositions de reprises' .. py:data:: OP_RECEIVED :value: 'Appareils reçus' .. py:data:: OP_OPERATIONAL_STATUS_FIELD :value: 'Statut opérationnel' .. py:data:: OP_INVENTORY_DONE :value: 'Inventaire terminé' .. py:data:: PROPOSITION_EQUIPMENT_FIELD :value: 'Équipements' .. py:data:: UNIT_SNAPSHOT_FIELDS .. py:data:: EQUIPMENT_FIELDS .. py:data:: MAX_OPEN_OPERATIONS :value: 100 .. py:function:: normalize_serial(value: Any) -> str .. py:function:: 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). .. py:function:: equipment_view(record: dict[str, Any]) -> dict[str, Any] .. py:function:: unit_view(record: dict[str, Any]) -> dict[str, Any] .. py:function:: 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). .. py:function:: 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). .. py:function:: 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. .. py:function:: get_unit(gateway: api.services.catalog_sync.AirtableGateway, unit_id: str) -> dict[str, Any] .. py:function:: 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(). .. py:function:: 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.