Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commodity equivalences #5

Open
prataprc opened this issue May 6, 2017 · 0 comments
Open

Commodity equivalences #5

prataprc opened this issue May 6, 2017 · 0 comments
Labels

Comments

@prataprc
Copy link
Member

prataprc commented May 6, 2017

Can be considered after implementing #4

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

Defining other equivalences should be simple. The following is an example that
creates commodity 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

Equivalence chains can be as long as desired. While rendering the commodity,
as text, it 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.

Refer: ledger-cli:commodity-equivalence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant