Once the line-state service has established a relation between document lines (if necessary), the lines are ready for matching, which is carried out by the decision service. The decision service essentially compares the related lines to determine if they match: If they do, the invoice containing the matched lines can be automatically approved – and if they do not, the service creates one or more discrepancy tasks for users to handle.

Decisions and evaluations made by the decision service are accessible via API for each document, which may be useful for traceability purposes and for gaining insight into why a task was (or was not) created for any given document. The open API also allows users to configure the default matching criteria per order profile, if necessary.

Checking required states

The first step in determining if related document lines match is to verify if the most basic requirements are met. This includes checking and comparing line graphs and profile IDs: When an invoice is processed by the decision service, the profile ID of the order-line root is fetched for every invoice line. Currently, the following profile IDs are available:

Name Profile States expected Comment
Regular 2WM urn:tradeshift.com:profile:BasicOrder:ver1.0 Ordered, Billed Basic profile (two-way matching), which is also the fallback option for unknown profiles
3WM urn:tradeshift.com:profile:BasicOrder:grn:ver1.0 Ordered, Received, Billed Standard three-way matching profile
Skip invoice matching urn:tradeshift.com:profile:BasicOrder:skip:ver1.0 Ordered Profile that can be used for e.g. inter-company transactions which are not supposed to raise exceptions in any case

At the same time, the invoice line graphs are analysed and compared to the corresponding profile IDs to determine if all expected document line states are present. If not, an exception is raised, and a Missing document lines task is created and assigned to the relevant user. This basically means that the user to whom this discrepancy task has been assigned must deal with the task in order for the invoice to pass matching and be accepted.

Note that invoices can contain order line roots with different profile IDs. Also, profile IDs can be adjusted using order changes.

Creating tasks

The Missing document lines task mentioned above represents the most basic requirement for matching to be succesful, but several other task types exist as well, in order to ensure that the right person or team gets to handle the discrepancies.

Tasks are created automatically whenever the decision service determines that a document has at least one discrepancy (also known as an exception), and the different task types depend on which discrepancies are present in the case at hand. The creation of tasks is based on the fixed hierarchy illustrated below:

The task-creation logic is as follows:

  1. If there is at least one discrepancy involving missing expected lines, a Missing document lines task is created. If not, then
  2. If there is at least one discrepancy involving insufficient quantities or incorrect unit of measure, a Quantity exception task is created. If not, then
  3. If there is at least one discrepancy involving unit price, currency or line amounts, a Price exception task is created. If not, then
  4. If there is at least one discrepancy involving tax amount or tax categories, a Tax exception task is created. If not, then
  5. The document is accepted.
No matter which discrepancy task is created, the task will be assigned to a relevant user in accordance with a clearly defined set of rules. Note that documents with different exceptions can be routed differently, as queues can be defined for each task type. This makes it possible to, for instance, route missing document lines to the requester, while tax discrepancies are routed to the tax department.