.. _anomalies:

Anomalies
=========

Different types of anomalies can occur, as a result of incorrect operation by the user or system crash:

#. cancellation of the sales order (Sales order missing)
#. account cancellation (Account missing)
#. cancellation of the service (Service missing)
#. cancellation of contact (Contact missing)
#. lineitem deletion (rare - system problem) (Lineitem missing)
#. not marked as executed (Passed not executed)
#. deactivating field :guilabel:`Create jobs for services` (Zombies)
#. sales order has got lacking jobs
#. sales order has got jobs in excess

| While the first 4 are caused by an incorrect user action,
| the 5th could be caused by a system error which for some reason eliminated a lineitem from the database.
| The sixth type of anomaly concerns jobs that have been executed, but their status is not set to :guilabel:`executed`;
| these jobs are the ones that should be billed.
| The seventh one, happens if the :guilabel:`Create jobs for services` option is deactivated,
| but some jobs have been modified, and therefore are not automatically deleted.
| The last two anomalies are issued if the number of jobs related to the sales order is different
| from the quantity of some service in the sales order.

| NB: if no job has been modified, upon disabling the :guilabel:`Create jobs for services`,
| all jobs related to the sales order are automatically deleted.

| To intercept all these types of anomalies,
| a CRON task is available that checks all jobs and notifies,
| via email or system notification, any anomalous jobs.
| To correct anomalies, a frontend module is available that lists all anomalous jobs of all types,
| allowing you to view/edit each anomalous job or its sales order.

.. image:: ../_images/anomalies_001.png
   :class: with-shadow
   :width: 400px
   :alt: anomalies