Karyo
Documentation/ Configuration

Company and Business Units

Karyo 2.1.1rendered at build time
On this page

Karyo uses Company > Business Unit > Facility. One installation has one Company. A Business Unit represents a 3PL customer or a division of a non-3PL Company. A Facility belongs to exactly one Business Unit. The term unit load is unrelated.

Company

Company is an independent singleton at id 1. It is not configuration key 0. GET /api/v1/company reads its name, immutable code and descriptive business-model label. PUT /api/v1/company changes its name and business-model label. The label grants no authority. Mutation requires organization.manage at the Company and an OPS principal.

Business Unit storage and API

business_units stores positive Business Unit rows. Client remains the internal Kotlin entity name; BusinessUnit is its type alias. There is one table and one public API, /api/v1/business-units. The response includes companyId = 1, the stable number, name, contact fields and state. number cannot change. Both name and number are unique.

ClientService checks uniqueness before writing. It also maps concurrent violations of idx_business_units_name and idx_business_units_number to the same 409 response. BusinessUnitService exposes these operations in Business Unit vocabulary.

Business Units have two states: ACTIVE (100) and INACTIVE (900). There is no delete route. Retirement preserves references and history. An inactive unit cannot receive new operational work. A new Business Unit has no Facility until an administrator creates one.

Administration authority

Every route declares one catalogue action. Stored grants, not provider roles, authorize it.

Route Action
GET /api/v1/business-units, GET /{id}, GET /references organization.read
GET /api/v1/business-units/consistency organization.manage
Business Unit mutations organization.manage
GET /api/v1/company organization.read
PUT /api/v1/company organization.manage

Reads follow TenantContext.reachesBusinessUnit. An out-of-reach id returns 404. Updates require organization.manage at the unit or Company node. Creation, retirement and reactivation require that action at the Company. A BUSINESS_UNIT_USER cannot create a unit or run the installation-wide consistency report.

OrganizationLookup supplies identity and parentage to other modules. It grants no authority. Operational scope comes from stored grants and the selected Facility, not identity affiliation. The console uses Administration > Business Units, at /admin/business-units.

Company configuration key

There is no SYS Business Unit row. Business Unit id 0 returns 404 on row routes. In a configuration layer, Business Unit 0 means the Company layer; it is not a Business Unit row. system_properties, home_layouts and document_templates retain that key.

GET /api/v1/business-units/references supplies configuration choices. It returns reachable Business Units. It also returns a Company entry with key 0 for an OPS principal with organization.read at the Company. The document-template selector keeps this entry viewable and uploadable. Writing Company templates still requires settings.manage at the Company.

Users' affiliation choices use /api/v1/users/affiliations, not configuration references. Warehouse setup names only an explicit Facility (targetFacilityId); its Business Unit follows from that Facility.

Consistency report

GET /api/v1/business-units/consistency reports danglingBusinessUnitIds and checkedAt. ClientRepository.findDanglingClientIds discovers base tables with business_unit_id. It reports ids without a business_units row. Company configuration and outbox key 0 do not count as dangling references. Views are excluded. The report does not check whether an existing unit is inactive. Operational rows store only facility_id; their immutable Facility parent supplies the Business Unit.

Fresh installation

A production installation starts with no Business Unit. Migration auth/V1602__business_unit_storage_and_principal_kind.sql retires SYS and renames storage. Earlier migrations remain unchanged. Generated Business Unit ids start at 100. ACME (1) and Globex (2) remain development and test fixtures only. The fixture_organizations Flyway placeholder controls those fixtures. The demo engine creates its configured Business Unit when seeded; its tree is separate from these fixtures.