From 051e4ab1ef82c58dc9563281ec14c02fc250e20f Mon Sep 17 00:00:00 2001 From: Daraul Harris Date: Sat, 5 Dec 2020 14:43:21 +0800 Subject: Do not treat balance assignments with 0 diff as a null posting Ledger is treating balance assignments that have a 0 diff as having a null posting, leading to the posting being auto-balanced and therefore causing incorrect values to be returned for the transaction. I fixed this by just making the posting equal to amt - amt (0 in the right commodity). Fixes #1942 --- src/textual.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/textual.cc b/src/textual.cc index b4e51fbe..70bf4129 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1705,7 +1705,11 @@ post_t * instance_t::parse_post(char * line, // as amount cannot store more than 1 commodity. post->amount = diff.to_amount(); DEBUG("textual.parse", "line " << context.linenum << ": " - << "Overwrite null posting"); + << "Overwrite null posting with " << diff.to_amount()); + } else { + post->amount = amt - amt; // this is '0' with the correct commodity. + DEBUG("textual.parse", "line " << context.linenum << ": " + << "Overwrite null posting with zero diff with " << amt - amt); } } else { // balance assertion -- cgit v1.2.3