The matching algorithm aims to match a provided AP Invoice total value with a set of un-invoiced receipt lines.
It completes the following steps:
1) Identify the matching range
As part of the Invoice ingest a gross total value and a net total value are imported.
The matching algorithm will select one of these as the matching target based on the 'TaxIncl' user code setting.
If TaxIncl is set to true it will use the gross total.
If TaxIncl is set to false it will use the net amount.
It then calculates an upper and lower limit for the matching range based on the tolerance user code settings.
The goal for the rest of the process is to find a collection of valid receipt lines that combined value falls within this matching range.
2) Receipt line filtering
The algorithm queries all un-invoiced receipt lines and then filters them based on the following conditions:
The receipt line must be associated with the ingested Supplier.
The receipt line must be associated with the ingested PONum.
The receipt line value must be less than the upper limit of the matching range.
If this filtering results in no valid receipt lines, the process returns an error.
3) Impossible matching checks
The algorithm confirms that the matching is technically possible by confirming that the below statements are true:
The sum of all the receipt line values is greater than the lower limit of the matching range
None of the receipt lines have a zero value.
4) Simple solution checks
The algorithm checks for the following simple solutions and returns them if found:
A single receipt line's value falls within the matching range.
The sum off all the receipt line values is within the matching range.
5) Matching process
The algorithm utilises a backtracking algorithm method to try and find possible sets of receipt lines whose total value falls within the matching range. The process is stopped when one of the following conditions is met:
Two valid solutions are found.
All possible combinations have been checked.
The process times out (1-minute limit).
6) Parse matching result
If the matching process returns only one valid solution, then this is created as an invoice.
For any other result an error is returned to the Auto AP Invoice Review screen.