============ Audit APIs ============ GreyMatter allows performing inventory audits in which manual count of selected inventory can be performed. Audits can be created either from the Manager Dashboard or via API. But, they can be started only from the Manager Dashboard. Audit Lifecycle =============== .. mermaid:: graph TD A[created] --> |Start Audit from MD| B[processing_start] B --> C[auditlines_created] C --> |Ongoing operations on
selected inventory/slot| D[waiting_on_conflict] C --> E[queued] D --> E E --> F[started] F --> |Some discrepancy found| G[pending_approval] F --> |No discrepancy| H[completed] G --> I[approved] G --> J[rejected] J --> K[sent_for_reaudit] Any --> L[cancelled] B --> |No matching
inventory found| M[aborted] A --> N[deleted] Any --> O[paused] class G node-failure class H node-success class I node-success class J node-failure class K node-success class L node-success class M node-failure class N node-success Audit Object ============ Audits can be of two types: location audit or SKU audit: * In a location audit, a list of slots or MSUs are specified which have to be audited, and all inventory present in those slots are audited. * In an SKU audit, product parameters are given, and all products matching those parameters are audited. All slots which have those products are brought to the audit station for this purpose. .. gm:data:: audit_id A unique auto-generated string that identifies the audit .. gm:data:: audit_param_name *required string, not unique* A string that will be displayed against the audit in manager dashboard .. gm:data:: audit_param_type Can be either ``location`` or ``sku``. .. gm:data:: audit_param_value .. gm:data:: locations_list *In case of a location audit* A list of strings denoting locations (either slot ids or MSU ids) **Example** .. sourcecode:: json { "locations_list": [ "014", "039", "001", "039.1.E.02", "014.1.E.05" ] } .. gm:data:: attributes_list *In case of SKU audit* A list of SKU selector objects. Each object has two properties: ``sku`` and ``attributes_sets``. **Example** .. sourcecode:: json { "attributes_list": [{ "attributes_sets": [{ "product_color": [ "Green" ] }], "sku": "3001" }] } Creating an Audit ================= .. http:post:: /api-gateway/integration-service/wms-integration/butler/api/audit :reqheader Content-Type: the request's content-type has to be passed in this header :reqheader Accept: the response content type depends on :mailheader:`Accept` header :reqheader Authorization: OAuth token to authenticate :statuscode 200: No error :statuscode 400: Bad data :json string audit_id: Unique auto-generated id of the created audit. This can be used for further requests related to the audit. .. container:: toggle .. container:: header **Example: Audit by Location** .. compound:: Request .. sourcecode:: http POST /api-gateway/integration-service/wms-integration/butler/api/audit HTTP/1.1 Host: example.com Content-Type: application/json Accept: application/json, text/javascript .. literalinclude:: create_audit_location_request.json :language: JSON Response .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 .. literalinclude:: create_audit_location_response.json :language: JSON .. container:: toggle .. container:: header **Example: Audit by SKU** .. compound:: Request .. sourcecode:: http POST /api-gateway/integration-service/wms-integration/butler/api/audit HTTP/1.1 Host: example.com Content-Type: application/json Accept: application/json, text/javascript .. literalinclude:: create_audit_sku_request.json :language: JSON Response .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 .. literalinclude:: create_audit_sku_response.json :language: JSON Delete an Audit =============== An audit can only be deleted before it is started. .. http:delete:: /api-gateway/integration-service/wms-integration/butler/api/audit/delete/(audit_id) :param audit_id: Id of the audit to be deleted. :reqheader Authorization: OAuth token to authenticate :statuscode 200: No error :statuscode 404: Audit id not found Audit Notifications =================== Audit notifications are generated for most :ref:`Audit Lifecycle` events. Audit Notifications Structure ----------------------------- All Audit notifications follow the generic notification format (see :ref:`Event Notifications`), and contain the relevant payload in the :gm:data:`notification.notification_data` attribute. .. gm:data:: auditNotificationData .. gm:data:: audit_id A unique auto-generated string that identifies the audit .. gm:data:: audit_param_name *required string, not unique* A string that will be displayed against the audit in manager dashboard .. gm:data:: audit_param_type .. versionadded:: 4.1 Can be either ``location`` or ``sku``. .. gm:data:: audit_status This denotes the status of the whole audit. See :ref:`Audit Lifecycle` for possible audit statuses. .. gm:data:: audit_data[] This is a list of objects of type :gm:data:`auditlineNotificationData`. .. gm:data:: auditlineNotificationData .. gm:data:: audit_line_id A unique auto-generated string that identifies this audit line. .. gm:data:: status This denotes the status of the audit line. .. gm:data:: pdfa_values This is an object containing the key value pairs denoting the product audited in this audit line. .. gm:data:: location This is a string representing the location id being audited in this audit line. .. gm:data:: expected_qty This is the expected quantity of the product above in the location above. .. gm:data:: actual_qty This is the actual quantity of the product kept in the location at the time the audit line finished. Note that if extra items were found at a location, and only some of it was allowed back into the location, then this quantity will contain the count of inventory finally kept in the slot. .. gm:data:: extra_qty This is the quantity of extra products removed from the slot either due to some exceptions like damaged or unscannable, or due to COG/algo restrictions, etc.. The removed items are kept in IRT bin. .. gm:data:: quantity_details .. versionadded:: 4.1 This is an object representing the breakup of found quantity and exceptions. .. gm:data:: good_qty This is the total good quantity (non-exceptional) found in the location. .. gm:data:: missing_qty This is the quantity calculated as missing from the slot. .. gm:data:: damaged_qty This is the number of items removed from the slot because they were reported as damaged. .. gm:data:: unscannable_qty This is the number of items removed from the slot because they were reported as unscannable. .. gm:data:: system_removed_qty This is the number of good (non-exceptional) extra items which were removed from the slot due to system limitations like COG, etc.. Audit Created Notification -------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: audit_created_notification.json :language: JSON Auditlines Created Notification ------------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: auditlines_created_notification.json :language: JSON Waiting on Conflict Notification -------------------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: waiting_on_conflict_notification.json :language: JSON Queued Notification ------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: queued_notification.json :language: JSON Started Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: started_notification.json :language: JSON Completed Notification ---------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: completed_notification.json :language: JSON Pending Approval Notification ----------------------------- .. container:: toggle .. container:: header Example with 1 auditline started and 1 pending approval .. literalinclude:: pending_approval_notification_1.json :language: JSON .. container:: toggle .. container:: header Example with 1 auditline completed and 1 pending approval .. literalinclude:: pending_approval_notification_2.json :language: JSON Rejected Notification --------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: rejected_notification.json :language: JSON Approved Notification --------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: approved_notification.json :language: JSON Sent for Re-audit Notification ------------------------------ .. container:: toggle .. container:: header Show/Hide .. literalinclude:: sent_for_reaudit_notification.json :language: JSON Cancelled Notification ---------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: cancelled_notification.json :language: JSON Deleted Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: deleted_notification.json :language: JSON Aborted Notification -------------------- .. container:: toggle .. container:: header Show/Hide .. literalinclude:: aborted_notification.json :language: JSON