Skip to content

Commit

Permalink
Add CREATE_BALANCE_SHEET feature, clean up config docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaich committed Jan 16, 2020
1 parent 5deb127 commit 2dde8b7
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 80 deletions.
158 changes: 110 additions & 48 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,85 @@ All configurations below can be made using the web configuration framework or by

> **Pro Tip:** You can use Dropbox or another trusted service to sync `mintable.config.json` across your machines. Run `ln -s <path_to_cloud_folder>/mintable.config.json .` from the repo root to symlink Mintable to the cloud version.
### Automate Updates with a CI Provider
#### Table of Contents

- [General configuration](#general-configuration)
- [Fetching Balances](#fetching-balances)
- [Fetching Transactions](#fetching-transactions)
- [Plaid](#plaid)
- [Google Sheets](#google-sheets)

## General configuration

#### Debug Mode

`DEBUG` mode logs the output of each API call and function to the console.

**Default:**

```javascript
"DEBUG": undefined // If unspecified, defaults to false
```

If you want to enable debug mode, you can add the following line to your `mintable.config.json` file:

```javascript
"DEBUG": true
```

#### Host

`HOST` specifies the host for Mintable's setup server.

**Default:**

```javascript
"HOST": "localhost"
```

For example, if you want to run Mintable on a custom server and listen on `0.0.0.0`, you could add the following line to your `mintable.config.json` file:

```javascript
"HOST": "0.0.0.0"
```

#### Port

`PORT` specifies the port for Mintable's setup server.

**Default:**

```javascript
"PORT": 3000
```

For example, if you already have an application running on port `3000` and instead want to use port `8080`, you could add the following line to your `mintable.config.json` file:

```javascript
"PORT": "8080"
```

#### Account Provider

`ACCOUNT_PROVIDER` specifies which service to use to fetch transactions.

**Default:**

```javascript
"ACCOUNT_PROVIDER": "plaid"
```

#### Spreadsheet Provider

`SHEET_PROVIDER` specifies which service to use to automate spreadsheet updates.

**Default:**

```javascript
"SHEET_PROVIDER": "sheets" // "sheets" = Google Sheets
```

#### Automate Updates with a CI Provider

This repo includes config files for both [CircleCI](https://circleci.com/) and [Travis CI](https://travis-ci.com) to run builds automatically.

Expand All @@ -22,71 +100,75 @@ Run this command and paste the result into an environment variable called `MINTA
> **Warning:** If you choose to use CircleCI, you should turn off **Pass secrets to builds from forked pull requests** under **Build Settings** > **Advanced Settings**.
### Start Date
## Fetching Balances

`START_DATE` specifies the lower bound for fetching transactions in `YYYY.MM.DD` format.
#### Create Balances Sheet

`CREATE_BALANCES_SHEET` optionally fetches the balances of all your connected accounts and places them in a sheet called `Balances`.

**Default:**

```javascript
"START_DATE": undefined // If end date is not specified, Mintable will fetch the last 2 months of transactions
"CREATE_BALANCES_SHEET": undefined // If unspecified, defaults to false
```

For example, if you only want to fetch transactions which occur after or on December 1, 2018, you could add the following line to your `mintable.config.json` file:
If you want to enable this, you can add the following line to your `mintable.config.json` file:

```javascript
"START_DATE": "2018.12.01"
"CREATE_BALANCES_SHEET": true
```

### End Date
#### Balance Columns

`END_DATE` specifies the upper bound for fetching transactions in `YYYY.MM.DD` format.
`BALANCE_COLUMNS` specifies a list of account properties (using [`_.get()` syntax](https://lodash.com/docs/4.17.11#get)) to automatically update in your `Balances` spreadsheet. All the contents of these columns will be cleared and overwritten each time you run Mintable.

**Default:**
**Default:**

```javascript
"END_DATE": undefined // If end date is not specified, Mintable will fetch up until the current date
"BALANCE_COLUMNS": ['name', 'official_name', 'type', 'balances.available', 'balances.current', 'balances.limit']
```

For example, if you only want to fetch transactions which occur before or on December 1, 2018, you could add the following line to your `mintable.config.json` file:
For example, if you only want to auto-populate the name and amount for each account, you could add the following line to your `mintable.config.json` file:

```javascript
"END_DATE": "2018.12.01"
"TRANSACTION_COLUMNS": ["name", "balances.current"]
```

### Host
## Fetching Transactions

`HOST` specifies the host for Mintable's setup server.
#### Start Date

**Default:**
`START_DATE` specifies the lower bound for fetching transactions in `YYYY.MM.DD` format.

**Default:**

```javascript
"HOST": "localhost"
"START_DATE": undefined // If end date is not specified, Mintable will fetch the last 2 months of transactions
```

For example, if you want to run Mintable on a custom server and listen on `0.0.0.0`, you could add the following line to your `mintable.config.json` file:
For example, if you only want to fetch transactions which occur after or on December 1, 2018, you could add the following line to your `mintable.config.json` file:

```javascript
"HOST": "0.0.0.0"
"START_DATE": "2018.12.01"
```

### Port
#### End Date

`PORT` specifies the port for Mintable's setup server.
`END_DATE` specifies the upper bound for fetching transactions in `YYYY.MM.DD` format.

**Default:**
**Default:**

```javascript
"PORT": 3000
"END_DATE": undefined // If end date is not specified, Mintable will fetch up until the current date
```

For example, if you already have an application running on port `3000` and instead want to use port `8080`, you could add the following line to your `mintable.config.json` file:
For example, if you only want to fetch transactions which occur before or on December 1, 2018, you could add the following line to your `mintable.config.json` file:

```javascript
"PORT": "8080"
"END_DATE": "2018.12.01"
```

### Transaction Columns
#### Transaction Columns

`TRANSACTION_COLUMNS` specifies a list of transaction properties (using [`_.get()` syntax](https://lodash.com/docs/4.17.11#get)) to automatically update in your spreadsheet. All the contents of these columns will be cleared and overwritten each time you run Mintable.

Expand All @@ -102,7 +184,7 @@ For example, if you only want to auto-populate the name and amount for each tran
"TRANSACTION_COLUMNS": ["name", "amount"]
```

### Reference Columns
#### Reference Columns

`REFERENCE_COLUMNS` specifies a list of additional, non-automated columns for your reference/bookkeeping purposes. Each time you run Mintable, the contents of these columns will be preserved.

Expand All @@ -120,33 +202,13 @@ For example, if you want to add one column to track work expenses, and another t

> **Warning:** Since reference columns are not automated by Mintable, they have the potential to get out of sync with transaction data (for example, if your bank deletes a transaction, causing a row to get removed in `TRANSACTION_COLUMNS`)
### Account Provider

`ACCOUNT_PROVIDER` specifies which service to use to fetch transactions.

**Default:**

```javascript
"ACCOUNT_PROVIDER": "plaid"
```

### Spreadsheet Provider

`SHEET_PROVIDER` specifies which service to use to automate spreadsheet updates.

**Default:**

```javascript
"SHEET_PROVIDER": "sheets" // "sheets" = Google Sheets
```

# Provider-Specific Configuration

You can see the API definitions for account & spreadsheet providers in the **[provider docs](./docs/PROVIDERS.md)**.

## Plaid

### Category Overrides
#### Category Overrides

`CATEGORY_OVERRIDES` specifies a list of overrides to handle transactions that are routinely miscategorized by Plaid's servers.

Expand Down Expand Up @@ -178,7 +240,7 @@ For example, if you want anything matching `autopay` or `e-payment` to get categ

## Google Sheets

### Template Sheet
#### Template Sheet

`TEMPLATE_SHEET` specifies the template spreadsheet to use when creating a _new_ sheet for a month.

Expand Down
4 changes: 2 additions & 2 deletions src/components/accounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Accounts extends React.Component {
window.Plaid.create({
clientName: 'Mintable',
env: this.props.config.PLAID_ENVIRONMENT,
product: ['auth', 'transactions'],
product: ['transactions'],
key: this.props.config.PLAID_PUBLIC_KEY,
onExit: this.handleOnExit,
onSuccess: this.handleOnSuccess,
Expand Down Expand Up @@ -99,7 +99,7 @@ class Accounts extends React.Component {
<PlaidLink
clientName='Mintable'
env={this.props.config.PLAID_ENVIRONMENT}
product={['auth', 'transactions']}
product={['transactions']}
publicKey={this.props.config.PLAID_PUBLIC_KEY}
onSuccess={this.handleOnSuccess}
style={{
Expand Down
1 change: 1 addition & 0 deletions src/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const DEFAULT_CONFIG = {
HOST: 'localhost',
PORT: 3000,

BALANCE_COLUMNS: ['name', 'official_name', 'type', 'balances.available', 'balances.current', 'balances.limit'],
TRANSACTION_COLUMNS: ['date', 'amount', 'name', 'account', 'category.0', 'category.1', 'pending'],
REFERENCE_COLUMNS: ['notes', 'work', 'joint'],

Expand Down
36 changes: 17 additions & 19 deletions src/lib/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,22 @@ const formatSheets = (sheetIds, numColumnsToResize) =>

const sortSheets = order =>
wrapPromise(
promisify(
sheets.spreadsheets.batchUpdate,
{
spreadsheetId: process.env.SHEETS_SHEET_ID,
resource: {
requests: _.flatten(
_.map(order, sheetId => [
{
updateSheetProperties: {
properties: { sheetId: sheetId[0], index: sheetId[1] },
fields: 'index'
}
promisify(sheets.spreadsheets.batchUpdate, {
spreadsheetId: process.env.SHEETS_SHEET_ID,
resource: {
requests: _.flatten(
_.map(order, sheetId => [
{
updateSheetProperties: {
properties: { sheetId: sheetId[0], index: sheetId[1] },
fields: 'index'
}
])
)
}
},
`Sorting sheets`
)
}
])
)
}
}),
`Sorting sheets`
)

const updateSheets = async (updates, options) => {
Expand Down Expand Up @@ -248,5 +245,6 @@ module.exports = {
renameSheet,
clearRanges,
updateRanges,
updateSheets
updateSheets,
formatSheets
}
18 changes: 10 additions & 8 deletions src/lib/plaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ const fetchBalances = options => {

const fetchBalanceForAccount = account => {
return wrapPromise(
PLAID_CLIENT.getBalance(account.token).then(data => {
return {
...data,
nickname: account.nickname
}
}).catch(error => {
return { nickname: account.nickname, error: JSON.stringify(error, null, 2) }
}),
PLAID_CLIENT.getBalance(account.token)
.then(data => {
return {
...data,
nickname: account.nickname
}
})
.catch(error => {
return { nickname: account.nickname, error: JSON.stringify(error, null, 2) }
}),
`Fetching balance for account ${account.nickname}`,
options
)
Expand Down
1 change: 1 addition & 0 deletions src/scripts/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const dotenv = require('dotenv')
'CATEGORY_OVERRIDES',
'TRANSACTION_PROVIDER',
'SPREADSHEET_PROVIDER',
'BALANCE_COLUMNS',
'TRANSACTION_COLUMNS',
'REFERENCE_COLUMNS'
]
Expand Down
Loading

0 comments on commit 2dde8b7

Please sign in to comment.