Skip to content
This repository was archived by the owner on Aug 11, 2026. It is now read-only.
This repository was archived by the owner on Aug 11, 2026. It is now read-only.

feat(organization-structure): add optional legal entities, organization units, hierarchies, and effective-dated assignments #749

Description

@ahliweb

Parent epic: #738
Depends on: #739, #746
Admission requirement: apply docs/awcms-mini/21_module_admission_governance.md before implementation.

Context

Many derived applications need reusable organization primitives: legal entity, department, branch, cost center, warehouse, operational location, or program unit. These are business/operational scopes inside a tenant; they are not tenant records and must not weaken tenant isolation.

This should be an optional reusable business-foundation capability, not a mandatory Core dependency and not an ERP implementation.

Objective

Add an optional, tenant-scoped organization-structure module with legal entities, typed organization units, effective-dated hierarchies, operational locations, and assignments exposed through capability ports.

Scope

Security and integrity requirements

  • Tenant and legal entity remain distinct concepts in schema, API, documentation, and tests.
  • All tenant tables use tenant_id, ENABLE + FORCE RLS, tenant-first indexes, default-deny permissions, and least-privilege roles.
  • Hierarchy writes use concurrency control and validate no self-parent/cycle/overlapping invalid periods.
  • Reorganization does not rewrite historical assignments or past hierarchy state.
  • Cross-tenant parent, location, legal entity, unit, and assignment references are rejected.
  • Delete behavior is soft-delete/deactivate by default; referenced/effective history is preserved.

Out of scope

  • Tenant provisioning or subscription management.
  • Chart of accounts, inventory, warehouse stock, HR, payroll, tax, organizational payroll positions, or government-specific organization rules.
  • Treating branch or legal entity as an RLS tenant boundary.

Acceptance criteria

  • Admission decision and ADR classify the module and dependencies before implementation.
  • Legal entity is demonstrably not identical to tenant in schema/API/docs/tests.
  • Unit types, units, locations, relationships, and assignments support effective dates and as-of queries.
  • Cycle, self-parent, invalid period, and cross-tenant relationships are rejected.
  • Reorganization preserves historical hierarchy/assignment views.
  • Hierarchy/scope capability port is usable by identity-access without direct table imports/writes.
  • CRUD/tree/list/search endpoints are paginated where appropriate, permission-gated, audited for high-risk changes, and accessible in UI.
  • Cross-tenant RLS/ABAC, no-cycle, concurrency, effective-date, reorganization, soft-delete, and capability-port tests pass.
  • OpenAPI/AsyncAPI, ERD/data dictionary, architecture/admission docs, threat model, admin/user guide, repository inventory, and changeset are updated.
  • bun run modules:dag:check, bun run api:spec:check, bun run security:readiness, tests, build, and bun run check pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:architectureStruktur repo, module contract, registryarea:databaseSchema, migration, pooling, RLSarea:frontendAstro SSR, islands, UI clientpriority:p1Prioritas tinggi - core domaintype:featureFitur baru sesuai doc 06

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions