GitHub
Invoicer command line

Command line

ledgeline-invoicer is the app and a command-line tool in one. With no command it opens the app’s window. With a command it does that one job and exits, which makes it easy to use from scripts. Everything the command line does goes through the same code as the app, and writes the same files.

ledgeline-invoicer [OPTIONS] [JOURNAL] [COMMAND]

Finding your books

Every command needs your books’ main journal. It looks, in order, at:

  1. JOURNAL before the command, or -f JOURNAL anywhere on the line;
  2. the LEDGELINE_FIXTURE environment variable;
  3. the journal you opened last in Ledgeline or the invoicer.

In the last two cases it prints which journal it used on the error output. It never reads LEDGER_FILE, so a shell set up for hledger doesn’t send it to the wrong books.

ledgeline-invoicer ~/books/books.journal list
ledgeline-invoicer list -f ~/books/books.journal

Options for every command

OptionDoes
-f, --file JOURNALThe books’ main journal. The same as JOURNAL, but it can go after the command.
--jsonPrint one JSON value instead of text. See JSON output.
--today DATETreat DATE (YYYY-MM-DD) as today: the default date of a new invoice, and what “overdue” is measured against.
-h, --helpHelp for the tool or a command: ledgeline-invoicer send --help.
-V, --versionThe version.

Naming an invoice

A command that works on one invoice takes its number (105) or its file. A file can be a path from the current folder, or a path from the books folder with or without .md.

Commands

CommandDoesWrites
newCreate a draft invoicean invoice file
listList invoices, newest firstnothing
showShow one invoice: its fields, its computed table, its problemsnothing
setSet or remove fields in an invoicethe invoice file
recalcRewrite bill-table amounts that don’t add upinvoice files
checkCheck every invoice, customer and the catalog against each other and the booksnothing
next-numberPrint the next invoice numbernothing
configPrint the settings the app is usingnothing
customersList customers, or show onenothing
sendBook an invoice and mark it sentthe journal and the file
voidReverse an invoice’s booking and mark it voidthe journal and the file
rebookRe-book a sent invoice after an editthe journal
update-companyCopy your company’s current details into a sent invoice, and re-book itthe file and the journal
apply-paymentCash books: apply a deposit to an invoice, or undo itthe journal and the file
reconcileUpdate each sent invoice’s paid status from the booksinvoice files
pdfExport an invoice’s PDFa PDF
receivablesOpen invoices, aging, DSO and average days to paynothing
recognizePost the recognition entries duethe journal
timeTime tracking: the tracker, entries, billing time and paying for it. See Tracking time and Billing time.time files, drafts, the journal

new

Create a draft. It doesn’t change the books.

ledgeline-invoicer new --customer Contoso \
  --row 'Strategy workshop|1|$2,500' \
  --row 'Discount||-10%' \
  --from-catalog WKSHP:2 \
  --dry-run
OptionDoes
--customer NAMERequired. The customer’s note title, another name it goes by, or a link to it.
--template PATHThe template, as a path from the books folder: /invoices/tpl/classic.html. Default: the customer’s, else the first in your books, else Classic.
--number NThe number. Default: the next one.
--date DATEThe issue date. Default: today.
--terms DAYSNet days. Default: the customer’s.
--reference TEXTWhat the customer quotes back, such as "PO #105".
--row SPECA row: description, quantity, rate and account, separated by |. Repeatable. See below.
--from-catalog CODE[:QTY]A row from the catalog. Repeatable.
--field KEY=VALUEA field of your own. KEY:=JSON writes any value. Repeatable.
--dry-runPrint the draft instead of writing it.

Rows keep the order you give them, across --row and --from-catalog. In --row:

If the template is a starter your books don’t have yet, new copies it in.

list

ledgeline-invoicer list --overdue
OptionLists
--status STATUSOnly draft, sent or void.
--customer NAMEOnly this customer’s: a title, link or billed name.
--type TYPEOnly invoice, estimate or credit-note.
--openOnly open invoices: sent and not paid in full.
--overdueOnly overdue invoices: open and past due.

Open and overdue come from the books, so they are right even before the paid status in the files has been refreshed.

show

ledgeline-invoicer show 105

Prints the invoice’s fields, its bill table as the app computes it (with any amount that disagrees), the text around the table, and every problem found with it, the books included.

set

Set or remove fields, one key at a time. Everything else in the file, comments included, stays as it was.

ledgeline-invoicer set 108 reference="PO #PY75334" support_tier=gold
ledgeline-invoicer set 108 terms=45
ledgeline-invoicer set 108 --unset support_tier
FormWrites
key=valueText. A whole number is written as a number, so terms=45 is a number but invoice_num=0042 stays text.
key:=JSONAny value: tags:='["rush"]'.
--unset KEYRemoves the field. Repeatable.

set refuses three fields. status changes only through send and void. paid is written from the books by reconcile. invoice_num can change only on a draft, and only to a number not in use.

