Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate

155 views
Skip to first unread message

Chary Chary

unread,
Feb 26, 2019, 3:16:46 PM2/26/19
to Ledger
Hello everybody!

I stumbled on ledger in my search for finance bookkeeping system as Excel does not really satisfy all my needs

I first tested gnucash but I was told it can't do what I need. So I am just wondering whether ledger can do this:

Sorry, if express what I need in gnucash terms, I am just not familiar with ledger terminology yet

What I need is following:

======================================

I am looking for Income Statement" aka "Profit/Loss Statement"  report which would show unrealized gain due to changes in stock and currency exchange rate

Say at the beginning of the year I have produced a Balance Sheet report. 
This report shows how much assets I have, which liabilities and delta 
between them. Suppose at begging of the year I had checking accounts in USD 
and Euro and some stock. 
Throughout the year I was getting salary, paying expenses, at the same time 
exchange rate was changing, stock price was changing etc. My be I sold some 
stock, moved money between USD and Euro accounts 

Now at the end of the year I have produced a new balance sheet. 

So, I want to be able to explain a delta between a balance sheet at the 
beginning of the ear and at the end. 

E.g.: 

I got so much salary 
I paid so much costs 

But also: 
Lost so much due to exchange rate change 
Gained to much due to stock price increase etc. 

So, effectively I need to be able to drill down in the delta in Balance 
Sheet report 

Regards. 
Chary 

Richard Lawrence

unread,
Feb 27, 2019, 8:26:01 AM2/27/19
to Chary Chary, Ledger
Dear Chary,

Chary Chary <char...@gmail.com> writes:

> So, I want to be able to explain a delta between a balance sheet at the
> beginning of the ear and at the end.
>
> E.g.:
>
> I got so much salary
> I paid so much costs
>
> But also:
> Lost so much due to exchange rate change
> Gained to much due to stock price increase etc.

The short answer to your question is yes, ledger can do that.

The long answer as to *how* exactly you get it to do that depends
somewhat on your needs. It's straightforward to do things like show how
much salary you earned. It's also pretty straightforward to find out
how much you lost or gained due to currency exchanges or stock gains,
though these depend on you representing your data in the right way. I'd
suggest that you install ledger and then read the first few sections of
the manual:

https://www.ledger-cli.org/docs.html

Section 4.5 ("Currency and commodities") and Section 5 ("Transactions")
will be especially relevant for you. I suggest you play around with
representing your data after reading these sections, then ask again here
if you need help building reports with exactly the output you want.

--
Best,
Richard

Chary Chary

unread,
Mar 5, 2019, 7:01:40 PM3/5/19
to Ledger
Hello.

I did some reading, but I still can't figure out how to do what I need.

I have a very simple ledger file:

==============================
2018-01-01  Opening Balance
    Assets:Checking                         1000.00 USD
    Equity:Opening Balances

P 2018-01-01 USD 1 EUR
P 2018-07-01 USD 2 EUR
===============================

So, so transactions what so ever, only opening balance and  price change

If I run balance report for the beginning of period I get expected result

============================

ledger -f ledger.txt balance -X EUR --now 2018-01-01
             EUR1000  Assets:Checking
            EUR-1000  Equity:Opening Balances
--------------------
                   0

===========================

If I run balance report for end of the year (after exchange rate changed), I also get correct result


=======================

C:\_code\ledger>ledger -f ledger.txt balance -X EUR --now 2018-12-31
             EUR2000  Assets:Checking
            EUR-2000  Equity:Opening Balances
--------------------
                   0
=======================

But I can't find any report, which would show me why assets have increased 2 times. Option --unrealized  does not have any effect in this case

I would expect some report, which would say something like 

-1000 EUR Unrealized gain
-1000 EUR    Unrealized gain due to EUR/USD changes

So, how can it be done?

John Wiegley

unread,
Mar 5, 2019, 11:39:56 PM3/5/19
to Chary Chary, Ledger
>>>>> "CC" == Chary Chary <char...@gmail.com> writes:

CC> But I can't find any report, which would show me why assets have increased
CC> 2 times. Option --unrealized  does not have any effect in this case

It's giving you present market valuation, which has doubled because you stated
that the price had doubled.

Perhaps you wanted the --unrealized options?

--unrealized
Show generated unrealized gain and loss accounts in the balance report.

--unrealized-gains
Allow the user to specify what account name should be used for unrealized
gains. Defaults to Equity:Unrealized Gains. Often set in one's ~/.ledgerrc
file to change the default.

--unrealized-losses
Allow the user to specify what account name should be used for unrealized
losses. Defaults to Equity:Unrealized Losses. Often set in one's
~/.ledgerrc file to change the default.

John

Richard Lawrence

unread,
Mar 6, 2019, 7:29:43 AM3/6/19
to Chary Chary, John Wiegley, Ledger
Hi Chary,

Chary Chary <char...@gmail.com> writes:

> But I can't find any report, which would show me why assets have increased
> 2 times. Option --unrealized does not have any effect in this case
>
> I would expect some report, which would say something like
>
> -1000 EUR Unrealized gain
> -1000 EUR Unrealized gain due to EUR/USD changes
>
> So, how can it be done?

I think John answered without seeing that you had already tried
--unrealized, so let me try to help:

There is something sort of subtle going on with --unrealized. If you
just run the balance report with --unrealized, but without specifying
any account like you did here:

> C:\_code\ledger>ledger -f ledger.txt balance -X EUR --now 2018-12-31
> EUR2000 Assets:Checking
> EUR-2000 Equity:Opening Balances
> --------------------
> 0

then you won't see any unrealized gains. But if you specifically ask
for the balance of the Checking account in EUR, you'll see the
unrealized gains:

ledger -f ledger.txt bal Checking -X EUR --now 2018-12-31 --unrealized
EUR2000 Assets:Checking
EUR-1000 Equity:Unrealized Gains
--------------------
EUR1000

I don't know exactly why this is, or even whether it's expected
(vs. being a bug), but maybe it makes some sense: when you're getting
the balance of all accounts together, including Equity, there are no
"unrealized" gains (the gains are "realized" in Equity, or at least
reflected in the balance of the Equity account, as you noticed). But
when you are just getting the balance of Checking, and you're getting it
in a currency other than the amount actually inside that account, then
there are unrealized gains in that account, which ledger notices.

Hope that helps!

--
Best,
Richard

Chary Chary

unread,
Mar 6, 2019, 8:22:57 AM3/6/19
to Ledger
Richard,

ok, thanks, it works indeed! Great!  It also works if I run report on assets all together

ledger -f ledger.txt bal Assets  -X EUR --now 2018-12-31 --unrealized


But I am just thinking aloud here.

Unrealized gains can only happen against assets, they cannot happen against expenses or income. Correct?  So, to see all unrealized gains one just needs to mention

 
bal Assets
 

However unrealized gains only make sense to show in "Income statement-like report", hence in report, which contains Income and Expenses, but not Assets, however I am forced to include Assets.

You can see on the below example

====================================================================

2018-01-01  Opening Balance
   
Assets:Checking                         1000.00 USD
   
Equity:Opening Balances


P
2018-01-01 USD 1
EUR
P
2018-07-01 USD 1.5 EUR
==================================================================


So, at the end of the year I became 500 Euro richer due to exchange rate change.

Ledger does calculate unrealized gain correctly

ledger -f ledger.txt bal Assets  -X EUR --now 2018-12-31 --unrealized
             EUR1500  
Assets:Checking
             EUR
-500  Equity:Unrealized Gains
--------------------
             EUR1000



But what is the meaning of these EUR1000 below the line?
What Ledger is trying to tell me?
Does it make any sense to add together Assets and unrealized gains? 
I don't think these 1000 EUR have any sense

I would expect some report, which would have EUR -500 below the line. Because I because richer by 500 EUR, which is supposed to be -500 in income statement in ledger's terms

Do you have any comments?

Richard Lawrence

unread,
Mar 6, 2019, 1:01:52 PM3/6/19
to Chary Chary, Ledger
Hi Chary and all,

Here's a few more thoughts.

Chary Chary <char...@gmail.com> writes:

