All docs
Evaluation policyData definitionsPosting rulesdashboard

Posting rules

Posting rules check an accounting agent's journal entries: allowed and forbidden accounts per document type, VAT/GST at the rule's rate, closed periods, the entry's currency against its document's, documents never to post, plus the bookkeeping checks that always run.

What you'll have

A supplier invoice posted to the wrong or a forbidden account, a wrong VAT amount, an entry in a closed period or in another currency than its invoice, a pro-forma that was posted, or an invoice left unposted is proven wrong on the answer's claims.

What it is and what it powers

A finance and accounting agent posts journals: "Debit 1200 Inventory 5,760.00 / Credit 2000 Accounts Payable 5,760.00 for invoice INV-2207". Which document must be posted, and how, is not in the answer or the sources: a bank statement is reference, a supplier invoice must be posted, a duplicate copy must never be. Posting rules state it, and code checks it.

A rule can find:

FindingMeaning
missing entryA document a post rule matches has no entry citing it: "no entry posts INV-0042 (Supplier invoice), which your posting rules require"
posted excludedAn entry cites a document a do_not_post rule matches: "PF-0007 is a Pro-forma invoice, which your posting rules say must not be posted"
wrong accountsThe entries citing a matched document debit (or credit) none of the rule's accounts: "INV-0042 (Supplier invoice) is posted with debit Office Supplies; your posting rules expect debit Inventory"
forbidden accountAn entry citing a matched document posts to one of the rule's forbidden_accounts, on either side: "INV-2207 (Inventory purchase) is posted to Suspense, an account your posting rules say this document must not post to"
wrong taxThe tax line is not the rule's rate of the net (the other lines on its side), within the tolerance: "VAT-118 (VAT purchase invoice): VAT Input is 250.00, but 20% of the net 1,000.00 is 200.00 (tolerance 0.01)"; or, with required, the entry has no tax line

Findings land on the claims that state the entry, as a proven error with the reason Journal entry breaks a rule. They count as proven wrong in Grounding and No contradictions, like any other claim the evidence contradicts.

When a correct entry passes. A source document never writes the posting itself, so a correct entry cannot be supported by reading the documents. It passes as checked in code when every condition holds: every line was read, the entry cites a document given (or only one was given), every amount is in that document, it balances, every account is in your chart of accounts, a posting rule covers each document it cites, and none of the checks above found anything. The claim then shows "Checked in code: balanced, every amount in INV-2207, every account in the chart of accounts, posting rule Inventory purchases". If a condition is missing, the entry stays Not in the sources and says which one: "This journal entry has no errors, but it can't be confirmed: no posting rule covers INV-2207, so its accounts aren't checked." Add a chart of accounts and a posting rule for each kind of document your agent posts to have correct entries confirmed.

These bookkeeping checks always run, with or without rules:

CheckFails when
unbalancedAn entry's debits do not equal its credits (only when every debit and credit line was read)
periodAn entry is dated outside the period the question states ("for the period 2026-03-01 to 2026-03-31")
closed periodAn entry is dated in one of your closed periods (closed_periods, below)
duplicateThe same posting (date, accounts, amounts, documents) appears twice
accountAn account the chart of accounts does not have: an unknown name or code, a code that names another account, or a name that could be several accounts (never guessed)
currencyThe entry is written in another currency than the document it cites: "the entry is in USD, but INV-2207 is in EUR; an entry is posted in its document's currency (no conversion is assumed)"
amountAn amount written in none of the documents the entry cites: every line amount must be a figure traced to its source document

When it's not set. No rule finding is added; the bookkeeping checks above still run.

How documents and entries are matched

  • The document. A rule applies when one of its document_match phrases is in the document's title (its source) or in its first 400 characters, as whole words, without case. When several rules match, the longest phrase wins.
  • The entry. An entry is tied to a document by the document ids it cites: "per document INV-0042", "for invoice INV-2207", "per policy POL-77", "ref: INV-0042 & BILL-0007", a Ref column in a table, or doc_refs in JSON entries. The document's id in reference_materials must be that id.
  • The accounts. A rule passes when the entries for the document use at least one of its debit accounts and one of its credit accounts. Accounts are written by name or code: with a chart of accounts, "1200", "1200 Inventory", "Inventory (1200)" and "Inventory" are the same account on both sides (the entry's and the rule's). Without a chart, "1200 Inventory" matches a rule listing "Inventory" or "1200". Other lines in the same entry are allowed unless they are forbidden.
  • The tax line. The lines posting to the rule's tax.accounts are the tax; the other lines on the same side are the net. The tax must be rate_percent of the net, within tolerance (0.01 when not given). Tax lines alone on a side (a reverse charge, a VAT settlement) have no net, so no tax verdict.
  • The currency. An entry's currency is the one written next to its amounts (USD 5,760.00, 5,760.00 EUR, €5,760.00, $5,760.00). A document's currency is the one written next to its amounts. They must agree: "$" agrees with USD, CAD, AUD and other dollars; "USD" only with USD. A document that writes amounts in two currencies, or an entry or document that writes none, gives no currency verdict. There is no conversion.

Entry formats the reader takes

Each of these is one entry, read as Debit 1200 Inventory 5,760.00 and Credit 2000 Accounts Payable 5,760.00, citing INV-2207:

Written asNotes
Debit 1200 Inventory 5,760.00 / Credit 2000 Accounts Payable 5,760.00 for invoice INV-2207Lines joined by "/" or ";", with a trailing narrative
Dr 1200 5,760.00; Cr 2000 5,760.00 (per invoice INV-2207)Codes only: resolved through the chart
Dr 1200 - Inventory 5,760.00; Cr Accounts Payable (2000) 5,760.00Code and name in either order
Dr Inventory $5,760.00 / Cr Accounts Payable ($5,760.00)Currency symbols and codes; a bracketed or negative credit is notation, not a reversal
Dr Inventory €5.760,00European number format
One line per side, under a heading such as Journal entry JE-14 (2026-03-04), with a Narration: lineMulti-line entries
A table with Account (or Account Code and Account Name), Debit and Credit columnsPipes or columns aligned with spaces; an Entry or Date column groups rows
A table with Account and one signed Amount columnPositive is a debit, negative or bracketed a credit; or an Amount with a Dr/Cr column
JSON entries with lines of {account, account_code, debit, credit} or {account, amount, side}Or debit_account, credit_account, amount

Dates are read as 2026-03-04, 4 March 2026 or March 4, 2026. Text the reader cannot read as an entry is left to the other checks: no entry read, no finding.

Use cases

Inventory purchase

evaluation_config:
  posting_rules:
    - name: Inventory purchase
      document_match: ["SUPPLIER INVOICE", "Vendor invoice"]
      action: post
      debit_accounts: ["Inventory"]
      credit_accounts: ["Accounts Payable"]
      forbidden_accounts: ["Suspense"]
The answer posts INV-2207 (a supplier invoice, total 5,760.00) asResult
Debit 1200 Inventory 5,760.00 / Credit 2000 Accounts Payable 5,760.00 for invoice INV-2207pass
Dr Office Supplies 5,760.00; Cr Accounts Payable 5,760.00wrong accounts (debit)
Dr Inventory 5,000.00; Dr Suspense 760.00; Cr Accounts Payable 5,760.00forbidden account (Suspense), and 5,000.00 and 760.00 are not in INV-2207
Dr Inventory 5,760.00; Cr Accounts Payable 5,670.00unbalanced, and 5,670.00 is not in INV-2207
Dr 1299 Inventory 5,760.00; …account: "code 1299 is not in the project's chart of accounts (Inventory is 1200)"
no entry citing INV-2207, other entries cite documentsmissing entry

Prepaid expense

An annual insurance policy paid up front is an asset (Prepaid Expenses), not this month's expense:

- name: Insurance prepayment
  document_match: ["INSURANCE POLICY"]
  debit_accounts: ["Prepaid Expenses"]
  credit_accounts: ["Cash"]
  forbidden_accounts: ["Insurance Expense"]

Dr Prepaid Expenses 12,000.00; Cr Cash 12,000.00 (per policy POL-77) passes. Dr 6300 12,000.00; Cr 1000 12,000.00 (per policy POL-77), where 6300 is Insurance Expense in the chart, is a forbidden account and wrong accounts.

Accrual

Services received but not yet billed:

- name: Legal fees accrual
  document_match: ["LEGAL SERVICES - UNBILLED"]
  debit_accounts: ["Legal Fees"]
  credit_accounts: ["Accrued Expenses"]

Dr 6400 Legal Fees 3,400.00 / Cr 2100 Accrued Expenses 3,400.00 per document LS-90 passes.

VAT / GST invoice

- name: VAT purchase invoice
  document_match: ["VAT INVOICE"]
  debit_accounts: ["Office Supplies Expense"]
  credit_accounts: ["Accounts Payable"]
  tax: {rate_percent: 20, accounts: ["VAT Input"], required: true}
