Problem using the fixed rate commodity syntax

11 views
Skip to first unread message

Peter Ross

unread,
Feb 17, 2010, 12:23:22 AM2/17/10
to ledge...@googlegroups.com
Hi,

I'm using the latest version of ledger from the git master branch.

I run the following command and get an error

$ ~/personal/workspaces/ledger/ledger -f ledger.dat bal
While parsing file "ledger.dat", line 37:
While balancing transaction from "ledger.dat", lines 35-37:
> 2010/01/22 Marketing B
> Expenses:Marketing 55EUR {=$1.81818181818}
> Liabilities:Accounts Payable -$100
Unbalanced remainder is:
$10
Amount to balance against:
$110
Error: Transaction does not balance

From what I understand I should be using the rate 1.81818181818 to
convert the 55 euros into 100 dollars.

However this doesn't seem to be happening.

Here is the full ledger file

2009/01/01 Invoice A
Assets:Accounts Payable $1000
Income:Sales

2009/01/21 Payment Invoice A
Assets:NAB $1000
Assets:Accounts Receivable

2009/01/22 Pay expenses
Expenses:Payroll $800
Assets:NAB

2009/01/22 Marketing A
Expenses:Marketing 50EUR {=$2}
Liabilities:Accounts Payable -$100

2009/01/23 Pay MC Marketing
Assets:NAB -$100
Liabilities:Accounts Payable

;-------------------------------------------------------

2010/01/01 Invoice B
Assets:Accounts Payable $1000
Income:Sales

2010/01/21 Payment Invoice B
Assets:NAB $1000
Assets:Accounts Receivable

2010/01/22 Pay expenses
Expenses:Payroll $800
Assets:NAB

2010/01/22 Marketing B
Expenses:Marketing 55EUR {=$1.81818181818}
Liabilities:Accounts Payable -$101

2010/02/23 Pay MC Marketing
Assets:NAB -$100
Liabilities:Accounts Payable

Hope someone can explain to me what I'm doing wrong.

I also tried to use the fixed syntax

fixed EUR $1.81818181818
....
end fixed

but that always reported a parse error.

Pete

John Wiegley

unread,
Feb 17, 2010, 1:33:07 AM2/17/10
to ledge...@googlegroups.com
On Feb 17, 2010, at 12:23 AM, Peter Ross wrote:

> From what I understand I should be using the rate 1.81818181818 to
> convert the 55 euros into 100 dollars.

Your problem is with rounding. Put this at the top of your file:

D $1,000.00

Then your problem should go away. It's not that your transaction didn't balance, it's that the *display value* of the transaction didn't balance; and since you never use decimal points in any of your dollar amounts, Ledger rounds all display value to the nearest dollar.

There is a bug here, in that it should round the 55*1.818 after the multiplication, not before. I'll add an issue for this.

John

Peter Ross

unread,
Feb 17, 2010, 1:55:08 AM2/17/10
to ledge...@googlegroups.com
Thanks John.

That did solve the problem.

John Wiegley

unread,
Jun 8, 2010, 5:14:05 AM6/8/10
to ledge...@googlegroups.com
On Feb 17, 2010, at 12:23 AM, Peter Ross wrote:

> I run the following command and get an error
>
> $ ~/personal/workspaces/ledger/ledger -f ledger.dat bal
> While parsing file "ledger.dat", line 37:
> While balancing transaction from "ledger.dat", lines 35-37:
>> 2010/01/22 Marketing B
>> Expenses:Marketing 55EUR {=$1.81818181818}
>> Liabilities:Accounts Payable -$100
> Unbalanced remainder is:
> $10
> Amount to balance against:
> $110
> Error: Transaction does not balance
>
> From what I understand I should be using the rate 1.81818181818 to
> convert the 55 euros into 100 dollars.
>
> However this doesn't seem to be happening.

Peter, this should work for you now. I just tested again the 'next' branch.

John

Reply all
Reply to author
Forward
0 new messages