Create a Ledger Product via CLI Tool - Tutorial

Let's start by building a simple Ledger product using our command line tool, Luca. This should help you to understand the basic logic and workflow of Ledger.

This guide will walk you through setting up a basic financial ledger using the Luca Command Line Tool. The goal is to establish a structured ledger to manage payroll payments, ensuring that funds flow correctly from a Revenue Account to a Salary Account, while also maintaining accurate balance updates.

After completing this guide, you will be able to:

  • Set up a Chart of Accounts for the main Financial Ledger.

  • Create an Employee Funds Group to manage salary accounts and wallets.

  • Set up wallets under these accounts for revenue collection and salary disbursement.

  • Initiate a fund transfer from the Funds Wallet to the Salary Wallet.

  • Verify transactions and balances in the ledger after movement.


🛠️ Pre-requisites

Before starting, ensure:

  • You have the Luca Command Line tool installed and initialized with verified credentials. (Refer to the setup guide if needed.)

  • You have a basic understanding of accounts, wallets, and financial transactions.

a) Setting up the Chart Structure

The Chart of Accounts defines the organization’s financial structure. It tracks income and transactions by categorizing accounts for different purposes.

Step 1: Create a Chart of Accounts for the Financial Ledger

./luca write-chart FIN_CHART

This creates a Chart of Accounts named FIN_CHART, which will serve as the foundation for all financial transactions.


Step 2: Create a Revenue Account under the Financial Ledger

./luca write-chart-account FIN_CHART REV_ACC

This creates a Revenue Account (REV_ACC) under FIN_CHART, which will store business income before allocation to expenses (e.g., salaries).


Step 3: Create a Funds Wallet under the Revenue Account

./luca write-chart-wallet FIN_CHART REV_ACC FUNDS_WALLET EUR REVENUE --decimal-places=2

The Funds Wallet (FUNDS_WALLET) is created under REV_ACC.

  • Currency: EUR

  • Type: REVENUE (indicates income)

  • Decimal Places: 2 (ensures accurate fund tracking) This wallet holds company revenue before it is allocated to employee payments.


Step 4: Open the Revenue Account

./luca transition /chart/FIN_CHART/REV_ACC OPEN

This activates the Revenue Account (REV_ACC) so it can start processing transactions.


b) Setting up the Group Structure

We now set up a Group Account for employees based in Europe. This group will manage payroll transactions, including salary disbursements.

Step 5: Create an Employee Group Account (Europe)

./luca write-group EMP_EU

This creates an Employee Group (EMP_EU), which will manage payroll and operational costs for European employees.


Step 6: Create an Employee Payroll Account

./luca write-group-account EMP_EU EMP_A_ACCOUNT

This creates an Employee Payroll Account (EMP_A_ACCOUNT) under the EMP_EU group. This account is responsible for salary disbursements.


Step 7: Create a Salary Wallet under the Payroll Account

./luca write-group-wallet EMP_EU EMP_A_ACCOUNT SALARY_WALLET_A EUR EXPENSE --decimal-places=2

The Salary Wallet (SALARY_WALLET_A) is created under EMP_A_ACCOUNT.

  • Currency: EUR

  • Type: EXPENSE (as salaries are an outgoing cost)

  • Decimal Places: 2 This wallet is where employee salaries will be credited before being paid out.


Step 8: Open the Employee Payroll Account

./luca transition /group/EMP_EU/EMP_A_ACCOUNT OPEN

This activates the Employee Payroll Account, allowing funds to be received and distributed.


c) Record transactions and review balances

With the structure set up, we will record the fund transfer from the Funds Wallet (Revenue Account) to the Salary Wallet (Payroll Account) and verify the balances. To do this, you need to create and execute an instruction that updates the wallet balances.

In a real-world scenario, this action would be triggered by a fund movement, with the Ledger monitoring the event and recording it accordingly. For this example, we will assume that the transfer has already occurred.

Step 9: Create the Instruction for fund transfer recording from Revenue to Payroll

To record this transfer, we will create an instruction that specifies the movement of funds and finalizes the transaction. Define the fund movement activity by specifying the source and destination wallets:

./luca add-activity - /chart/FIN_CHART/REV_ACC/FUNDS_WALLET/EUR/ \
/group/EMP_EU/EMP_A_ACCOUNT/SALARY_WALLET_A 1000 --finalize
  • /chart/FIN_CHART/REV_ACC/FUNDS_WALLET/EUR/ → Source wallet (Revenue Account).

  • /group/EMP_EU/EMP_A_ACCOUNT/SALARY_WALLET_A → Destination wallet (Payroll Account).

  • 1000 → Amount being transferred.

  • --finalize → Ensures the transaction is fully committed.

Step 10: Execute the instruction to send it to the ledger for processing:

./luca write-instruction

This command finalizes the movement and records the transaction for audit purposes.


Step 11: Verify Transactions & Update Wallet Balances

Check Employee Payroll Account Balance

To confirm that the payroll account balance is updated after the fund transfer, run:

./luca read-group-account EMP_EU EMP_A_ACCOUNT

This retrieves the latest balance of EMP_A_ACCOUNT, ensuring that the ledger correctly reflects the fund movement.

Check Transaction Postings

To verify that the salary funds have been recorded as committed, run:

./luca read-postings /group/EMP_EU/EMP_A_ACCOUNT/SALARY_WALLET_A/EUR --status=COMMITTED

This confirms that the ledger has recognized and finalized the postings, aligning with the external payment execution.

By performing these checks, we ensure that the ledger accurately reflects the completed fund transfer and maintains a reliable record for reconciliation and auditing.


Last updated