d58b7919

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Add lot prices

An asset held at a lot price becomes its own commodity: `2 SWDA lot @ 500 EUR`
is an amount of 2 in the commodity "SWDA acquired at 500 EUR per unit", a
distinct key in every balance map from plain `SWDA` and from `SWDA` bought at
another price.

A lot balances at its lot rate, exactly like `@` does, and converts one to one
into the commodity it is a lot of, so it is worth whatever the underlying is
worth rather than what it cost.  Disposal is a negative posting in the same lot,
which leaves the difference between basis and proceeds for a capital gains
posting to absorb.  A lot-free assertion sums across every lot of a symbol, so
an assertion copied off a broker statement stays writable once lots are in play.

This also splits `Currency`, which was doing two jobs: a declared currency, and
whatever a balance is denominated in.  The lot rode on it as a Maybe field,
which is why `declaredCurrency` had to exist.  A `Commodity` is now a currency
or a lot, and one rule decides every site: conversion targets are currencies,
balance keys are commodities.

What follows from the types rather than from a validity rule:

  * a cost converts to a `Currency`, so nothing can convert into a lot
  * a `Lot` holds a `Currency`, so a lot of a lot cannot be built
  * `PostingPrice` has nowhere to put a cost beside a lot

A currency can no longer be called `lot`.

Suite timing

Time to Start Worker time Duration Time to finish Idle
Config 0s 1s 1s 1s 0s
Eval 1s 14s 14s 15s 0s
Build 12s 0s 0s 12s 0s
Suite 0s 15s 15s 15s 0s

Timeline

0s10s