Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wellapp.ai/llms.txt

Use this file to discover all available pages before exploring further.

CompanyFinancial is a one-to-one “financial profile” extension of the Company entity that stores default ledger-account preferences (accounts receivable and payable) plus classifier provenance metadata indicating how and with what confidence those defaults were assigned. It is written exclusively by the internal classification pipeline — never directly by users — making it a read-only supporting record from the API consumer perspective. Each company may have at most one CompanyFinancial row (enforced by a UNIQUE constraint on company_pk). The source / confidence pair is governed by a database-level invariant: confidence is stored only when source = 'classifier_auto'; any transition away from the auto-classifier must clear confidence in the same write.
NamingValue
ObjectCompanyFinancial
Resource type (JSON:API type)company_financial
Collection / records root(not a records root)
REST base/v1/company-financials
Entity classCompanyFinancial
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

OperationMethod & pathStatus
ListGET /v1/company-financials🟡 Planned
RetrieveGET /v1/company-financials/{id}🟡 Planned
CreatePOST /v1/company-financials🟡 Planned
UpdatePATCH /v1/company-financials/{id}🟡 Planned
DeleteDELETE /v1/company-financials/{id}🟡 Planned

Data model

Attributes

FieldTypeRequiredConstraintsAllowed valuesDescription
company_financial_idstring (UUID)✅ YesUNIQUE; DEFAULT gen_random_uuid()Public UUID identifier for this record. Generated via gen_random_uuid() on insert. Used as the JSON:API resource id.
source🔒 system — enum (CompanyFinancialSourceEnum) | null⚪ NoNullable; native PostgreSQL enum ‘core_api.company_financial_source_enum’; CHECK company_financials_source_confidence_invariantclassifier_auto | classifier_suggested_human_confirmed | human_override | imported_chart_rule | migrationProvenance of the default ledger-account assignment. Set by the classification pipeline; never written directly by users. When ‘classifier_auto’, the confidence field must also be non-null (enforced by DB CHECK). Transitions away from ‘classifier_auto’ must clear confidence in the same write.
confidence🔒 system — decimal(4,3) stored as string | null⚪ NoNullable; DECIMAL(4,3); CHECK confidence IS NULL OR (confidence >= 0 AND confidence <= 1); CHECK company_financials_source_confidence_invariant (confidence non-null ↔ source=‘classifier_auto’)0.000 – 1.000Classifier confidence score in the range [0, 1] with three decimal places. Non-null only when source=‘classifier_auto’; any other source value requires this to be null (DB CHECK invariant). Stored as DECIMAL(4,3) and returned as a string by MikroORM.
created_at🔒 system — Date✅ YesNOT NULL; set once on createTimestamp of record creation. Set automatically on insert via MikroORM onCreate hook; never updated.
updated_at🔒 system — Date | null⚪ NoNullable on initial read before first update; set on create and updateTimestamp of the last update. Set on create and on every subsequent update via MikroORM onUpdate hook.
deleted_at🔒 system — Date | null⚪ NoNullableSoft-delete timestamp. Null means the record is active. All live queries must filter deleted_at IS NULL.

Relationships

NameTypeRequiredDescription
companyto-one (OneToOne → Company)✅ YesThe company this financial profile belongs to. Enforced unique at the DB level (company_pk UNIQUE), guaranteeing at most one CompanyFinancial per Company.
account_receivable_defaultto-one (ManyToOne → LedgerAccount)⚪ NoDefault ledger account applied to accounts-receivable postings for this company. Nullable; set by the chart-of-accounts classification pipeline.
account_payable_defaultto-one (ManyToOne → LedgerAccount)⚪ NoDefault ledger account applied to accounts-payable postings for this company. Nullable; set by the chart-of-accounts classification pipeline.

System-computed

  • company_financial_id — generated via gen_random_uuid() on insert; unique public identifier
  • created_at — set to new Date() on insert via MikroORM onCreate hook
  • updated_at — set to new Date() on insert and on every update via MikroORM onUpdate hook
  • deleted_at — set by the pipeline soft-delete path; null for active records
  • source + confidence — both fields are written exclusively by the chart-of-accounts classification pipeline (classifier_auto), human review confirmation flow (classifier_suggested_human_confirmed, human_override), rule import (imported_chart_rule), or data migration (migration); never set via a user-facing PATCH
  • DB CHECK company_financials_confidence_range — database enforces confidence ∈ [0,1] when non-null
  • DB CHECK company_financials_source_confidence_invariant — database enforces that confidence is non-null iff source=‘classifier_auto’; any pipeline transition clearing the auto-classifier must write confidence=null in the same statement

Example

{
  "data": {
    "type": "company_financial",
    "id": "b3e7c1a2-84fd-4f1e-9c20-3a77d5e82b01",
    "attributes": {
      "company_financial_id": "b3e7c1a2-84fd-4f1e-9c20-3a77d5e82b01",
      "source": "classifier_auto",
      "confidence": "0.921",
      "created_at": "2026-03-15T10:42:00.000Z",
      "updated_at": "2026-05-20T14:08:33.000Z",
      "deleted_at": null
    },
    "relationships": {
      "company": {
        "data": { "type": "company", "id": "e1c4a7b0-1234-4abc-b000-99aabb001122" }
      },
      "account_receivable_default": {
        "data": { "type": "ledger_account", "id": "d9f3a100-aaaa-4bbb-cccc-000011112222" }
      },
      "account_payable_default": {
        "data": { "type": "ledger_account", "id": "f2e1b200-bbbb-4ccc-dddd-111122223333" }
      }
    }
  }
}
Source: apps/api/src/database/entities/CompanyFinancial.ts · domain: financial-graph · tier: Supporting