# Recurring templates

> Auto-generate the same invoice or bill on a schedule — retainers, rent, subscriptions — as drafts or auto-approved.

Source: https://www.accountfun.com/docs/guides/recurring-templates/

**Recurring templates** (menu: **Accounting → Recurring Templates**) auto-generate [invoices](https://www.accountfun.com/docs/guides/invoices/) or [bills](https://www.accountfun.com/docs/guides/bills/) on a schedule. Use them for anything that repeats: a monthly retainer, quarterly rent, annual software subscriptions, or a regular supplier order.

A template is a **recipe**, not a document. It defines *what* to generate, *when*, and *whether to approve automatically*. Each run spawns a real invoice or bill, identical to one you’d create by hand.

## Create a template

**Recurring Templates → New Recurring Template.**

| Section              | Fields                                                                                                                                                                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Template Details** | Template Name, Document Type (**Invoice (AR)** or **Bill (AP)** — you’re only offered the types your role can create), Reference, Customer/Supplier, Currency, Tax Mode, and — for a foreign currency — the exchange rate (see below) |
| **Schedule**         | Frequency (**Weekly/Monthly/Yearly**), interval (every N), day of month, start date, due-date offset (days)                                                                                                                           |
| **Line Items**       | Same drag-and-drop grid as documents — items, accounts, tax, tracking                                                                                                                                                                 |
| **Auto-approve**     | Switch: generate **drafts** (default) or **auto-approve and post** each run                                                                                                                                                           |

For example: *every 1 month, on the 1st, starting Jan 1, due 14 days after issue* generates an invoice dated the 1st of each month, due on the 15th.

**Foreign-currency templates** show an exchange-rate field under **Currency**: leave it on **System rate on issue date** (each generated document takes the system rate on its own issue date), or click **Use custom rate** to use the same rate every time (**Use system rate** switches back). The rate is entered in market order — see [Currencies & exchange rates](https://www.accountfun.com/docs/guides/currencies/#how-rates-are-shown).

### Schedule math

* **Weekly** advances by `interval × 7` days (same weekday).
* **Monthly** advances by `interval` months and snaps to your day-of-month. Day 31 clamps to month-end (so the 31st becomes the 28th/29th in February).
* **Yearly** advances by `interval` years (Feb 29 rolls to Feb 28 on non-leap years).
* An optional **end date** or **max occurrences** retires the template to **completed** when reached.

## Template statuses

```text
active ⇄ paused → completed
```

* **Active** — scheduled; generates on each next-run date.
* **Paused** — halted. **Resume** jumps the next run forward to the next valid future date (it won’t fire a backlog burst for the paused period).
* **Completed** — reached its end date or max occurrences; no further runs.

## Drafts vs auto-approve

The **Auto-approve** switch decides what each run produces:

* **Off (default)** — generates a **draft** invoice/bill for review. Safe; a human still approves before anything posts.
* **On** — immediately **approves and posts** each generated document (as the system actor). Requires the **Approve Documents** permission (plus access to the invoice or bill side) and that the org’s system accounts (AR/AP + Tax Payable) exist. Best for rock-solid repeating items like rent.

## Accept online payments

For **invoice** templates, an **Accept online payments on generated invoices** toggle seeds the Pay Now button on every invoice this template spawns. Each generated invoice inherits this setting (independent of your org-wide default), and can still be toggled per invoice afterward. Requires a connected Stripe account — see [Online invoice payments](https://www.accountfun.com/docs/guides/online-payments/).

## Run, pause, and inspect

From a template’s detail page you can:

* **Run now** — generate immediately (useful for catching up or testing), choosing create-draft vs create-and-post.
* **Pause / Resume**.
* View the **schedule**, **last run**, **next run**, **generated count**, and the **generated documents** table (links to every spawned invoice/bill).

If the most recent run **failed** (e.g. a locked period or missing system account), a colored banner shows the status and the error so you can fix it. Failures leave no partial document — generation is atomic per run.

## How generation stays reliable

* **Idempotent.** Re-running the same occurrence won’t duplicate — the job’s idempotency key plus a check for an existing document on that issue date prevent double generation.
* **Lock date respected.** A run targeting a locked period fails cleanly and retries with backoff.
* **Schedule advances only on success.** `nextRunDate`, `lastRunDate`, and `generatedCount` update atomically after the document is created.
* **Deleting a template keeps its generated documents** — only the recipe is removed.

## Worked example: a monthly retainer

You bill Acme Co $2,000 + tax on the 1st of every month.

1. **New Recurring Template**, type Invoice (AR), customer Acme Co, currency USD, Tax Exclusive.
2. Schedule: Monthly, every 1, day 1, start next month, due-date offset 14.
3. Line: *Monthly design retainer*, qty 1, price $2,000, account *Sales Revenue*, tax *Tax on Sales (10%)*.
4. Auto-approve **on** (you trust this one).
5. **Create template.**

On the 1st of each month, AccountFUN generates and approves an invoice for $2,200 (revenue $2,000 + tax $200), due on the 15th. It appears in your Invoices list as **Approved** and posts to your ledger — no manual entry, every month, forever (or until you pause or set an end date).

If Acme cancels after a year, just **Pause** the template; the twelve already- generated invoices stay exactly as they are.
