33.2 Contacts

In LedgerSMB, a ”Contact” is either a person, a company or a robot.

The person, company or robot has a uniquely corresponding entity, where it is assigned an entity_class such as Vendor, Customer, Employee, Robot. This class is a marker only. It has no bearing on what the Contact is able to do, so, for example, a Contact marked as ”Employee” can also act as a vendor who we purchase from and a customer who we sell things to.

The entity may be further extended such that it becomes:

A LedgerSMBuser, by linking with the users table. The schema allows the Contact to link with multiple LedgerSMBusers (so a person may have one username they use for general accounting and another they use for administrative functions), though the UI does not currently support this. A user belongs only to a single Contact entity.

An employee, by linking with entity_employee. This is a 1:1 relationship. Table entity_employee is used to extend the entity. Note that employee has start and end dates, but there is no provision for multiple employments, such as when an employee leaves and is later re-employed by the company.

The Contact entity may have multiple entity_credit_accounts associated, which can be classed as either ”Vendor or ”Customer”. These do affect what a Contact is able to do. For example, to act as a vendor who we purchase from, the Contact must have an entity_credit_account of class ”Vendor”. For us to be able to raise a sales invoice to the Contact, it must have an
entity_credit_account of class ”Customer”.

A Contact may have multiple entity_credit_accounts of each class, for example it may have multiple ”Customer” accounts corresponding with different divisions of a single company to be invoiced separately.

The entity_credit_account may optionally be assigned a business type.

A Contact may be known by multiple names through the entity_other_name table, though this is not yet supported in the UI.

Multiple notes, locations (being addresses) or contact elements (being a single telephone number, e-mail address, social media handle or similar) may be associated with either the overall Contact, or individual entity_credit_accounts.

An summary outline of the related database tables is as follows:

company -|
  robot -|--entity
 person -|   |
             |--users
             |--entity_employee
             |--entity_other_name
             |--entity_note
             |--entity_to_contact
             |--entity_to_location
                 |-- location
             |--entity_credit_account
                 |-- eca_to_location
                      |-- location
                 |--eca_to_contact
                 |--eca_note
                 |--person
                 |--business