Bugzilla – Bug 374
Problem with periodic transactions having a null posting
Last modified: 2010-07-02 03:16:26
You need to log in before you can comment on or make changes to this bug.
$ ledger -J reg checking -f finances.txt While parsing file "finances.txt", line 23: While parsing periodic transaction: > ~ Monthly from 2010/7/1 > Expenses:Auto:Gas $####.## > Expenses:Auto:Insurance $####.## > Expenses:Childcare $####.## > Expenses:Entertainment:Blizzard $####.## > Expenses:Entertainment:Netflix $####.## > Expenses:Groceries $####.## > Expenses:Utilities:Electric $####.## > Expenses:Utilities:Water $####.## > Expenses:Utilities:Sewage $####.## > Liabilities:Education:ULL $####.## > Liabilities:Mortgage $####.## > Assets:Bank:Checking Error: Only one posting with null amount allowed per transaction
Retried with a current debug build built from source. Issue still appears to be present. $ ./ledger --version Ledger 3.0.0-20100623, the command-line accounting tool Copyright (c) 2003-2010, John Wiegley. All rights reserved. This program is made available under the terms of the BSD Public License. See LICENSE file included with the distribution for details and disclaimer. $ ./ledger -J reg checking -f ~/Documents/finances.txt --debug xact.finalize 0ms [INFO] Ledger starting 2ms [INFO] Parsing file '/home/matt/Documents/finances.txt' 3ms [DEBUG] post must balance = $####.## 3ms [DEBUG] post must balance = $####.## 3ms [DEBUG] initial balance = $####.## 3ms [DEBUG] balance is an amount 3ms [DEBUG] there was a null posting 3ms [DEBUG] resolved balance = 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] initial balance = $####.## 4ms [DEBUG] balance is an amount 4ms [DEBUG] there was a null posting 4ms [DEBUG] resolved balance = 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] post must balance = $####.## 4ms [DEBUG] post must balance = $####.## 5ms [DEBUG] post must balance = $####.## 5ms [DEBUG] post must balance = $####.## 5ms [DEBUG] post must balance = $####.## 5ms [DEBUG] post must balance = $####.## 5ms [DEBUG] post must balance = $####.## While parsing file "/home/matt/Documents/finances.txt", line 23: While parsing periodic transaction: > ~ Monthly from 2010/7/1 > Expenses:Auto:Gas $####.## > Expenses:Auto:Insurance $####.## > Expenses:Childcare $####.## > Expenses:Entertainment:Blizzard $####.## > Expenses:Entertainment:Netflix $####.## > Expenses:Groceries $####.## > Expenses:Utilities:Electric $####.## > Expenses:Utilities:Water $####.## > Expenses:Utilities:Sewage $####.## > Liabilities:Education:ULL $####.## > Liabilities:Mortgage $####.## > Assets:Bank:Checking Error: Only one posting with null amount allowed per transaction 5ms [DEBUG] post must balance = $####.## 5ms [DEBUG] initial balance = $####.## 5ms [DEBUG] balance is an amount 5ms [DEBUG] there was a null posting 6ms [DEBUG] resolved balance = 6ms [DEBUG] post must balance = $####.## 6ms [DEBUG] initial balance = $####.## 6ms [DEBUG] balance is an amount 6ms [DEBUG] there was a null posting 6ms [DEBUG] resolved balance = 6ms [DEBUG] post must balance = $####.## 6ms [DEBUG] initial balance = $####.## 6ms [DEBUG] balance is an amount 6ms [DEBUG] there was a null posting 6ms [DEBUG] resolved balance = 6ms [DEBUG] post must balance = $####.## 6ms [DEBUG] initial balance = $####.## 6ms [DEBUG] balance is an amount 6ms [DEBUG] there was a null posting 6ms [DEBUG] resolved balance = 7ms [DEBUG] post must balance = $####.## 7ms [DEBUG] initial balance = $####.## 7ms [DEBUG] balance is an amount 7ms [DEBUG] there was a null posting 7ms [DEBUG] resolved balance = 7ms [INFO] Ledger ended
Found the problem. In xact.cc, within the declaration for bool xact_base_t::finalize(), I tried changing this... else if (null_post) { to this... else if (null_post) { DEBUG("xact.finalize", "first null post = " << null_post->reported_account()->fullname()); DEBUG("xact.finalize", "second null post = " << post->reported_account()->fullname()); and came up with this output... 5ms [DEBUG] post must balance = $1062.96 5ms [DEBUG] first null post = Expenses:Entertainment:Blizzard $16.00 5ms [DEBUG] second null post = Assets:Bank:Checking So there needed to be more than a single space between the account name and the transaction amount, or the intended amount was read as part of the transaction name. I would imagine that this is expected behavior, though if possible it would be nice if the parser would account for it such that the last non-whitespace text element on a line is used as the amount regardless of the amount of space separating it from the previous text element.
Yes, it is expected behavior. Nice find! I don't like the idea of making a hack to try and get around this, though, it's likely to only work right in the most obvious situations. I'll think about having a better way to catch this (like having a warning if a null posting's account name contains digits).