# Understanding Accounts Receivable (A Beancount Guide)

If you run a business that bills clients, you need a rock-solid way to track who owes you money. This is where Accounts Receivable (AR) comes in. It’s more than just a number on a report; it’s the lifeblood of your cash flow.

Once you know what AR is, measure collection speed with the [accounts receivable turnover formula guide](/blog/2026/04/03/accounts-receivable-turnover-ratio-formula-calculation-examples).

This guide will walk you through what Accounts Receivable is, why it matters, and how to manage it with precision and clarity using the plain-text accounting system, Beancount.

---

## TL;DR

**Accounts receivable (AR)** is the money customers owe you for goods or services you’ve already delivered. It’s a **current asset** on your balance sheet, central to accrual accounting, and a key driver of your business's cash flow. You can track AR cleanly in Beancount by using customer sub-accounts, linking invoices to payments with `^links`, and running a few simple queries. To measure your collection speed, you can calculate **AR Turnover** and **Days Sales Outstanding (DSO)**. To handle risk, you can use an **allowance for doubtful accounts**.

---

### What is Accounts Receivable?

**Definition**
Accounts Receivable represents the balance of money due to your firm for goods or services delivered or used but not yet paid for by customers. Under **accrual accounting**, you recognize this revenue when you earn it, not when you receive the cash. As a result, AR appears as a **current asset** on your company's balance sheet.

**Why It Matters**
Effectively managing your AR is critical for maintaining healthy liquidity. The faster you collect on your invoices, the shorter your **cash conversion cycle**—the time it takes to turn your investments in inventory and other resources back into cash. By monitoring metrics like AR Turnover and Days Sales Outstanding (DSO), you can get a clear picture of your collection efficiency and take action to improve it.

**Accounts Receivable vs. Accounts Payable (One-Line Refresher)**