> ok, thanks, it works indeed! Great! It also works if I run report on
> assets all together
>
> ledger -f ledger.txt bal Assets -X EUR --now 2018-12-31 --unrealized
>
> But I am just thinking aloud here.
>
> Unrealized gains can only happen against assets, they cannot happen against
> expenses or income. Correct? So, to see all unrealized gains one just
> needs to mention
>
> bal Assets

Yes, that makes sense to me.

> However unrealized gains only make sense to show in "Income statement-like
> report", hence in report, which contains Income and Expenses, but not
> Assets, however I am forced to include Assets.

Here, I don't follow you. (Maybe I don't understand what an "income
statement-like" report is?)

Conceptually, it seems to me that unrealized gains or losses have
nothing to do with income and expenses. Income and expenses seem like
*realized* gains and losses, pretty much by definition, right? If
you're in the context of asking about unrealized gains and losses,
you're not asking about income and expenses you actually had -- you're
asking about what income or expenses you *could potentially* have, if
you were to make a transaction that realizes them.

> Ledger does calculate unrealized gain correctly
>
> ledger -f ledger.txt bal Assets -X EUR --now 2018-12-31 --unrealized
> EUR1500 Assets:Checking
> EUR-500 Equity:Unrealized Gains
> --------------------
> EUR1000
>
> But what is the meaning of these EUR1000 below the line?
> What Ledger is trying to tell me?
> Does it make any sense to add together Assets and unrealized gains?
> I don't think these 1000 EUR have any sense

Well, as you recognize, the 1000 EUR you see here is just the sum of the
lines above. Here's how I'd think about this report:

(potential assets) - (unrealized gains) = (actual assets)

From that perspective, it makes sense. The 1500 EUR on the first line
does not represent your actual current assets (according to your example
file, you don't *actually* have *any* euros!), but your potential
assets. I guess the question is in what sense 1000 EUR represents your
"actual assets" here, but that has a pretty straightforward answer: it
represents the value in euros of the actual dollars in your account, at
the time they entered that account.

If you were to realize these gains by exchanging currencies, then you
could record the gains as Income. I *think* this would be the right way
to do that:

2018-01-01 Opening Balance
Assets:Checking 1000.00 USD
Equity:Opening Balances

2018-07-10 My Currency Broker
; cash in on a sweet exchange rate!
Assets:Checking 1500.00 EUR
Assets:Checking -1000.00 USD {1 EUR} @ 1.5 EUR
Income:Realized Currency Gains

This uses ledger's notion of "lot price" to track the gains, following
the example with stocks in the manual. Basically, the second
transaction says: I exchanged 1000 USD, which were valued at 1 EUR at
the time I acquired them, for 1500 EUR, at a rate of 1.5 EUR/USD. The
unbalanced 500 EUR is realized as income, as you'll see if you run the
balance report.

Can someone with more experience confirm that this is the right way to
do it? I'm also interested in this question.

--
Best,
Richard

John Wiegley

unread,
Mar 7, 2019, 1:18:08 AM3/7/19
to Richard Lawrence, Chary Chary, Ledger
>>>>> Richard Lawrence <wyl...@gmail.com> writes:

> I think John answered without seeing that you had already tried
> --unrealized, so let me try to help:

Indeed, thank you for catching that, Richard. :)

John

Chary Chary

unread,
Mar 7, 2019, 4:39:11 AM3/7/19
to Ledger

 
Here, I don't follow you.  (Maybe I don't understand what an "income
statement-like" report is?)


Ok, I am not an accountant, so  am expressing this from my personal point of view and personal needs

There are 2  financial reports, which are linked to each other


It effectively lists Assets and Liabilities. The difference between them shows your net worth. It shows how much you have at a specific moment in time. Since ledger does not have explicit special Balance Sheet report, one can produce something like this by running: 

ledger -f ledger.txt bal Assets Liabilities



It shows changes to your finance over period of time. Changes happen due to expenses and incomes. Difference between them shows how much you lost or gained over a period of time.

Since ledger does not have explicit special Income statement report, to produce an equivalent report one would need to do:

