# Company selection
At this step, the booking manager chooses a company in which the appointment will be booked. To that end, a list of companies is displayed, following these rules:
RULES
- All the companies in the list are close enough to intervene on the appointment address.
- The companies are ordered by priority descending.
To arrive at that result, Calizy needs to:
- filter the companies, to only keep the ones that can intervene
- order the filtered companies by priority
# Companies filtering
Two filters are used to determine which companies can intervene.
# Filter by company status
Calizy only keeps the companies that have an "active" status. All the other companies are straight away excluded from the list.
# Filter by appointment address
All Calizy companies have a geographic zone, which is a list of postcodes in which the company can intervene. To learn more on geographic zones, see LINK TO GEO ZONES. Calizy only keeps the companies whose geographic zone includes the appointment postcode.
# Fallback
It's possible that 0 company will remain after these 2 filters, for example if the appointment is located in a very remote place. If 0 "active" company covers the appointment's postcode, then an error message is displayed to the booking manager, telling him to contact support.
# Companies ordering
Companies are ordered by priority descending. This priority is computed for each filtered company, by taking into account:
- an arbitrary priority set by IMA, let's call it
priority_ima - the distance between the appointment and the company (the closer the better), let's call it
priority_distance
# priority_ima
This parameter is set by IMA managers in Coheris, and is then assigned to the Calizy companies via a nightly synchronization. It's an integer, ranging from 0 to 444.
# priority_distance
For all the companies that can intervene, Calizy computes the geographic distance (as the crow flies) between the company and the appointment address.
With this value, we assign a priority_distance to each company, according to this table:
| Distance to the appointment (kms) | priority_distance |
|---|---|
<= 30 | 5 |
> 30 && <= 60 | 4 |
> 60 && <= 90 | 3 |
> 90 && <= 120 | 2 |
> 120 | 1 |
# Final priority computation
For each company, Calizy computes priority = priority_distance * 100 + priority_ima.
The companies that can intervene are then sorted by priority descending. If 2 companies have the same priority, then we sort them by distance to the appointment (ascending).