Giter Club home page Giter Club logo

import-ynab5's Introduction

This repository is archived.

New location for the package: https://github.com/actualbudget/actual/tree/master/packages/import-ynab5


This is a beta importer for YNAB5 (nYNAB) data.

To run:

npx @actual-app/import-ynab5 <path-to-ynab5-file>

Read below for how to get your YNAB5 file.

Almost everything should be working now.

TODO

  • There might be a way to set carryover using internal categories from YNAB (Deferred Income Subcategory and Immediate Income Subcategory)
  • Docs of how credit cards translate from Actual to YNAB
  • Maybe something else I'm missing
  • Remove ynab transfer payees not used by actual

How to use the importer

To use the importer, you will first need to export your budget, then have the correct software installed, and then run the importer.

Note: currently this does not work under WSL in Windows. Run this directly in Windows.

Exporting from YNAB

In order to export your budget from YNAB, you will need an API key.

If you haven't already got an API key, you'll need to:

  • Sign in to the YNAB web app
  • Go to the "Account Settings" page, then to the "Developer Settings" page
  • Under the "Personal Access Tokens" section, click "New Token"
  • Enter your password and click "Generate" to get a new access token

The API key is only shown once, so make sure you copy it down somewhere! More information on how to access the YNAB API can be found at https://api.youneedabudget.com/

Now open a terminal window / command prompt, and enter:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" https://api.youneedabudget.com/v1/budgets

This will get the list of all the budgets you have. You'll need to find the id of the budget you want to export and use it to perform the following API request:

curl -H "Authorization: Bearer <ACCESS_TOKEN>" https://api.youneedabudget.com/v1/budgets/<BUDGET ID> --output budget.json

Getting the right tools installed

For the importer to run, you will need nodejs installed. Details on doing that are too long for this README, but you can find details at https://nodejs.org/.

Once you have nodejs installed, you'll need to get download this importer. If you're familiar with GitHub and Git then you probably have everything setup to easily clone this repository. If not, the easiest way to get this importer is to use the Code button and then use the Download ZIP file.

Once you have downloaded the zip file, unzip it on your computer to extract the files. Then in a terminal / command prompt, navigate into the directory and type the command:

npm i

This will install the required libraries for the importer.

Running the importer

  • Have Actual running locally on your computer
  • Open a terminal / command prompt in the unzipped directory from the previous steps
  • Run the following command, substituting the /path/to with where ever you saved the budget.json file:
npx @actual-app/import-ynab5 /path/to/budget.json

If you have checked out this code and running it locally, do node index.js instead of the npx command.

Refresh the cache

Once the import is complete, it may not show all the up-to-date information correctly. In order to refresh the view:

  • Click the โš™๏ธ icon next to the budget name
  • Click Advanced -> Reset budget cache
  • Restart Actual

Contributions

If you would like to contribute, check out the documentation for the API, specifically about importers. All of the available methods can be found here.

import-ynab5's People

Contributors

amnuts avatar aon avatar ashraymehta avatar jlongster avatar matissjanis avatar mikebishop avatar skrobul avatar trevdor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

import-ynab5's Issues

Missing Category Amounts from Import

Category Budgeted amounts aren't being updated by the importer.

Is there a bug in actual.setBudgetAmount()?

I can see an amount getting to the call, but the budgeted value doesn't appear to be updating (verified by checking both the final budget file via UI as well as adding a call to actual.getBudgetMonth() after the import.)

await actual.setBudgetAmount(month, catId, amount);

Failing on "Handle transfer payee"

Importing Accounts...
Importing Categories...
Importing Payees...
Importing Transactions...
TypeError: Cannot read properties of undefined (reading 'id')
    at /Users/bzupnick/Desktop/import-ynab5/importer.js:226:14
    at Array.map (<anonymous>)
    at /Users/bzupnick/Desktop/import-ynab5/importer.js:190:35
    at Array.map (<anonymous>)
    at importTransactions (/Users/bzupnick/Desktop/import-ynab5/importer.js:187:38)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async doImport (/Users/bzupnick/Desktop/import-ynab5/importer.js:306:3)
    at async /Users/bzupnick/Desktop/import-ynab5/node_modules/@actual-app/api/connection.js:113:5
    at async _run (/Users/bzupnick/Desktop/import-ynab5/node_modules/@actual-app/api/connection.js:91:11)
    at async run (/Users/bzupnick/Desktop/import-ynab5/index.js:6:3)