- name: Sales invoice
  document_match: ["SALES INVOICE"]
  debit_accounts: ["Accounts Receivable"]
  credit_accounts: ["Sales Revenue"]
  tax: {rate_percent: 7.5, accounts: ["2200"], tolerance: 0.05}

VAT-118 is 1,000.00 net, 200.00 VAT, 1,200.00 total:

The answer posts VAT-118 asResult
Dr Office Supplies Expense 1,000.00; Dr VAT Input 200.00; Cr Accounts Payable 1,200.00pass (the 1,200.00 credit is traced as the sum of the debit lines)
Dr Office Supplies Expense 1,000.00; Dr VAT Input 250.00; Cr Accounts Payable 1,250.00wrong tax: 20% of the net 1,000.00 is 200.00
Dr Office Supplies Expense 1,200.00; Cr Accounts Payable 1,200.00wrong tax: no tax line, which the rule requires

On the sales side the tax is a credit: Dr 1100 Accounts Receivable 2,150.00; Cr 4000 Sales Revenue 2,000.00; Cr 2200 VAT Output 150.00 passes (7.5% of 2,000.00); 150.04 passes within the 0.05 tolerance, 150.10 does not.

Closed period

Once a month is closed, nothing may be posted into it. State the closed periods once, in the policy:

evaluation_config:
  closed_periods:
    closed_through: "2026-02-28"     # every date on or before it is closed
    periods: ["2026-04"]             # and these months

2026-02-15 Dr Inventory 5,760.00; Cr Accounts Payable 5,760.00 (per invoice INV-2207) is proven wrong: "dated 2026-02-15, in a closed period: the books are closed through 2026-02-28". An entry dated 2026-03-04 passes; an entry with no date gets no closed-period verdict. To check only one open period instead, state it in the question ("for the period 2026-03-01 to 2026-03-31").

Forbidden account

forbidden_accounts lists accounts an entry for the document must never use, on either side: a suspense account, an expense account for a capital purchase, a personal account. An account cannot be both allowed (debit_accounts, credit_accounts) and forbidden.

Currency mismatch

INV-2207 says "Total: EUR 5,760.00". Dr Inventory USD 5,760.00; Cr Accounts Payable USD 5,760.00 (per invoice INV-2207) is proven wrong: "the entry is in USD, but INV-2207 is in EUR; an entry is posted in its document's currency (no conversion is assumed)". The same entry in EUR, in €, or with no currency written passes.

Documents that must never be posted

posting_rules:
  - name: Pro-forma invoice
    document_match: ["PRO FORMA INVOICE", "PRO-FORMA"]
    action: do_not_post
  - name: Duplicate copy
    document_match: ["DUPLICATE COPY"]
    action: do_not_post

Edge cases

SituationWhat happens
An account not in the chartProven wrong: "'Misc Expense' is not in the project's chart of accounts", with the nearest accounts named but never assumed. Without a policy chart, a source that lists "Chart of accounts:" or "Allowed accounts:" is used instead.
A name that could be several accounts ("Accounts Receivable" when the chart has "Accounts Receivable - Trade" and "- Other")Proven wrong, naming both: it is not guessed.
Multi-line entriesEvery debit and credit line is read; the balance is checked when every line was read. A line the reader cannot read gives no balance verdict.
Entries that cite no document idsNo missing-entry verdict and no rule findings; the bookkeeping checks still run. With one document, the currency is checked against it.
Amounts in different currenciesOnly compared as written: an entry must be in its document's currency. There is no conversion.
Number formats2,148.80, 2.148,80 and 2 148,80 are the same amount.
A phrase that matches two rulesRefused when saved: a document would fall under both.
A tax rate that differs by line (several rates on one invoice)One rate per rule. Split the document types, or leave tax out.
Dates written 04/03/2026Not read as a date (the day and month order is unknown): no period or closed-period verdict.

How to add it

In the app

