# Financial Concepts

This page explains the fundamental accounting concepts that EntryTarget implements.

## Double-Entry Bookkeeping

Double-entry bookkeeping is the foundation of modern accounting. Every financial transaction is recorded in at least two accounts: one account is debited and another is credited. The total debits must always equal the total credits across the entire system.

**Example:** A customer sends R$10.00 via PIX.

| Account                | Debit   | Credit  |
| ---------------------- | ------- | ------- |
| Customer Payment (BRL) | R$10.00 |         |
| PIX Asset (BRL)        |         | R$10.00 |

The customer's payment account balance decreases by R$10.00 (debit), and the PIX asset account balance increases by R$10.00 (credit).

### Why Double-Entry?

* **Self-balancing** — the sum of all account balances in the system is always zero
* **Auditability** — every movement of money is traceable to its counterpart
* **Error detection** — if debits don't equal credits, something is wrong

## Integer Amounts

All monetary values in EntryTarget are **integers**. You control the number of decimal places on your side.

| Real Amount    | Stored Value | Your Decimal Places |
| -------------- | ------------ | ------------------- |
| R$1.00         | `100`        | 2                   |
| $1.00          | `100`        | 2                   |
| BTC 0.00000001 | `1`          | 8                   |

This design eliminates floating-point rounding errors that plague financial systems.

## Debits and Credits

In EntryTarget:

* A **debit** operation **decreases** the account balance
* A **credit** operation **increases** the account balance

Each journal entry in a transaction specifies one debit account and one credit account. The amount is subtracted from the debit account and added to the credit account.

## Assets (Currencies)

An asset represents a currency or unit of value (e.g., `BRL`, `USD`, `EUR`, `BTC`). Every account has a single asset, and every journal entry declares its asset.

**Rule:** Both the debit account and the credit account of a journal entry must have the same asset as the entry's declared asset. This prevents accidental cross-currency movements within a single journal entry.

A single transaction can contain journal entries in different currencies — for example, one journal entry moving BRL and another moving USD — as long as each individual journal entry's accounts match its declared asset.

## Account Categories

Categories are free-form labels that describe the purpose of an account (e.g., `PAYMENT_ACCOUNT`, `PIX_ASSET`, `FEE_REVENUE`). They are normalized to uppercase automatically. Categories help you organize accounts by their business function.

## Balance Policies

Balance policies control whether an account's balance can go positive, negative, or both. They are applied per-side (debit or credit) in each journal entry. See [Balance Policies](/docs/concepts/balance-policies.md) for details.

## Consistency Guarantees

EntryTarget guarantees:

1. **Sum of all balances = 0** — the total across all accounts is always zero
2. **Per-asset balance = 0** — the sum of balances for each asset is independently zero
3. **Sequential versioning** — each account's version increments by 1 with no gaps
4. **Atomic transactions** — all journal entries in a transaction succeed or none do
5. **Balance evolution** — the ledger records the exact post-balance after each operation, and it evolves correctly (credit adds, debit subtracts)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://entrytarget.gitbook.io/docs/concepts/financial-concepts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
