Re: Simplified Python importing
Simon Michael simon-jbxitmbj2llqt0dzr+a...@public.gmane.org writes: Just a little honest feedback, of a kind I never see here, offered in case it might be useful to improve ledger, which I care about, contribute to, and want to thrive. I hoped John knows me well enough to not take offense, and I beg lenience... I certainly didn't take it that way. Consistency is awesome, I loves me some consistency. But 3.0 is still beta, which means: Let there be Flux. PS I'm not aware of any serious problem with the way I/hledger relates with the ledger community.. if anyone is, please let's discuss. I think hledger, and all that has gone on around it, has been a great companion to Ledger's goals and progress. John
Re: No rounding applied to transactions?
Robert Lehmann lehmannro-re5jqeeqqe8avxtiumw...@public.gmane.org writes: The automatic transaction (1%) should generate a post of $0.04 and one of $0.03 (which it does!). Then, when adding those posts for balance/ registers, it instead seems to sum up $0.044 and $0.033 (which is $0.077 and rounds up, instead of rounding down two times): This is expected behavior. Ledger never rounds internally, as all values are kept as rational numbers. It only converts them to decimal floating point -- and performs rounding -- to *display* figures; but never to perform math on them. If you want the kind of rounding you're describing, you can use this: = /Expenses:Bug Fixes/ Liabilites:Refactoring (truncated(amount) * 0.01) Be aware that doing so converts the amount to a floating point, performs the truncation based on the visual characteristics of that commodity *as known at the relevant point in the input stream*, and then converts the floating point back to a rational. I.e., such an automated transaction will be slow, although it's just O(N) slow added to whatever time it takes now. John
Re: docs status (Re: consolidate docs?)
Simon Michael simon-jbxitmbj2llqt0dzr+a...@public.gmane.org writes: Moving it, perhaps preserving history, requires a bit of git-fu. That type of moving I've done many times. If you're amenable, I already know the git-fu. It will basically be just like having two repos in a single repository: they will just be differentiated by branch name rather than by clone URL. John
Understanding transactions
The following mini-doc attempts to cover every syntactic corner of the Ledger transaction syntax. If I've missed anything, please let me know. Note that this is a subset of all the syntax allowed in a journal file. I haven't covered directives here or file-level comments. John # Basic format The most basic form of transaction is: 2012-03-10 KFC Expenses:Food$20.00 Assets:Cash $-20.00 This transaction has a date, a payee or description, a target account (the first posting), and a source account (the second posting). Each posting specifies what action is taken related to that account. ## Multiple postings A transaction can have any number of postings: 2012-03-10 KFC Expenses:Food$20.00 Assets:Cash $-10.00 Liabilities:Credit $-10.00 # Eliding amounts The first thing you can do to make things easier is elide amounts. That is, if exactly one posting has no amount specified, Ledger will infer the inverse of the other postings' amounts: 2012-03-10 KFC Expenses:Food$20.00 Assets:Cash $-10.00 Liabilities:Credit ; same as specifying $-10 ## Elision with multiple commodities If the other postings use multiple commodities, Ledger will copy the empty posting N times and fill in the negated values of the various commodities: 2012-03-10 KFC Expenses:Food$20.00 Expenses:Tips $2.00 Assets:Cash EUR -10.00 Assets:Cash GBP -10.00 Liabilities:Credit This transaction is identical to writing: 2012-03-10 KFC Expenses:Food$20.00 Expenses:Tips $2.00 Assets:Cash EUR -10.00 Assets:Cash GBP -10.00 Liabilities:Credit $-22.00 Liabilities:CreditEUR 10.00 Liabilities:CreditGBP 10.00 # Auxiliary dates You can associate a second date with a transaction by following the primary date with an equals sign: 2012-03-10=2012-03-08 KFC Expenses:Food$20.00 Assets:Cash $-20.00 What this auxiliary date means is entirely up to you. The only use Ledger has for it is that if you specify --aux-date, then all reports and calculations (including pricing) will use the aux date as if it were the primary date. # Codes A transaction can have a textual code. This has no meaning and is only displayed by the print command. Checking accounts often use codes like DEP, XFER, etc., as well as check numbers. This is to give you a place to put those codes: 2012-03-10 (#100) KFC Expenses:Food$20.00 Assets:Checking # Transaction state A transaction can have a state: cleared, pending, or uncleared. The default is uncleared. To mark a transaction cleared, put a * before the payee, and after date or code: 2012-03-10 * KFC Expenses:Food$20.00 Assets:Cash To mark it pending, use a !: 2012-03-10 ! KFC Expenses:Food$20.00 Assets:Cash What these mean is entirely up to you. The --cleared option will limits to reports to only cleared items, while --uncleared shows both uncleared and pending items, and --pending shows only pending items. I use cleared to mean that I've reconciled the transaction with my bank statement, and pending to mean that I'm in the middle of a reconciliation. ## Posting state When you clear a transaction, that's really just shorthand for clearing all of postings. That is: 2012-03-10 * KFC Expenses:Food$20.00 Assets:Cash Is the same as writing: 2012-03-10 KFC * Expenses:Food$20.00 * Assets:Cash You can mark individual postings as cleared or pending, in case one side of the transaction has cleared, but the other hasn't yet: 2012-03-10 * KFC Liabilities:Credit$100.00 * Assets:Checking # Transaction notes After the payee, and after at least one tab or two spaces (or a space and a tab) [Ledger calls this a hard separator], you may introduce a note about the transaction using the ; character: 2012-03-10 * KFC; yum, chicken... Expenses:Food$20.00 Assets:Cash Notes can also appear on the next line, so long as that line begins with whitespace: 2012-03-10 * KFC; yum, chicken... ; and more notes... Expenses:Food$20.00 Assets:Cash 2012-03-10 * KFC ; just these notes... Expenses:Food$20.00 Assets:Cash ## Posting notes A transaction notes is shared by all its postings. This becomes significant when querying for metadata (see below). To specify that a note belongs
Complete control over commodity pricing has arrived
After more than two years of chewing over the design for this feature, it has finally arrived. If you don't need it, you can ignore this post. But if you've ever wanted to fine tune the results you get from either -V or -X $, there are now several points of interception: You can specify the valuation method: 1. on a commodity itself 2. on a posting, via metadata (affect is largely the same as #1) 3. on an xact, which then applies to all postings in that xact 4. on any posting via an automated transaction 5. on a per-account basis 6. on a per-commodity basis 7. by changing the journal default of market Fixated pricing (such as {=$20}) still plays a role in this scheme. As far as valuation goes, it's shorthand for writing ((s,d,t - market($20,d,t))). I'm including the test for this feature below, to give you an idea of how it looks in practice. Still one piece of this puzzle left, which is to disassociate -V and -X from -B (so that you can apply -V to the basis cost) or the yet-to-be-written -H (so you can see historical values in terms of another commodity with -X). John ;; A valuation function receives three arguments: ;; ;; 'source'A string identifying the commodity whose price ;; is being asked for (example: EUR) ;; ;; 'date' The reference date the price should be relative. ;; ;; 'target'A string identifying the target commodity, or ;; the commodity the returned price should be in. ;; This argument is null if -V was used instead of -X. ;; ;; The valuation function should return an amount. If you've written your ;; function in Python, you can return something like Amount($100). If the ;; function returns an explicit value, that value is always used, regardless ;; of the commodity, the date, or the desired target commodity. define myfunc_seven(s, d, t) = 7 EUR ;; In order to specific a fixed price, but still valuate that price into the ;; target commodity, use something like this: define myfunc_five(s, d, t) = market(5 EUR, d, t) ;; The 'value' directive sets the valuation used for all commodities used in ;; the rest of the daat stream. This is the fallback, if nothing more ;; specific is found. value myfunc_seven ;; You can set a specific valuation function on a per-commodity basis. ;; Instead of defining a function, you can also pass a lambda. commodity $ value s, d, t - 6 EUR ;; Each account can also provide a default valuation function for any ;; commodities transferred to that account. account Expenses:Food5 value myfunc_five ;; The metadata field Value, if found, overrides the valuation function on a ;; transaction-wide or per-posting basis. = @XACT and Food ; Value:: 8 EUR (Equity) $1 = @POST and Dining (Expenses:Food9) $1 ; Value:: 9 EUR ;; Lastly, you can specify the valuation function/value for any specific ;; amount using the (( )) commodity annotation. 2012-03-02 KFC Expenses:Food2 $1 ((2 EUR)) Assets:Cash2 2012-03-03 KFC Expenses:Food3 $1 ; Value:: 3 EUR Assets:Cash3 2012-03-04 KFC ; Value:: 4 EUR Expenses:Food4 $1 Assets:Cash4 2012-03-05 KFC Expenses:Food5 $1 Assets:Cash5 2012-03-06 KFC Expenses:Food6 $1 Assets:Cash6 2012-03-07 KFC Expenses:Food71 CAD Assets:Cas7 2012-03-08 XACT Expenses:Food8 $1 Assets:Cash8 2012-03-09 POST Expenses:Dining9 $1 Assets:Cash9 test reg -V food 12-Mar-02 KFC Expenses:Food22 EUR2 EUR 12-Mar-03 KFC Adjustment -1 EUR1 EUR Expenses:Food33 EUR4 EUR 12-Mar-04 KFC Adjustment -2 EUR2 EUR Expenses:Food44 EUR6 EUR 12-Mar-05 KFC Adjustment -3 EUR3 EUR Expenses:Food55 EUR8 EUR 12-Mar-06 KFC Adjustment -4 EUR4 EUR Expenses:Food66 EUR 10 EUR 12-Mar-07 KFC Expenses:Food77 EUR 17 EUR 12-Mar-08 XACT Expenses:Food88 EUR 25 EUR 12-Mar-09 POST (Expenses:Food9) 9 EUR 34 EUR end test
Re: Complete control over commodity pricing has arrived
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Latest upstream next breaks: /opt/local/include/boost/smart_ptr/intrusive_ptr.hpp: In destructor 'boost::intrusive_ptrT::~intrusive_ptr() [with T = ledger::expr_t::op_t]': /Users/cpearls/ledger/src/expr.h:77: instantiated from here /opt/local/include/boost/smart_ptr/intrusive_ptr.hpp:96: error: 'intrusive_ptr_release' was not declared in this scope /opt/local/include/boost/smart_ptr/intrusive_ptr.hpp: In copy constructor 'boost::intrusive_ptrT::intrusive_ptr(const boost::intrusive_ptrT) [with T = ledger::expr_t::op_t]': /Users/cpearls/ledger/src/expr.h:81: instantiated from here /opt/local/include/boost/smart_ptr/intrusive_ptr.hpp:91: error: 'intrusive_ptr_add_ref' was not declared in this scope make[2]: *** [libledger_math_la-balance.lo] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 acprep: ERROR: Execution failed: make I can't reproduce this on my machine, even though many are seeing this problem. Can you tell me what compiler you're using, what version of Boost, what compiler Boost was built with, and also send me the output from ./acprep make -- distclean; ./acprep --debug --python make -- check. Thanks, John
Re: Simplified Python importing
Alexandre Rademaker arademaker-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I am afraid that Ledger has began to be more complex than necessary! Sure we really need this feature? The manual has now more than 100 pages! Ledger is made up of layers. The core layers are not overly complex, and were hardly affected at all by adding this Python support. My whole intention with the design of Ledger is to make the design supportive of future additions without introducing new complexity at the lower levels. Thus, if you don't build in the Python support, then Ledger runs very much as it would have if I'd never written that support. If you don't use it, you don't pay for it. If all these features were coming at the cost of core elegance and simplicity, that is when I would balk at adding them. But in actual fact, some of the new support I've added in the past two weeks has actually made Ledger *cleaner and simpler* internally, even though outwardly I've enriched its capabilities. John
Re: ledger v3 slower than ledger v2
thierry thierry.daucourt-ganu6spq...@public.gmane.org writes: Hello, On below tests, ledger v3 is 21 and 46 times slower that ledger v2. Some specs: - CPU is AMD Athlon(tm) Dual Core Processor 4850e, 2500MHz, 64 bits - RAM is 1790MiB - OS is Ubuntu 9.10 At last, Thierry, this is solved. I'm now using the Boost.Graph library to manage historical commodity prices, and Dijkstra's shortest-path algorithm to find most-recent conversion rates. Care to test out your example again? :) John
About to start commodity valuation overhaul
Here are my notes on rewriting many aspects of how commodities are valuated, or appraised, via the -X and -V options. Many things will change, but I think it makes nearly any usage scenario implementable. Comments welcome! This file is the beginnings of my baseline test for this feature. John ; Changes to options: ; ; -O--quantityuse each posting's amOunt (DEFAULT) ; -B--costuse each posting's cost Basis ; -I--price use each posting's commodity prIce (i.e., {$10}) ; this is the same as the cost if none specified ; ; -V--value request to value commodities, DWIM-style ; -X $ --exchangerequest to value commodities in terms of $ ; -G--change show difference between cost basis and value, ; whatever that means based on the options used ; ; -H--historical value commodities at time of acquisition ; --current value commodities as of today (DEFAULT) ; --now=define today ; These can all be mixed now, so: ; ; bal brokerage --cost --exchange $ --historical ; show much I spent to buy stocks, in $ ; ; bal brokerage --cost --exchange $ ; show much I spent to buy stocks, in today's $ ; ; bal assets --exchange $ --historical ; how many $ would it have taken (at the time) to acquire my assets? ; ; bal assets --exchange $ ; present value of my assets in $, or how many $ it would take to ; replace those assets today ; NEW: Virtual Costs : ; Normally each exchange of a commodity in a journal is recorded as an ; historical price point. You can now use virtual costs to keep a ; particular exchange off the record. Simply surround the @ or @@ symbols ; with parentheses: (@) (@@). ; NEW: Value Annotations ; ; Commodities can now have a valuation expression, surrounded by (()): ; ; $20 {30 CAD} ((market)) ; value these $20 using market price ; $20 {30 CAD} ((30 CAD)) ; value is always 30 CAD, no matter what ; ; $20 {30 CAD} ((a, d, c - market(30 CAD, d, c) )) ; ; value is always 30 CAD, but report that ; ; 30 CAD in terms of user's request ; Value expression functions: ; ;appraise(a [, d, c]) ask the amount a for its value (opt. on d in c) ;market(a , d, c) return the market price of a on d in c ; TODOs: ; - jww (2012-03-03): Change from the current, special-casey lot logic to a ; further generalization of commodity annotations. ; ; - jww (2012-03-03): Rewrite the way annotated commodities are kept in the ; pool, and how they are found. python from datetime import * def download_price(amount, when=datetime.now(), commodity=None): value = Amount(current_value_of(commodity or amount.commodity)) return value * amount define myfunc(a, d, c) = market(a, d, c) value market ; change the default valuation commodity $ value a, d, c - market(a, d, c) * 2 account Assets:Cash value market ; function to use to get the value value myfunc ; use myfunc function defined above value a, d, c - market(a, d, c) ; expression to use to get the value value $10 ; just use a literal value value download_price ; use the Python function above to ; always download the latest price payee KFC value market 2012-03-03 KFC ; Value:: market Expenses:Food$20 ((market)) ; Value:: market Assets:Cash commodity $ value market
Re: Another major change: renamed actual/effective dates
Kamal Marhubi kamal-7mlawaoftq1bdgjk7y7...@public.gmane.org writes: Now that is interesting. I had been using the actual date as the date it showed up on the account, ie the transaction date, and the effective date as the date at which I would like the transaction to be effective for budgeting purposes. Yes, a lot people did what you were doing. So with the new options, left of the = is primary, and right of the = is secondary, and you get to pick which trait you consider a primary trait: the purchase date, or the date it was posted to your real account. John
Re: About to start commodity valuation overhaul
Martin Michlmayr tbm-r+vwnyxsfmfqt0dzr+a...@public.gmane.org writes: * John Wiegley jwiegley-re5jqeeqqe8avxtiumw...@public.gmane.org [2012-03-03 02:22]: ; Changes to options: ; ; -O --quantity use each posting's amOunt (DEFAULT) -B --cost use each ; posting's cost Basis Can you give some examples outlining the difference between these two? If you have a posting like this: Expenses:Food$20 @ 10 EUR The -O (--quantity) will use the $20 as the basis for calculations, and -B (--cost) will use the 10 EUR. Implicitly, this $20 is really $20 {10 EUR}, so that 10 EUR would also be used if you selected -I (--price). John
Getting start with Ledger and Python
Hello all, I think it's time for a primer on using Python to extend your Ledger experience. But first, a word must be said about Ledger's data model, so that other things make sense later. -- # Basic data traversal Every interaction with Ledger happens in the context of a Session. Even if you don't create a session manually, one is created for you by the top-level interface functions. The Session is where objects live like the Commodity's that Amount's refer to. The make a Session useful, you must read a Journal into it, using the function `read_journal`. This reads Ledger data from the given file, populates a Journal object within the current Session, and returns a reference to that Journal object. Within the Journal live all the Transaction's, Posting's, and other objects related to your data. There are also AutomatedTransaction's and PeriodicTransaction's, etc. Here is how you would traverse all the postings in your data file: import ledger for xact in ledger.read_journal(sample.dat).xacts: for post in xact.posts: print Transferring %s to/from %s % (post.amount, post.account) -- # Raw vs. Cooked Ledger data exists in one of two forms: raw and cooked. Raw objects are what you get from a traversal like the above, and represent exactly what was seen in the data file. Consider this journal: = true (Assets:Cash)$100 2012-03-01 KFC Expenses:Food$100 Assets:Credit In this case, the *raw* regular transaction in this file is: 2012-03-01 KFC Expenses:Food$100 Assets:Credit While the cooked form is: 2012-03-01 KFC Expenses:Food$100 Assets:Credit $-100 (Assets:Cash)$100 So the easy way to think about raw vs. cooked is that raw is the unprocessed data, and cooked has had all considerations applied. When you traverse a Journal by iterating its transactions, you are generally looking at raw data. In order to look at cooked data, you must generate a report of some kind by querying the journal: for post in ledger.read_journal(sample.dat).query(food): print Transferring %s to/from %s % (post.amount, post.account) The reason why queries iterate over postings instead of transactions is that queries often return only a slice of the transactions they apply to. You can always get at a matching posting's transaction by looking at its xact member: last_xact = None for post in ledger.read_journal(sample.dat).query(): if post.xact != last_xact: for post in post.xact.posts: print Transferring %s to/from %s % (post.amount, post.account) last_xact = post.xact This query ends up reporting every cooked posting in the Journal, but does it transaction-wise. It relies on the fact that an unsorted report returns postings in the exact order they were parsed from the journal file. -- # Queries The Journal.query() method accepts every argument you can specify on the command-line, including --options. Since a query cooks the journal it applies to, only one query may be active for that journal at a given time. Once the query object is gone (after the for loop), then the data reverts back to its raw state. -- # Embedded Python Can you embed Python into your data files using the 'python' directive: python import so def check_path(path_value): print %s = %s % (str(path_value), os.path.isfile(str(path_value))) return os.path.isfile(str(path_value)) tag PATH assert check_path(value) 2012-02-29 KFC ; PATH: somebogusfile.dat Expenses:Food$20 Assets:Cash Any Python functions you define this way become immediately available as valexpr functions. -- # Amounts When numbers come from Ledger, like post.amount, the type of the value is Amount. It can be used just like an ordinary number, except that addition and subtraction are restricted to amounts with the same commodity. If you need to create sums of multiple commodities, use a Balance. For example: total = Balance() for post in ledger.read_journal(sample.dat).query(): total += post.amount print total John
Re: selecting by payee
Donald sf.flyboy-re5jqeeqqe8avxtiumw...@public.gmane.org writes: $ ledger -f test2 -w reg exp -- rei The syntax for this has changed to: $ ledger -f test2 -w reg exp @rei John
Re: Segfault on next branch
Hyrum K Wright hyrum-krattusis2oizk9zyxr...@public.gmane.org writes: Running the following command on the next branch results in a segfault: $ ./ledger -s bal Checking See if what's on 'next' now fixes your problem. John
Another major change: renamed actual/effective dates
It has long been a point of confusion over what actual vs. effective dates are. For example: 2012-02-28=2012-03-01 KFC Expenses:Food$10.00 Assets:Cash In this example, I always considered the first date as the actual date when I bought the chicken, and the second date as when it become effective in my account. But others use these dates to mean other things, so I'm now changing these to PRIMARY and AUXILIARY dates: --actual-dates = --primary-date --effective = --aux-date Also the value expressions to reach these values are date and aux_date, respectively. The old options and value expressions functions are retained for compatibility, but are deprecated. John
Re: Record timelog hours on the day of check-in, instead of on the day of check-out?
Seppo Sade sepposade1-re5jqeeqqe8avxtiumw...@public.gmane.org writes: For a .timelog entry where the check-in is on one day and the check- out the following day: i 2011/07/20 17:00:00 Work project o 2011/07/21 01:00:00 Done for the day The output of ledger -f .timelog reg (ledger 2.6) records the entry on the day of the check-out: 2011/07/21 (Test) 8.0h 8.0h Would there be any way to get the entry recorded on the day of the check-in instead? The reason for asking this is that when you do workdays that end after midnight, you usually want the hours to show up on the date of the check-in (before midnight), instead of the day after. Otherwise reports by day look skewed, when the check-in day's hours are zero and the following days hours are doubled. If this is currently not supported by ledger, what would be the suggested way to implement support for it? This has been fixed in Ledger's current 'next' branch. John
Re: Having Problems With XML
Ryan May ryan-wtxsuusx66j3fq9qlvq...@public.gmane.org writes: But in XML such a relationship should be represented by the structure of the document, i.e. Chequing should be a sub-element of Assets and Bank should be a sub-element of Chequing. When I was preparing the example above I also noticed that the amount entries in the most deeply nested accounts (i.e. Bank) are duplicated: one set of amount entries followed by a second identical set inside a total tag. Is this duplication intended to handle a more complex situation? Fixed. John
Re: Own language
Jins renarsgrig-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I'm using ledger 3.0 can I use terminalogy of my language like instead Assets aktīvi and so on. Does ledger can work understand stuff like this? Yes, absolutely, part of Ledger's philosophy is that I never want to force you to think the way I think. It is still sad to me that Ledger is bound to the Gregorian calendar, but I haven't found a good technology/syntax to free me from that yet. If you do use names like aktīvi, be sure your build of Boost links with the icu library (this happens by default with MacPorts now). Otherwise, the case insensitivity of non-Latin characters will not work right (such as the case-insensitive identity of í and Í). John
Re: leap day
Alan Bram sf.flyboy-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I've finally gotten around to trying the latest version of ledger, from git. (I have been using 2.6.2, from MacPorts.) On this latest version, I get the following error message, running on the attached sample input: While parsing file test1, line 3: While parsing transaction: 2/29 E-trade Bank Error: Day of month is not valid for year It worked fine in 2.6.2. Hmm... do you use a 'Y' directive to specify the year? It sounds like a bug if I don't accept 2/29 this year. John
Re: leap day
Alan Bram sf.flyboy-re5jqeeqqe8avxtiumw...@public.gmane.org writes: On this latest version, I get the following error message, running on the attached sample input: While parsing file test1, line 3: While parsing transaction: 2/29 E-trade Bank Error: Day of month is not valid for year This is now fixed in 'next'. John
New feature: pre-declaring accounts, payees, commodities and tags
A long asked-for feature, pre-declarations, has now arrived! This feature comes with some breaking changes, even damaging backwards compatibility with 2.x. I believe it is worth it for the gain in consistency. -- # BREAKING CHANGES ## 'account' directive In 2.x, you could enclose a group of transactions within a parent account: account My Master ... end account This is now done with apply account instead of account: apply account My Master ... end apply You can also use end apply account, and Ledger will verify that it matches an enclosing apply account. ## 'tag' directive In 3.x, you could apply a tag to a group of transactions: tag Foo: Bar ... end tag This is now done with apply tag instead of tag: apply tag Foo: Bar ... end apply tag -- # NEW DIRECTIVES There are four all new directives: account payee commodity tag ## New 'account' directive You can now pre-declare account names. This only has effect if --strict or --pedantic is used (see below). account Expenses:Food account Expenses:Gas ### Account sub-directives The 'account' directive supports several optional sub-directives, if they immediately follow the account directive and if they begin with whitespace: account Expenses:Food note This account is all about the chicken! alias food payee ^(KFC|Popeyes)$ check commodity == $ assert commodity == $ eval print(Hello!) default The 'note' sub-directive associates a textual note with the account. This can be accessed later using the 'note' valexpr function in any account context. The 'alias' sub-directive, which can occur multiple times, allows the alias to be used in place of the full account name anywhere that account names are allowed. The 'payee' sub-directive, which can occur multiple times, provides regexps that identify the account if that payee is encountered and an account within its transaction ends in the name Unknown. Example: 2012-02-27 KFC Expenses:Unknown $10.00 ; Read now as Expenses:Food Assets:Cash The 'check' and 'assert' directives warn or error (respectively) if the given value expression evaluates to false within the context of any posting. The 'eval' directive evaluates the value expression in the context of the account at the time of definition. At the moment this has little value. The 'default' directive specifies that this account should be used as the balancing account for any future transactions that contain only a single posting. ## New 'payee' directive You can now pre-declare payee names. This only has effect if --check-payees is used in addition to --strict or --pedantic (see below). payee KFC payee Payless ### Payee sub-directives The 'payee' directive supports one optional sub-directive, if it immediately follows the payee directive and if it begins with whitespace: payee KFC alias KENTUCKY FRIED CHICKEN The 'alias' directive provides a regexp which, if it matches a parsed payee, the declared payee name is substituted: 2012-02-27 KENTUCKY FRIED CHICKEN ; will be read as being 'KFC' ... ## New 'commodity' directive You can now pre-declare commodity names. This only has effect if --strict or --pedantic is used (see below). commodity $ commodity CAD ### Commodity sub-directives The 'commodity' directive supports several optional sub-directives, if they immediately follow the commodity directive and if they begin with whitespace: commodity $ note American Dollars format $1,000.00 nomarket default The 'note' sub-directive associates a textual note with the commodity. At present this has no value other than documentation. The 'format' directive gives you a way to tell Ledger how to format this commodity. In future using this directive will disable Ledger's observation of other ways that commodity is used, and will provide the canonical representation. The 'nomarket' directive states that the commodity's price should never be auto-downloaded. The 'default' directive marks this as the default commodity, in contexts where that applies (the same as the current 'D' directive). ## New 'tag' directive You can now pre-declare tag names. This only has effect if --strict or --pedantic is used (see below). tag Receipt tag CSV ### Tag sub-directives The 'tag' directive supports two optional sub-directives, if they immediately follow the tag directive and if they begin with whitespace: tag Receipt check value =~ /pattern/ assert value != foobar The 'check' and 'assert' directives warn or error (respectively) if the given value expression evaluates to false within the context of any use of the related tag. In such a context, value is bound to the value of the tag (which may not be a string if typed-metadata is used!).
Re: New feature: pre-declaring accounts, payees, commodities and tags
Gabriel Kerneis kerneis-klhgwnj84bud5ynb6aa...@public.gmane.org writes: I don't like when ledger uses hard-coded (English) strings. IIRC, there are a few other places in ledger's code that do the same (something about equity?). Ledger is 100% localized, using the gettext library. You can provide a translation file during the build process in order to switch languages at runtime based on the current locale. That's why I haven't done more to make these strings configurable. That said, perhaps there should be an easier way to allow users to define important strings like this. Maybe a series of --string-XXX options? John
Re: New feature: pre-declaring accounts, payees, commodities and tags
Johann Klähn kljohann-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I would prefer a per-file configuration, too. This would also help with portability. With the current setup a ledger using english account names would not work correctly with the locale set to some other language. Ok, that does it, I will create configuration options for significant strings. John
Re: Strange print behavior in comments
thierry thierry.daucourt-ganu6spq...@public.gmane.org writes: This has introduced a bug filed as http://bugs.ledger-cli.org/show_bug.cgi?id=657It is severe from my point of view. I will fix it right away. John
Re: Cygwin Build Failed early in acprep
Will Whatley william.whatley-re5jqeeqqe8avxtiumw...@public.gmane.org writes: REDACTED /cygdrive/c/Home/ledger $ ./acprep update acprep: INFO: Invoking primary phase: update acprep: INFO: Executing phase: update acprep: INFO: Executing phase: pull Already up-to-date. acprep: INFO: Executing phase: submodule acprep: INFO: Executing phase: make acprep: INFO: Executing phase: config acprep: INFO: Executing phase: submodule acprep: INFO: Executing phase: autoconf acprep: INFO: autogen.sh must be run because acprep is newer than configure acprep: INFO: Executing phase: autogen tools/autogen.sh: line 75: $'\r': command not found tools/autogen.sh: line 93: syntax error near unexpected token `$'{\r'' 'ools/autogen.sh: line 93: `ident ( ) { acprep: ERROR: Execution failed: sh tools/autogen.sh This looks like a problem with running bash scripts on your Windows machine using cygwin. I'm not quite sure how to help at this point, I'm sad to say... Are you able to run tools/autogen.sh directly? John
Re: Invert all transactions in a ledger file
Zack Williams zdwzdw-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Anyone know of a simple way to invert all the transactions in a ledger file? Preferably without removing comments and other metadata? I do not, sorry. John
Re: Income deductions
Jim Robinson jim.robinson-re5jqeeqqe8avxtiumw...@public.gmane.org writes: The '; 403b:...' markers allow me to run a report like this: ledger bal 403b:SCRP --pivot=403b -b 2012 -e 2013 Just a quick note: -b 2012 -e 2013 is the same as -p 2012. :) John
Re: Strange print behavior in comments
Hsiu-Khuern Tang tangoh-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Related question: is there a way to specify that ledger should not reformat comments? In other words: This is an excellent suggestion, and would be trivial to implement. I'll add a feature request for Bugzilla. John
Re: Using ledger in emacs shell
Ivan ivan.inozemtsev-re5jqeeqqe8avxtiumw...@public.gmane.org writes: However after upgrading ledger does not work in primitive terminal — http://yfrog.com/obkh7kpI've read manual searching for some command line option to simplify output, but with no luck. Probably I am missing something? Can you go into a bit more detail to describe what does not work means? Have you tried --no-color, or --columns=80? John
Re: commodity flags cleanup
Martin Michlmayr t...@cyrius.com writes: Yep, this is something I'd like to see. At the moment, -X implies -V, even though there are a lot of use cases where I want to use -X -B. I agree, and I intend to make changes to support this kind of mix and match reporting. Ledger has always been about giving you the core tools, rather than forcing a particular view of your data. John
Re: periodic reports for expense category groups
Peter Keen peter.keen-qpbGg102UtMk+I/owrr...@public.gmane.org writes: You want to use a register report with the -M for monthly and -n for 'total' options. Like this: ledger -Mn -b 2011/01/01 reg expenses There is a --group-by option, which can segregate reports based on the differing values of the EXPR passed to --group-by. For example: --group-by format_date('%m') At least, that's exactly what it's intended to do. This feature still needs more testing, so let me know if you run into problems. John
Re: Multiple commodity conversions?
Zack Williams zdwzdw-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Is there a way to force a specific ledger to display with a certain set of units, no matter whether another, more compact rate is available? Not yet. Base conversions (--base) are different from commodity price conversions (-X). This is a limitation in the reporting code which I intend to address. I think there's even a bug on it... John
Re: Multiple commodity conversions?
Zack Williams zdwzdw-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Is it possible to perform multiple commodity conversions in order to get output in a specific commodity? I'm trying to abuse Ledger again (this time for calculating the power/cooling budget on a server room), and various devices have their power use ratings given in different ways - for example, in Watts, Amps, or BTU. These are all simple multiplicative conversions, so they can be expressed using Ledger's commodity pricing - for example: If you use the 'C' directive to setup conversion rates, then everything will be output by default using the most compact rate. Or, use --base to see the base rate. This is how Ledger report time, for example. C 1.0m 60s John
Re: Rounding formula for automatic transactions
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Unfortunately, round doesn't seem to let you control the precision so you won't notice much since it will round to two digits. I have another request to allow user controlled precision, but maybe John has a different method. You can use (0.1 * unround(amount)), to turn rounding off. But currently there is not a way to set the rounding precision for a given value. However, that would be really easy to do, so that's a great feature idea. John
Re: Rounding formula for automatic transactions
André Coelho andrecoelho-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I've seen a floor function, but it seems to actually round to the nearest integer (not a floor as I'm used to). I wonder how do you manage precision, I would think this should be critical, how do you guys deal with that? Yeah, floor has a bug, and their needs to be a ceiling too. That one is known at least. :) John
Re: How to represent loans to other parties
Matt Seburn mattseburn-re5jqeeqqe8avxtiumw...@public.gmane.org writes: How do I represent the situation where I loan someone else money? The specific situation I have in mind involves buying someone for something out of my chequing account, and then receiving cash as repayment. How do I (a) properly record the loan in the first place, and (b) mark it as repaid without necessarily depositing the funds into my account? I consider loans to other people as an asset held at another location, so it's never income when the money is simply transferred back to me. It's my money either way. Now if the loan gets forgiven, then I transfer it to an Expense. John
Re: A web-based reporting system for Ledger
Peter Keen peter.keen-qpbGg102UtMk+I/owrr...@public.gmane.org writes: The 0.937 VISGX comes out just fine as display_amount and commodity, but for the life of me I can't figure out how to get the $21.54. What's the format command for that? That's the cost. To get the per-unit cost, you'll have to divide it as in cost / quantity(amount). John
Re: A web-based reporting system for Ledger
Peter Keen peter.keen-re5jqeeqqe8avxtiumw...@public.gmane.org writes: To answer the obvious question, I feel that the SQL+HTML combo allows quite a bit more flexibility than raw ledger with respect to the kinds of reports I can write and how they can be presented. Things that would require multiple calls to ledger and a bunch of shell scripting become a straightforward SQL query, especially with PostgreSQL 9's with expression and window queries. How exactly are you loading the Ledger data into SQL? I've actually been wanting an 'sql' report for some data, to facility data mining with professional DB tools... Maybe we can get native SQL generation in for 3.1 or something. John
Re: slightly OT: inventory system w/ledger integration
Zack Williams zdwzdw-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Every once in a while it comes up that ledger's commodity system isn't suited for managing an inventory of items, for example, widgets being sold at a retail store, as there's no unique tracking of individual items in the system or ways to keep track of which items were purchased at what price, which would sometimes be needed. Ledger's lot-marking facility was designed just for this purpose. You can, in fact, track items uniquely, or by purchase price, or even by purchase date. That said, does anyone know of a a tool that would work with Ledger to manage a physical inventory - say, manage a list of similar items, track their purchase/sale price, other information (serial numbers, where purchased from, etc.), do FIFO or LIFO queuing of items upon sale, and generate appropriate ledger files when items move in and out of the system? The LIFO/FIFO thing is not implemented in Ledger, but I'd be interested too in seeing it implemented via some external tool. John
Re: report on income vs expense?
Jim Robinson jim.robinson-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Hi folks, Is it possible to generate an income vs expense report in one shot using ledger? You can generate a net income/expense report by month in one go, but to see separated Income and Expense figures by month, you'll need to merge the results from two separate reports: one for income by month, and one for expenses by month. Ledger currently has no facility for aggregating reports like this, although it's the kind of thing that would be perfectly suited for writing in Python using Ledger as a module. John
Re: report on income vs expense?
Jim Robinson jim.robinson-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I don't think I can use paste to compute the difference between income and expenses, and I don't think I know how to use paste w/o putting the data into files. If you have bash or zsh, this will work: paste (first command) (second command) The functionality of (command) is: run command, capture the output a file in /tmp, pass that filename in place of (command), then delete the temp file after execution of the command. John
Re: [DOCS] various format string
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Ledger pays attention to a lot of different format strings. For example: --budget-format --cleared-format --format etc. Are those there to support future growth with users that can have multiple reports per session? They're there mainly so you can change one kind of report in your ~/.ledgerrc file without changing the other reports. John
Re: [DOCS] Setting the date format for convert
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Writing documentation for the 'convert' command. Can the input date format be set separately for the convert command? --input-date-format doesn't seem to affect it, nor does --date-format Those should work as expected, since --[input-]date-format is supposed to change the way dates are handled globally, throughout Ledger -- not just in specific areas. Bug me! :) John
Re: Set first day of the week for --weekly register
Felix Geisendoerfer haimuiba-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Since I prefer to think of Monday as the start of the week, is there any way to make Ledger do the same? In this case I'd like my current week to be Dec 5 - 11. --start-of-week=Monday :) John
Re: conditional on tag exisence?
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Is there a way to check if a tag has been applied to a xact? For example 2011/11/01 Amazon :Arrived: Expenses:Books Assets:Cheking I want to use ?: based on whether the xact has the tag :Arrived: applied. I have tried simply using tag('Arrived') as a boolean value, and tag('Arrived') == true. I didn't understand. Can you give me an example of what you're trying to accomplish? Thanks, John
Re: Significance of lot tags
Martin Michlmayr tbm-r+vwnyxsfmfqt0dzr+a...@public.gmane.org writes: Well, this is the question I was trying to ask: are commodities with lot tags different commodities or not? My belief so far was that they are *not* different commodities (i.e. the lot tags are just some meta info), but the example I posted indicates otherwise. Lot tags/prices/dates represent a new commodity within Ledger itself, but they are only *displayed* as unique commodities when you use --lots or --lot-dates/prices/tags options. So, say you have: Expenses$10 (a) Expenses$10 (b) Although by default this total is displayed as $20, internally the real amount is $10 (a) + $10 (b). The --lot-tags option is what differentiates display. There is a value expression function strip() whose job is to remove/collapse lot annotations, and scrub(), which only conditionally collapses them (based on whether you use one of the above-mentioned options). It's this latter function which is used by all the built-in reports. John
Re: Significance of lot tags
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Does the entire commodity have to be surround by parens? When does ledger distinguish between two lots of the same commodity and two different commodities? No, only the tag is surrounded by parens. The full syntax is: COMMODITY {price} [date] (tag aka note) Tag here is not anything like a metadata tag, but is rather an arbitrary text string you can use to differentiate lots. In other words: GBP (test) GBP (abc) (GBP test) The third is not a valid commodity, but the first two are. Stripping them would yield just GBP. John
Re: [DOCS] Different ways Commenting Journals
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: This may be common knowledge but I haven't seen it written anywhere. While combing through the code (textual.cc instance_t::read_next_directive() to be specific) I found that ledger will allow a few different kinds of comment characters. You can use # | * AT THE BEGINNING OF A LINE and that line will be ignored (print will also ignore it as usual). I have added it to the docs. It also allows ; and %, doesn't it? It should. John
Re: --inject?
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I am combing bug reports for interesting undocumented features and I ran across --inject. I spent some time going through the code but can't really see what it is for. Anyone have any clues? For my paychecks at a previous employer, I knew how much should be in them. This wasn't always the amount that was there. So I had a metadata field like this: ; Expected:: $1,000.00 Then I would inject these amounts into a query like this: ledger reg --inject=Expected '^income:foo' That way, Income:FOO, which is a negative value, would be balanced by the injected Expected values. If the final results was positive, they owed me that much money. This was intended a shorthand for something that I wasn't able to find an easier way to do. John
Re: building next on ubuntu lucid
Dan White etihwnad-re5jqeeqqe8avxtiumw...@public.gmane.org writes: With the appropriate -dev packages, which I should have documented to help better, the current ledger next can't build because the MPFR_RNDx symbols in src/amount.cc are not found. Those symbols are present in mpfr-3.0 but not in lucid's mpfr-2.4. This is has been reported, and will be fixed shortly. I had thought that Ledger required mpfr-3.0, but I guess not. John
Re: Controlling the precision displayed in amounts
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Actually quantity isn't rounding at all, as expected. It is giving me full precision, sometime 9 or 10 digits. Here is an example: ledger bal Investments --collapse --limit commodity=='VIFSX' --format %(quantity(strip (display_total))) %(quantity(market(total))) 123.1234567891 12345.123456789123 Ah, yes, well non commoditized integers don't round. I'll have to add a function for this to the valexpr language. John
Re: Having Problems With XML
Ryan May ryan-wtxsuusx66j3fq9qlvq...@public.gmane.org writes: Hi John, I'm unsure how else an XML reader would build up an accounts tree without additional information. Given the following list of accounts: Oh, I had thought the account tags were nested? If not, then fullname will be necessary. John
Re: What is the actual --print-format used in 2.6?
markscottwright markscottwright-re5jqeeqqe8avxtiumw...@public.gmane.org writes: The one in the manual doesn't seem to be right. It should in the source code, I think in report.h. John
Re: Having Problems With XML
Ryan May ryan-wtxsuusx66j3fq9qlvq...@public.gmane.org writes: i.e. The name of an account like Assets:Chequing:Bank is recorded simply as nameBank/bank. The full name of the account does seem to be implied by the ordering of the XML: I believe it's expected that the reader will build up an accounts tree, but I can certainly add a fullname tag. John
Re: Controlling the precision displayed in amounts
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I am totally mystified at how ledger is determining what to display. Is there a way to control the precision used to display a quantity? e.g.: force --format %(quantity(strip(display_total))) to show only 4 significant figures? I am trying to generate data for an external program and it would be more convenient to be able to export the quantities and bare numbers without annotations. It's rounding even after you use quantity? And what kinds of annotations do you mean? Can you give me a little example? Thx, John
Re: Having Problems With XML
Ryan May ryan-wtxsuusx66j3fq9qlvq...@public.gmane.org writes: Is Ledger 3 supposed to support processing XML or just exporting it? Ledger 3 only exports, it does not parse. John
Re: Sort income and expenses report by absolute value of account, largest to smallest.
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Good, glad i could help. T is the amount reported from the account in the balance report. T is the display_total, which can be modified with -T. This is different from sorting on total, which is not affected by -T. U is not longer supported in 3.X as far as I can tell. Ux is now abs(x). I am taking it out of the documentation. The new value expression language is much easier to understand than the old single character, unfortunately the documentation hasn't caught up with it. I am working that as fast as I can. Yes, this is where the documentation is weakest right now. The new valexpr parser can do LOTS of things that 2.x never could. John
Re: Having Problems With XML
rtjmay ryan-wtxsuusx66j3fq9qlvq...@public.gmane.org writes: I'm having an issue with Ledger's XML output. I'm using version 2.6.2 from the Ubuntu 10.10 repo, and when I generate XML (using 'ledger xml') the information on currency type (commodity) is lost. I use CAD and USD to represent Canadian and U.S, dollars, with CAD set as the default. But, the commodity tag for every transaction is empty, containing only a newline and some whitespace: amount commodity flags=S /commodity quantity483.72/quantity /amount I am doing something wrong or is this a bug? I think it's a bug, but I am no longer supporting the 2.x series. Can you please try building the current beta from Git, and see if you still have a problem? Thanks, John
Re: Ledger BETA under Mac OS X Lion using Xcode 4.2?
Jim Robinson jim.robinson-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Hi folks, Have any of you successfully built the Ledger 3 beta under Mac OS X Lion using Xcode 4.2? I have, and it passes all tests here, FWIW. John
Re: [DOCS] Arguments to the payees and accounts commands
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I figured out that ledger requires the @ even when used with the payees command. So, ledger payees Som.*dy returns all payees the required syntax is ledger payees @Som.*dy returns Somebody Ah, hmm... There is something here I'd forgotten about: The arguments to the payees and accounts commands take a regular report query. They then determine which postings which participate in such a report, and then report the payees/accounts relating to those postings. Make sure to quote arguments containing '*' too, just so that your shell isn't turning the glob pattern into a null string... John
Re: timeclock missing?
fsiefken fsiefken-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Hi, I want to log my time with timeclock as documented here: /usr/share/doc/ledger/ledger.html/Using-timeclock-to-record-billable- time.html I can't find it in Ledger 2.6.2, I understand that there is a timelog.el available - but I don't want to be dependent on emacs. In github I found timelog.cc but that seems to be an internal function. Can someone help me out here, or is there another python, ruby or sh script that I can use to produce these files? timeclock.el is part of Emacs, since version Emacs 20 or 21. John
Re: 'getquote' responsibilities
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Is getquote supposed to provide ledger with only a price for the specified symbol, or update the pricedb file with all the required information? The included example script only return a price, which seems very limited since the time of the trade is also very important... It should only return a price. I'm open to suggestions on this front, however, since for people with hundreds of commodities this would become embarrassingly slow. John
Re: Expressing share purchases by total cost, rather than shares
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I would like to instruct ledger to buy $140.56 shares of @ $10.94 The way I am doing it now is the following: 2011/10/12 401K Buy Assets:Investments:401K Deferred (140.56/10.94 ) Assets:Investments:401K $-140.56 Is there a way to have ledger help me out a bit more. Something like 2011/10/12 401K Buy Assets:Investments:401K Deferred $140.56 of @ 10.94 Assets:Investments:401K Saves a bit of typing, If it doesn't already do it, I doubt it is worth a feature request. Closest I can think of is: 2011/10/12 401K Buy Assets:Investments:401K Deferred (140.45 / 10.94) @ $10.94 Assets:Investments:401K Doesn't seem that great, though... John
Re: Possible value expression bug.
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I was playing around with numerical value expressions in postings and found some interesting behavior. Behavior #1: Assets:401K (1 * 7.456) Results in 7 shares of being reported. Assets:401K (1.0 * 7.456) Results in 7.5 shares of being reported Behavior #2: Assets:401K (1 * 7.58/85.88) Results in an unbalance error since the second number rounds to zero. Ledger uses the number of significant figures describe the commodity, ignoring other figures in the calculation I am using no other formatting suggestions in my ledger command. I would expect it would use the largest number of significant figures available in the calculation. So If my expectations are correct, this should be a bug. If not I will add this behavior to the documentation. This is a bug. Within parenthesized amounts, all precision should be both used and ignored for display (that is, it won't affect future display of amounts of that commodity type). John
Re: Ledger 3.0 performance compared with older versions
Vinod Kurup vvkurup-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I tried ledger 3.0 after using a combination of ledger 2.5 and 2.6 happily for many years. I've found 3.0 to be too slow for my needs. My ledger file is huge and I use the emacs reconcile mode extensively, which calls ledger frequently, so performance issues are very noticeable. Please note that this really isn't a complaint. I know 3.0 brings a lot of new functionality and bug fixes, and performance may be perfectly fine for normal size ledger files. I just wanted to report this in case I'm doing something wrong or there exist some easy ways to improve 3.0 performance. For the moment, I'm sticking with 2.5 since it works perfectly for me. Hi Vinod! As always, I am extremely concerned about performance, and will go to great lengths to achieve it, since this is a CLI tool meant to be executed many times. Now, there are some correctness issues which will prevent 3.0 from being faster than 2.x at times, but it shouldn't be pathologically slower -- as your data definitely shows. So, my first questions are: What OS? What compiler? How did you build Boost and which compiler flags? How did you build Ledger and which compiler flags? Thanks, John
Re: Ledger 3.0 performance compared with older versions
Vinod Kurup vinod-46o65aadjccavxtiumw...@public.gmane.org writes: I wonder if those '--enable-debug' lines are what's hurting me. Let me know if I can provide any other info. Oh, yes indeed. The debug build of 3.0 is significantly slower. Please try this: ./acprep opt That should cure some of your problems, with the exception that -V can become quite slow in certain circumstances. John
Re: US payroll withholding, or automated transactions on ranges of amounts
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I was thinking about this more and had a possible (impossible?) suggestion. Can you use value expressions in the posting? Like this: = /Employees:.*:Payroll$/ and expr (amount = X or amount Y) Taxes Owed 1+0.27(amount-1) Assets Why, of course you can, just with a slightly different syntax. = /Employees:.*:Payroll$/ and expr (amount = X or amount Y) Taxes Owed (1+0.27*(amount-1)) Assets Note that you are using amounts without commodities here with addition/subtraction, which may cause an error, or multiple postings to get generated in the final transaction. John
Re: US payroll withholding, or automated transactions on ranges of amounts
Zack Williams zdwzdw-re5jqeeqqe8avxtiumw...@public.gmane.org writes: From what I can tell, there's no way to have several automated transactions that only happen when an amount is within a certain range, is there? Would this feature be useful to others? Automated transactions can use the full range of value expressions in their predicate: = /Employees:.*:Payroll$/ and expr (amount = X or amount Y) ... In this case, 'amount' is tied to the amount of the posting being tested. John
Re: [DOCS] Significance of '%' in tags?
Peter Keen peter.keen-qpbGg102UtMk+I/owrr...@public.gmane.org writes: It's part of the filter language. %tag means filter to only transactions marked with 'tag'. Similarly, @string means filter to only transactions where the payee matches 'string'. Someone correct me if I'm wrong, but I believe both of these can accept a regular expression as well. That's right. %foo is shorthand for tag foo on the command-line. John
Re: Clearing virtual transactions
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I have several virtual transaction set up that add multiples of amounts credited to specific accounts. It appears that the transactions are always consider uncleared. Is there a way to tell ledger to give a virtual transaction the same cleared status as the triggering transaction? Great question. Can you add a feature request for this in the bug tracker? It should only take me about 5 minutes to add this. Thanks, John
Re: Documentation Project
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Can anyone tell me if the IRC channel is still alive? You bet, about 30 of us are there most of the time. John
Re: ledger error generation
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I was playing around with the file format today to generate some examples and noticed something. I know there is a requirement for the first line of a transaction to be at the beginning of a line and that the account entries need to be indented. I found that if you don't indent the account lines, ledger ignores the transaction completely and doesn't complain. This may be inherent in the way the file is parsed, but could it be caught and flagged as an error? Sure, I think this. Please log a bug for this. John
Re: report sorting based on tag values
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Is there a way to produce a register report that lists all the transaction that contain a certain tag, and sort them based on the value of the tag? ledger reg --sort tag('foo') %foo John
Re: report sorting based on tag values
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: I really need to study the docs, I missed that syntax. It's not there yet, so it's my fault! Right now I'm the Living Manual. John
Re: report sorting based on tag values
Craig Earls enderw88-re5jqeeqqe8avxtiumw...@public.gmane.org writes: Now I don't feel so bad. If there is anything I can do to help with the manual I would be happy to. I am comfortable with LaTeX and TeXinfo. If you need someone to start assembling notes etc. Please take a look at doc/ledger3.texi. I began the chapter on the journal data format. That could use proofing and comments, as well as fleshing out topics for anything you feel comfortable talking about. In fact, if you guys could help me write the less technical stuff (accounting principles, common examples of usage, common reports with example output, etc), then I could focus on the reference material that only I can write at the moment, such as the value expression language, formatting strings, documenting all the options, etc. Some community help may just be the push I need to get back into the swing of writing the new manual. Thanks, John
Re: report sorting based on tag values
John Rakestraw johnr-hdTKlMK9g6hNu5YjidvPyAC/g2k4z...@public.gmane.org writes: Is it possible to get subtotals for each tag value? In my continuing effort, as the Living Manual, to anticipate your every desire before you even think of it, I see this option before my eyes; ledger --group-by tag('foo') bal This will group by the differing values of the 'foo' tag. There is presently no option to group by any tag, since that set might be 1, causing the same item to be reported multiple times. :) John
Re: date syntax
thierry thierry.dauco...@free.fr writes: Hi, I would like to report monthly data, starting the 1st day of the month, 12 month ago. I can use the period command to see how Ledger parses a given date: $ ./ledger period 12 months ago --- Period expression tokens --- TOK_INT: 12 TOK_MONTHS: months TOK_AGO: ago END_REACHED: EOF --- Before stabilization --- range: in year 2010 month Aug day 30 --- After stabilization --- range: in year 2010 month Aug day 30 start: 10-Aug-30 finish: 10-Aug-31 --- Sample dates in range (max. 20) --- 1: 10-Aug-30 Any idea how I could do that using ledger syntax? There is no syntax which would allow you to say the 1st day of the month, 12 months ago. I have a workaround that I am not satisfied with because it uses external perl trick ledger --begin=`perl -e 'use Date::Manip; print UnixDate(ParseDateString(12 months ago),%Y/%m);'` -M reg Well, Ledger was written with the UNIX philosophy in mind, so the use of external tools to enrich the core tool is not foreign, by any means. John
Re: Using Ledger to track inventory
Travis B Hartwell na...@travishartwell.net writes: Is what I want possible with Ledger? I'm thinking I would write an interface to keep track of my dosages and then enter refills, and it would generate the ledger file and call ledger to calculate dates of needed refills, calculate the cost per month, etc. I think it's entirely possible! You could use the forecaster for the when will I run out question, but everything else you described should be directly translatable. John
Re: Format strings 2.6 - 3.0
John Rakestraw jo...@johnrakestraw.com writes: I'm embarrassed to say that I don't remember where I found each of these. I got some hints by reading through the forum archives. And I figured out others by trial and error (e.g., I wonder if code will give me my check number). I'd love to see a list of all the possibilities. The basic format string syntax is based on printf: %[-][MIN][.MAX]CODE Where - makes the interpolated string left-justified, min is the minimum width, and max causes truncation if it exceeds that length. CODE is where things get tricky. 2.x used a series of hard-to-remember, single-letter characters to express things like payee (P), account (A), amount (a), etc. 3.x will support these as deprecated alternatives, although that support is not complete yet. In 3.x, the preferred way to use CODE is '(valexpr)', where valexpr is any Ledger value expression which yields a string, or can be coerced into a string. This means you can say %(10 + 20) to interpolate the string 30. There are lots and lots of value expression functions, taking no arguments, that resolve to parts of the current transaction or posting, such as code, payee, amount... Throughout the code, you can find methods defined with name ::lookup. These define the meaning of all valexpr literals. In addition, valexprs may use most C-style math and logic operators. This is a facility that Ledger itself uses extensively. Wherever possible I prefer using valexprs that can be overridden, to keep the code as flexible as possible. You may even define Python functions, and call them from Ledger value expressions, if that support has been compiled in and you use --import FILE to load the Python functions. You can pre-test your format strings and value expressions with these commands: ledger format 'FORMAT-STRING' ledger expr 'VALUE-EXPRESSION' You can also test out report queries and drafts (aka ledger xact) with: ledger query 'REPORT-QUERY' ledger template 'DRAFT-EXPRESSION' A report query is a simplified form of writing a value expression, and is what you type after reg and bal to specify which postings you want to see reported. The report query foo is shorthand for the value expression account =~ /foo/. I realize all this is in _sore_ need of documentation, and I have really been wanting to get back to this. It's simply that work has had me snowed under lately, since I became a partner in a C++ consulting company at the beginning of this year: BoostPro Computing (http://www.boostpro.com). Business ownership has been far more consuming than being an employee ever was, and it's been hard to find the long tracts of time that writing a good manual requires. (And I can't resist saying that the fact that I use ledger 3 despite occasional frustrations like these is testimony to the power and elegance of the program. I think John W is doing really good work here.) I really appreciate this, John, and it's my full intention to let you know everything Ledger 3 can do in the not too distant future. Yours, John
Re: Ledger Entry
Michael Farnbach noble.obl...@gmail.com writes: Now, I see a problem in doing this. Ledger's strengths in my opinion are in its stateless ledger, and by that I mean each entry can be anywhere in the ledger. And to add this to the entry itself in the ledger file would create a state that would then have to be tracked or conflict with what happens before or after it. Ledger is not really stateless. There are a lot of features that depend on the order it sees transactions in, since sorting by date is not strict enough. You can accomplish setting to the bank's view with a transaction like this: 2011-08-12 Sample Assets:Checking= $200.00 Equity:Adjustments This tells Ledger (Git/3.0) that your checking account's balance must be $200 after this transaction is completed. It will put whatever amounts are required to accomplish this into the Equity:Adjustments account. Now, in full disclosure I'm an avid 2.6 user, I don't know if Hledger, Beancount, or 3.0 Ledger has this functionality already. I think it does. :) I call it a balance adjustment. John
Re: Choosing the commodity in automatic transactions
rjc richard+goo...@richardcooper.net writes: = expr account =~ /^Asset:Checking/ payee =~ /^Buying Shares/ (Temp) 1 but that seems to match *everything*. IS that a bug in ledger or me not understanding the syntax? Is the new syntax documented anywhere? Try this: = /^Asset:Checking/ expr payee =~ /^Buying Shares/ (Temp) 1 John
Re: Choosing the commodity in automatic transactions
rjc richard+goo...@richardcooper.net writes: $ ledger bal -f test.txt While parsing file test.txt, line 1: While parsing automated transaction: = /^Asset:Checking/ expr payee =~ /^Buying Shares/ Error: payee operator not followed by argument $ Ok, I'll try to track this down when I get a moment. John
Re: Choosing the commodity in automatic transactions
rjc richard+goo...@richardcooper.net writes: If that's not directly possible I think I could live with the workaround: Ah. You can do this with value expressions if you are using the latest version of Ledger from Git: = /^Asset:Checking/p/Buying Shares/ (Virtual Account) (-1 EUR * amount) John
Re: Choosing the commodity in automatic transactions
rjc richard+goo...@richardcooper.net writes: I know about the -X and -V command line options, but I don't just want to alter the final display, I want the Virtual Account to actually contain dollars. I would say either use -B or -X '$'. But I'm not sure exactly what you want, since your question seems to preclude the use of -X? John
Re: Strange cleared report formatting
Craig Earls ender...@gmail.com writes: The report seems bit garbled, there are unexpected line feeds. I replaced all numerals with 'X' in below: This is what happens when there are totals which multiple commodities. At the moment, there is no way to collapse the unnecessary whitespace. The display engine was never built for multi-column output. However, I would love to support that in future. John
Re: Are automatic transactions working in the latest 3.0.0
Craig Earls ender...@gmail.com writes: = expr account =~ /^ Liabilities:test0.5 Use the same query you'd use on the command line: = /(Expenses:(Medical|Clothing))/ The expr version you specified was just missing a final /, but otherwise should have worked. John
Re: Building latest on OS X 10.6.8
Craig Earls ender...@gmail.com writes: Xcode 4.0.2. I admit to treating Macports like a black box and I have not really explored it much. I will look into having it build only the intel binaries vice universal. I have yet to try Xcode 4, FWIW. John
Re: Building latest on OS X 10.6.8
Craig Earls ender...@gmail.com writes: I just ran make check and it was clean. Not sure if I built debug or optimized. If you used acprep, the default is a debug build. ./acprep opt update builds the fully optimized version. With a debug build, you can use --trace 2, or --debug calc.expr, or --verify. Until your data file is several megabytes and uses many automated transactions, you won't notice the difference between the debug and optimized builds. Performance has been at the fore of my thinking since the very beginning of Ledger. John
Re: Building latest on OS X 10.6.8
Craig Earls ender...@gmail.com writes: OS X 10.6.8 Macport 2.0.0 with all dependencies installed git cloned lates revsion and ran ./acprep dependencies which went fine. ./acprep update failed becuase it couldn't find gmp libraries. port installed show gmp @5.0.2_1 and gmp @5.0.2_1+universal (active). I'm unable to confirm this. I have OS X 10.6.8 with MacPorts 2.0.0, and gmp @5.0.2_1+universal (active), and things build fine. Can you send me your config.log file? Thanks, John
Re: Ledger on Mac
rjc richard+goo...@richardcooper.net writes: As a new user of Ledger, the install experience left a lot be be desired. First the DMG download didn't work and then the compile-it- yourself route turns out to need MacPorts. I've opened https://github.com/jwiegley/ledger/issues/32 and https://github.com/jwiegley/ledger/issues/33with suggestions based on my experiences. I hope they're useful. They are quite useful! I will get this fixed. John
Re: Ledger on Mac
On Jul 21, 2011, at 3:21 PM, rjc wrote: I'm trying to run ledger on a Mac (latest Snow Leopard) without much luck. Any help would be much appreciated. Make sure you have gettext installed. If you use MacPorts, just run: ./acprep dependencies John
Re: Format output width to 79 characters by default, instead of 80?
Seppo Sade sepposa...@gmail.com writes: Currently Ledger seems to format output to a default width of 80 characters for register output. When generating such output in e.g. an Emacs buffer in a standard 80 character wide terminal, each 80- character line gets wrapped (because Emacs needs to insert a line- wrapping marker at the end, so there is no space for the last 80th character which has to go on a new line). Would it make sense to limit the default output to 79 characters instead to accomodate for editors having this behavior? It is just a minor annoyance, but still an annoyance when you do e.g. M-! ledger - f data reg and each entry is spread out over two lines, when ledger clearly tries to put it on a single line by limiting it to 80 characters. Ledger 3 adapts to whatever $COLUMNS is set to, or you can use --columns=X in your ~/.ledgerrc to setup a different default. John
Re: Trouble using the python interface
Hyrum K Wright hy...@hyrumwright.org writes: I don't know if there is a better way to debug this. The first thing to confirm is that Ledger and your boost_python shared library are both linking to the exact same Python library. That's usually the reason for startup crashes when using the Python bridge. John
Re: Trouble using the python interface
Hyrum K Wright hy...@hyrumwright.org writes: $ python Could you try using ledger python instead of just python? I've seen this problem before, it'll just take a moment to remember. John
Re: Printing monthly balances
On Jun 30, 2011, at 11:44 AM, Matthew Harris wrote: So now I get February's value, but I'm still getting two entries for March. Here's another view: ledger -f test2.dat reg -MVnEn account 2010/01/01 - 2010/01/31 Account $1 $1 2010/02/01 - 2010/02/28 None 0 $2 2010/03/01 - 2010/03/31 Adjustment$2 $3 Account $6 $9 How can I collapse the last two lines and just get exactly one value for each month? AhA! You have found another bug, my friend. Bugzilla me? John
Re: Automated entries
Matthew Palmer mpal...@hezmatt.org writes: When I asked this, several years ago, I was advised that the best way was to use cron (or some other automated task scheduler) to write entries into the ledger file automatically. Whilst it's a fairly big departure from what one might expect, I've never had cause to regret receiving that advice. Yes, one of Ledger's cardinal rules is that it never edits your data -- it only reports on it. Therefore, automatically generated entries, like repeating bill payments, must be done by some other tool such as cron. John
Re: Limiting transacations by related accounts
Martin Michlmayr t...@cyrius.com writes: Is it possible to limit transacations shown by 'ledger reg' based on other accounts in the transacation? I receive interest on various bank accounts but some of those are not taxable so I want to exclude them for my tax return. This is what the 'any' and 'all' directives do: ledger reg savings and expr 'any(account =~ /interest/)' This will include only those postings to savings where there was also a posting to interest within the same transaction. Is this a bug or does this 'related' have a different meaning to what I expect? Related means invert the sense of my query with respect to the transaction. I.e., if there is a transaction with a five postings, and one posting matches your criteria, then report the other four. John
Re: -X without revaluation
Martin Michlmayr t...@cyrius.com writes: I'm working on my tax return and I have to convert foreign currency income/expenses transacations at the rate on the date of the transacation. You can use -e DATE to report up to a given date, with valuation done as of that date. Or you can use --now DATE to valuate anything as if DATE was today. John
Re: -X without revaluation
Martin Michlmayr t...@cyrius.com writes: Right, but neither of those do what I want. What I need is a list of transactions with the valuation of the date of the transaction (and without any later revaluation). I think this is a pretty common use pattern so it would be nice if ledger would support it. Ah, this is in the schedule to be done soon, just, need, time... John
Re: Timeclock transactions balanced?
Seppo Sade sepposa...@gmail.com writes: Currently timeclock entries result in a virtual transaction were the time is just added to that account. But I would instead like to make it a balanced transaction, with both a source and destination account. Any hints on how to accomplish this? This is a good request, but it won't be possible to do in 2.6. John