Data definitions: Posting rules, with Try itData definitions: Posting rules, with Try it

  1. Open Evaluation policy › Advanced settings ▸ › Data definitions › Posting rules.
  2. Click Add rule. In Posting rule fill Rule (the name), Applies when the document is (phrases from the document's title or header, separated by commas), Action (Post or Do not post), Debit one of, Credit one of and Never post to (accounts separated by commas), and for a tax line Tax rate %, Tax accounts, Tolerance and The entry must have a tax line.
  3. Click Check to have the server check the rule against the rest of the policy (an account a rule names must be on the chart), then Add. To edit or remove a rule, change it in the YAML.
  4. Under Closed periods, set Books closed through and/or Closed months, Check, then Save to draft.
  5. Publish: Publish vN… › Publish.

Try it

Try it, under the rules, runs the same journal checks scoring runs on one sample: write an entry as your agent writes it, the document id it cites and the document's text (its title or header says what it is). The result shows the verdict scoring would give (passes when checked completely; no errors but not confirmed, with the reason, when a condition for confirming it is missing; proven wrong; amount not in the document; or no entry read), the rule each document falls under, each entry as it was read (accounts and amounts per side), and every finding with its reason. It uses the draft's rules, chart of accounts and closed periods (else the version in force). Nothing is stored or scored.

In YAML

Any of the examples above, under evaluation_config.posting_rules and evaluation_config.closed_periods. Check a file without saving it with variably policy validate FILE.

From the SDK

client.set_posting_rules(experiment_id, "settings/posting_rules.yaml", note="VAT at 20%")

On a project scored by its evaluation policy this publishes a new policy version with only the posting rules changed (and the same change on the open draft). The API key needs the scope policy.write. From CI: python -m variably.settings push --experiment-id EXP --chart-of-accounts chart.csv --posting-rules posting_rules.json --note "..." pushes the chart before the rules.

Write a posting rule for your own document type

  1. Name the document type as people would: "Customer credit note".
  2. Pick phrases that identify it from its title or header (4 characters or more, with letters): ["CREDIT NOTE", "CREDIT MEMO"]. Make them specific enough that no other rule shares them.
  3. Decide the action: post, or do_not_post for documents that are reference only (and then give no accounts and no tax).
  4. List the accounts allowed on each side. At least one debit from debit_accounts and one credit from credit_accounts must appear in the entries for that document. Leave a side out to not check it. Add forbidden_accounts for accounts that must never appear.
  5. Add the tax line if the document carries one: its rate and account.
  6. Make the answer cite document ids ("per document CN-0012") and send each document with that id.
- name: Customer credit note
  document_match: ["CREDIT NOTE", "CREDIT MEMO"]
  action: post
  debit_accounts: ["Sales Returns", "Revenue"]
  credit_accounts: ["Accounts Receivable"]
  forbidden_accounts: ["Cash"]
  tax: {rate_percent: 20, accounts: ["VAT Output"]}

Paste this into your coding agent

Paste this into Claude Code, Cursor, or whichever agent has your repository open. It writes the rules from your ledger configuration.

Prompt for your coding agent
Write variA/Bly posting rules for this project from the bookkeeping configuration in this
repository. Posting rules say which documents must be posted, to which debit and credit accounts,
which accounts they must never use, the tax line's rate, and which documents must never be posted.

Look first:
1. Find the posting logic and its configuration: document types, account mappings, tax codes
   and rates, documents that are reference-only (pro-forma invoices, quotes), and closed
   periods. Show me what you found, with file paths, before you write anything.

Then write it under evaluation_config.posting_rules (and evaluation_config.closed_periods if
the code has closed periods):

evaluation_config:
  posting_rules:
    - name: Supplier invoice
      document_match: ["SUPPLIER INVOICE", "Vendor invoice"]
      action: post
      debit_accounts: [Inventory]
      credit_accounts: [Accounts Payable]
      tax: {rate_percent: 20, accounts: [VAT Input]}
    - name: Pro-forma invoice
      document_match: ["PRO-FORMA"]
      action: do_not_post
  closed_periods: {closed_through: "2026-02-28"}

- action is post or do_not_post. A post rule names at least one debit and one credit account.
- document_match: phrases found in the document's title or its first lines.
- Accounts are named exactly as in the chart of accounts (by name or code); every account a
  rule names must be in the chart, so write the chart too if it is not in the policy yet.
- The format is described at https://www.variably.dev/docs/data-posting-rules.

How to write it, as policy YAML:
1. The variably command comes with the SDK (pip install variably-sdk). It reads
   VARIABLY_API_KEY and VARIABLY_BASE_URL from the environment; never hard-code the key or write it into a file.
2. If variably-policy.yaml is not in the repository yet, run `variably policy pull`: it writes
   the version in force to variably-policy.yaml. Change only evaluation_config.posting_rules in that
   file and leave every other key exactly as it is.
3. Verify: run `variably policy validate variably-policy.yaml`. It checks the file as the server would
   and saves nothing; each problem is printed as "line N: path: message". Fix every problem and
   run it again until it exits 0. Do not guess a key the error does not name: unknown keys are
   refused.
4. Run `variably policy diff variably-policy.yaml` and show me what would change.
5. Do not push or publish. Tell me the two ways to save it as a draft: paste the file into
   Evaluation policy › YAML and click Apply as draft, or run
   `variably policy push variably-policy.yaml --note "<why>"` with a key allowed to change the
   evaluation policy. A draft scores nothing until it is published.

When you are done, tell me each rule, the code it came from, and any document type you could not
map. Verify further with Try it on Evaluation policy › Data definitions › Posting rules.

Common mistakes

MistakeWhat happensFix
document_match words that don't appear on your documentsNo rule applies; the entry gets no posting findingUse words printed on the document, such as its title ("SUPPLIER INVOICE")
Accounts named differently from the chart ("A/P" vs "Accounts Payable")The entry looks like it uses an unknown accountUse the chart's names or codes, or add the name to the chart
Forgetting reference-only documents (quotes, statements)They are posted and nothing flags itAdd a rule with action: do_not_post
Saving, but not publishingEntries are checked with the old rulesPublish the draft; Try it shows the verdict first

Format reference

FieldTypeRequiredAllowed valuesDefaultMeaning
nametextyesup to 80 characters, uniquenoneThe rule, as findings name it
document_matchlist of textyes1–10 phrases, each 4+ characters with a letter, unique across rulesnonePhrases the document's title or header carries
actiontextnopost, do_not_postpostWhether the document must be posted
debit_accountslist of textno (not with do_not_post)up to 25, names or codesnoneAt least one must be debited
credit_accountslist of textno (not with do_not_post)up to 25, names or codesnoneAt least one must be credited
forbidden_accountslist of textno (not with do_not_post)up to 25, none also allowednoneNever used, on either side
tax.rate_percentnumberwith taxabove 0, at most 100 (20 means 20%)noneThe tax line is this share of the net
tax.accountslist of textwith tax1–10, not also debit, credit or forbidden accountsnoneThe accounts the tax line posts to
tax.tolerancenumberno0 to 10000.01How far the tax line may be from rate × net
tax.requiredtrue / falsenofalseAn entry without a tax line is a finding

Up to 100 rules. With a chart of accounts, every account a rule names (allowed, forbidden or tax) must be on it.

closed_periods (a policy setting):

FieldTypeRequiredAllowed valuesMeaning
closed_throughtextone of the twoa date YYYY-MM-DDEvery date on or before it is closed
periodslist of textone of the twomonths YYYY-MM, unique, up to 600Each month is closed

Minimal:

posting_rules:
  - {name: Supplier invoice, document_match: ["SUPPLIER INVOICE"]}
closed_periods: {closed_through: "2026-02-28"}

Validation messages

ProblemMessage
No nameRule 2 has no name.
Unknown fieldRule 1: unknown field(s) must_not_accounts.
No phraseRule 'Supplier invoice': give at least one phrase that identifies the document (for example its title, 'SUPPLIER INVOICE').
Short phraseRule 'Supplier invoice': the phrase 'INV' is too short to identify a document (4 characters at least).
Shared phraseRules 'Supplier invoice' and 'Vendor bill' both match the phrase 'INVOICE': a document would fall under both.
ActionRule 'Supplier invoice': action must be 'post' or 'do_not_post'.
Accounts on do-not-postRule 'Pro-forma invoice': a document that must not be posted cannot have accounts or tax.
Same account both sidesRule 'Transfer': the same account 'Cash' is the only debit and the only credit.
Allowed and forbiddenRule 'Inventory purchase': the account 'Inventory' is both allowed and forbidden.
Tax rateRule 'VAT purchase invoice': tax rate_percent must be more than 0 and at most 100 (20 means 20%).
No tax accountRule 'VAT purchase invoice': tax accounts must name the account(s) the tax line posts to.
Tax account also a line accountRule 'VAT purchase invoice': the tax account 'VAT Input' is also a debit or credit account; the net is the other lines, so list it only under tax.
Account not in the chartposting rule 'VAT purchase invoice': tax account VAT Recoverable is not in the chart of accounts (add it, or use 1400 VAT Input)
Closed period dateevaluation_config.closed_periods: closed_through: 2026-02-30 is not a date written YYYY-MM-DD
Closed monthevaluation_config.closed_periods: periods[0]: 2026-13 is not a month written YYYY-MM
Duplicate nameTwo rules are named 'Supplier invoice'.

Concepts on this page: Data definitions