Re: include directives in ledger 3.2.1 and ledger-reconcile
Hi Colin and all, Colin Dean writes: > I'm using ledger 3.2.1-7build2 from ubuntu impish in the particular records > I'm looking at right now. My includes are using "!include" are relative Thanks, that's good to know. To be clear, ledger itself still seems to read the included files (with relative paths) just fine when I run it from the command line. I only see the error when it is run via ledger-mode in emacs. But I do not see the problem with ledger 3.1.2, so I suspect something changed in ledger between 3.1.2 and 3.2.1 (or between the Debian build and the Guix build) that ledger-mode was implicitly relying on. I am suspicious of the fact that ".path()" was dropped in the last part of the diff here: https://github.com/emin63/ledger/commit/9c1a7b1b1dbad11196571b1114ddaf23ae5345ff I don't know exactly what .path() does, but could that have something to do with this issue? It would be great if someone familiar with the source code could chime in on this. Thanks in advance! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87sfu6lys5.fsf%40aquinas.i-did-not-set--mail-host-address--so-tickle-me.
include directives in ledger 3.2.1 and ledger-reconcile
Hi everyone, I recently switched from ledger 3.1.22-20190205 (in Debian oldstable) to 3.2.1-20200518 (in GNU Guix) and I'm encountering the following issue. At the top of my ledger file are two include directives: include strict.db include prices.db The two included files are in the same directory as the ledger file. But after upgrading, when I try to reconcile an account using ledger-reconcile in Emacs' ledger-mode, I get the following errors: While parsing file "", line 1: Error: File to include was not found: "strict.db" While parsing file "", line 2: Error: File to include was not found: "prices.db" I'm not sure exactly what the cause of this is, but I did confirm that the issue does not occur if I switch back to ledger 3.1.2. It also goes away if I enter full absolute paths for the files, but not relative paths like "./prices.db". I also found this issue about include directives: https://github.com/ledger/ledger/issues/1659 which resulted in this change: https://github.com/emin63/ledger/commit/9c1a7b1b1dbad11196571b1114ddaf23ae5345ff Could this be related to the problem? Is it now required to specify absolute paths in include directives? Many thanks for your insights? -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/877dbjxwtz.fsf%40aquinas.i-did-not-set--mail-host-address--so-tickle-me.
Re: prices & pricedb Reporting Commands
Hi lipp, lipp f writes: > Thank you for your answer Richard. For me, it makes no difference if I use > a real jurnal or an empty one. Absolutely nothing on the screen. > > Can you please explain what each command does and how are they different? > Maybe to show how you run them, what parameters are you using and what the > output is? The command 'ledger pricedb' outputs prices in a format that can be read back in by ledger, like: P 2021/09/29 00:00:00 VBTLX $11.269182911655 P 2021/10/04 00:00:00 VBTLX $11.29 P 2021/10/11 00:00:00 VBTLX $11.19 P 2021/10/18 00:00:00 VBTLX $11.24 'ledger prices' basically outputs the same information but not in the format of a ledger price declaration, and only one price per day, like: 2021/09/29 VBTLX$11.269182911655 2021/10/04 VBTLX $11.29 2021/10/11 VBTLX $11.19 2021/10/18 VBTLX $11.24 As you can see, there is very little difference here in my case (VBTLX has a price at most once a day anyway) but the pricedb format above starts with "P" and has a slot for the seconds. Note also that both commands output prices calculated by ledger (the first line in both cases), as well as those explicitly recorded in the price database. The entries in my prices.db file, which I just include in my main ledger file with the line include prices.db look like this: P 2021/10/18 VBTLX $11.24 (I have a custom script that I use to fetch these periodically and append them to the prices.db file.) Thus, both of these commands require specifying the ledger file, which I do implicitly via the LEDGER_FILE environment variable, but you can do explicitly with e.g. ledger -f path/to/file prices ledger -f path/to/file pricedb and the price declarations are then pulled in from the separate prices.db file via the include line. Of course, there are transactions involving these commodities in my main ledger file, which look like 2021/09/29 * Broker assets:Retirement:Roth IRA10. VBTLX @@ $112.69 revenues:Investments:Dividends -$112.69 Again, without any transactions that actually the commodities which have prices, you probably won't see any output. So that's my setup. Does that help? -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87r1chpftk.fsf%40aquinas.rewrittenlocator.xyz.
Re: prices & pricedb Reporting Commands
Hi lipp, lipp f writes: > My understanding is that these commands are supposed to somehow show > records from the price database. > > I have tried the following commands > > $ ledger --args-only --price-db prices-db.j -f empty.j pricedb > > $ ledger --args-only --price-db prices-db.j -f empty.j prices > > ..., eventually followed by a commodity name or a commodity filter like -l > 'commodity=~/USD/'and I don't get anything. I suspect this is because you are using an empty journal file (based on the name you've given here). Is that the case? These commands work fine for me if I use my regular journal file. If I use an empty one, I get no output. I'm not sure what you'd expect ledger to report for an empty journal file, since there are no transactions from which prices can be calculated. (Are you just expecting it to echo your prices-db.j? If so, I'd recommend a different command for that ;) -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87wnmcf5yo.fsf%40aquinas.rewrittenlocator.xyz.
Re: Feasability of using ledger an co. for small business accounting automation
Tomás de Almeida writes: > I was thinking about doing something very simple and barebones. Akin to > having job that extracts and parses daily transaction reports from the > company's bank account into the main ledger data file. > > I imagine some of the transactions would be easy to automate as writing > them into the proper category: repeat customers, periodic fees of > subscribed services, etc. > > The "new" transactions would always be a mistery on which category they > should be parsed, so they would go into a "to insert manually later" file > that we would hsve to take a look from time to time. I don't have any experience using ledger to manage a business, but I thought it would be useful to add here that you shouldn't underestimate the power of a good text editor to help with this automation. Customizing your editor to help with data entry can save you a lot of time and effort without taking a human who has all the necessary context out of the loop. For example, I use ledger-mode for Emacs, which provides great features like completion of account names. I also have various abbrevs setup for common transactions, so that I can just type e.g. "atm" and get a transaction filled out for a typical ATM withdrawal, for which I can then adjust the amount if necessary. I have written custom commands to automate other things too, like adding the exchange rate on a certain date. You can go really far with this kind of mostly-automated-but-human-adjusted data entry. Writing custom scripts can be a lot of work (depending on what the incoming data looks like) and as you note, there will probably be many cases where more context is needed to categorize something properly. At least for me personally, it works better to start with editor customization, and only move to a fully-automated script in cases where I'm sure I will not need to do any manual review. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87blcdq2kz.fsf%40aquinas.
Re: Arithmetic
Dan Sladden writes: > Why does this do what I expect: > > 2020/01/01 Works > Assets:Cash(£10*(3 -1)) > Equity > > but this (without the space before the minus sign) doesn't: > > 2020/01/01 Doesn't work > Assets:Cash(£10*(3-1)) > Equity Whoa, strange. I think this is probably a bug. I can confirm that the first transaction puts £20 in Assets:Cash, but the second does not, on ledger 3.1.2. (I realize this version is a bit old; I'm on Debian stable.) Dan, what version are you running? Can anyone test on a more recent version? It's also strange that ledger does not throw an error or complain or anything about the second transaction. It's as if it's simply blind to it. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87sg67vtqq.fsf%40aquinas.
Retrieving and inserting exchange rates in ledger-mode
Hi all, In case there are ledger-mode users here who might find this useful, I wanted to share a snippet of code I wrote as I was doing my end-of-year journal file tidying. It scrapes the USD-EUR exchange rate from exchange-rates.org for the date of the transaction at point, then enters it as a price declaration for the same date on the line before the transaction. Thus it transforms something like 2020/12/29 * Salary assets:Checking €10 revenues:Income into P 2020/12/29 € $1.2255 2020/12/29 * Salary assets:Checking €10 revenues:Income Useful if, like me, you have to report overseas earnings on your US taxes! I have ledger-insert-exchange-rate bound to C-c X in ledger-mode. The currency names and symbols are hardcoded but they'd be easy to adapt to your own needs. Improvements welcome. Happy New Year! Best, Richard (defun parse-EUR-USD-exchange-rate () "Find and parse the exchange rate out of a buffer containing the HTML from exchange-rates.org" (goto-char (point-min)) (if (re-search-forward "1 Euro in US Dollars is \\([[:digit:]]+\\.[[:digit:]]+\\)" (point-max) t) (match-string 1) (error "Exchange rate not found in HTML"))) (defun fetch-exchange-rate-on (month day year) "Return the exchange rate from exchange-rates.org on a given date" (let* ((url (format "https://www.exchange-rates.org/Rate/EUR/USD/%s-%s-%s; month day year))) (with-current-buffer (url-retrieve-synchronously url t t) (parse-EUR-USD-exchange-rate (defun ledger-insert-exchange-rate () "Add the exchange rate on a certain date as a price declaration to the line before point" (interactive) (save-excursion (goto-char (car (ledger-navigate-find-xact-extents (point (when (looking-at ledger-iso-date-regexp) (let* ((year (match-string 2)) (month (match-string 3)) (day (match-string 4)) (date-str (match-string 0)) (ex-rate (fetch-exchange-rate-on month day year)) (price-str (format "P %s € $%s\n" date-str ex-rate))) (insert price-str) -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87wnwycapa.fsf%40aquinas.
Re: Question
o1bigtenor writes: > On Sun, Dec 22, 2019 at 9:47 AM Richard Lawrence wrote: >> But at least in this case you can fake it with regexps: >> >> ledger reg --limit 'account =~ /9795\.00\.[0-9][0-8]\.(([0-4][0-9])|50)/' >> > Could you possible explain the part from the first '/' - - - - or - - > - -point me > to a reasonably decent guide on how to do this? I'm not quite sure I understand the question. 'account =~ /something/' is ledger's syntax for an expression that is true if the account name in a posting matches the regular expression "something" (the regular expression is everything between the '/' characters). See section 11.4, "Complex expressions", in the manual. Basically, the regular expression I gave you says: match any account name - that starts exactly with '9795.00.' - followed by two digits, where the second digit maxes out at '8' - followed by '.' - followed by two digits, where either the two match exactly '50', or the first maxes out at '4' and the second maxes out at '9' Is that the explanation you're looking for? If you don't know how to write regular expressions like this, there are zillions of guides out there -- you can search the web for one that works well for you. This is a pretty cumbersome way to filter on account names, though! If I were you, I would use human-readable strings as account names, because it's much easier to filter text with regular expressions (which is pretty much the only way ledger has to filter by account, as far as I know). If you really want to filter using the numbering system you've developed, you might consider putting those numbers in a metadata field where you can actually use them as numbers. For example, if you put the number as the value of a tag in a posting, like 2019/12/12 Some postings expenses:Something €3.00 ; AcctNum: 9795006948 expenses:Something €4.00 ; AcctNum: 9795006928 assets:Cash then you can use a value expression like to_int(tag("AcctNum")) > 9795006929 as the argument to --limit, which will in this case show you just the first posting for €3.00. I'd recommend looking over the EXPRESSIONS section in the ledger manual page to see what other possibilities might work for you. Hope that's helpful! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87woan8fzr.fsf%40aquinas.
Re: Question
o1bigtenor writes: > My record keeping system is a little complex and I have lots of levels > of sub-accounts. As I'm doing my 'do the taxes trick' life would be > quite a bit simpler if I could total the amounts in all the levels of > sub-accounts under a particular account. > > Now 9795.00.66.01 is a sub-account in a group that starts at > 9795.00.00.00 (The major sub-account) and runs to 9795.00.98.50 with > presently 57 sub-accounts. > > Is there some way to ask ledger to print and sum all the transactions > from 9795.00.00.00 to 9795.00.98.50? The best way I know to do this would be to use the --limit flag with an expression that matches just the accounts you want to sum. I don't know that ledger has a good way of treating account names as numbers inside an expression, and I suspect that you will end up fighting with ledger a lot if your accounts tree is based on assuming that it can. But at least in this case you can fake it with regexps: ledger reg --limit 'account =~ /9795\.00\.[0-9][0-8]\.(([0-4][0-9])|50)/' Hope that helps! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87zhfk8irx.fsf%40aquinas.
Re: Auto-completion on Tab in Emacs?
Hi Oscar, Oscar writes: > I can't seem to have auto-completion to work when I press tab in > ledger-mode in Emacs . > > Previous versions I never had this problem. Is this a bug? It does indent > but pressing tab doesn't do the autocomplete. This was changed recently; I noticed it too when I recently upgraded ledger-mode. Discussion here: https://github.com/ledger/ledger-mode/pull/174 To get (something like) the old behavior back, you can do: (add-hook 'ledger-mode-hook (lambda () (setq-local tab-always-indent 'complete) (setq-local completion-cycle-threshold t) (setq-local ledger-complete-in-steps t))) I found that this solution was not quite satisfying; whatever the old version did to guess the ordering of completions was better. But I also recently decided to try out Ivy for completion; with ivy-mode on, I find this is enough: (add-hook 'ledger-mode-hook (lambda () (setq-local tab-always-indent 'complete) (setq-local completion-cycle-threshold t))) -- HTH, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87impix1pd.fsf%40aquinas.i-did-not-set--mail-host-address--so-tickle-me.
Re: Data Entry GUI - Cashier
Hi Alen and all, Interesting idea! Alen Šiljak writes: > Sure. If there is a quick way of entering transactions on the phone, I'm > all ears! It would save me a lot of time of reinventing the wheel, then. ;) I too would like a better way to capture transactions on my phone when I'm on the go. For me, it's not important to see balances or other reports on the phone. But it would be really great to have a quick way to enter data at the moment that I make the transaction, so I don't have to carry the receipt home (or remember the amount if I don't get a receipt). Most of my daily transactions are in cash, so it's particularly important to capture these things before I forget. I have a separate file that defines my accounts for ledger's --strict option. It would be great to pass this file to an app so that it could help me quickly select the right accounts to define the transaction. The tricky part is then getting that data into a ledger file on my computer. I would be somewhat reluctant to trust yet another third-party server for this. It would be great if I could e.g. copy and paste it from an email (or an IMAP-based "Note", available on iOS) on a server I already have to trust, or if the app could briefly upload data to a server I run from my local computer when I want to sync. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87h89yij3z.fsf%40aquinas.i-did-not-set--mail-host-address--so-tickle-me. For more options, visit https://groups.google.com/d/optout.
Possible bug: Re: How does --unrealized work?
Hi all, I never got a reply, so since it's possible there's a bug here, I thought I would bump this message. Does anyone have any insights about my Example 3? Best, Richard Richard Lawrence writes: > Hi everyone, > > In trying to answer Chary's question, I have realized I do not have a > very good grip on how to think about "unrealized" gains and losses, and > how ledger calculates them. So I wrote a few test cases to help explain > it to myself. (Can you tell I'm procrastinating a little bit? ;) I am > not sure, but I *may* have discovered a bug: see Example 3. Can someone > explain this to me? > > Example 1: you hold a certain quantity of stock throughout the > entire period, during which its value fluctuates. Say you hold 2 > shares of AAPL. At the beginning of the period, each is worth $500. > At the end, each is worth $525. > > 2018/12/31 Opening Balances > Assets:Stocks 2 AAPL @ $500 > Equity:Opening Balances > > P 2019/01/01 AAPL $500 > P 2019/02/01 AAPL $515 > P 2019/03/01 AAPL $525 > > The unrealized gain is then: > (2 AAPL * $525) - (2 AAPL * $500) = $1050 - $1000 = $50 > i.e., > (end quantity * end price) - (beginning quantity * beginning price) > > That is exactly what ledger reports, with --unrealized: > > ledger -f test.journal bal Assets:Stocks -X '$' --unrealized > >$1050 Assets:Stocks > $-50 Equity:Unrealized Gains > >$1000 > > == > Example 2: you hold a certain quantity of stock throughout the > entire period, but you also acquire more at some point in the > middle. Say you hold 2 AAPL at the beginning of the period, each > worth $500. At some later point, when AAPL is up to $510, you buy > one more share. At the end of the period, all three shares are > worth $525. > > 2018/12/31 Opening Balances > Assets:Stocks 2 AAPL @ $500 > Assets:Checking $1000.00 > Equity:Opening Balances > > P 2019/01/01 AAPL $500 > > P 2019/02/01 AAPL $510 > > 2019/02/02 Broker > Assets:Stocks 1 AAPL @ $510.00 > Assets:Checking > > P 2019/03/01 AAPL $525 > > I would then expect the unrealized gain to be: > (3 AAPL * $525) - (2 AAPL * $500 + 1 AAPL * $510) = $65 > > Again, this is just what ledger says: > > ledger -f test.journal bal Assets:Stocks -X '$' --unrealized > $1575.00 Assets:Stocks > $-65.00 Equity:Unrealized Gains > > $1510.00 > > == > Now for the problematic example: > > Example 3: you sell some stock at one point when the price > rises, and reacquire it when the price drops. Say you start holding > 2 shares of AAPL, each worth $500. Then, when the price is up to > $540, you sell one share, resulting in a realized gain of $40. > Later, the price drops to $490 and you buy another share. At the > end of the period, the price is $525, and you also have $50 in the bank. > > 2018/12/31 Opening Balances > Assets:Stocks 2 AAPL @ $500 > Equity:Opening Balances > > P 2019/02/01 AAPL $540 > > 2019/02/02 Broker > Assets:Stocks -1 AAPL @ $540.00 > Assets:Checking > > P 2019/02/10 AAPL $490 > > 2019/02/10 Broker > Assets:Stocks 1 AAPL @ $490 > Assets:Checking > > P 2019/03/01 AAPL $525 > > Now, what is the unrealized gain here? First of all, it's not clear how > this should be calculated. I thought of two reasonable ways to > calculate it, which give different results. From one perspective, this > example is the same as Example 1: you started and ended the period with > 2 shares of AAPL, worth $500 each at the beginning and $525 at the end, > for an unrealized gain of $50. But following the logic of Example 2, > counting unrealized gains only from the first time the share is > acquired, we'd get: > $525 - $500 = $25 unrealized gain for Share #1 (held the whole period) > $525 - $490 = $35 unrealized gain for Share #3 (bought on 2019/02/10) > leading to a total of $60 of unrealized gain. > > Ledger actually does it differently. It says we have $150 in > unrealized gains, and $50 in unrealized losses: > > ledger -f test.journal bal Assets:Stocks -X '$' --unrealized > $1050.00 Assets:Stocks > $-100.00 Equity > $-150.00Unrealized Gains >
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Hi Chary and all, I don't have time for a long reply but here are some quick thoughts: Chary Chary 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
How does --unrealized work?
Hi everyone, In trying to answer Chary's question, I have realized I do not have a very good grip on how to think about "unrealized" gains and losses, and how ledger calculates them. So I wrote a few test cases to help explain it to myself. (Can you tell I'm procrastinating a little bit? ;) I am not sure, but I *may* have discovered a bug: see Example 3. Can someone explain this to me? Example 1: you hold a certain quantity of stock throughout the entire period, during which its value fluctuates. Say you hold 2 shares of AAPL. At the beginning of the period, each is worth $500. At the end, each is worth $525. 2018/12/31 Opening Balances Assets:Stocks 2 AAPL @ $500 Equity:Opening Balances P 2019/01/01 AAPL $500 P 2019/02/01 AAPL $515 P 2019/03/01 AAPL $525 The unrealized gain is then: (2 AAPL * $525) - (2 AAPL * $500) = $1050 - $1000 = $50 i.e., (end quantity * end price) - (beginning quantity * beginning price) That is exactly what ledger reports, with --unrealized: ledger -f test.journal bal Assets:Stocks -X '$' --unrealized $1050 Assets:Stocks $-50 Equity:Unrealized Gains $1000 == Example 2: you hold a certain quantity of stock throughout the entire period, but you also acquire more at some point in the middle. Say you hold 2 AAPL at the beginning of the period, each worth $500. At some later point, when AAPL is up to $510, you buy one more share. At the end of the period, all three shares are worth $525. 2018/12/31 Opening Balances Assets:Stocks 2 AAPL @ $500 Assets:Checking $1000.00 Equity:Opening Balances P 2019/01/01 AAPL $500 P 2019/02/01 AAPL $510 2019/02/02 Broker Assets:Stocks 1 AAPL @ $510.00 Assets:Checking P 2019/03/01 AAPL $525 I would then expect the unrealized gain to be: (3 AAPL * $525) - (2 AAPL * $500 + 1 AAPL * $510) = $65 Again, this is just what ledger says: ledger -f test.journal bal Assets:Stocks -X '$' --unrealized $1575.00 Assets:Stocks $-65.00 Equity:Unrealized Gains $1510.00 == Now for the problematic example: Example 3: you sell some stock at one point when the price rises, and reacquire it when the price drops. Say you start holding 2 shares of AAPL, each worth $500. Then, when the price is up to $540, you sell one share, resulting in a realized gain of $40. Later, the price drops to $490 and you buy another share. At the end of the period, the price is $525, and you also have $50 in the bank. 2018/12/31 Opening Balances Assets:Stocks 2 AAPL @ $500 Equity:Opening Balances P 2019/02/01 AAPL $540 2019/02/02 Broker Assets:Stocks -1 AAPL @ $540.00 Assets:Checking P 2019/02/10 AAPL $490 2019/02/10 Broker Assets:Stocks 1 AAPL @ $490 Assets:Checking P 2019/03/01 AAPL $525 Now, what is the unrealized gain here? First of all, it's not clear how this should be calculated. I thought of two reasonable ways to calculate it, which give different results. From one perspective, this example is the same as Example 1: you started and ended the period with 2 shares of AAPL, worth $500 each at the beginning and $525 at the end, for an unrealized gain of $50. But following the logic of Example 2, counting unrealized gains only from the first time the share is acquired, we'd get: $525 - $500 = $25 unrealized gain for Share #1 (held the whole period) $525 - $490 = $35 unrealized gain for Share #3 (bought on 2019/02/10) leading to a total of $60 of unrealized gain. Ledger actually does it differently. It says we have $150 in unrealized gains, and $50 in unrealized losses: ledger -f test.journal bal Assets:Stocks -X '$' --unrealized $1050.00 Assets:Stocks $-100.00 Equity $-150.00Unrealized Gains $50.00Unrealized Losses $950.00 Huh? Here's what I think is going on: Consider Share #1, held for the whole period. It first gained $40 in value, lost $50, and then gained $35. So, $75 in unrealized gains, $50 in unrealized losses. Share #3 was bought at $490 and then moved to $525 at the end of the period. So, that's another $35 in unrealized gains. Together with Share #1's unrealized gains, that's a total of $110. Share #2 was sold at the first price move, on 2019/02/02. As far as I can see, it should have *no* unrealized gains or losses. (It has, instead, a *realized* gain of $40.) Ledger reports $150 in unrealized gains rather than $110, so it must be including that $40 from Share #2 as unrealized gains. That
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Hi Chary and all, Chary Chary 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Hi Chary and all, Chary Chary 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 > > 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Hi Chary and all, Here's a few more thoughts. Chary Chary 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Hi Chary, Chary Chary 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 EURUnrealized 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Need Ledger Information
Hi Megha, megha g writes: > That's Great Richard, (Please reply to the whole list, not just to me! That way, the conversation also helps other people getting started.) > it's working fine and i ran few Reports as well. > > 1) How can i create a New journal to my existing project. > > 2) Do i need to create new Journal or i can modify the existing file. A journal is just a text file. You can create a new journal, or edit an existing one, using any text editor you like. If you don't have one yet, I recommend Emacs. It has a very nice mode for editing ledger journals. To install (a graphical version of) Emacs on Ubuntu, as well as the support for ledger (called "ledger-mode"), run: sudo apt-get install emacs-gtk ledger-el I would also recommend installing the Emacs documentation: sudo apt-get install emacs-common-non-dfsg Of course, there's a lot to learn about Emacs, too! To learn the basics, start Emacs and then type "C-h t" (that's "Control-h" followed by "t"). To read the manuals that come with Emacs, type "C-h i". If you need more help, you should ask on the Emacs mailing list; that's off-topic for this mailing list. Here's the manual for ledger-mode: https://www.ledger-cli.org/3.0/doc/ledger-mode.html That should get you started with editing ledger journals in Emacs. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Need Ledger Information
megha g writes: > Thank you for the information. > > 1) And, i am using *Ubuntu *operating system. Great! > 2) Shell is *command prompt.* OK, so your shell is probably bash, then. (Run the command "echo $SHELL" to be sure.) That should be fine. > 3) Path is /home/megha/ledger Hmm. I think you mean that's the path to your ledger executable. How did you install it? If you're using Ubuntu, ledger is available through the package manager, so you don't need to install it in a special location like your home directory. You can type: sudo apt-get install ledger in your shell (and then enter your password) to install ledger. After you do that, the program should be available. To check, run the command: which ledger You should see something like "/usr/bin/ledger". If you then run ledger --help you'll see the system help file (i.e., the "man page") for ledger. Type "q" to exit and get back to your command line. If all that works as expect, congratulations! You have a working ledger installation. The next step is to create a journal file, and use ledger to run some reports. You can read about how to do that in the manual, starting in section 2. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Income Statement" aka "Profit/Loss Statement" with unrealized gain due to changes in stock and currency exchange rate
Dear Chary, Chary Chary 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 -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Need Ledger Information
Dear Megha, megha g writes: > As i am new to this Ledger topic. I am not getting proper idea about > ledger, From where it will run, where i need to do changes in order to get > the ledger output, can anybody please help me out to understand the > details of the ledger. Please guide me. Well, a good place to start is with the manual: https://www.ledger-cli.org/docs.html https://www.ledger-cli.org/3.0/doc/ledger3.html As for where and how it will run, we'd need to know more about your environment. In general, you run ledger from the command line, so you must install it in a location where your shell (your command line program) can find it. This is usually straightforward, especially if you install it using a package manager on an operating system like GNU/Linux. But to help you with this we'd need more information about your operating system and shell. Can you answer these questions? 1) What operating system are you using? 2) What shell are you using? 3) Where does your shell look for the programs it runs, i.e., what is your $PATH? -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Backup and cloud-storage
Hi Daniel and all, Dániel Fancsali writes: > Long story short, I was just wondering, what others do to back-up their > work? Do you use version control? Do you back-up to a cloud storage; or > even sync it to multiple machines? What about encryption? I keep my ledger files in a dedicated git repository, with a script to auto-commit them every hour via cron, and push to one of the major git hosting services. That's my backup solution. I don't have more than one machine where I need to work with this repository, but if I did it would be trivial to use git to sync, too. I use git-crypt [1] in a commit hook to keep the unencrypted data off the servers. HTH! -- Best, Richard [1] https://www.agwa.name/projects/git-crypt/ -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Transaction date vs statement date
Budiman Snowman writes: > I want to be able to produce report of monthly expenses as > they are incurred (tuition fee in Aug and doctor visit in Oct) and also > want to record my cash flow (reimburse my wife in Jan). ... > Is there a shorter way, e.g. if ledger lets me put in transaction date and > statement date in one entry. Well, there are auxiliary dates: https://www.ledger-cli.org/3.0/doc/ledger3.html#Auxiliary-dates Those are useful for this kind of thing, if you don't need both dates in the same report. But if you do, then the way you have already represented it seems like the best way to me, though perhaps others have better ideas. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Unclear on monthly average balances
Hi Norman, Norman Walsh writes: > I've been happily using ledger-cli for years, but I'm sure I hardly scratch > the surface of what it can do. Every now and then, I get an idea to see if > I can learn to use more of it. Today's thought was "would having a budget > be useful?" > > So I go digging through the docs and I come to this example of how to get > the current monthly average expenses: > > $ ledger -p "this year" --monthly --average balance ^expenses > > But the numbers don't make any sense. My average rent is apparently $99.55!? The short answer is that --average doesn't work with the balance command; it only works with the register command. Do you get more sensible results with a command like this? ledger -p "this year" --monthly --average reg 'expenses:Groceries$' (Another gotcha: --average also seems to interact badly with subaccounts, which is why I have the '$' in there.) FWIW, I think hledger is able to do averages with the balance command, and I find its output much more intuitive and useful, so you could try that. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. signature.asc Description: PGP signature
Re: Monthly balance position
John Wiegley <jwieg...@gmail.com> writes: "RL" == Richard Lawrence <wyle...@gmail.com> writes: RL> I don't think so, at least not with regular ledger. I'd be happy to be RL> proven wrong, though! I have also wanted this feature. You can use: ledger --group-by 'format_date(date, "%Y/%m")' bal Ah, that's helpful! Thanks! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Monthly balance position
Hi Klauss, Klauss Hasswrites: Is there any way to use the argument —monthly or --weekly for bal transactions? I value my assets weekly and it would be useful to see the month ending value variation of my assets:investments accounts along with the -V argument. I don't think so, at least not with regular ledger. I'd be happy to be proven wrong, though! I have also wanted this feature. hledger (hledger.org), however, does allow --monthly (and similar flags) with the balance command. You might want to check that out. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Cannot get ledger-mode to run properly
Hi Nikolai, Nikolai Stenforswrites: 1. Debian GNU/Linux 9.3 (stretch), xfce4 2. M-x list-packages, marked ledger-mode, Install 3. PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games No, I cannot find ledger in any of these directories. Ah. Do you have ledger itself installed? (Try 'which ledger' in a shell.) You will need ledger to use ledger-mode. If not, you can install it on Debian with # aptitude install ledger (or apt-get, etc.). Looking at *exec-path,* I also see "/usr/lib/emacs/25.1/x86_64-linux-gnu" listed. Should I add/insert "~/Dropbox/.emacs.d/elpa/" to *exec-path?* (all my installed packages are listed in this directory) No, I don't think that will help: I suspect the problem is that the ledger binary is not on your PATH. That binary isn't included in the ledger-mode package, so it won't help to add your elpa directory to exec-path. -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Cannot get ledger-mode to run properly
Hi Nikolai, Nikolai Stenforswrites: When I invoke ledger mode, M-x ledger-mode, I get the error (translation from Swedish): Searching for program: File or catalog does not exist, ledger This sounds to me like a problem with your PATH. What platform are you on? How and where did you install ledger? In Emacs, try evaluating the following (via M-:) (getenv "PATH") You should see a list of directories. Do you see the directory where the ledger binary is installed there? -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: how to strip dollar sign in reports
Hi Alan, Alanwrites: What's the new way to ask for the amounts as plain, unadorned numbers? Well, I don't know how to do this with ledger, but if you're on some flavor of unix you can always do: ledger (whatever) | tr -d '$' Hope that helps! -- Best, Richard OpenPGP Key ID: CF6FA646 Fingerprint: 9969 43E1 CF6F A646 https://www.ocf.berkeley.edu/~rwl/ -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Referring to account in automated transactions
cesar.m...@gmail.com writes: Justin St-Amantwrites: Is there a way to refer to the tail-end of the matched account in an automated transaction, using a variable such as '$account_base' or similar? The ledger manual has a section that shows how to refer to the matching posting's account, by using '$account', but that expands to the full account name, rather than just the end. i was looking for something similar. as per this article: https://frdmtoplay.com/envelope-budgeting-with-ledger/ it seems one needs to create an automated transaction for each type of budgeted expense. I read the same article, and this is one reason that I don't use very fine-grained "envelopes". Instead, I have just three budget categories: Fixed (stuff I have no choice about whether or how much to pay, like rent and utilities), Discretionary (stuff I have choices about, like groceries or restaurants) and Savings. I find this system more useful for budgeting than putting every individual kind of expense in its own account/"envelope". To implement this system, I use a regexp matching specific Expense accounts to trigger automatic transactions that should go under Fixed or Savings. Then, every other transaction in Expenses gets deducted from the Discretionary budget category. My setup looks like this: = expr 'account =~ /expenses:(Rent|Utilities|Medical|Phone|Financial||Taxes)/' ; :FIXED: [assets:Budget:Fixed] -1.0 [assets:Checking]1.0 = expr 'account =~ /expenses/ and not has_tag("FIXED") and not (account =~ /Reimbursable/)' ; :DISCRETIONARY: [assets:Budget:Discretionary] -1.0 [assets:Checking]1.0 = expr 'account =~ /assets:(Retirement|Emergency)/ and has_tag("contribution")' ; :SAVINGS: [assets:Budget:Savings] (cost * -1.0) [assets:Checking] (cost * 1.0) I then use the tags in these automated transactions to produce a custom balance report for my budget: $ ledger balance budget -e 'next month' will show how much is remaining in each assets:Budget account for the month. Hope that helps! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Recording real balances in the presence of virtual transactions
Hi John, John Leewrites: However, I guess I can't do this: 2017-10-01 * Opening Balance Assets:CurrentAccount $1000 Equity:OpeningBalances 2017-10-02 * Savings Assets:CurrentAccount:Savings $100 Assets:CurrentAccount Because then if I go on to do this: 2017-10-03 * Adjustment Assets:CurrentAccount = $1005 Equity:Adjustments then this balance command tells me I have made $100 out of thin air ($1105 total): ledger b Assets:CurrentAccount That's because in that final txn I'm actually setting not the summed-up total of everything in *or under* Assets:CurrentAccount, as appears in the balance output, but the amount that lives in that *exact* location (which you might write in a balance command as '^Assets:CurrentAccount$'). I'm not sure there's any way to fix that final txn to say that it's actually the *total* "descendant-or-self" value I want to set equal to $1005? Hmm, I see. I'm surprised by this, but I don't use balance assignments myself. If you need balance assignments like this, I guess subaccounts are not the way to go. (Unless this is a bug?) Personally, I want every transaction recorded -- independently, so I can check my record against my bank's. Thus, I avoid what you're trying to do here: automatic adjustments via balance assertions. But I realize that "don't do that" is not very helpful advice. :) Can anyone else lend some insights? -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Opening Balances problem
Hi Filipo, Filipo Vwrites: Hi all, I'm new to ledger and I'm frustrated I can't figure out what I've done wrong to begin with. Here is part of my file: 2015/05/27 * Opening Balance Assets:BankA:Current 482.40 Equity:Opening Balances Now, when I try to run the basic balance command, I get this: While parsing file "myledger.dat", line 6: Error: Posting with null amount's account may be misspelled: "Assets:BankA:Current 482.40" Can anyone help? Looks like the problem here is that you only have one space between the account name and the amount. Since spaces are allowed in account names, you must have at least two spaces between the account name and the amount. Hope that helps! -- Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Conversion nightmares: gnucash to ledger-cli
Dear Rushad, Rushad Faridiwrites: > Firs I tried ledger 2.x approach since 3.x can not do the conversion. I > had not much of a problem installing 2.x but after I issued the command " > ledger -f myfile.gnucash print > myfile.txt" it spitted out 27 lines of > error with something " invalid date string". I had a cursory look at my > account entries but did not find anything wrong. Any suggestions on how to > fix that? What were the errors that you saw? Probably someone here can help you with this, but we'd need more information about what went wrong. > Anyway, I went ahead > and ran the python script "gnucash2ledger.py" downloaded from > "https://github.com/MatzeB/pygnucash; in the following manner: > > python2.7 gnucash2ledger.py myfile.gnucash print > test.txt (It does not look like you should have "print" in this command line invocation, though probably the Python program is just ignoring it.) > The error came through is as follows: > > Traceback (most recent call last): > File "gnucash2ledger.py", line 35, in > data = gnucash.read_file(sys.argv[1]) > AttributeError: 'module' object has no attribute 'read_file' This is a strange error to see, if you are indeed using the code from that repository. Python is complaining that it can't find the read_file function in the gnucash module. But the gnucash module from that repository does contain such a function. So either you're importing a *different* module named "gnucash", or something very weird is happening in the gnucash2ledger module that messes up the attributes of its own gnucash module. I suspect the former. Try this: 1) Run a Python interpreter from a directory *outside* the repository you referenced (so that the pygnucash code is not on Python's search path). 2) Type 'import gnucash' at the prompt. You should see an ImportError. 3) If you do *not* see an ImportError, your Python is importing some other module named 'gnucash' (perhaps this comes with GnuCash itself?). Try typing: gnucash.__file__ gnucash.__path__ at the Python prompt. This will tell you where the conflicting gnucash module is located. 4) If you *do* see an ImportError, quit Python, and try these steps again, but this time run Python from *inside* the pygnucash repository. This time, you should *not* see an ImportError. In that case, make sure that gnucash.__file__ and gnucash.__path__ are what you'd expect, and then try hasattr(gnucash, 'read_file') This should return True. Let us know what you see! Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Reconciling and virtual accounts
Hi everyone, I recently tried to set up "envelope" budgeting, following this guide: https://frdmtoplay.com/envelope-budgeting-with-ledger/ One important aspect of this system is that money is moved from a (real) checking account to a virtual budget account at the start of the budget period, and expense transactions then "return" money from the virtual budget account to the real checking account. The overall result is that expenses are really covered by the checking account, but are virtually covered by a particular budget account. The setup works fine for budgeting, but there's one major problem: it breaks the Reconciliation mode in Ledger mode for Emacs. The problem seems to be that Ledger includes all virtual transactions on an account by default, unless the --real option is passed. Because there are virtual budget transactions "returning" money to the checking account, this screws up the balances in Reconciliation mode for the checking account. In short: I always want to reconcile with the real balance, not the virtual balance, but I can't figure out how to pass --real to the commands used by Reconciliation mode. I tried adding this flag to the register report command in the ledger-reports variable, but it didn't seem to have any effect. Is there a way to pass --real to the reconciliation commands? Or is there another workaround that I haven't thought of? How do others deal with reconciliation under envelope budgeting? Thanks for your help! Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Combining within entries in a single posting
Hi Kumar, Kumar Appaiahwrites: > Now, I'd like to view a register containing ONLY the total of Incomes. For > example: > > # ledger -f test.dat reg Income > > This will display the Income:Salary and Income:Allowances separately. Is > there a way that I can get them combined? In other words, a register that > would display -10,000, -8,000 and -9,000? It looks like the -n (--collapse) option does what you want here: # ledger -f test.dat reg -n Income With your file, this gives: 16-Jan-01 Salary-10,000.00 INR -10,000.00 INR 16-Feb-01 Salary-8,000.00 INR -18,000.00 INR 16-Mar-01 Salary-9,000.00 INR -27,000.00 INR Note that this option is only documented in the man page under the balance report, not the register report. So I'm not sure if this is intended behavior, but it works! Hope that helps! Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Annual Averages Report
Hi Brian, Brian Exelbierdwrites: > I am not seeing a report command line that will give me a list of all > accounts and their average amounts for a given period. > > For example, this will give me one account: > > ledger -f all.ledger --empty register Expense:Food -M --average -p "last > 12 months" > > but I don't see way to see every Expense account. I would expect > something like this to work: > > ledger -f all.ledger --empty register Expense -M --average -p "last 12 > months" > > Any suggestions? I don't have a good way to do this with standard ledger. The ledger --average option is a little opaque; at least, it does not behave the way I would expect. Maybe there's a straightforward way to do this with the balance report using a format string (e.g., divide the total for each account by the number of periods)? I hope someone else can give a better answer to this question! But I wanted to say that one reason I have both ledger and hledger installed is that hledger handles this kind of thing very nicely. In hledger, hledger -f all.ledger bal Expense -p monthly --average does exactly what you want, I think. In general, I find the behavior of --average in hledger a lot more intuitive. HTH, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Feature idea: custom named reports!
Hi Josh, Josh Hansonwrites: > Since I don't have every detail of Ledger's syntax memorized, and there are > a few standard reports that I run regularly, I have several ledger command > lines recorded as comments in my journal that I can copy and paste as > needed. > > I'd really like to be able to run those automatically. Here's an easy, > straightforward implementation that feels very "ledger-y" to me: add a > "report" directive to save named reports in the journal, and a "report" > command to run those reports. > > The syntax for the directive might be: > *report *To run the report, > you'd run at the command line: *ledger report * I like this idea. It might be especially useful for very complex reports. I do wonder if ledger itself is the best place to implement it, though. You can already mostly achieve what you want with shell aliases. That's what I do. I have a bunch of lines like this in my .bashrc: alias ldg="ledger --no-color" alias regcc="ldg register --aux-date -S 'date' 'liabilities:Richard:Chase CC'" alias cash="ldg bal --limit 'account =~ /Savings$|Checking$|Cash$/'" So the alias command acts as the name for a report. It doesn't have the advantage of recording the report in your journal file, but at least it means you don't have to copy and paste! HTH, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Question about Automated transactions
Hi Phil, 'Phil Gee' via Ledgerwrites: > I'm back again with a question. I really, really love what I can do with > automated transactions. However, I run into one problem: Suppose I have a > credit card whose debt I track in Liabilities:CreditCard. Generally its > rather nice to see how my equity is in the current month. That I can do > with ledger assets liabilities. Each month I pay my current credit card > debt, i.e. I know that after this payments that Liabilities:CreditCard > won't affect this months' equity. However, running ledger assets liabilities > would be affected by all credit card payments done afterwards. I would like > to split Liabilities:CreditCard in Liabilities:CreditCard:Current and > Liabilities:CreditCard:Next. In Liabilities:CreditCard:Current I would have > all payments which are due this month, in Liabilities:CreditCard:Next all > payments due next month. > It would be great to have an automated transaction which transfers the > content of Liabilities:CreditCard:Next to Liabilities:CreditCard:Current > when my paycheck arrives. Not sure if this helps, but here's what I do to solve a similar problem, without automated transactions or splitting the account. When I schedule a payment for a CC account, I use the auxiliary date field to back-date the payment to the date of the bill. For example, if the billing cycle ends on 4/13, the payment is due 5/13, and I schedule the payment for 5/9, the transaction looks like: 2016/05/09=2016/04/13 CC payment Liabilities:CreditCard $200.00 Assets:Checking Then I run credit card reports with the --effective/--aux-date flag. This has the effect, in the register report for the CC account, of showing the balance going to zero at the billing cycle boundaries (assuming I pay the full balance). Thus, the running total at the end of this report shows the correct balance on the card for every transaction since the billing cycle turned over, even though the payment is technically in the future. Meanwhile, the balance and register reports for the checking account (without the --effective flag) reflect the scheduled payment, unless I set an end date that is not in the future. This makes it easy to tell how much money I actually have in the account (via -e today), and also how much money in the account is not already allocated (no end date), i.e., what my equity is. Hope that helps! Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Related accounts and running totals
John Wiegley <jo...@newartisans.com> writes: >>>>>> Richard Lawrence <wyle...@gmail.com> writes: > >> I think what I'd like to do is limit transactions by the *related* account, >> something like > >> ledger --limit 'related =~ /assets:Me/' reg expenses:shared > > One reason this doesn't exist is because there can be multiple related > accounts. Right, good point. > I suppose that "related" could become the textual sum of all the > related accounts? After thinking about this, I'm not sure it would work in my current setup. I have transactions like this: 2015/08/07 Shared credit card payment liabilities:shared:CC $1000.00 assets:Me:Checking$-600.00 assets:Roommate $-400.00 I'd like to be able to use two different expressions here to generate two reports, for Me and for Roommate. The first report would include my $600 payment in the running total of what I've paid toward the shared account; the second report would include my roommate's $400 payment in her running total. So, given my current setup, I guess what I would need is a way to limit by individual related accounts within a transaction, not just their textual sum. I was envisioning "related =~ /assets:Me/" in the pseudo-command above as selecting just my `side' of transactions like this for inclusion into the report. I have no idea if that's compatible with the way ledger actually works internally, though. (This may not be the best way to record such payments, though it does make it easy to see at a glance that the correct total amount was paid, while recording the different contributions. But I'm willing to switch to separate transactions if it makes the reporting easier.) Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. signature.asc Description: PGP signature
Re: Related accounts and running totals
Hi John and all, John Wiegley <jo...@newartisans.com> writes: >>>>>> Richard Lawrence <wyle...@gmail.com> writes: > >> So my question is, is there some way to get a correct running total when >> using --related and limiting to a subset of transactions? Perhaps by using >> --limit instead of --display, or some kind of fancy format string...? >> Nothing I have been able to come up with seems to work. > > The only way to affect the running total is either to use --total or > --display-total to change how it's computed (or displayed), or to use --amount > to change the component values that make it up. --display especially will lead > to mismatched running totals; in fact, its ability to do so is originally why > it was added, so that I could query for data subsets within the context of an > entire report. Thanks for your reply! Yes, I think that --display is not really what I want. I think what I'd like to do is limit transactions by the *related* account, something like ledger --limit 'related =~ /assets:Me/' reg expenses:shared I don't see a way to do this using the available expressions, but I'm pretty new to this; maybe I've overlooked something? Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. signature.asc Description: PGP signature
Related accounts and running totals
Hi all, I have a question about related accounts. I'm on ledger 3.1.0. (I also use hledger 0.27, which I'd be happy to employ here if it can answer this question more easily.) Here is my use case: I keep track of expenses shared with a roommate under expenses:shared, and at the end of a given reporting period I want to be able to ask, "How much did I pay to expenses:shared, and how much did my roommate pay?" to see who owes money to the other. >From the manual, I have gotten this far: I can do $ ledger --related --display 'account =~ /assets:Me/' reg expenses:shared to see transactions where I paid toward expenses shared, and similarly I could use assets:Roommate in the display predicate to see what my roommate paid. But as the manual notes, "The running total...is off, however, since a display expression is being used." The running total reflects all transactions on expenses:shared, not just the ones that are selected by the display predicate. So the above command is only useful for telling me the amounts of the individual transactions displayed; I must tally them up some other way before I can figure out who owes who, and how much. So my question is, is there some way to get a correct running total when using --related and limiting to a subset of transactions? Perhaps by using --limit instead of --display, or some kind of fancy format string...? Nothing I have been able to come up with seems to work. Thanks for any insights you can provide! Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: What to do next
Hi Dee, (Please reply to the list, not just me.) o1bigtenorwrites: >>> How do I get back to the # prompt (kill command isn't working)? >> >> Sounds like you are stuck in your pager (e.g., the `less' program). Try >> "q". >> > That works, thank you! > > Is there something that I can do so that this doesn't happen? On my system, ledger automatically figures out whether it needs the pager or not, and doesn't use it if its output is small enough to fit on the screen. Is your system different? Why don't you want to use the pager? I think you'd probably be better off learning to use the pager if you are not familiar with it, rather than trying to turn it off. Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: What to do next
o1bigtenorwrites: > When I use this command: > > ledger balance -f /some/file/20xx.dat > > if things are in balance the last line is: > > (END) > > How do I get back to the # prompt (kill command isn't working)? Sounds like you are stuck in your pager (e.g., the `less' program). Try "q". Best, Richard -- --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.