ledger -f ledger.txt bal Income Expenses

Now, if one does not do investment and uses only single currency, Income Statement, when run over period of time will show you exactly where the difference between 2 balance sheet reports came from. In another words:

Starting Balance Sheet Net Worth + Income statement Net Gain/ Loss = Closing Balance  Sheet Net Worth

However if you deal with different commodities, this will not work.  (See my original example).

There is however another report for this. In Financial world it is called Statement of Comprehensive Income https://www.investopedia.com/terms/c/comprehensiveincome.asp

Comprehensive income includes net income and unrealized income, such as unrealized gains/losses on hedge/derivative financial instruments and foreign currency transaction gains/losses. Comprehensive income provides a holistic view of a company's income not fully captured on the income statement.

Here is example https://www.myaccountingcourse.com/financial-statements/images/other-comprehensive-income-statement-example.jpg

I referenced  investopedia just to show, that what I am looking for is not something strange.

Originally I was just looking for some report to provide a delta between 2 of my balances sheets reports.


Ledger is able to show unrealized gains, however it also pulls Assets in the same report. But I do not want assets to be shown on the same report together with unrealized gains. 

  

I must say though, I have a feeling, that I am still missing something. I just don't understand how people, who do investments, own stock can live without such report. Is't it logical to be able to explain a delta in your financial net worth between 2 periods of time?

So much salary
so much expenses
so much increase due to company XXX shared change

Overall change XXXX
 

Without such report you would look at 2 balance sheet reports (A and B) but would not know how exactly you came from A to B.

Richard Lawrence

unread,
Mar 7, 2019, 7:18:59 AM3/7/19
to Chary Chary, Ledger
Hi Chary and all,

Chary Chary <char...@gmail.com> writes:

> Ok, I am not an accountant, so am expressing this from my personal point
> of view and personal needs

Me too. :)

To be honest, I don't approach ledger by thinking in terms of reports.
Instead, I just have a bunch of questions I like to ask of my finances,
some of them regularly, some of them only once in a while. For the
former kind of question, I have a few pre-defined commands. For the
latter kind of question, I usually just figure out how to query ledger
for the information I want on the fly. I don't worry about how the
output looks, as long as it contains the information I'm looking for.

You seem to be thinking about ledger more in terms of predefined
reports. That's fine! These reports exist, after all, because they're
useful ways of organizing and conceptualizing financial data. But I
would suggest that you might find it more helpful to think in terms of
"What kind of questions do I need ledger to answer?" My experience,
anyway, is that it's usually more straightforward to think in these
terms than in terms of "How can I use ledger to generate report X?"
(mostly because that question gets you thinking more about formatting,
rather than the information itself, and formatting can get complicated).

If you need reports in a specific format -- e.g. because you are running
a business -- ledger can probably produce them (possibly in combination
with other tools). But I'm not the best person to help with that,
unfortunately. :)

> I must say though, I have a feeling, that I am still missing something. I
> just don't understand how people, who do investments, own stock can live
> without such report. Is't it logical to be able to explain a delta in your
> financial net worth between 2 periods of time?

> So much salary
> so much expenses
> so much increase due to company XXX shared change
>
> Overall change XXXX
>
> Without such report you would look at 2 balance sheet reports (A and B) but
> would not know how exactly you came from A to B.

OK, I think I see more clearly what you're looking for now: you want

- a single report
- that shows the change in your assets between two points in time
- grouped into positive and negative changes (i.e., Income and Expenses)
- which includes unrealized gains and losses
- where the total reflects the overall change

Is that right? If so, I don't think it's super trivial but I believe it
is possible, so let's figure out how to do it. (Hopefully other people
can chime in here, because as I said, reports are not my strong point.)

A reasonable first approximation is something like:

ledger -f your_file reg Assets --group-by='amount < 0' --related -X EUR

though that doesn't show the total, and has one transaction (rather than
one account) per line.

--
Best,
Richard

Chary Chary

unread,
Mar 7, 2019, 10:16:21 AM3/7/19
to Richard Lawrence, Ledger
Richard,

yes, thanks for your patience. Sorry if I did not express myself correctly initially. You got me right with small corrections. I want:

- a single report

- that shows the change in your assets and Liabilities between two points in time

- grouped into Accounts (line with the balance) command

- which includes unrealized gains and losses

- where the total reflects the overall change


Your proposed command did not really worked for me (generated an error). But this one worked 

ledger -f ledger.txt  reg Assets -X EUR
18-Jan-01 Opening Balance       Assets:Checking             EUR1000      EUR1000
18-Jul-01 Commodities revalued  <Revalued>                   EUR500      EUR1500

So, now ledger  shows unrealized gain as Commodities revalued  <Revalued>.

I need to study more all these Leger's options

It seems to be really powerful tool, but not straightforward. I think to understand ones needs to know internal data representation of the tool, what it does and how it presents data internally.

o1bigtenor

unread,
Mar 7, 2019, 11:41:54 AM3/7/19
to ledge...@googlegroups.com, Richard Lawrence
On Thu, Mar 7, 2019 at 9:16 AM Chary Chary <char...@gmail.com> wrote:
>
> Richard,
>
> yes, thanks for your patience. Sorry if I did not express myself correctly initially. You got me right with small corrections. I want:
> - a single report - that shows the change in your assets and Liabilities between two points in time
>
This report is called 'Net Worth' using GAAP terms. Used by businesses
all the time.
>
> I need to study more all these Leger's options.
> It seems to be really powerful tool, but not straightforward. I think to understand ones needs to know internal data representation of the tool, what it does and how it presents data internally.
>
I agree with the first part of your sentence. The second is perhaps
not accurate.
Excellent accounting information is highly complex. Check out forward
cost accounting
for product development if you want to have a lot of 'fun'. Often that
innate complexity of
accounting is what is being reflected by ledger . The logic is simple
- - as is that for 'record
keeping' but that doesn't mean that the process nor the use is. I find
that's why some people
get someone else to do this - - - its easier to just use the final
reports. (Making sure that
these reports are accurate is quite another job though!)

Dee

Richard Lawrence

unread,
Mar 8, 2019, 3:59:26 AM3/8/19
to Chary Chary, Ledger
Hi Chary and all,

Chary Chary <char...@gmail.com> writes:

> yes, thanks for your patience. Sorry if I did not express myself correctly
> initially. You got me right with small corrections. I want:
>
> - a single report
>
> - that shows the change in your assets and Liabilities between two points
> in time
>
> - grouped into Accounts (line with the balance) command
>
> - which includes unrealized gains and losses
>
> - where the total reflects the overall change

OK, after thinking through this a bunch more, and getting myself fairly
confused, I believe I have convinced myself that what you're looking for
doesn't make sense yet.

Here's the problem. You want a report that lumps together two kinds of
changes during a specific time period: actual transactions, recorded in
a specific currency (say, USD) and potential gains/losses due to changes
of prices in commodities during that period, including alternate
currencies (say, EUR). But these two kinds of changes are orthogonal to
one another and it's not yet clear how they should interact.

For example, say you gain 1000 USD in income during that period. What's
the right way to understand that change in terms of EUR? Should we
value the 1000 in EUR on the date that you took it in, and use that
number in a running total of EUR gained and lost throughout the period?
Or should we continue to think of it as 1000 USD until the very end of
the period in question, and then convert the running total to EUR using
the exchange rate at the end of the period?

It seems that you can *either* ask the question:

(1) How did my *actual* assets change during a specific *period* in time?

or:

(2) Given my actual assets at a specific *point* in time, what potential
gains/losses would I incur by converting those assets to another
commodity (say, another currency) *at that point in time*?

but I don't think it makes sense to ask:

(3) How did my assets, including *unrealized* (i.e., potential)
gains/losses due to currency conversions, change during a specific
period?

In other words, I don't think it makes sense to talk about how the
*unrealized* value of assets *changed* over a period in time. Or at
least, it doesn't make sense until you make some decisions about how to
define the non-actual value of assets at different points in time.

You can answer question (1) in a variety of ways. The easiest one is
just:

ledger bal Assets -b begin_date -e end_date

