-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transactions are not added in new version #24
Comments
Hi Tobias, |
Hi, |
I managed to add a new transaction using v0.3 - well a newer commit to that. However something really weird has happened. A load - perhaps most - of my existing transactions have had their amounts changed. The amounts have been rounded to the nearest whole number: e.g. 4.80 -> 5.00 This happened after I tried to add a transaction. I'm not sure how long adding a transaction should take but it took a few minutes then had a connection error:
some of the trace
Any idea what happened!?! It seems really odd that this could even happen. I'm guessing that the I can help test although I'll have to create a test budget that can be sacrificed. Probably should have done that rather than my actual one. Does the server keep old versions like the desktop app or am I just gonna have to adjust the transactions myself? 😢 |
Hi gehan, The rounding might be a problem wth the scaling. The server does not store amount = $ 1.23, but amount=123, so scaling by 100 - at least util now, I've seen that the server recently apparently changed to scale by 1000 instead of 100. Maybe the scaling is not active for every client (they have a system of gradually rolling out features to people), that's a mess. Any idea how we could decipher the api's convention for that scaling at runtime instead of hardcoding the 100 or 1000 ? BadStatusLine might be a problem with the HTTPS connection, that might not have anything to do with the library, not sure, how much is it reproducible ? |
I was running this on GAE - I'll try locally later to see if it's something to do with the connection. Yeah it's annoying but I'll sort it out - I've borked many of my things over the years from hacking things about 😉 I'm more interested in how the lib works to be honest! It seems a bit nuts that adding a transaction can cause existing transactions to update - however that's easy to say when I don't know how it works. When the Client object is created it looks like the entire contents (or some?) of the budget is downloaded. So thats the account list, payee list... but also all transactions? Or last x days. From looking at server requests that seems to be what the webapp does. So after a transaction has been added then the server returns some object of things to change, then the lib does another sync or something? I'm wondering if it's possible to make the server the source of truth and therefore add safeguards to stop this happening to someone else - or me again! |
I'm tied to the way the web app works, and yep it fetches everything. We can't really use the server as source of truth because it's completely feasible, and the library doesnt hold your hand, to modify everything or most everything. I can delete budgets, delete all the transactions, everything is possible. Maybe we could add another layer to the client (and that's what I've kind of started with the add_transaction methods on the client): limit the number of modified transaction to 1 and if the library wants to send modifications for N transactions, error out. |
Right that makes sense now. Preloading data makes sense - for instance fetching payee list and account list. But fetching all transactions? That's insane to me! No wonder the webapp takes a minute or 2 to load for me. Anyway that's just how the person who made it decided to handle it. I like the extra layer you're talking about! I think the client should only alter the server copy in specific circumstances otherwise bad things can happen - like incorrectly modifying 3-4,000 transactions when YNAB changes its API behaviour 😭 Is this what you envisage then? When the client is first instantiated it does the sync thing and creates the in-memory copy of the account. After we assume the server is correct. The only times we ever try to alter the the server copy is when we perform an operation explicitly - and then we only modify things to do with that operation. For instance:
For add transaction we just tell the server to add the transaction, nothing else. Is that possible with how the nynab client works?! Is it actually necessary to ever call sync except when first instantiating the client? |
I like your idea. For now the sync method is common to "first sync" and to the others, because there is no functional difference (merging created/modified/added entities, etc). But I will add a layer, hide the sync method, reserve it to first sync, and make the entry points "modification methods" seding the info "how many entities should be changed down the line and error out before sending a modification for thousands of entities ! |
Nice one! Sounds very nice 👍 |
I have just realised that I have nYNAB on my phone! Since the client appears to download the entire budget I guess this copy is correct!? Do you think there is a way to modify the phone's data to be the latest version and therefore overwrite the cloud data when i refresh from the phone? |
no idea. You'd have to talk to nynab app developers ^^ |
oh yeah good point. well - the server copy's borked anyway so nothing to
lose!
…On Tue, 24 Jan 2017 at 13:40 rienafairefr ***@***.***> wrote:
no idea. You'd have to talk to nynab app developers ^^
If you can extract the data from the phone you could send it back to the
server using pynynab, but that's a loooong stretch.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOkRi7qk4TbVqK-nREizLzzlKob8lxHks5rVf82gaJpZM4K57s1>
.
|
gehan, |
Nice work! Will check it out :)
…On Fri, 27 Jan 2017, 16:02 rienafairefr, ***@***.***> wrote:
gehan,
I've pushed a syncchange branch that incorporates the ideas we floated
here on safeguards and differentiation between sync (from server) and push
(to server), check it out
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOkRjOECfKfYINSd6_Jliy3UgV0RGrxks5rWgcZgaJpZM4K57s1>
.
|
Hi,
i have a problem with the new version of your api.
i use the following code to add transaction to my YNAB account
db = Database(sqliteConfig.path)
ynabc = db.GetYnabLogin(account['UserID'])
parser = configargparse.getArgumentParser('pynYNAB')
args = parser.parse_args()
args.email = ynabc['Email']
args.password = ynabc['Password']
args.budgetname = ynabc['Budget']
client = clientfromargs(args)
client.sync()
accounts = {x.account_name: x for x in client.budget.be_accounts}
accountid = accounts[account['YnabAccountName']].id
imported_date = datetime.now().date()
transaction = Transaction(
entities_account_id=accountid,
amount=clearedTransaction['amount'],
date=datetime.strptime(clearedTransaction['Date'], '%d.%m.%Y'),
imported_date=imported_date,
memo=clearedTransaction['Memo'],
source="Imported",
)
if not client.budget.be_transactions.containsduplicate(transaction):
client.add_transaction(transaction)
client.sync()
return True
return False
It was working well , till i updated to version 3 of your api. Now, the transaction isn't added, but i don't get errors. Did i miss something, that was changed?
Thanks for your help and your work.
Tobias
The text was updated successfully, but these errors were encountered: