MFYNAB

Sync transaction history from MoneyForward to YNAB.


License
MIT
Install
gem install MFYNAB -v 0.1.0

Documentation

MoneyForward to YNAB migrator

This Ruby script downloads transaction history from Money Forward then uploads it to YNAB.

Principle

  • Use Capybara with the Cuprite driver to log into the Money Forward website and download transaction history CSV files.
  • Parse the CSV files and converts the data to a format that works with YNAB.
  • Use YNAB API Ruby library to post transactions to your YNAB budget.
  • Budget and account mappings are set in a configuration file (config.yml).

Setup

You'll need Ruby and Bundler.

# Install dependencies
bundle install

# Start a config YAML file
cp config/example.yml config/david.yml

The script currently looks for credentials in environment variables:

  • MONEYFORWARD_USERNAME
  • MONEYFORWARD_PASSWORD
  • YNAB_ACCESS_TOKEN

You can for example use envchain to manage those credentials:

envchain --set --noecho mfynab MONEYFORWARD_USERNAME MONEYFORWARD_PASSWORD YNAB_ACCESS_TOKEN

Running

To run, you'll simply need to set the environment variables. Using envchain, that'll look like this:

envchain mfynab bin/mfynab config/david.yml

Development

After checking out the repo, run bundle install to install dependencies. Then, run bin/rake test to run the tests.

Todo

  • Force MoneyForward to sync all accounts before downloading data. (Can take a while.)
  • Use Thor to manage the CLI. (And/or TTY?)
  • Implement Transaction model to extract some logic from existing classes.
  • Turn into a gem and publish.
  • Handle the Amazon account differently (use account name as payee instead of content?)
  • Implement CLI to setup config.
    • Save/update session_id so browser is only needed once.
  • Get rid of envchain?
    • Store config/credentials in ~/.config/?
    • Encrypt config, use Keyring or other OS-level secure storage?
    • Open browser, ask user to log into MoneyForward and store cookie? (Does it expire though?)
      • Or prompt user from credentials in terminal and fill in form in headless browser
      • Need to handle case when cookie has expired:

        セキュリティ設定 最終利用時間から[30日]後に自動ログアウト