Some issues with Pad/Balance directive

188 views
Skip to first unread message

Daniël Bos

unread,
Jun 6, 2016, 2:28:10 AM6/6/16
to Beancount
Hi Martin,

Are you aware of the following issues:

1. Sort order (?) is incorrect. If I have a Pad and a Balance on the same date, the Balance applies first, causing an error:

2016-01-01 balance Assets:Bank 1,000.00 CNY
2016-01-02 pad Assets:Bank Expenses:Groceries
2016-01-02 balance Assets:Bank 900.00 CNY

I'd expect pad/padding to be applied before balance assertions. 

2. Paddings involving the same account don't work, even when they're unambiguous:

2016-01-04 pad Expenses:Unknown Assets:Bank
2016-01-05 pad Assets:Bank Expenses:Groceries
2016-01-06 balance Expenses:Unknown 100.00 CNY
2016-01-07 balance Assets:Bank 700.00 CNY

I've had to deal with these cases a couple of times, and had to resort to writing the transaction manually, which isn't ideal. 

Best regards, 
Daniël Bos 

yegle

unread,
Jun 6, 2016, 2:46:26 AM6/6/16
to Beancount
For the first issue: balance is made at the beginning of the day, so if you want to assert on the ending balance on 2016-01-02, you should write it on 2016-01-03.

I think there were some discussions about adding a closing_balance directive or something so you can assert on closing balance instead of opening balance.

Daniël Bos 

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CADPdpKbe_iE6fT5osz1yA3CYFmwou2s1OppXHtL%2BCoOy-a-yfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--

Daniël Bos

unread,
Jun 6, 2016, 3:30:06 AM6/6/16
to Beancount

I've seen that discussion. Compared to normal transactions, it makes sense a balance takes precedence. However, I think padding aught to be applied before the balance that defines it.



For more options, visit https://groups.google.com/d/optout.
--

Best regards,
Daniël Bos

Your government is reading your email. Slow them down with encryption.

My public key: http://goo.gl/gms497 (4096 bit RSA, id EF2D5D91)
Fingerprint  : D8D0 9FBE F075 F709 7B52  2F73 326C 2123 EF2D 5D91

Martin Blais

unread,
Jun 6, 2016, 10:21:45 PM6/6/16
to Beancount
On Mon, Jun 6, 2016 at 2:28 AM, Daniël Bos <cor...@gmail.com> wrote:
Hi Martin,

Are you aware of the following issues:

1. Sort order (?) is incorrect. If I have a Pad and a Balance on the same date, the Balance applies first, causing an error:

2016-01-01 balance Assets:Bank 1,000.00 CNY
2016-01-02 pad Assets:Bank Expenses:Groceries
2016-01-02 balance Assets:Bank 900.00 CNY

I'd expect pad/padding to be applied before balance assertions. 

File order is meaningless in Beancount.
Furthermore, the effect of a Pad directive is to insert a corresponding transaction at the _same_ date as that Pad directive.
It would be strange to insert new transactions on the following day...
Balance is defined to apply at the beginning of the day.
To accomplish what you want above, increment the balance directives by one day.


2. Paddings involving the same account don't work, even when they're unambiguous:

2016-01-04 pad Expenses:Unknown Assets:Bank
2016-01-05 pad Assets:Bank Expenses:Groceries
2016-01-06 balance Expenses:Unknown 100.00 CNY
2016-01-07 balance Assets:Bank 700.00 CNY 

I've had to deal with these cases a couple of times, and had to resort to writing the transaction manually, which isn't ideal. 

Ha! That's an interesting case. I haven't had to deal with those, and I don't think there's a unit test for them.
Reply all
Reply to author
Forward
0 new messages