Setting terms also sets due_date to the invoice date plus the new terms, unless you give due_date in the same command. Changing date alone doesn’t move due_date; set it too.

Setting template to a starter your books don’t have copies the starter in.

recalc

ledgeline-invoicer recalc --dry-run
ledgeline-invoicer recalc 105

With no invoices named, rewrites every draft whose amounts don’t match its rows, and reports sent and void invoices that don’t match without changing them. Name a sent invoice to rewrite it, then rebook it. --dry-run reports without writing.

check

ledgeline-invoicer check
ledgeline-invoicer check --strict

Checks every invoice, customer and the catalog, and compares each invoice with its booking. Each problem is printed with its file and line and, where there is one, the command that fixes it. Booking lists the book problems it finds. Exits 1 on errors; --strict exits 1 on warnings too.

next-number

ledgeline-invoicer next-number

Prints the number the next invoice gets: one more than the highest in your files and your books, or the number-start setting when there are none.

config

Prints the books’ [books] settings and every [invoicer] setting as the app uses them, defaults included, in the same form as ledgeline.toml. It includes default-terms and default-template once they are set. Under them, as comments, it prints the two payment-matching settings in use, settlementLookbackDays and settlementLeadDays. Those are shared with Ledgeline, so they come from ui-prefs.toml, or from [ui] in these books’ ledgeline.toml when the books keep their own. See In the settings file.

ledgeline-invoicer config

The Settings page in the app changes the same settings; config shows what it saved.

customers

ledgeline-invoicer customers list
ledgeline-invoicer customers show "Customer X"

list prints every customer with their kind, terms, billing email and portal, how many invoices they have and how many are open. show adds the contact details, accounts, template, contracts (and whether each file exists), portal, open purchase orders with what is left of each, snippets and invoices.

Adding customers

customers new and customers import-csv create customer notes in your customers folder, the same way Add customer in the app does, so the same details make the same file.

