modities and Currencies [Contents][Index]
Sometimes a commodity has several forms which are all equivalent. An example of this is time. Whether tracked in terms of minutes, hours or days, it should be possible to convert between the various forms. Doing this requires the use of commodity equivalences.
For example, you might have the following two postings, one which transfers an hour of time into a ‘ Billable ’ account, and another which decreases the same account by ten minutes. The resulting report will indicate that fifty minutes remain:
2005/10/01 Work done for company Billable:Client 1h Project:XYZ 2005/10/02 Return ten minutes to the project Project:XYZ 10m Billable:Client
Reporting the balance for this ledger file produces:
$ ledger --no-total balance Billable Project
50.0m Billable:Client -50.0m Project:XYZ
This example works because ledger already knows how to handle seconds, minutes and hours, as part of its time tracking support. Defining other equivalences is simple. The following is an example that creates data equivalences, helpful for tracking bytes, kilobytes, megabytes, and more:
C 1.00 Kb = 1024 b C 1.00 Mb = 1024 Kb C 1.00 Gb = 1024 Mb C 1.00 Tb = 1024 Gb
Each of these definitions correlates a commodity (such as ‘ Kb ’) and a default precision, with a certain quantity of another commodity. In the above example, kilobytes are reported with two decimal places of precision and each kilobyte is equal to 1024 bytes.
Equivalence chains can be as long as desired. Whenever a commodity would report as a decimal amount (less than ‘ 1.00 ’), the next smallest commodity is used. If a commodity could be reported in terms of a higher commodity without resulting to a partial fraction, then the larger commodity is used.
status | not read | reprioritisations | ||
---|---|---|---|---|
last reprioritisation on | suggested re-reading day | |||
started reading on | finished reading on |