node index.js Error reading file

I'm not a developer so stumbling around a little with this.. can anyone assist me with this error? I've got nodejs installed running latest version, and updated npm. I downloaded the zip file and extracted it to c:\temp, so the files are in c:\temp\import-ynab5-master. From that path I ran npm i in bash to install the libraries.
Then with Actual running, in command prompt, I cd to that directory and run node index.js /budget.json and get 'Error Reading File'. I get the same error if I don't give a file name (node index.js). The budget file I downloaded is in the same directory, so not adding a path to that file name (have also tried putting in the full file path/name, same result).

I have set permissions on the folders to Everyone full access, as well as local machine users (needed to do that to write the file from ynab).
Is anyone able to assist me with this? is it a permissions issue? version issue?

Running W10 latest version.
WLS2
Default node v16.13.0 (have also installed 17.1.0 and running that get same issue)
npm version 8.1.3
Any assistance or pointers appreciated.

Directory of C:\Temp\import-ynab5-master

14/11/2021 06:17 PM

.
14/11/2021 06:17 PM ..
14/11/2021 05:39 PM 12 .gitignore
14/11/2021 12:30 PM 2,106,753 budget.json
14/11/2021 05:39 PM 4,525 example.json
14/11/2021 05:39 PM 9,517 importer.js
14/11/2021 05:39 PM 179 index.js
14/11/2021 05:42 PM node_modules
14/11/2021 07:12 PM 5,222 package-lock.json
14/11/2021 05:39 PM 587 package.json
14/11/2021 05:39 PM 1,158 README.md
14/11/2021 07:12 PM 1,898 yarn.lock
9 File(s) 2,129,851 bytes
3 Dir(s) 148,388,691,968 bytes free

