Closed bzupnick closed 2 years ago
update: After deleting all the transactions for this account (g/.*58543bed-6c70-4074-97ab-1a1c35b17a7d.*/d
) and running the script again, it worked!
I'm seeing a similar error, but I have not created transactions via the YNAB API ever.
@bzupnick , was your solution to delete all transactions from the offending account in the YNAB JSON file, and re-import?
Weird. I wonder why it happens, though. What's your offending error and corresponding line in the json file?
And yeah, I deleted all the transactions from the account and re-imported. It was a "tracking" account so it didn't effect my budget at all
That's strange, that happened with a tracking account for me as well, an investment account to be precise. I ended up actually having 2 accounts that were causing issues, both needed to be deleted for the import to go smoothly.
Ended up downloading VS code and manually deleting the offending account lines from the JSON via regex. ^.account-guid-here.,
for those curious.
So I bumped onto the same bug while trying to import my transactions. The example offending transaction is:
{"id":"790438ac-0d28-4031-9ba9-b3e349475356","date":"2021-08-03","amount":-4059,"memo":"Groceries PLN 21.58","cleared":"reconciled","approved":true,"flag_color":"green","account_id":"3e4e34a2-82d1-4f34-aa44-a10d75a188c1","payee_id":"ada7a8b8-e47b-4143-a9fb-9a407d5eec92","category_id":"29ae8dc4-2534-4a9a-b1cd-25aa07fd70b9","transfer_account_id":null,"transfer_transaction_id":null,"matched_transaction_id":null,"import_id":"YNAB:-4059:2021-08-03:1","deleted":false}
This is what I have tried so far with no results:
-14059
which resulted in updated error message of Can't convert to integer -1405.9
as expectednull
- no differencenull
. no differenceSo I looked into the code and it's this function throwing the error:
function ct(e, t) {
if (void 0 === e) throw new Error("Query value cannot be undefined");
if (null === e) return "boolean" === t ? 0 : null;
switch (t) {
case "date":
if (e instanceof Date) return V($e(e));
if (null == e.match(/^\d{4}-\d{2}-\d{2}$/) || e.date < "2000-01-01") throw new Error("Invalid date: " + e);
return V(e);
case "date-month":
return V(e.slice(0, 7));
case "date-year":
return V(e.slice(0, 4));
case "boolean":
return e ? 1 : 0;
case "id":
if ("string" != typeof e && null !== e) throw new Error("Invalid id, must be string: " + e);
return e;
case "integer":
if ("number" == typeof e && (0 | e) === e) return e;
throw new Error("Can't convert to integer: " + JSON.stringify(e));
case "json":
return JSON.stringify(e)
}
return e
}
specifically, it's the (0 | e) === e)
condition that is not matched because -1405.9 | 0
gives -1405
.
So it looks like those are just amounts that have not been rounded properly. In my case, these have also been created by a script (like in @bzupnick's case). I will figure out some script to fix those to be round numbers.
Same bug here. All my transactions are written through the YNAB API :-)
fix got merged
I'm getting the following error:
When I open up
YourBudget.json
, though, I'm not seeing-3506.9
. I am seeing:which is the closest I can see to being the "culprit" transaction.
The weird thing is that if, in YNAB, I go to that account on that day I only see a transaction for $35.07 🤔
So I tried changing
35069
to35070
inYourBudget.json
and reran it. I got a similar error but a different number:and that's just from the next transaction, as you can see in the screenshot above, that in the GUI says $1.85.
So obviously I fixed that one number again, ran it to confirm, and the third number tripped up. We've found the pattern.
Note that this account is populated twice daily automatically by a Google script I wrote up that creates a YNAB transaction via it's API. Unfortunately I don't have access to that script anymore since Google decided to not open that page:
But I wonder if the issue is that maybe my script is sending numbers like $5.345 or something? That's getting rounded in the GUI, not in the backend, and is screwing with the script here? Since I don't have access to my spreadsheet macros it's hard to debug and give it exactly what's being sent. Sorry!