(Note: begin_date must be some time *after* your opening balances, if
you only want to see changes, not the full total for the account on the
day before end_date.)

If you want a breakdown of where those changes come from, you might find
this version more helpful:

ledger reg Assets -b begin_date -e end_date --related --subtotal

On the other hand, using -b/-e with -X and --unrealized doesn't seem to
make sense, as I explained above (although ledger happily accepts them
both, probably because it uses one of the specific interpretations I
mentioned to understand your non-actual assets across a given period).
To answer question (2), you need something like:

ledger bal Assets --unrealized -X some_commodity

perhaps adding --now=... or -e end_date if you want to know your
unrealized gains/losses in some_commodity at a point in time other than
right now.

Does this make sense?

--
Best,
Richard

Chary Chary

unread,
Mar 10, 2019, 11:46:42 AM3/10/19
to Ledger
Richard,

thanks for your inputs.

I also was thinking about this. Even more, I have now written a document (Multiple currency accounting example with trading account), which describes proposed calculation method. As an appendix, this document contains google sheet, where you can see how the method is implemented and play around with it.

The approach is quite simple

  1. Expenses are tracked at the historical exchange rate (e.i. at the exchange rate, available during transaction). When exchange rate changes, Expenses and Income do not get re-calculated.  

This is believed to be inline with conventional wisdom , that if you have consumed pizza for 10 USD, there is no reason to re-calculate how much this pizza is worth now in EUR, when USD/EUR exchange rate changed. It only makes sense to know how much that pizza was worth in EUR, when you consumed it.


  1. Assets and Liabilities on the other side are recalculated with every event of exchange rate change.  

This is also inline with conventional wisdom. If you own 1000 of Currency / stock XYZ and all of a sudden this currency became more expensive (just think of Bitcoin), this means you actually got reacher and you want to see it.


  1. The exchange rate changes are taken care in the following way:

A special Commodity Revaluation transaction is logged. Following the principle of double-entry accounting

  • one shoulder of transaction is logged to corresponding Asset and / or Liability accounts to adjust these accounts to new exchange rate.

  • another shoulder is logged to special Gain due to commodity price change (trading account, using Peter Selinger’s terminology).


The example calculation can be seen in Appendix A. Google sheet - based calculation example


So, to answer your particular question:

For example, say you gain 1000 USD in income during that period.  What's 
the right way to understand that change in terms of EUR?  Should we 
value the 1000 in EUR on the date that you took it in, and use that 
number in a running total of EUR gained and lost throughout the period? 
Or should we continue to think of it as 1000 USD until the very end of 
the period in question, and then convert the running total to EUR using 
the exchange rate at the end of the period? 


In income account, this 1000 USD have to be tracked with historical exchange rate
If however these 1000 USD were put as asset in bank account, then they now have to be re-calculated to follow changes in USD/EUR exchange rate AND gain due to revaluation has to be logged

Please check my document and see whether it makes sense.

I still need to check your ledger examples. I must say it is quite possible, that ledger actually does something like that. 

Regards.

Chary

Chary Chary

unread,
Mar 10, 2019, 12:14:38 PM3/10/19
to Ledger
Sorry,

small correction 

Expenses and Incomes are tracked at the historical exchange rate  



--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Lawrence

unread,
Mar 11, 2019, 6:05:26 AM3/11/19
to Chary Chary, Ledger
Hi Chary and all,

I don't have time for a long reply but here are some quick thoughts:

Chary Chary <char...@gmail.com> writes:


> The approach is quite simple
>
> 1.
>
> Expenses are tracked at the historical exchange rate (e.i. at the
> exchange rate, available during transaction). When exchange rate changes,
> Expenses and Income do not get re-calculated.


> This is believed to be inline with conventional wisdom , that if you have
> consumed pizza for 10 USD, there is no reason to re-calculate how much this
> pizza is worth now in EUR, when USD/EUR exchange rate changed. It only
> makes sense to know how much that pizza was worth in EUR, when you consumed
> it.

This sounds like ledger's -H/--historical flag.

> 1.
>
> Assets and Liabilities on the other side are recalculated with every
> event of exchange rate change.
>
> This is also inline with conventional wisdom. If you own 1000 of Currency /
> stock XYZ and all of a sudden this currency became more expensive (just
> think of Bitcoin), this means you actually got reacher and you want to see
> it.

This sounds like ledger's -X/--exchange flag, in combination with price
declarations.

> 1.
>
> The exchange rate changes are taken care in the following way:
>
> A special Commodity Revaluation transaction is logged. Following the
> principle of double-entry accounting
>
> -
>
> one shoulder of transaction is logged to corresponding Asset and / or
> Liability accounts to adjust these accounts to new exchange rate.
> -
>
> another shoulder is logged to special Gain due to commodity price change (trading
> account, using Peter Selinger’s terminology).


I *think* these commodity revaluation transactions are the same as those
generated automatically (which you can see in the register report) when
you run with -X. (If not, you may need to do something to model these
transactions in your journal file the way you want them, perhaps with
some combination of costs ('@' syntax), lot prices ('{ }' syntax), and
(real or virtual) accounts to track the gains and losses.)

So do the following commands show you the answers to the questions that
you're looking for?

1) ledger reg -H Expenses Income
2) ledger reg Assets Liabilities -X 'USD' # or whatever currency

I realize that these are not balance reports where the totals are
grouped by account (but then again, neither is your spreadsheet). But
do they give you all the information you need to see how you got from
one balance sheet to a later one?

It would be helpful if you could enter the data in your spreadsheet into
a ledger journal file and then see if/how these reports from ledger
differ from what you expect, based on your own spreadsheet.

--
Best,
Richard

Chary Chary

unread,
Mar 12, 2019, 4:55:05 AM3/12/19
to Ledger
Richard,

I have tested ledger on my example. Once can see input file in Appendix B of my document

It looks like ledger is able to do calculation they I would have expected them to be done. 

Which is cool! 

But, as you said yourself, it is not possible to make ledger put in all in one report and to show overall balance

One would have to query ledger is different ways and paste together different parts of different reports, to get the situation as presented in Appendix A


To get Gain due to commodity price change (trading account)


ledger -f InputFile.txt bal Assets Liabilities --unrealized -X EUR

            EUR2048 Assets:Payment

            EUR-736  Equity:Unrealized Gains

--------------------

            EUR1312


Note: the fact that ledger puts Assets / Liabilities and Unrealized gain in the same report and shows balance between then does not seem to make sense for me at the moment. It is not clear, what the resulting balance EUR1312 is meant to show. Any way, the unrealized gain is calculated as per Appendix A


To see the latest balance sheet-like report


ledger -f InputFile.txt bal Assets Liabilities -X EUR

            EUR2048  Assets:Payment


To see the Expenses and Income and their balance


ledger -f InputFile.txt bal Expenses Income -X EUR -H

             EUR288  Expenses:Shopping

            EUR-600  Income:Salary

--------------------

            EUR-312


Note: it there would be a way to add unrealized gains in this report, but NOT to include Assets and Liabilities, this would be exactly what I am looking for in terms of Income statement-like report, which shows all changes in one report


To list all changes to Assets and Liabilities including “Gain due to commodity price change”


ledger -f InputFile.txt reg Assets Liabilities -X EUR

18-Jan-01 Opening balance       Assets:Payment EUR1000      EUR1000

18-Feb-01 Commodities revalued  <Revalued>       EUR200      EUR1200

18-Feb-02 Step 2 Shopping 1     Assets:Payment EUR-120      EUR1080

18-Feb-03 Step 3. Salary 1      Assets:Payment EUR600      EUR1680

18-Feb-04 Commodities revalued  <Revalued>       EUR280      EUR1960

18-Feb-05 step 5. Shopping wi.. Liabilities:CreditCard      EUR-168 EUR1792

18-Feb-06 Commodities revalued  <Revalued>       EUR256      EUR2048

18-Feb-07 Step 7. Payment to .. Liabilities:CreditCard       EUR192 EUR2240

                               Assets:Payment EUR-192      EUR2048


Reply all
Reply to author
Forward
0 new messages