rienafairefr / pynYNAB

a python client for the new YNAB
MIT License
138 stars 12 forks source link

All amounts are rounded #38

Closed rossdargan closed 7 years ago

rossdargan commented 7 years ago

All of the Transaction.amounts that I check are whole integers... Adding them all up using a sql query: session.query(func.sum(Transaction.amount)).scalar()

gives a whole number, and checking many transactions results in the same thing.

rienafairefr commented 7 years ago

Yes indeed, the amounts are stored in the internal database as whole integers. this custom type. I would have thought this query would scale the value and give you back a normal value (in dollars), apparently not. The simplest solution is to scale the value yourself, divide by 1000 and this gives you the good value :-)

rossdargan commented 7 years ago

Once it's been placed into that custom type I don't think there is much I can do - I've tried dividing it by 1000 but the loss of precision is just maintained. I might be missing something!

>>> ynab_client.budget.be_transactions[6].amount/1000
-0.014
>>> ynab_client.budget.be_transactions[6].amount
-14.0
rienafairefr commented 7 years ago

Normally it should be transparent, the amount field should contain the actual dollar values. What is the amount displayed in YNAB website for this transaction ?

rossdargan commented 7 years ago

£13.03 :)

rienafairefr commented 7 years ago

yeah, that's an unacceptable rounding ! I can confirm the error, just replicated! Why that hasnt been caught by anyone else is remarkably horrible

rienafairefr commented 7 years ago

I think that's a python incompatibility. Are you using python 2 ?

rienafairefr commented 7 years ago

can you try latest master 7af5f1d ? I added a float(x) to handle how python 2.x does divisions involving integers.

rossdargan commented 7 years ago

Yup, that solves it - cheers!