hledger is known as a tool for money: a plain-text journal of transactions, double-entry checks, balance sheets and income statements. Underneath, an amount is a quantity of a commodity, and nothing requires the commodity to be a currency. EUR and km are both just symbols to hledger. What a journal needs for figures that are not money is a way to record them without disturbing the balancing of the money, and hledger has one: virtual postings. A posting whose account is written in parentheses is added up in reports like any other and takes no part in the check that each transaction sums to zero.
This article starts with an app that uses this in production for play time, kept in seconds, and for a theoretical value that must never be mistaken for money. Then it applies the same pattern to kilometres per truck, hours per client and parts per batch, running every example through hledger and showing what came back. The last part is about what this costs.
The app, briefly
Pachinko and pachislot are machine games played in pachinko parlors across Japan. A player rents balls (pachinko) or tokens (pachislot) with cash, plays them, and takes what is left to the counter. In Japan, you cannot cash out at the pachinko parlor: the law does not let a parlor pay out cash or buy back the prizes it gives, so at the counter balls are exchanged only for prizes, and special prizes (特殊景品, to-ku-shu kay-hin) are bought for cash by a separate prize exchange shop, an arrangement known as the three-shop system (三店方式, sahn-ten hoh-shi-ki; the full story). That is why, in the journal below, balls are a commodity of their own and not yen: the parlor that holds them never exchanges them for yen.
A player can also leave the balls on deposit with the parlor and play them another day; that deposit is a balance at one parlor only.
P-Lens is a bookkeeping app for a player’s own results. Its ledger is hledger, compiled to WebAssembly and run in the browser, and its book of record is a set of hledger journal files on the device. Each parlor’s balls are a commodity of their own; that part is a story for another article. This one needs only two facts: one play is one transaction, and two figures that belong to a play are not money. One is how long it lasted. The other is its theoretical value, the figure pachinko players call 仕事量 (shi-go-to-ryoh, literally “amount of work”): for the play actually done, the theoretical gain or loss that occurred under its calculation conditions (算出条件), meaning the machine’s figures and what the player measured, such as how many spins 1,000 yen of balls bought, set against the machine’s border, the spin rate at which a play breaks even. It is recorded for each play and adds up over plays. It is not the play’s result: the result is the money that actually moved, and it routinely lands far from the theoretical value in either direction. The account it is kept in reads 統計:期待値, 期待値 (ki-tai-chi) meaning “expected value”, because the app uses that word both for the figure its calculator shows apart from any play and for this one; what the postings hold is the theoretical value (仕事量) of plays already made.
All code is quoted from p-lens at v0.10.63 (GPL-3.0-or-later). The journal examples come from its test fixture, apps/web/fixtures/basic-play, whose parlor names, マレハン東京皇国第8支店 (read Ma-re-han Toh-kyoh Koh-ko-ku Dai-ha-chi Shi-ten, “Marehan, Tokyo Empire, Branch No. 8”) and 723豚の帽子亭店 (read Shi-chi-nissan Buta-no-boh-shi-tei, “723, the Pig’s Hat Tavern”), are invented.
How the figures were produced
Native hledger was not used. Every report in this article comes from the hledger that P-Lens ships, hledger-lib 1.99.5 compiled to WebAssembly (with one change to the parser for speed, made on the condition that it changes no answer), driven from Bun with the app’s own engine wrapper. That wrapper reads journals with strict checks on, as hledger check --strict would: every account and commodity must be declared. It returns hledger’s JSON rather than the text the command line prints, so the reports below are shown as tables. The rows, columns and figures are hledger’s; only the layout is this article’s, with each number written to its commodity’s declared precision. Where hledger refused a journal, the error text is quoted as it came back. Queries are hledger query syntax; where this article says real:1, that is the query form of -R/--real.
Play time: seconds in parentheses
Here is the first transaction of the fixture, from transactions/2026.journal. The account names are Japanese; 資産 is assets, 現金 cash, 費用 expenses, 収益 revenue, 貯玉 (cho-dah-ma) balls on deposit, 統計 statistics, 期待値 expected value, 時間 time, and 秒 is a second.
2026-09-05 マレハン東京皇国第8支店 | 流星 123番台 ; play-id: made-up-0905, parlor-id: malehan-tokyokoukoku, game-kind: pachinko, machine: 流星, cabinet-number: 123
資産:現金 -12000 JPY
費用:貸玉差額 1290 JPY
費用:遊技 3000 "玉(4円・マレハン東京皇国第8支店)" @ 3.57 JPY
資産:貯玉:マレハン東京皇国第8支店:4円 4800 "玉(4円・マレハン東京皇国第8支店)"
収益:遊技 -4800 "玉(4円・マレハン東京皇国第8支店)"
(統計:期待値) 5500 JPY
(統計:時間) 10800 秒
The first five postings are what happened: 12,000 yen of cash went into rented balls, and 4,800 balls were left and put on deposit. They balance. The last two are the play’s theoretical value, 5,500 yen, and its length, 10,800 seconds, which is three hours. Both are unbalanced virtual postings, so hledger does not ask what they balance against. That is the point: nobody paid or received the 5,500 yen, and three hours are not owed to anyone.
The play-time posting is made by playTimePosting:
/** A play's time, in seconds, as a posting of statistics beside its tally: virtual, so it balances nothing. */
export const playTimePosting = (seconds: Decimal): Posting => ({
account: ACCOUNTS.playTime,
amount: { quantity: seconds, commodity: SECONDS },
kind: "virtual",
})
SECONDS is the string "秒". The parentheses are added in one place, when a posting is written out as text (entry.ts):
const renderAccount = (posting: StatedPosting): string => (posting.kind === "virtual" ? `(${posting.account})` : posting.account)
The account name itself never carries them, so the code that queries 統計:時間 and the code that writes (統計:時間) agree on what the account is called.
A commodity named 秒 needs a declaration like any other, and every new book starts with one (first-book.ts):
/** The accounts every book starts with: a parlor's savings are declared when a play first opens its pool. */
const ACCOUNTS = `commodity 1. JPY
commodity 1. 秒
account 資産 ; type: A
account 資産:現金 ; type: C
account 収益 ; type: R
account 収益:遊技
account 費用 ; type: X
account 費用:遊技
account 費用:貸玉差額
account 費用:貸メダル差額
account 費用:再プレイ手数料
account 純資産 ; type: E
account 純資産:開始残高
account 純資産:残高調整
account 純資産:特殊景品
account 純資産:端玉景品等
account 純資産:換算調整勘定
account 統計:期待値
account 統計:時間
`
commodity 1. 秒 says the unit has no decimal places. The money accounts carry type: tags because hledger cannot infer account types from Japanese names; 統計:期待値 and 統計:時間 carry none on purpose, which matters below.
The design document, ARCHITECTURE.md, gives the reason for seconds:
Play time (
(統計:時間), in秒) is a virtual posting too: the seconds a play lasted, from its clock where both its start and its finish are said (the finish on the day after where it is the earlier), else from the hours told of it to the nearest minute (hours are kept to a hundredth, 36 seconds, so 5時間20分 is 5.33 and comes back as 320 minutes), and none where neither says. Kept in seconds so that a book’s plays add up, over any period, in hledger. A tally set right writes it again from its clock and hours, never from the posting.
Adding play time to an app whose ledger was already hledger took a commodity, an account, a function that writes the posting, and a function that declares the two in books made before play time existed (withPlayTimeDeclaredFor, in the same file). Summing it by month, by machine or by parlor needed nothing new. hledger already does that for any commodity, and it did it for seconds without comment.
Theoretical value: the same pattern, more care
For a pachinko play, the figure comes from a few lines in core/pachinko/theoretical-value.ts: a spin is worth what it wins on average, exchanged at the parlor’s rate, less what it cost, and a play is worth that times its spins.
/** Spins per ¥1,000 at which the balls a spin wins, exchanged, repay what it costs. */
export const borderOf = (figures: Figures, ballValue: number): number => 1000 / (ballsPerSpin(figures) * ballValue)
/** Yen a spin is worth under play: what it wins, exchanged, less what it costs. */
export const yenPerSpin = (figures: Figures, play: PlayRate): number =>
ballsPerSpin(figures) * play.ballValue - 1000 / play.spinPerformance
/** The theoretical value of an hour's play (時給), where the formula says how fast a cabinet plays. */
export const yenPerHour = (figures: Figures, play: PlayRate): number | undefined =>
figures.spinsPerHour === undefined ? undefined : yenPerSpin(figures, play) * figures.spinsPerHour
/** The theoretical value of so many spins played under these conditions. */
export const theoreticalValueOf = (figures: Figures, play: PlayRate, spins: number): number => yenPerSpin(figures, play) * spins
The theoretical value goes into the book the same way play time does, with a function that cannot produce anything but a virtual posting (theoretical.ts):
/**
* The theoretical value of a play, as a posting.
*
* Neither money nor a promise of money, so never a real posting: a virtual one
* on an account with no type. hledger sums it when asked about
* `統計:期待値` and leaves it out of every balanced report, which is what
* keeps it apart from what was actually won or lost.
*/
export const theoreticalValuePosting = (value: Decimal): Posting => ({
account: ACCOUNTS.theoreticalValue,
amount: { quantity: value, commodity: YEN },
kind: "virtual",
})
It takes an amount and nothing else; there is no argument through which a caller could ask for a real posting. Some theoretical values are measured during play and some are inferred afterwards from a play’s hours and its two sides of cash. The inferred ones go to a child account, 統計:期待値:推定 (推定: inferred), made by a twin function in the same file. The query terms then pick the two together or the inferred part alone (terms.ts):
/** The theoretical value's account and what is kept under it: the measured and the inferred together. */
export const theoreticalValueTerm = `^${escapeRegex(ACCOUNTS.theoreticalValue)}(:|$)`
/** The inferred theoretical value's account alone: what nobody measured, apart from what was. */
export const inferredValueTerm = `^${escapeRegex(ACCOUNTS.inferredTheoreticalValue)}$`
The play-time term, a few lines up, is anchored at both ends:
/** The play time's account alone. */
export const playTimeTerm = `^${escapeRegex(ACCOUNTS.playTime)}$`
hledger reads an account query as a regular expression that may match anywhere in the name, so the anchors are what stop a query for 統計:時間 from also matching an account that merely contains those characters.
When a play has no theoretical value or no clock, the posting is not written at all, rather than written as zero (compose.ts):
/** The tally's theoretical value, where it was given, and its play's time, where its clock or the hours told of it say it. */
const statisticPostings = (tally: TallyHead, hours?: Decimal): readonly Posting[] => {
const seconds = playSecondsOf(tally.clock, hours)
return [...(tally.theoreticalValue === undefined ? [] : [theoreticalValuePosting(tally.theoreticalValue)]), ...(seconds === undefined ? [] : [playTimePosting(seconds)])]
}
That keeps “zero” and “not recorded” apart in the file, where a query can still tell them apart.
Asking for them
Parentheses only exempt a posting from the balancing check. They do not hide it from reports. Here is the whole fixture (five plays) as an unfiltered balance report, and the same report with real:1:
| Account | Unfiltered | real:1 |
|---|---|---|
| 資産:現金 | -30000 JPY | -30000 JPY |
| 費用:貸玉差額 | 2630 JPY | 2630 JPY |
| 費用:貸メダル差額 | 1628 JPY | 1628 JPY |
| 統計:期待値 | 13200 JPY | (gone) |
| 統計:時間 | 19800 秒 | (gone) |
| Total, JPY part | -12542 JPY | -25742 JPY |
| Total, 秒 part | 19800 秒 | (gone) |
(Rows in ball and token commodities are left out of the table; they are the same in both columns.) Two things show here. Play time is in its own commodity, so it gets its own part of the total and never mixes with yen. The theoretical value is in yen, so an unfiltered report adds its 13,200 to the yen total, which then means nothing in particular. That is the price of keeping it in the commodity it is measured in.
P-Lens never asks an unfiltered question. Every balance request in requests.ts names its accounts or their type. Play time is asked for by account (lines 67–71):
/** The time the tallies of a query were played for, in seconds, as hledger sums it. */
export const playTimeRequest = (query: string): RequestOf<"balance"> => ({ kind: "balance", query: combine(playTimeTerm, query) })
/** The time the tallies of a query were played for, cut the same way. */
export const playTimeCutRequest = (query: string, cut: Cut): RequestOf<"balance"> => ({ ...playTimeRequest(query), ...cut })
and actual results are asked for by account type. The request kind the app calls incomestatement is a balance report with type:RX (revenue and expenses) added to the query (Bindings.hs):
"incomestatement" -> balanceOf ["type:RX"]
The statistics accounts have no type, so they cannot appear there. For the 5 September play, that report lists revenue -17136 JPY, 費用:遊技 10710 JPY and 費用:貸玉差額 1290 JPY, total -5136 JPY (revenue is negative in a balance report, so this is a gain of 5,136 yen; the balls are valued in yen at each posting’s date with --value=then,JPY). Neither the 5,500 nor the 10,800 seconds is in it.
Because both figures live in the same transaction as the money, the same query and the same monthly interval cut all three the same way:
| Report (monthly) | 2026-09 | 2026-10 | Total |
|---|---|---|---|
type:RX, valued in JPY |
-41142 JPY | 1998 JPY | -39144 JPY |
^統計:期待値(:|$) |
10500 JPY | 2700 JPY | 13200 JPY |
^統計:時間$ |
19800 秒 | empty | 19800 秒 |
There is no join between three data sources, because there is one source. A play late on 30 September cannot land in September for money and in October for time. When a play is corrected or deleted, its transaction is replaced or removed, and both statistics go with it.
The empty October cell is hledger’s empty amount, which is zero: none of the October plays has a clock. P-Lens does not want to show “0 seconds played” for a month nobody timed, so it checks whether any amount in seconds came back before believing the total (figures.ts):
/** The seconds a balance report of the play time's account came to; none where no posting was in it. */
export const secondsOf = (balance: BalanceReport): Decimal | undefined =>
balance.prTotals.prrTotal.some((amount) => amount.acommodity === SECONDS) ? quantityIn(balance.prTotals.prrTotal, SECONDS) : undefined
This works only because the app never writes 0 秒 for a play without a clock.
The design document’s invariant 6 (ARCHITECTURE.md) puts the whole arrangement in two sentences:
A theoretical figure is never real. The theoretical value (期待値) is an unbalanced virtual posting,
(統計:期待値), on an account with no type: hledger sums it when asked and leaves it out of every balanced report. Play time is kept the same way,(統計:時間)in秒: a statistic hledger adds up, never money.
“Leaves it out of every balanced report” should be read with the unfiltered table above in mind: it holds for reports that select by type or by real:1, which are the only ones P-Lens asks for.
Isn’t this what timeclock is for?
hledger already reads time logs, in two formats of its own: timeclock (clock-in and clock-out lines) and timedot (one line per account per day, with dots for quarter hours or a number with a unit). A fair question is whether P-Lens is reinventing them.
The shape is the same. hledger turns a timeclock session into a transaction with one posting, and that posting is an unbalanced virtual posting in hours (Timeclock.hs in hledger 1.99.5):
-- Generate an hours amount. Unusually, we also round the internal Decimal value,
-- since otherwise it will often have large recurring decimal parts which (since 1.21)
-- print would display all 255 digits of. timeclock amounts have one second resolution,
-- so two decimal places is precise enough (#1527).
amt = case mixedAmount $ setAmountInternalPrecision 2 $ hrs hours of
a | not $ a < 0 -> a
_ -> error' $ timeclockEntryError [i] o $
printf "This clockout is earlier than its clockin, on line %d." (timeclockEntryLine i)
ps = [posting{paccount=acctname, pamount=amt, preal=VirtualPosting, ptransaction=Just t}]
Timedot does the same; the manual says a timedot day is read “as a transaction on this day with three (unbalanced) postings” (hledger manual, Timedot). So (統計:時間) 10800 秒 is the shape hledger itself produces for a time log, written by hand.
The rounding in that comment is visible in practice. Three 20-minute sessions in a timeclock file:
i 2026-10-05 09:00:00 time:client-a:support call
o 2026-10-05 09:20:00
i 2026-10-05 11:00:00 time:client-a:support call
o 2026-10-05 11:20:00
i 2026-10-05 15:00:00 time:client-a:support call
o 2026-10-05 15:20:00
came back as three transactions of 0.33 h each, and a balance of 0.99 h. Three timedot days of 20m each gave the same 0.33 h postings and the same 0.99 h. The same three sessions written as (time:client-a:support) 1200 s in a journal, with commodity 1. s, summed to 3600 s. Integer seconds have no recurring decimals to round, and an hour is something to compute when displaying, not something to store.
The difference that can be observed is where the time lives. Timeclock and timedot are separate files (a journal can include them), and each session or day becomes a transaction of its own, holding time and nothing else. P-Lens keeps one transaction per play, with the play’s time next to its money, its tags and its theoretical value. A timeclock session would be a second transaction that only a matching date and description could tie back to the play. For a log of time on its own, the formats hledger already has are the better tool, as the freelancer example below uses.
Kilometres per truck
A small haulier wants fuel and tolls per truck, and kilometres per truck beside them. Each trip is one transaction; the distance is a virtual posting in km.
commodity 1,000.00 EUR
commodity 1. km
account assets:bank
account revenue:freight
account expenses:fuel:truck-a
account expenses:fuel:truck-b
account expenses:tolls:truck-a
account expenses:tolls:truck-b
account stats:distance:truck-a
account stats:distance:truck-b
2026-10-02 Depot to port ; route: depot-port
expenses:fuel:truck-a 182.40 EUR
expenses:tolls:truck-a 36.00 EUR
assets:bank
(stats:distance:truck-a) 412 km
2026-10-02 Depot to north yard ; route: depot-north
expenses:fuel:truck-b 97.10 EUR
assets:bank
(stats:distance:truck-b) 238 km
2026-10-09 Depot to port ; route: depot-port
expenses:fuel:truck-b 176.90 EUR
expenses:tolls:truck-b 36.00 EUR
assets:bank
(stats:distance:truck-b) 409 km
2026-10-31 Freight invoices, October
assets:bank 2,400.00 EUR
revenue:freight
2026-11-04 Depot to port ; route: depot-port
expenses:fuel:truck-a 188.20 EUR
expenses:tolls:truck-a 36.00 EUR
assets:bank
(stats:distance:truck-a) 415 km
The accounts have English top-level names, so hledger infers their types (assets, revenue, expenses) and no type: tags are needed. stats is not a name hledger recognises, so it has no type.
Distance per month, query ^stats:distance with a monthly interval:
| Account | 2026-10 | 2026-11 | Total |
|---|---|---|---|
| stats:distance:truck-a | 412 km | 415 km | 827 km |
| stats:distance:truck-b | 647 km | 0 | 647 km |
| Total | 1059 km | 415 km | 1474 km |
Putting the truck at the end of every account name means a plain-text query for the truck collects its money and its distance in one report. Query truck-a:
| Account | Amount |
|---|---|
| expenses:fuel:truck-a | 370.60 EUR |
| expenses:tolls:truck-a | 72.00 EUR |
| stats:distance:truck-a | 827 km |
| Total | 442.60 EUR, 827 km |
The route is a transaction tag, and the distance posting inherits it like every other posting. Query tag:route=depot-port:
| Account | Amount |
|---|---|
| assets:bank | -655.50 EUR |
| expenses:fuel:truck-a | 370.60 EUR |
| expenses:fuel:truck-b | 176.90 EUR |
| expenses:tolls:truck-a | 72.00 EUR |
| expenses:tolls:truck-b | 36.00 EUR |
| stats:distance:truck-a | 827 km |
| stats:distance:truck-b | 409 km |
| Total | 0.00 EUR, 1236 km |
The euro total is zero because the trips balance; the kilometres stand next to it, unbalanced and unbothered. The income statement (type:RX, monthly) contains fuel, tolls and freight and no distance: October -1871.60 EUR, November 224.20 EUR. What hledger will not do is divide: fuel per kilometre for truck A is 370.60 / 827, worked out by whoever reads the report.
Hours per client, from a timedot file
A freelancer logs hours per client and project and sends invoices. Time logged without any money in the same transaction is what timedot is for, so the hours go in a timedot file and the journal includes it:
commodity 1,000.00 EUR
commodity 1.00 h
D 1.00 h
account assets:receivable
account revenue:client-a
account revenue:client-b
account time:client-a:website
account time:client-a:support
account time:client-b:audit
P 2026-10-01 h 90.00 EUR
include timedot:hours.journal
2026-10-31 Invoice 2026-017, client-a, October
assets:receivable 360.00 EUR
revenue:client-a
2026-10-01
time:client-a:website .... ....
time:client-b:audit ....
2026-10-02
time:client-a:website .... ..
time:client-a:support ..
2026-10-30
time:client-b:audit 3h
2026-11-02
time:client-a:support 45m
time:client-b:audit .... .... ..
Two details came from running it. Timedot amounts have no commodity symbol of their own; they take the default commodity, so the journal sets one with D 1.00 h. Without that line, the strict checks refused the file: Strict commodity checking is enabled, and commodity "" has not been declared. And the harness only passes files ending in .journal to hledger, so the timedot file is named hours.journal and included with the timedot: reader prefix. With a .timedot extension, a plain include hours.timedot is the usual form; that variant was not run here.
Hours per month, query ^time, monthly:
| Account | 2026-10 | 2026-11 | Total |
|---|---|---|---|
| time:client-a:website | 3.50 h | 0 | 3.50 h |
| time:client-a:support | 0.50 h | 0.75 h | 1.25 h |
| time:client-b:audit | 4.00 h | 2.50 h | 6.50 h |
| Total | 8.00 h | 3.25 h | 11.25 h |
The price directive P 2026-10-01 h 90.00 EUR says an hour is worth 90 euros from 1 October. With --value=end,EUR, hledger converts the hours at that rate, and a query that takes a client’s revenue and time together shows what is not yet invoiced. Query ^(revenue|time):client-a date:2026-10, valued:
| Account | Amount |
|---|---|
| revenue:client-a | -360.00 EUR |
| time:client-a:website | 315.00 EUR |
| time:client-a:support | 45.00 EUR |
| Total | 0.00 EUR |
The same query for client-b returns time:client-b:audit 360.00 EUR and nothing else: four hours logged, nothing invoiced. Without the valuation, the client-a query shows -360.00 EUR, 4.00 h, money and hours side by side in the total. A price belongs to a commodity, not to an account, so one h means one rate; clients at different rates would need a commodity each, or the conversion done elsewhere.
Parts per batch, with balanced virtual postings
A workshop presses steel brackets and plates in batches. Each batch costs material and energy, starts some number of blanks, ends as good parts and scrap, and uses a press for some hours. The parts have something money accounts have and play time does not: a conservation rule. Every blank started ends as either good or scrap. Balanced virtual postings, in square brackets, give that rule a check of its own: they must sum to zero among themselves, separately from the real postings.
commodity 1,000.00 EUR
commodity 1. pcs
commodity 1.0 h
account assets:bank
account expenses:materials:steel
account expenses:energy
account units:started
account units:good
account units:scrap
account machine:press-1
account machine:press-2
2026-10-06 Batch 41, bracket B-200 ; batch: 41, part: B-200
expenses:materials:steel 412.00 EUR
expenses:energy 61.30 EUR
assets:bank
[units:started] -500 pcs
[units:good] 488 pcs
[units:scrap] 12 pcs
(machine:press-1) 7.5 h
2026-10-07 Batch 42, bracket B-200 ; batch: 42, part: B-200
expenses:materials:steel 405.00 EUR
expenses:energy 58.90 EUR
assets:bank
[units:started] -500 pcs
[units:good] 471 pcs
[units:scrap] 29 pcs
(machine:press-2) 8.0 h
2026-10-08 Batch 43, plate P-10 ; batch: 43, part: P-10
expenses:materials:steel 220.00 EUR
expenses:energy 30.10 EUR
assets:bank
[units:started] -300 pcs
[units:good] 297 pcs
[units:scrap] 3 pcs
(machine:press-1) 4.0 h
Each transaction now holds three groups: real postings that balance in euros, bracketed postings that balance in pieces, and a parenthesised posting that balances nothing. Change batch 42’s scrap from 29 to 19 and hledger refuses the journal:
This multi-commodity transaction is unbalanced.
The balanced virtual postings' sum should be 0 but is: -10 pcs
-500 pcs + 471 pcs + 19 pcs = -10 pcs
(hledger prints the transaction above that message; it is left out here.) Written with parentheses instead of brackets, the same miscount is accepted, and only shows up later as a units total of -10 pcs that should have been zero. A count that has to add up belongs in brackets.
Query tag:part=B-200, the two bracket batches:
| Account | Amount |
|---|---|
| assets:bank | -937.20 EUR |
| expenses:energy | 120.20 EUR |
| expenses:materials:steel | 817.00 EUR |
| machine:press-1 | 7.5 h |
| machine:press-2 | 8.0 h |
| units:started | -1000 pcs |
| units:good | 959 pcs |
| units:scrap | 41 pcs |
| Total | 0.00 EUR, 15.5 h, 0 pcs |
Machine hours over all batches, query ^machine: press-1 11.5 h, press-2 8.0 h, total 19.5 h. Scrap for B-200 alone, query ^units:scrap tag:part=B-200: 41 pcs. The income statement for B-200 holds energy and steel only, 937.20 EUR. The scrap rate, 41 of 1,000, is again a division left to the reader.
What it costs
Everything in this section was observed in the runs above, apart from the two quotations, which say so.
Unfiltered reports show everything. A plain balance report lists the statistics accounts beside cash, and their units in the total: 0.00 EUR, 1474 km, or P-Lens’s 19800 秒 next to yen. Anyone opening the journal with hledger directly will see them. Accounts with no type keep them out of type-based reports, but a query has to be written to benefit.
Same commodity, same column. A virtual posting in the same commodity as the money is added to the money’s total in any report that includes it. P-Lens’s theoretical value in JPY made the unfiltered yen total -12542 instead of -25742. Units of their own (秒, km, h, pcs) avoid that; a figure that has to be in the money’s own currency needs every query to choose its accounts.
real:1 takes both kinds of virtual posting away. With real:1, the workshop’s bracketed piece counts disappeared along with the parenthesised press hours. To drop one and keep the other, select by account.
Strict checks want every unit declared. Every statistics account and every unit commodity needs a declaration under strict checks, and so does the default commodity timedot amounts take, as the refused timedot file showed.
Empty and zero look the same. A month with no postings to an account comes back as an empty amount, which is zero. If “nothing recorded” has to be told from “recorded as zero”, never write zero postings and check for the commodity’s presence, as P-Lens’s secondsOf does, or ask how many transactions match.
Hours from clocks get rounded. Timeclock and timedot amounts are rounded to two decimal places of an hour; three 20-minute sessions made 0.99 h. Integer seconds in a journal made 3600 s.
Valuation looks at every commodity. P-Lens’s bindings keep a comment about valuing a book in yen (Bindings.hs):
-- Only amounts in a commodity some price names are valued: the oracle finds
-- no price for any other, and leaves it as it was — but only after looking
-- through every price for it, day by day. A book's play time, in seconds,
-- on every tally, made that most of a book's first valued question.
The fix there was to value only the commodities some price directive names. The cost was measured in P-Lens; it was not measured again for this article.
It is not double-entry, and it does not travel. The hledger manual is frank about unbalanced virtual postings (hledger manual, Virtual postings): they “do not participate in transaction balancing”, and “can occasionally be convenient for special circumstances, but they violate double entry bookkeeping and make your data less portable across applications, so many people avoid using them at all.” Its section on Beancount output adds that “Virtual postings are not allowed by Beancount, so any virtual postings are omitted.” A journal that leans on them is a journal for hledger.
hledger sums; it does not divide. Fuel per kilometre, scrap rate, revenue per hour: every ratio in the examples was left to the reader. A dedicated fleet, timesheet or production tool would compute those, and would also have the parts that are not arithmetic at all: timers, approvals, schedules. What the journal gives instead is the money and the counts in one file, under one query language, with no join between them.
Summary
- An hledger amount is a quantity of any commodity. Declare a unit (
commodity 1. km,commodity 1.00 h,commodity 1. 秒) and hledger sums it by account, tag and period like money. - Unbalanced virtual postings,
(account), put such figures in the same transaction as the money without taking part in its balancing. Balanced virtual postings,[account], do the same with a zero-sum check of their own, for counts that must add up. - Parentheses do not hide anything from reports. Put the figures on accounts with no type, and have every query select by account or type, or use
real:1. - P-Lens keeps play time as
(統計:時間)in seconds and the theoretical value (仕事量), kept apart from the actual result, as(統計:期待値)in yen, one transaction per play, and asks for each by an anchored account query. - hledger’s own timeclock and timedot produce the same shape of posting, in separate transactions, in hours rounded to two decimals. They suit time logged on its own; a figure that belongs to one transaction goes in that transaction.
- A
Pdirective turns a unit into money when asked (--value). Ratios between accounts remain the reader’s job.
Links
- P-Lens: p-lens.jp
- Source: github.com/p-lens-dev/p-lens (GPL-3.0-or-later); the code quoted here is at v0.10.63
- hledger: hledger.org; manual sections on virtual postings, timeclock and timedot
- The hledger source quoted: hledger 1.99.5