Manual N-line balanced journal-entry write API (draft/posted, draft-only edit/delete) over the domain-ledger schema, gated by forge-rbac UserPermissions.
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/ledger-entries |
| Edition | 2021 |
| Targets | application_ledger_entries |
| Public items | 7 across 0 modules |
| Tests | 6 |
What it is for
Manual N-line balanced journal-entry write API over the domain-ledger schema, gated by application-rbac UserPermissions.
Routes (mount under the host's admin prefix, e.g. /api/v1/admin):
POST /ledger/entriesgatedPERM_WRITE— create draft|postedGET /ledger/entries/{id}gatedPERM_READ— fetch entry + linesPATCH /ledger/entries/{id}gatedPERM_WRITE— edit a DRAFT (header
and/or lines); may also post it (status:"posted"). Posted → 409.
DELETE /ledger/entries/{id}gatedPERM_WRITE— delete a DRAFT.
Posted → 409 (corrections are reversals; INV-1).
Posting is enforced twice: a friendly service-level balance check (Gate 1.5 A3) and the DB journal_entries_check_balance trigger as the backstop. All entry kinds share one shape + a kind tag (Gate 1.5 A2); drafts may be unbalanced/incomplete (Gate 1.5 B4), only posting requires balance.
Capabilities
crate root
Manual N-line balanced journal-entry write API over the domain-ledger
| Item |
|---|
pub const PERM_READ: & str |
pub const PERM_WRITE: & str |
pub const PERM_REVERSE: & str |
pub const PERM_SETTINGS_WRITE: & str |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
ReverseOutcome
Manual N-line balanced journal-entry write API over the domain-ledger
| Item |
|---|
pub enum ReverseOutcome |
async fn reverse_in_tx(tx : & mut sqlx::Transaction <'_, sqlx::Postgres>, tenant_id : Uuid, original_id : Uuid, reversal_date : Option <& str>, memo : Option <& str>,) -> Result <ReverseOutcome, 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
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub const PERM_READ: & str | Permission to read journal entries. |
pub const PERM_WRITE: & str | Permission to write (create/edit/delete/post) journal entries. |
pub const PERM_REVERSE: & str | Dedicated permission to reverse (void) a posted entry |
pub const PERM_SETTINGS_WRITE: & str | Permission to change the ledger org settings (the reversal policy) |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | Build the journal-entry write sub-router. |
pub enum ReverseOutcome | Outcome of reverse_in_tx. |
async fn reverse_in_tx(tx : & mut sqlx::Transaction <'_, sqlx::Postgres>, tenant_id : Uuid, original_id : Uuid, reversal_date : Option <& str>, memo : Option <& str>,) -> Result <ReverseOutcome, sqlx::Error> | Reverse a posted entry inside an existing transaction: lock it (FOR UPDATE), require posted + not-already-reversed, insert a balanced reversing entry (lines swapped), post it, and set reversed_by_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) |
| Location | crates/application/ledger-entries |
| 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.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-rbac` | application | no | always |
| `domain-ledger` | domain | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
axum | ^0.7 | multipart | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["application-ledger-entries"] 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
| Kind | Name | Source |
|---|---|---|
| lib | application_ledger_entries | `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
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | yes |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 6 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 7 | 0 | 0 |
What the tests establish, by name:
check_postable_requires_two_balanced_lines—src/lib.rsparse_write_status_allows_draft_posted_only—src/lib.rsreverse_allowed_enforced_requires_reverse_perm—src/lib.rsreverse_allowed_relaxed_overrides_with_write—src/lib.rssums_split_by_direction—src/lib.rsvalid_date_accepts_iso_and_rejects_junk—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 7 | 7 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 7
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 1143 |
| Code lines | 982 |
| Public API items | 7 |
| Public modules | 0 |
| Tests | 6 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 7 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"constant" : 4
"enum" : 1
"function" : 2
pie showData
title Rust source composition
"Code" : 982
"Blank or comment" : 161
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.