Hi all,In current hledger, a balance assertion likesome:account $1 = $4asserts that after the $1 posting, some:account's balance is $4.
I learned from https://github.com/simonmichael/hledger/issues/195 that in Ledger, it means that some:account's *dollar* balance is $4, and says nothing about any other commodities in the account. This should be clarified at http://ledger-cli.org/3.0/doc/ledger3.html#Balance-assertions.
I find this a little harder to understand and explain, and unsatisfying that a balance assertion doesn't definitively nail down (programmatically and visually) what's in an account. You can add more postings, with 0 amount if necessary, to assert the balance of each individual commodity:
some:account $1 = $4some:account 0 = EUR 10some:account 0 = FRF 15but you're still not absolutely sure of the account's balance - new commodities can show up there and the assertions won't notice.
Also, what does it mean to assert a commodity-less zero balance ? Ledger accepts all the assertions below, which seems wrong:1/1a 1 = 1a $1 = $1a $-1 = 0a 1 = 0a 1 = 0bThe advantage of Ledger's current way is that you can make at least some assertions about a multi-commodity account. In current hledger this is explicitly not supported, so if you really needed to assert a multi-commodity balance you'd have to separate the commodities into subaccounts.
Compatible balance assertions are important for interoperability between ledger-likes, so I'm wondering how to harmonise this. I can make hledger's assertions work like current Ledger, or we could agree to target a new design. Eg I propose we add a one-line syntax for multi-commodity amounts, such as:
some:account $1 = $4, EUR 10, FRF15 ; comma followed by a space separates amountsand agree that assertions disallow commodities not explicitly mentioned. What do you think ?There's at least one other incompatibility between Ledger and hledger balance assertions:1/1a 1 = 1a 1 = 1 ; Ledger expects a to be 1 again, ignoring the previous posting; hledger expects 2bCan I persuade you that hledger's interpretation is better here ?
Either way, I'd also like to have --no-balance-assertions or similar widely supported, so that you can at least ignore them temporarily while running another ledger-like on your data.Thoughts ?
Just to be clear, it also makes sense to do this in Beancount:2014-06-20 balance Assets:Some:Account 413.43 USD2014-06-20 balance Assets:Some:Account 201.24 CADI too have been wondering if a check on the totality of an inventory might be useful.Something like this:2014-06-20 balance* Assets:Some:Account 413.43 USD, 201.24 CADwhereby if there are any other commodities in this account at that time (e.g., EUR) this would raise an error.
Thanks Martin. I agree that the repetition above is more effort, but I
tend to think it's worth the trouble - explicitness and correctness are
why assertions exist after all.
And I feel multi-commodity accounts are
rare and needing to write many assertions on them will be rarer
And different from currency, as soon as you are trading, then multiple *commodity* is standard. BTW, it is not difficult to start trading, if your company is traded on any stock exchange, you can not avoid that your company is distributing shares.
> 2014-06-20 balance* Assets:Some:Account 10 GOOG, 640.40 USDAbout that syntax:
- I have at least 2 accounts, where I do have more than 6 commodities. With names of commodities that are 20 characters long. This would make things tedious...
- Also, do not forget that some of us are using comma as decimal separator That syntax above may not be the best one.
On 6/30/14 9:55 PM, John Wiegley wrote:I feel sympathetic to Martin here - a separate directive seems more orthogonal. Postings are already expressing quite a lot.
Sure, but then a transaction that does nothing would appear in the register,Martin Blais <bl...@furius.ca> writes:
no?
Though, if not taking journal order into account I would have processed it last, after any transactions on that day.
If taking order into account, which I wouldn't mind doing - h/ledger do it elsewhere - the separate directive would be just as expressive as the current scheme, no ? More so, as it would never introduce dummy transactions and requiring -E to hide (possibly disturbing your report in other ways).
;; Credit card account 2014/05/01 opening Liabilities:CreditCard $-1000.00 Expenses:OpeningBalances 2014/05/12 dinner Liabilities:CreditCard $-74.20 Expenses:Restaurant ;; Checking account 2014/06/05 salary Assets:Checking $4082.87 Income:Salary 2014/06/05 cc payment Assets:Checking $-1074.20 = $3008.67 Liabilities:CreditCard = $0
;; Credit card account 2014/05/01 opening Liabilities:CreditCard $-1000.00 Expenses:OpeningBalances 2014/05/12 dinner Liabilities:CreditCard $-74.20 Expenses:Restaurant 2014/06/05 cc payment Assets:Checking $-1074.20 = $3008.67 Liabilities:CreditCard = $0 ;; Checking account 2014/06/05 salary Assets:Checking $4082.87 Income:Salary
If the posting-based assertions do remain, then hledger will probably go ahead and add == to assert against the full multi-commodity amount.
On 7/1/14 7:55 AM, Martin Blais wrote:I'm used to h/ledger working this way (entries with the same date being processed in journal order). I don't mind it because a. it's intuitive to users and b. it allows you to assert intra-day balances as well as inter-day ones.
because of this, if you reorder your directives, e.g., you insert a new
directive before one that has a balance assertion on a posting that
affects an account with another assertion on the same date, it might
break a balance assertion that had previously been working.
I do see that being completely independent of journal order is nice too.I haven't made a balance assertion corresponding to a bank statement yet (good idea). Mine are more commonly for cash and need not be at the end of the day. Eg:
IMHO, when designing this, the question you have to ask yourself is:
where do the balance amounts you report come from? Usually they come
from some statement, you copy the value from the line on your statement
which says "your balance on YYYY/MM/DD is X". OFX also has a field that
2014/6/25 * adjust/reconcile cash
assets:personal:cash:wallet $-1 = $14.50
expenses:personal:miscOrder invariance, and having balance assertions on postings or as separate directives, are mostly orthogonal issues I think.
Choosing to define balance assertions on their own removes _just_ enough
degrees of freedom that it makes it unambiguous and order-invariant. I
think you could easily do the same thing in Ledger, in fact, this _may_
be the only thing that is needed to make Ledger's balance assertions
order-invariant.
Do you mean the ordering issue ? The comment you're quoting there doesn't change anything there, hledger would still process transactions, postings and assertions in (1) date and (2) journal order.
If the posting-based assertions do remain, then hledger will
probably go ahead and add == to assert against the full
multi-commodity amount.
How do you plan to disambiguate for the case I point out above?
On 7/1/14 6:23 PM, Martin Blais wrote:Yes, I agree.
A dedicated balance directive is also quite intuitive IMO.
Ok, not completely orthogonal, there is overlap. Having assertions on postings does partly determine the order they must be applied. This depends also on how order-independent transactions (and postings within transactions) are.
Order invariance, and having balance assertions on postings or as
separate directives, are mostly orthogonal issues I think.
No... that's exactly the problem I'm pointing out! They're not
orthogonal.
This gets a bit complicated. Eg, currently Ledger respects journal order more, and transaction dates less, than hledger does when deciding the order in which to to apply postings and assertions (I don't have an example to hand). And on the other hand, hledger is more respectful of journal order than Ledger is when processing postings and assertions within a single transaction.
On 7/1/14 7:45 PM, Martin Blais wrote:Indeed we would, of course, at the cost of giving up intra-day assertions.
Alright... so here's the punchline: I'm claiming that if Ledger or
HLedger gave up on balance assertions attached to postings, if you
separated them as I do, just that change, you would both very likely be
able to guarantee order-independence w.r.t. your input files! Think
I don't feel too strongly about intra-day assertions either way. But I think hledger needs to support Ledger's style of assertions, at least. (Though I just added a --ignore-assertions flag as an alternative.)
We could also name and implement all of these three kinds of assertions:
- ledger's single-commodity, ordered, posting-based assertions
- hledger's multi-commodity, ordered, posting-based assertions (using ==)
- beancount's order-independent, directive-based assertions (do these assert one commodity or all of them ?)
This gives most power and compatibility.. but also more feature bloat. Anyway I probably shouldn't think about supporting beancount format with hledger's main parser, due to its other differences.
On 7/2/14 6:35 AM, Simon Michael wrote:
I don't feel too strongly about intra-day assertions either way. But I
think hledger needs to support Ledger's style of assertions, at least.
(Though I just added a --ignore-assertions flag as an alternative.)
To be clear: I mean I'd like hledger to include support for the idiomatic style of assertions Ledger uses going forward, whatever that ends up being.
>>>>> Martin Blais <bl...@furius.ca> writes:For me, this loses the value of balance assertions for a convenience I don't
> Yes, I'm suggesting that making such an assertion should not be possible
> anymore. You give up this capability, in exchange for the property of
> order-independence. That's the compromise I made; for me, order-independence
> is a much more important property than the capability to make balance
> assertions between transactions within a day.
presently need.
> You often have this? What kind of account is this? Bank, credit card,My credit card statements regularly have transactions within one day, for
> trading? And how often do this occur? I have seen very few cases in 8 years
> where I could not just increment or decrement the balance assertion date, or
> skip an assertion (very rarely occurs - it's okay to skip one if you have
> another one later on, they're entirely optional anyway).
which other transactions on that same day occur only on the next statement.
Hence, not having intra-day assertions would mean I couldn't make use of
assertions to help manage reconciliation of statements (my primary use of
them, in fact).
The goal of Ledger has always been flexibility first, allowing users to define
their own semantics. I recognize that Beancount is much more oriented toward
an accounting-centric semantics for the sake of that use case. This is a
healthy division, and I think a cross-pollinating one too.
Intra-day assertions could have other uses too, which I'm unaware of at the
moment. That's reason enough for me to be unwilling to sacrifice them for
convenience. There may even be other solutions here that allow us to have
both that have yet to be explored.
John
--
---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wed, Jul 2, 2014 at 7:04 PM, John Wiegley <jo...@newartisans.com> wrote:
My credit card statements regularly have transactions within one day, for
which other transactions on that same day occur only on the next statement.
Hence, not having intra-day assertions would mean I couldn't make use of
assertions to help manage reconciliation of statements (my primary use of
them, in fact).
The goal of Ledger has always been flexibility first, allowing users to define
their own semantics. I recognize that Beancount is much more oriented toward
an accounting-centric semantics for the sake of that use case. This is a
healthy division, and I think a cross-pollinating one too.I don't think how that lets users define their own semantics.
>>>>> Simon Michael <si...@joyful.com> writes:
> But note they can't choose (in Ledger) to place dated assertions at one end
> of the journal, or in a separate file - because Ledger's assertions
> currently follow *only* parse order, ignoring of the date of the posting
> they're on. I had forgotten this. It sounds like John would change this but
> it's awkward with the current implementation, because it processes
> assertions during parsing.
Yes, I've dumped at least a day into this problem, but Ledger's current
processing pipeline won't allow it without back-tracking or caching huge
amounts of data in memory, or recalculating certain figures from scratch each
time they are needed.
I'm convinced Ledger should have adopted an intermediary data representation:
Parse data into "raw" structures, and then "cooking" these structures. At the
moment it parses directly into the cooked form. Having an intermediate "raw"
representation would allow me to do many things much more easily,
order-independence being among them (or so I believe).
My Haskell version of the Ledger parser does exactly this, but changing the
C++ code would be a huge refactoring, and beyond the scope of what I want to
do to that code right now. If I were to spend large amounts of time doing new
development, it would be in Haskell with a hope to merge efforts with Simon
toward more feature parity for hledger. I'm quite happy with C++ ledger's
current feature set and stability, so my goal there is to keep that purring
along, modulo fixing important problems like rounding and currency evaluation.