application capa

application-ledger-accounts

Generic chart-of-accounts management (CRUD + per-type numbering) over the domain-ledger schema, gated by application-rbac UserPermissions.

Generic chart-of-accounts management (CRUD + per-type numbering) over the domain-ledger schema, gated by application-rbac UserPermissions.

Tierapplication
Roleunclassified (baselined)
Pathcrates/application/ledger-accounts
Edition2021
Targetsapplication_ledger_accounts
Public items5 across 1 module
Tests16

What it is for

Generic chart-of-accounts management API over the domain-ledger schema.

Lifted from the books consumer app (Sprint 03, US-3.1 + US-3.2). This is the chart-management surface (the list / CRUD, distinct from the per-account register which lives in application-ledger-reports). CRUD over the chart with two ratified invariants enforced server-side:

line item = a line_items row joined to a journal_entries row with status='posted'. We never accept account_type in PATCH — the type is set only at create — so a type change is structurally impossible (the field is not in the PATCH body). has_postings is surfaced so the UI can disable the field.

account. DELETE soft-deletes (sets deleted_at) ONLY when the account has ZERO line_items; otherwise 409 "account has transactions; deactivate instead". We NEVER hard-delete.

Mutability rules on PATCH: name always editable; code editable (must stay unique among non-deleted accounts); parent_id editable only to a parent that exists, is not deleted, shares the SAME account_type, and does not create a cycle (parent != self and the new parent is not a descendant of this account); description and is_active always editable.

Numbering (US-3.2): account_numbering holds per-type range_start, range_end, step. The next-free code is max(existing numeric code within the type's range) + step, clamped to range_end; when the type has no code yet, range_start. A consumer must apply ACCOUNT_NUMBERING_SCHEMA (or its own equivalent migration) so the account_numbering table exists and is seeded.

Routes (mount the router under whatever admin prefix the host uses)

NOTE: the GET /ledger/accounts/{code} register lives in application-ledger-reports. This router intentionally does NOT register a bare /ledger/accounts/{code} GET, only the management create/patch/delete + the next-code literal route.

Capabilities

crate root

Generic chart-of-accounts management API over the domain-ledger schema.

Item
pub const PERM_READ: & str
pub const PERM_WRITE: & str
pub const ACCOUNT_NUMBERING_SCHEMA: & str
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>,

seed (other)

Standard small-business chart of accounts (2026-08-13, operator: "a

Item
async fn apply_standard_small_business_coa(pool : & PgPool, tenant_id : Uuid,) -> Result <u32, sqlx::Error>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

application_ledger_accounts

Public surface

`crate root`

ItemWhat it is
pub const PERM_READ: & strPermission code required to READ the chart / numbering settings.
pub const PERM_WRITE: & strPermission code required to WRITE (create/patch/delete) accounts + settings.
pub const ACCOUNT_NUMBERING_SCHEMA: & strIdempotent DDL for the per-type account_numbering settings table plus the five default per-type range seeds
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>,Build the chart-management + numbering-settings sub-router

`seed`

ItemWhat it is
async fn apply_standard_small_business_coa(pool : & PgPool, tenant_id : Uuid,) -> Result <u32, sqlx::Error>Apply the standard small-business COA to tenant_id

No pub use re-exports: every item above is declared in this crate.

Boundary

Reaches into domain.

Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)application
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/application/ledger-accounts
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_application["application"] --> n_domain["domain"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`application-rbac`applicationnoalways
`domain-ledger`domainnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
axum^0.7multipartnoalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["application-ledger-accounts"]
  SELF -->|runtime| n_application_rbac["application-rbac"]
  SELF -->|runtime| n_domain_ledger["domain-ledger"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libapplication_ledger_accounts`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessyes
network I/Oyes
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
DATABASE_URLsrc/seed.rs
TEST_DATABASE_URLsrc/seed.rs

No workspace crate depends on this one.

Verification

KindCount
Unit tests16
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root400
seed100

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc55
Public modules with a //! block11
pie showData
    title Public items with rustdoc
    "Documented" : 5
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files2
Source lines1426
Code lines1104
Public API items5
Public modules1
Tests16
Examples0
Cargo features0
Direct runtime dependencies7
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 3
    "function" : 2
pie showData
    title Rust source composition
    "Code" : 1104
    "Blank or comment" : 322

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las application · Manual