- **AR** = money owed **to you** (it's an asset).
- **AP** = money **you owe** to others (it's a liability).

### The Accounts Receivable Flow in Double-Entry Accounting

Conceptually, the lifecycle of a receivable follows these steps:

1. **Issuing an Invoice (Credit Sale):** When you send an invoice, you increase your Assets (specifically, Accounts Receivable) and recognize the `Income` you've earned.
2. **Cash Collection:** When the customer pays, you increase one asset (your `Assets:Bank` account) and decrease another (`Assets:AR`). The net effect on your total assets is zero, but your cash position improves.
3. **Discounts or Credits:** If you offer an early-payment discount or issue a credit memo, you reduce the customer's AR balance and offset it with a discount expense or a reduction in revenue (contra-revenue).
4. **Bad Debts:** Unfortunately, not all invoices get paid. To account for this, you can recognize an allowance for doubtful accounts (a contra-asset that reduces your AR's value) and a corresponding bad debt expense. Later, you can write off a specific uncollectible invoice against this allowance.

---

### Modeling AR in Beancount

Beancount is a plain-text, double-entry accounting system that is perfectly suited for tracking AR. Its use of `tags` (which start with `#`), `links` (which start with `^`), and a SQL-like query language (`bean-query`) makes your entire AR process transparent, auditable, and scriptable.

#### Suggested Account Structure

A clean chart of accounts is the foundation. Here’s a recommended structure:

```beancount
; @m49-fragment dateless
Assets:AR
Assets:AR:Clients:<Name>
Assets:AR:Allowance            ; A contra-asset account

Income:Sales
Income:Contra:SalesDiscounts   ; An alternative to an expense account

Expenses:SalesDiscounts
Expenses:BadDebt
```

#### 1\. Record a Credit Sale (Issue an Invoice)

When you send an invoice to a client, you record it in your ledger.

```beancount
2025-07-01 * "Acme Co." "Invoice 2025-045 · Web design" ^INV-2025-045 #ar #client-acme
  invoice: "2025-045"
  due: "2025-07-31"
  document: "/invoices/2025/INV-2025-045.pdf"
  Assets:AR:Clients:Acme-Co           1200.00 USD
  Income:Sales                       -1200.00 USD
```

- The `^INV-2025-045` **link** is a unique identifier that will tie this invoice to its future payment(s).
- The `document:` **metadata** helps Fava (Beancount's web interface) render a clickable link directly to the invoice PDF.

#### 2\. Record Full Payment

When Acme Co. pays the invoice in full, you clear their receivable balance.

```beancount
2025-07-25 * "Acme Co." "Payment for INV-2025-045" ^INV-2025-045 #ar
  Assets:Bank:Checking                1200.00 USD
  Assets:AR:Clients:Acme-Co          -1200.00 USD
```

Using the same `^INV-2025-045` link creates a clear audit trail connecting the invoice and the payment.

#### 3\. Handling Partial Payments

If a client makes a partial payment, the process is the same. The link keeps everything connected.

```beancount
2025-07-20 * "Acme Co." "Partial payment INV-2025-045" ^INV-2025-045 #ar
  Assets:Bank:Checking                 400.00 USD
  Assets:AR:Clients:Acme-Co           -400.00 USD
```

A query on `^INV-2025-045` would show the original \$1200 invoice and this \$400 payment, leaving an \$800 balance.

#### 4\. Handling an Early-Payment Discount

Let's say you offer a 2% discount on a \$1000 invoice if paid early.

```beancount
2025-07-10 * "Acme Co." "2% early-payment discount on INV-2025-046" ^INV-2025-046 #ar
  Assets:Bank:Checking                 980.00 USD
  Expenses:SalesDiscounts               20.00 USD
  Assets:AR:Clients:Acme-Co          -1000.00 USD
```

Here, you clear the full \$1000 receivable, record the \$980 cash received, and book the \$20 discount as an expense. _Note: Many ledgers treat sales discounts as contra-revenue instead of an expense. Using an expense account is often simpler for smaller ledgers. The key is to choose one method and use it consistently._

#### 5\. Including Sales Tax on Invoices

If you collect sales tax, you record it as a liability at the time of invoicing.

```beancount
2025-07-01 * "Acme Co." "INV-2025-047 · Hardware + tax" ^INV-2025-047 #ar
  invoice: "2025-047"
  due: "2025-07-31"
  Assets:AR:Clients:Acme-Co           1100.00 USD
  Income:Sales                       -1000.00 USD
  Liabilities:Tax:Sales               -100.00 USD
```

You've invoiced for \$1100, recognized \$1000 in revenue, and now owe \$100 to the tax authority.

#### 6\. Handling Bad Debts (Allowance Method)

The allowance method is preferred under Generally Accepted Accounting Principles (GAAP) as it better matches expenses to revenues.

**Step 1: Estimate and Create the Allowance (e.g., at Year-End)**
Based on historical data, you estimate a percentage of your receivables may be uncollectible.

```beancount
2025-12-31 * "Allowance for doubtful accounts (2% of AR)"
  Expenses:BadDebt                     300.00 USD
  Assets:AR:Allowance                 -300.00 USD
```

This creates a contra-asset account (`Assets:AR:Allowance`) that reduces the book value of your total receivables.

**Step 2: Write Off a Specific Uncollectible Invoice Later**
When you are certain an invoice will not be paid, you write it off against the allowance.

```beancount
2026-03-05 * "Write-off INV-2025-049 for Insolvent Client" ^INV-2025-049 #ar
  Assets:AR:Allowance                 1200.00 USD
  Assets:AR:Clients:Insolvent-Client -1200.00 USD
```

Notice this transaction does not impact your expenses; the expense was already recognized when you created the allowance.

---

### Minimal Reporting & Queries

You can get quick snapshots of your AR using Fava or `bean-query`.

**Open Receivables by Customer**

```sql
SELECT account, SUM(position)
WHERE account ~ '^Assets:AR'
GROUP BY account
ORDER BY account;
```

**Journal of AR Activity for a Period**

```sql
JOURNAL
WHERE account ~ '^Assets:AR'
  AND date >= 2025-07-01 AND date < 2025-08-01;
```

---

### Core AR Metrics (With Quick Formulas)

For these ratios, a practical approach is to use `bean-query` to export the necessary numbers (period sales, beginning/ending AR balances) and then perform the calculations in a spreadsheet or a script. This keeps your ledger clean and your math explicit.

#### AR Turnover Ratio

This measures how many times per period your business collects its average accounts receivable. **Higher is better.**

$$AR\ Turnover = \frac{Net\ Credit\ Sales}{Average\ AR}$$

#### DSO (Days Sales Outstanding)

This tells you the average number of days it takes to collect payment after a sale has been made. **Lower is better.**

$$DSO = (\frac{Accounts\ Receivable}{Total\ Credit\ Sales}) \times Number\ of\ Days$$

Together, these metrics indicate how efficiently you convert invoices into cash.

---

### A Simple Beancount Starter File (Copy/Paste)

```beancount
; --- Accounts ---------------------------------------------------------------
1970-01-01 open Assets:Bank:Checking           USD
1970-01-01 open Assets:AR
1970-01-01 open Assets:AR:Clients:Acme-Co
1970-01-01 open Assets:AR:Allowance
1970-01-01 open Income:Sales
1970-01-01 open Expenses:SalesDiscounts
1970-01-01 open Expenses:BadDebt
1970-01-01 open Liabilities:Tax:Sales          USD
; ---------------------------------------------------------------------------

; Example invoice
2025-07-01 * "Acme Co." "Invoice 2025-045 · Web design" ^INV-2025-045 #ar
  invoice: "2025-045"
  due: "2025-07-31"
  document: "/invoices/2025/INV-2025-045.pdf"
  Assets:AR:Clients:Acme-Co           1200.00 USD
  Income:Sales                       -1200.00 USD

; Payment received
2025-07-25 * "Acme Co." "Payment INV-2025-045" ^INV-2025-045 #ar
  Assets:Bank:Checking                1200.00 USD
  Assets:AR:Clients:Acme-Co          -1200.00 USD
```

---

### Operational Tips to Keep AR Healthy

- **Set Clear Terms:** Include the due date, late fee policies, and any early-payment discount terms on every invoice.
- **Link Everything:** Use consistent `^INV-...` links to tie invoices, payments, and credit memos together for a clear audit trail.
- **Attach Documents:** Use the `document:` metadata to link to PDFs of invoices, purchase orders, and contracts.
- **Review Monthly:** Check your open AR report at least once a month and follow up on past-due invoices. Watch your AR Turnover and DSO trends to spot problems early.

---

#### Further Reading (Sources Used)

- [Investopedia on AR basics and DSO](https://www.investopedia.com/terms/a/accountsreceivable.asp)
- [Beancount documentation for syntax, links/tags, and the query language](https://beancount.github.io/docs/)
- [Lumen Learning on the allowance vs. direct write-off methods](https://www.google.com/search?q=https://courses.lumenlearning.com/wm-financialaccounting/chapter/allowance-method/)
