<!--
SPDX-FileCopyrightText: 2020 Zach Daniel
SPDX-License-Identifier: MIT
-->



[](https://opensource.org/licenses/MIT)
[](https://hex.pm/packages/ash_double_entry)
[](https://hexdocs.pm/ash_double_entry)
[](https://api.reuse.software/info/github.com/ash-project/ash_double_entry)
# AshDoubleEntry
Welcome! This is the extension for building a double entry accounting system in [Ash](https://hexdocs.pm/ash). This extension provides the basic building blocks for you to extend as necessary.
## Double Entry Accounting
Double entry is a fundamental accounting principle that ensures every financial transaction is recorded in at least two accounts. Each transaction records a **debit** (money going out) and **credit** (money coming in), where total debits must equal total credits. This dual-record system allows you to detect errors and ensures that books always balance.
AshDoubleEntry implements double entry accounting through three core resources:
1. **[AshDoubleEntry.Account DSL](documentation/dsls/DSL-AshDoubleEntry.Account.md)**, which represents accounts in your ledger (such as bank accounts, revenue accounts, expense accounts, etc.)
2. **[AshDoubleEntry.Transfer DSL](documentation/dsls/DSL-AshDoubleEntry.Transfer.md)**, which represents transactions between accounts, always linking a `from_account` and `to_account` with an amount
3. **[AshDoubleEntry.Balance DSL](documentation/dsls/DSL-AshDoubleEntry.Balance.md)**, which tracks the balance of each account at the point of each transfer for recordkeeping
When you create a balance transfer, the system creates entries for both the credit and debit accounts and updates all future balances to reflect the transaction.
## Why a Separate Repository?
As double entry accounting is a specialized financial feature that is only necessary for certain Ash applications, keeping it as a separate repository allows the main framework to remain focused on core functionality. This also allows the implementation of double entry to evolve separately from the core Ash framework. **Ash applications that don't need double entry accounting can safely ignore this.**
This follows the same pattern as other Ash extensions like [AshMoney](https://hexdocs.pm/ash_money) and [AshAuthentication](https://hexdocs.pm/ash_authentication), which are also maintained as separate packages.
## Tutorials
- [Getting Started with AshDoubleEntry](documentation/tutorials/getting-started-with-ash-double-entry.md)