ledgeline-invoicer customers new "Northwind Traders" --email ap@northwind.example --terms 30
FlagWrites
NAME (required)The customer’s name: what invoices link to, and the books’ customer
--kind person|organizationPerson or organization (default organization)
--email, --phone, --addressThe billing email, phone and address. Put line breaks in an address with $'…\n…'
--company ORGA person’s organization
--terms DAYSNet days
--revenue-account ACCOUNTThe revenue account for this customer’s lines
--invoice-template PATHThe customer’s invoice template, such as /invoices/tpl/x.html
--ledger-customer NAMEThe name the books use, when it differs
--contract LINK|PATHA contract: a note link, a path in the books, or a file outside them (~/…, file:///…); repeat for more
--portal-name, --portal-url, --portal-login, --portal-supplier-id, --portal-requires-reference, --portal-instructionsThe billing portal. The login is a username, never a password

The command refuses a name that any note already has, whatever its case, and never overwrites an existing file. --dry-run prints the note without writing it.

ledgeline-invoicer customers import-csv customers.csv --dry-run
ledgeline-invoicer customers import-csv customers.csv

The first row names the columns and each row after it is one customer:

name,kind,email,address,terms
"Smith, Jones & Co",organization,ap@sj.example,"1 Main St
Springfield, CO",30
Zoë Müller,person,zoe@example.de,,14

The columns are name (required), kind, email, phone, address, company, terms, revenue_account, invoice_template, ledger_customer, contracts (several separated by ;), portal_name, portal_url, portal_login, portal_supplier_id, portal_requires_reference (yes or no) and portal_instructions. They mean what the customers new options of the same name mean. Headers match whatever their case, spacing, - or _, so Revenue Account works. Any other header is refused, and the message lists the ones allowed. Blank cells and blank rows are skipped.

Save the file from your spreadsheet as CSV UTF-8. Quoted cells may hold commas and line breaks. Files are limited to 4 MiB and 10,000 rows.

All or nothing. The command checks every row before it writes anything. If a row doesn’t read, repeats another row’s customer, or names a customer that already exists, nothing is written and every such row is listed with its line number. To add only the new customers from a list you imported before, use --skip-existing: rows naming an existing customer are skipped and reported. --dry-run checks every row and lists what would be created.

send

ledgeline-invoicer send 108 --dry-run
ledgeline-invoicer send 108 --via email
OptionDoes
--via HOWRecord how it was delivered: email, portal, mail, or your own word.
--dry-runShow what would be booked, and write nothing.

In accrual books, send books the invoice, then marks the file sent. In cash books, it only marks the file sent. See Booking.

void

ledgeline-invoicer void 106 --date 2026-11-20

Reverses the booking on --date (default: today) and marks the file void with that date. A draft is only marked void.

--time release (the default) takes the invoice’s invoice: tags off its tracked time, so the time is unbilled again. --time nobill writes the time off instead. See Releasing time.

rebook

ledgeline-invoicer rebook 105 --dry-run
ledgeline-invoicer rebook 105

Replaces a sent invoice’s booking with one that matches the file. Does nothing when they already agree. --dry-run shows what is booked and what would be. It refuses an invoice in a closed period.

update-company

ledgeline-invoicer update-company 105

Replaces the invoice’s copy of your company’s details (name, email, phone, address, logo) with the company note’s, keeping everything else in the file as it was, then re-books a sent invoice. Drafts don’t need it: they always use the company’s current details. show says when a sent invoice’s details are out of date. It refuses a void invoice or an invoice in a closed period, and refuses any invoice when no company is set.

apply-payment

Cash books only.

ledgeline-invoicer apply-payment 207
ledgeline-invoicer apply-payment 207 --txn REF
ledgeline-invoicer apply-payment 207 --undo
ledgeline-invoicer apply-payment 207 --lookback-days 365
OptionDoes
(none)List the deposits in the books that might pay the invoice, best first, each with its reference.
--txn REFApply that deposit. Its first six or more characters are enough.
--undoUndo a payment applied to this invoice, restoring the deposit exactly as it was. With --txn, the one to undo when there are several.
--lookback-days DAYSHow many days back to look for deposits, 0 to 3650. 0 looks back forever.
--lead-days DAYSHow many days before the invoice a payment may come, 0 to 60.

Without the last two, apply-payment uses the same payment-matching settings as the app and Ledgeline: these books’ own, else the shared ones, else 180 days and 4 days. A deposit short of the invoice is always offered as a part payment. A flag changes them for that one run and saves nothing.

Applying writes an undo record under .ledgeline-invoicer/undo/ in the books folder and refreshes the invoice’s paid status. See Getting paid.

reconcile

ledgeline-invoicer reconcile --dry-run
ledgeline-invoicer reconcile 105 107

Updates the paid status of every sent invoice, or the ones named, from the books, and reports where the books and the files disagree. A file that changed while it ran is left for the next run. --dry-run reports without writing. Exits 1 on errors and 2 when a file couldn’t be written. The app does this by itself whenever your books change.

pdf

ledgeline-invoicer pdf 105
ledgeline-invoicer pdf 105 -o ~/Desktop/invoice-105.pdf

Exports the PDF through the invoice’s template. A sent invoice’s PDF is kept in the PDF folder (invoices/pdf/ by default), named like the invoice; an earlier export of the same invoice is kept with its date added to the name. A draft’s PDF goes to a temporary file.

-o PATH writes a copy to PATH instead, and keeps nothing in the PDF folder. The folder must exist.

pdf prints through the system’s web view, so it needs the desktop build and a desktop session. A build without the window (--no-default-features) refuses it.

receivables

ledgeline-invoicer receivables --aging
OptionDoes
--agingAdd the aging table to the text. --json always includes it.
--dso-days DAYSThe days sales outstanding period. Default: the dso-days setting, else 90.

In accrual books, lists every receivable still owed, including any without an invoice file, with days late, aging, DSO and average days to pay. In cash books it lists sent invoices less the payments applied. Aging uses the fixed ranges Current, 1–30, 31–60, 61–90 and 91+.

recognize

ledgeline-invoicer recognize --dry-run
ledgeline-invoicer recognize --through 2026-10-31
OptionDoes
--through DATEPost the entries dated on or before DATE. Default and latest: today.
--include-closedAlso post the entries due in closed periods, as one adjustment per schedule dated today.
--dry-runList what is due, and write nothing.

Posts the scheduled revenue and expense entries that Ledgeline’s Post through would. See Revenue and expense recognition.

Running the app

With no command, ledgeline-invoicer opens the window on the journal it finds. These options apply only then:

OptionDoes
-s, --serverRun without a window, serving the app on a local port (5199 by default).
--host HOSTThe address to listen on. Default: 127.0.0.1.
--port PORTThe port. Default: 5199 with --server, any free port for the window.
--allow-origin ORIGINFor development only: let a page served from ORIGIN call the app’s API.

JSON output

With --json, every command prints exactly one JSON value on standard output and nothing else there. Paths are from the books folder. Amounts in the books commands are plain decimals, such as "8350.00", next to their currency. Field names are only ever added, never renamed, so a script keeps working across versions.

A failure prints an object with error, and for the books commands a code:

{"error": "`paid` can't be set: paid is a mirror of the books, written only by the reconciler"}

The codes are not-found, ambiguous, invalid, booking, status, setup, refused, external-change, stale, books, markdown-not-written, markdown, frontmatter, storage, overflow and, from pdf, needs-gui.

Exit codes

CodeMeans
0Done.
1check or reconcile found errors (with check --strict, warnings too).
2The command couldn’t run: a bad option, books that don’t open, an invoice that isn’t there, a refused or failed write.

When the books change during a command

Before every write to the journal, the command checks that the journal and the file are still what it read. If Ledgeline or an editor changed them in between, it writes nothing, reads them again and tries once more, and puts an explanation in the error output.