Journals and Journal Entries (JRN)

The jrn submodule of acc is the heart of double-entry bookkeeping: it owns the journals (one per type — bank, cash, sales, purchase, memorandum), the immutable journal entries posted to those journals, and the lines (debit/credit postings against ledger accounts) that make up each entry. Every other accounting submodule routes its postings through this one. It depends on acc.bas for period gating, acc.gld for the ledger accounts, acc.bnk for bank-statement-line links, acc.doc for source-document links, acc.cst for cost-unit allocation, acc.vat for the VAT code on lines, cat.itm for the cost item, com.par / com.org for partner/company, and on the acc.inv extension interfaces (HasInvoice, HasInvoiceLine) for invoice posting.

Concepts

Journal

A named ledger book of a particular type (bank, cash, sales, purchase, memorandum, system memorandum). Each journal can have a default ledger account (used for balance lookups) and a default ledger account for currency differences.

Journal Entry

An immutable transaction posted to a journal. Carries the document the entry was created for, the financial period it posts to, and the lines that balance it. Goes through DraftConfirmedPosted to Ledger lifecycle.

Journal Entry Line

One debit or credit line of an entry, posting an amount in the transaction currency and the internal currency against a single ledger account, optionally tagged with partner, item, project unit, inventory unit, and VAT code.

Journal Entry IC

An intercompany journal-entry container that holds the matching ledger account on the receivable-creditor (RC) side; multiple JournalEntry rows in different companies can share one JournalEntryIc.

Journal Entry Type

What kind of transaction the entry represents — invoice sent/received, invoice payment initiated/received, money spent/received, purchase receipt, sales delivery, or memorandum.

Journal Entry Source

Whether the entry was entered manually or generated by the system from a downstream flow.

Entities

JRN entities

Journal (Journal)

A named ledger book.

FieldDescription

code

Business key (up to 4 characters).

journalType

Journal type — see Journal Types below (final).

description

Human-readable name.

ledgerAccount

Optional default account.

currency

Optional default currency.

ledgerAccountCurrencyDifferences

Optional ledger account used to book currency differences.

Journal Types (JournalType)

CodeNameUsed for

BNK

Bank

Bank statement and outbound payment postings.

CSH

Cash

Cash transactions.

SLS

Sales

Sales-invoice and sales-delivery postings.

PUR

Purchase

Purchase-invoice and purchase-receipt postings.

MEM

Manual Memorandum

Manually entered correction/adjustment entries.

MES

System Memorandum

System-generated correction/adjustment entries.

Journal Entry (JournalEntry)

An immutable transaction posted to a journal.

FieldDescription

journalEntryId

Business key — generated transaction id.

journalEntryIc

Optional intercompany container.

journalEntryType

The kind of transaction — see Journal Entry Types below (final).

journalEntrySource

Whether the entry was entered manually or generated (final).

documentLine

Optional document line the entry was created for (final).

documentDate

Optional document date (final).

documentId

Optional document id (final).

partner

Optional counter-party (final).

bankStatementLine

Optional originating bank-statement line (final).

journal

The journal the entry posts to (set while in draft).

journalCompany

The owning finance company (set while in draft).

journalDate

Posting date (set while in draft).

description

Free-form description (set while in draft).

postToYear / postToPeriod

The financial period the entry posts to (set while in draft).

reversalOfJournalEntry

Optional reverse-link to the entry this one reverses.

reversedByJournalEntry

Optional forward-link to the entry that reverses this one.

confirmed

Lifecycle flag.

postedToLedger

Lifecycle flag.

biJournalEntryStatus

Derived status — see Journal Entry Statuses below.

A validation rule enforces that any reversal/reversed-by entry shares the partner with this one, and that the bank-statement-line’s company equals the journal company.

Journal Entry Sources (JournalEntrySource)

CodeNameMeaning

M

Manual

Entered by a user.

S

System

Generated by a downstream flow.

Journal Entry Types (JournalEntryType / JournalEntryLineType)

CodeNameMeaning

IVSN

Invoice Sent

Sales invoice posting.

IVRC

Invoice Received

Purchase invoice posting.

IPIN

Invoice Payment Initiated

Outbound payment of an invoice.

IPRC

Invoice Payment Received

Inbound payment of an invoice.

MNSP

Money Spent

Outbound money movement (non-invoice).

MNRC

Money Received

Inbound money movement (non-invoice).

TRPR

Purchase Receipt

Inventory-side posting for a purchase receipt.

TRSD

Sales Delivery

Inventory-side posting for a sales delivery.

MEMO

Memorandum

Manual or system memorandum.

Journal Entry Statuses (JournalEntryStatus)

CodeNameMeaning

DR

Draft

Editable; not yet confirmed.

CF

Confirmed

Locked; ready to post to the ledger.

PS

Posted to Ledger

Archived; balances have been updated.

Journal Entry Line (JournalEntryLine)

One debit or credit line of an entry.

FieldDescription

journalEntry

Owning entry (composite business key with lineNumber).

lineNumber

Line number within the entry (a TransactionLineNumber).

referenceDocumentLine

Optional document line the posting is about (final).

ledgerAccount

The account being posted to.

currencyExt

Optional foreign currency.

currencyRate

Optional currency rate used for the conversion.

debitAmountInt / debitAmountExt

Optional debit amount in internal/foreign currency.

creditAmountInt / creditAmountExt

Optional credit amount in internal/foreign currency.

partner

Optional partner the line is for.

costItem

Optional product item.

costQuantityInt

Optional quantity in the item’s UoM.

projectUnit

Optional project cost-unit.

inventoryUnit

Optional inventory cost-unit.

inventoryQuantityInt

Optional inventory quantity.

vatCode

Optional VAT code (informative).

biPostingAmountInt

Derived posting amount in the internal currency.

A validation rule enforces that the line’s partner does not equal the entry’s partner (intercompany invariant) and that any inventory- or project-unit’s owning partner equals the line’s partner.

Journal Entry IC (JournalEntryIc)

An intercompany container.

FieldDescription

journalEntryIcId

Business key — generated transaction id.

ledgerAccountRc

The "RC" (receivable-creditor) ledger account used as the bridge between the participating entries (final).

journalEntries

The entries that share this container.

Functionality

Journal-entry creation

JournalEntryWriterService is the seam other modules call when they need to post. It builds a journal entry from an invoice abstraction (any type implementing acc.inv.extension.HasInvoice), populates the lines from the invoice’s lines (HasInvoiceLine), runs them through the line-completion pipeline (JournalEntryLineComplementor, JournalEntryLineBuilder), validates the resulting entry against JournalEntryValidator, and persists it. It can also remove an entry that was created for an invoice.

Validation

Three validators enforce the business invariants before an entry is allowed to confirm:

JournalEntryValidator

Cross-line and journal-level checks (line count, allowed entry types per journal type, period gating, total debit/credit balance).

JournalEntryLineValidator

Per-line checks (debit/credit XOR rule, exchange-rate bounds, maximum line amount, allowed account types for the journal type).

JournalEntryIcValidator

Cross-entry checks for intercompany containers.

The hard-coded bounds live in JournalConstant: exchange rate must be inside (1e-6, 999999.0), per-line amount must be ≤ 9 999 999.99, and an entry must have at most 999 lines. The same constant maps each journal type to its allowed entry types (e.g. a BNK journal accepts only IPIN, IPRC, MNSP, MNRC).

Confirm / unconfirm and post-to-ledger

The confirm and confirmUndo write actions on JournalEntryViewModel flip the entry between Draft and Confirmed. The postToLedger and postToLedgerUndo actions then move it between Confirmed and Posted-to-Ledger; posting updates the per-(account, company, year) LedgerAccountBalance rows and archives the entry. JournalEntryActionWriter is the action handler the framework dispatches to.

Public API

ACC_JRN_QueryApi and ACC_JRN_CommandApi

This submodule does not provide query- or command-API classes from its hand-written package. Other modules read journals and entries through the standard generated readers and post entries by calling JournalEntryWriterService (an internal service that other modules in the acc boundary inject).

ViewModel actions

ActionUser-visible effect

confirm (on Journal Entry)

Locks a draft entry after the validators pass.

confirmUndo (on Journal Entry)

Reverts a confirmed entry back to draft.

postToLedger (on Journal Entry)

Posts the confirmed entry to the ledger and archives it.

postToLedgerUndo (on Journal Entry)

Reverts a posted entry back to confirmed.