Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub

I can store the balance of an account

Overview

The AbstractLedgerAccount class, which is extended by GeneralLedgerAccount and AuxiliaryLedgerAccount, now includes a new field:

private Collection<Balance> balances;

Balance Class

The Balance class has the following structure:

public class Balance {
    private LocalDate postingDate;
    private Collection<BalanceAmount> amounts;
}

BalanceAmount Class

Each Balance contains a collection of BalanceAmount objects, which are structured as follows:

public class BalanceAmount {
    private CatalogValue qualifier;
    private AccountingEntryDirection direction;
    private Money amount;
}

AccountingEntry Trigger

Whenever a new AccountingEntry is added, a MongoDB trigger sends a message to the SQS queue accounting-accounting-entry-created. Upon receiving this message, the system calculates the balances for the account associated with the AccountingEntry. These balances are grouped by postingDate. Each record contains:

  • CREDIT and DEBIT sums for the selected postingDate
  • A cumulative total for the previous days

Qualifiers

The BalanceAmount.qualifier field specifies the context of the balance (e.g., AGENCY, TENANT, etc.). Here are some qualifiers:

  • ACCOUNTING_BALANCE_QUALIFIER.OWNER_GLOBAL
  • ACCOUNTING_BALANCE_QUALIFIER.TENANT_GLOBAL
  • ACCOUNTING_BALANCE_QUALIFIER.SUPPLIER_GLOBAL
  • ACCOUNTING_BALANCE_QUALIFIER.AGENCY_GLOBAL
  • ACCOUNTING_BALANCE_QUALIFIER.TENANT_CRG
  • For ledger accounts: ACCOUNTING_BALANCE_QUALIFIER.GLOBAL

Most balances will be grouped by the global qualifier. For example, an account related to an agency will have AGENCY_GLOBAL, while one related to a tenant will have TENANT_GLOBAL.

BalanceDetails

balanceDetails is another important field used to represent detailed balance information, including cumulative totals and categorized balance qualifiers.

Example: Balance Calculation

Let's assume you have the following AccountingEntry records:

  1. Entry 1 (Posting Date: 2024-09-01):

    • Credit: 100
    • Debit: 50
  2. Entry 2 (Posting Date: 2024-09-01):

    • Credit: 200
    • Debit: 0
  3. Entry 3 (Posting Date: 2024-09-02):

    • Credit: 150
    • Debit: 50

The calculated balances would be:

  • For 2024-09-01:

    • Total Credit: 100 + 200 = 300
    • Total Debit: 50
  • For 2024-09-02:

    • Total Credit: 300 + 150 = 450
    • Total Debit: 50 + 50 = 100
Edit this page
Last Updated:
Contributors: gregory