C:\Temp\import-ynab5-master>bash
[user@laptop]:/mnt/c/Temp/import-ynab5-master$ node index.js /budget.json
Error: Error reading file
at importYNAB5 (/mnt/c/Temp/import-ynab5-master/importer.js:319:11)
at run (/mnt/c/Temp/import-ynab5-master/index.js:6:9)
at Object. (/mnt/c/Temp/import-ynab5-master/index.js:9:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
[user@laptop]:/mnt/c/Temp/import-ynab5-master$

Cant download my budget file

Trying to get the ID of my budget from the nynab api results in

{"error":{"id":"404.1","name":"not_found","detail":"Invalid URI"}}

Failing to import transactions that were created via YNAB API

I'm getting the following error:

$ node index.js YourBudget.json
Importing Accounts...
Importing Categories...
Importing Payees...
Importing Transactions...
Error: [API Error] Can't convert to integer: -3506.9
    at /Users/bzupnick/Desktop/import-ynab5/node_modules/@actual-app/api/connection.js:26:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/bzupnick/Desktop/import-ynab5/importer.js:242:7
    at async Promise.all (index 3)
    at async importTransactions (/Users/bzupnick/Desktop/import-ynab5/importer.js:186:3)
    at async doImport (/Users/bzupnick/Desktop/import-ynab5/importer.js:306:3)
    at async /Users/bzupnick/Desktop/import-ynab5/node_modules/@actual-app/api/connection.js:113:5
    at async _run (/Users/bzupnick/Desktop/import-ynab5/node_modules/@actual-app/api/connection.js:91:11)
    at async run (/Users/bzupnick/Desktop/import-ynab5/index.js:6:3)

When I open up YourBudget.json, though, I'm not seeing -3506.9. I am seeing:

 {"id":"cef8382e-c42d-4241-af37-f1909175fb7b","date":"2021-11-05","amount":-35069,"memo":"Market Close","cleared":"cleared","approved":true,"flag_color":null,"account_id":"58543bed-6c70-4074-97ab-1a1c35b17a7d","payee_id":"4c48f4b2-b423-4aac-a898-5a84b3fd94b4","category_id":null,"transfer_account_id":null,"transfer_transaction_id":null,"matched_transaction_id":null,"import_id":null,"deleted":false},

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 ๐Ÿค”
image

So I tried changing 35069 to 35070 in YourBudget.json and reran it. I got a similar error but a different number:

Error: [API Error] Can't convert to integer: 184.8

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:
image

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!

Transfers that are part of a split transaction: how to manage them?

I withdraw cash while buying at the supermarket, which is a transfer to my purse (on-budget cash account).
The "Everyday" payment account has a split transaction, $24.19 groceries, $40 transfer.
This imports to Actual as $24.19 groceries, and $40 category needed.
The "Purse" account, has this transaction listed as a Transfer of $40 from the "Everyday" account. (This is accurate.)

My question is: how to fix/categorise the transfer transaction in the "Everyday" account?

To do a transfer I would have to change the split transaction into 2 transactions, I think.
I am guessing:
(1) change the split into 2 transactions, so one can be a transfer;
(2) delete the transaction already in the 'purse' account in favour of the new transaction the new transfer has created.

This is historical, obviously, but I would like to make sure I don't mess my history up as I start out in Actual.

snap_4032
snap_4031
.

Can't create payee with transfer_acct

Hey @jlongster ! I'm trying to work on this. I can currently import accounts and categories (tho not sorted yet, for some reason) but the issue I'm having is with payees. I can't seem to set transfer_acct. I don't know if there's maybe something wrong with the API or something wrong with my code:

let api = require('@actual-app/api');
const fs = require('fs') 


async function run() {
  let id = await api.createPayee({
    name: "Test - Tarjeta",
    transfer_acct: "86cf22d5-3ca1-434f-be14-489032bf3fea"
  });
  console.log(await api.getPayees());
}

api.runWithBudget('My-Finances-a8f9d08', run);

And the console logs:

D:\Documentos\GitHub\import-ynab5>node test.js
[
  {
    id: 'cc8010f5-c9f4-47bc-aa9f-cbbc5dd2b50e',
    name: 'cablevision',
    category: null,
    transfer_acct: null
  },
  {
    id: '1b4fb67f-51ea-4408-bf73-7a5243a4bc42',
    name: 'Test - Tarjeta',
    category: null,
    transfer_acct: null
  },
  {
    id: '5b5ef78e-d2ab-40e9-a8c0-2562c33b07b8',
    name: 'Efectivo',
    category: null,
    transfer_acct: '1f9959ad-2725-4dc1-b67f-b800d9a64883'
  },
  {
    id: '041e8dda-8a0e-4d75-975a-98e4080749d6',
    name: 'Tarjeta',
    category: null,
    transfer_acct: '86cf22d5-3ca1-434f-be14-489032bf3fea'
  }
]

Any help would be awesome. Thanks!

Help a noob get started

Hey, this looks like fun. I'm not a "developer" but I think I could handle this. The problem I have is that my experience is mostly in scripting (bash/powershell/etc). How do I get started in testing what I've written?

Have Actual running locally and run `node index.js /path/to/data.json`.

I'm on Windows. Do I need to install node.js or is it included in the Actual files?
I could use a 'prerequisites' section here: https://actualbudget.com/docs/developers/using-the-API/

TypeError: Cannot read properties of undefined (reading 'budget')

I'm getting the following error when importing my exported .json file from ynab5.

node version is v17.0.1 for Windows.

TypeError: Cannot read properties of undefined (reading 'budget')
at importYNAB5 (C:\temp\import\importer.js:329:37)
    at run (C:\temp\import\index.js:6:9)
    at Object.<anonymous> (C:\temp\import\index.js:9:1)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47
PS C:\temp\import>

I get the same error when importing on macOS, using the latest version installed through Brew.

import-ynab5 and my budget file are both located in C:\temp\import

Question re: Imported bank transaction IDs

Thinking about this repo's TODO around imported bank transactions ids.
API docs say imported_id is

A unique id usually given by the bank, if importing. Use this is avoid duplicate transactions.

Can anyone confirm or deny that YNAB import_id could be safely mapped to Actual imported_id?

YNAB import_ids look like YNAB:-127850:2021-11-08:1, which feels generated by YNAB rather than "given by the bank", but also feels adequately unique to use in avoiding duplicates.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.