Skip to content

Commit 2dde8b7

Browse files
committed
Add CREATE_BALANCE_SHEET feature, clean up config docs
1 parent 5deb127 commit 2dde8b7

File tree

8 files changed

+193
-80
lines changed

8 files changed

+193
-80
lines changed

docs/CONFIG.md

+110-48
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,85 @@ All configurations below can be made using the web configuration framework or by
66

77
> **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.
88
9-
### Automate Updates with a CI Provider
9+
#### Table of Contents
10+
11+
- [General configuration](#general-configuration)
12+
- [Fetching Balances](#fetching-balances)
13+
- [Fetching Transactions](#fetching-transactions)
14+
- [Plaid](#plaid)
15+
- [Google Sheets](#google-sheets)
16+
17+
## General configuration
18+
19+
#### Debug Mode
20+
21+
`DEBUG` mode logs the output of each API call and function to the console.
22+
23+
**Default:**
24+
25+
```javascript
26+
"DEBUG": undefined // If unspecified, defaults to false
27+
```
28+
29+
If you want to enable debug mode, you can add the following line to your `mintable.config.json` file:
30+
31+
```javascript
32+
"DEBUG": true
33+
```
34+
35+
#### Host
36+
37+
`HOST` specifies the host for Mintable's setup server.
38+
39+
**Default:**
40+
41+
```javascript
42+
"HOST": "localhost"
43+
```
44+
45+
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:
46+
47+
```javascript
48+
"HOST": "0.0.0.0"
49+
```
50+
51+
#### Port
52+
53+
`PORT` specifies the port for Mintable's setup server.
54+
55+
**Default:**
56+
57+
```javascript
58+
"PORT": 3000
59+
```
60+
61+
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:
62+
63+
```javascript
64+
"PORT": "8080"
65+
```
66+
67+
#### Account Provider
68+
69+
`ACCOUNT_PROVIDER` specifies which service to use to fetch transactions.
70+
71+
**Default:**
72+
73+
```javascript
74+
"ACCOUNT_PROVIDER": "plaid"
75+
```
76+
77+
#### Spreadsheet Provider
78+
79+
`SHEET_PROVIDER` specifies which service to use to automate spreadsheet updates.
80+
81+
**Default:**
82+
83+
```javascript
84+
"SHEET_PROVIDER": "sheets" // "sheets" = Google Sheets
85+
```
86+
87+
#### Automate Updates with a CI Provider
1088

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

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

27-
`START_DATE` specifies the lower bound for fetching transactions in `YYYY.MM.DD` format.
105+
#### Create Balances Sheet
106+
107+
`CREATE_BALANCES_SHEET` optionally fetches the balances of all your connected accounts and places them in a sheet called `Balances`.
28108

29109
**Default:**
30110

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

35-
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:
115+
If you want to enable this, you can add the following line to your `mintable.config.json` file:
36116

37117
```javascript
38-
"START_DATE": "2018.12.01"
118+
"CREATE_BALANCES_SHEET": true
39119
```
40120

41-
### End Date
121+
#### Balance Columns
42122

43-
`END_DATE` specifies the upper bound for fetching transactions in `YYYY.MM.DD` format.
123+
`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.
44124

45-
**Default:**
125+
**Default:**
46126

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

51-
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:
131+
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:
52132

53133
```javascript
54-
"END_DATE": "2018.12.01"
134+
"TRANSACTION_COLUMNS": ["name", "balances.current"]
55135
```
56136

57-
### Host
137+
## Fetching Transactions
58138

59-
`HOST` specifies the host for Mintable's setup server.
139+
#### Start Date
60140

61-
**Default:**
141+
`START_DATE` specifies the lower bound for fetching transactions in `YYYY.MM.DD` format.
142+
143+
**Default:**
62144

63145
```javascript
64-
"HOST": "localhost"
146+
"START_DATE": undefined // If end date is not specified, Mintable will fetch the last 2 months of transactions
65147
```
66148

67-
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:
149+
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:
68150

69151
```javascript
70-
"HOST": "0.0.0.0"
152+
"START_DATE": "2018.12.01"
71153
```
72154

73-
### Port
155+
#### End Date
74156

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

77-
**Default:**
159+
**Default:**
78160

79161
```javascript
80-
"PORT": 3000
162+
"END_DATE": undefined // If end date is not specified, Mintable will fetch up until the current date
81163
```
82164

83-
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:
165+
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:
84166

85167
```javascript
86-
"PORT": "8080"
168+
"END_DATE": "2018.12.01"
87169
```
88170

89-
### Transaction Columns
171+
#### Transaction Columns
90172

91173
`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.
92174

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

105-
### Reference Columns
187+
#### Reference Columns
106188

107189
`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.
108190

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

121203
> **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`)
122204
123-
### Account Provider
124-
125-
`ACCOUNT_PROVIDER` specifies which service to use to fetch transactions.
126-
127-
**Default:**
128-
129-
```javascript
130-
"ACCOUNT_PROVIDER": "plaid"
131-
```
132-
133-
### Spreadsheet Provider
134-
135-
`SHEET_PROVIDER` specifies which service to use to automate spreadsheet updates.
136-
137-
**Default:**
138-
139-
```javascript
140-
"SHEET_PROVIDER": "sheets" // "sheets" = Google Sheets
141-
```
142-
143205
# Provider-Specific Configuration
144206

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

147209
## Plaid
148210

149-
### Category Overrides
211+
#### Category Overrides
150212

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

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

179241
## Google Sheets
180242

181-
### Template Sheet
243+
#### Template Sheet
182244

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

src/components/accounts.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Accounts extends React.Component {
4343
window.Plaid.create({
4444
clientName: 'Mintable',
4545
env: this.props.config.PLAID_ENVIRONMENT,
46-
product: ['auth', 'transactions'],
46+
product: ['transactions'],
4747
key: this.props.config.PLAID_PUBLIC_KEY,
4848
onExit: this.handleOnExit,
4949
onSuccess: this.handleOnSuccess,
@@ -99,7 +99,7 @@ class Accounts extends React.Component {
9999
<PlaidLink
100100
clientName='Mintable'
101101
env={this.props.config.PLAID_ENVIRONMENT}
102-
product={['auth', 'transactions']}
102+
product={['transactions']}
103103
publicKey={this.props.config.PLAID_PUBLIC_KEY}
104104
onSuccess={this.handleOnSuccess}
105105
style={{

src/lib/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const DEFAULT_CONFIG = {
1212
HOST: 'localhost',
1313
PORT: 3000,
1414

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

src/lib/google.js

+17-19
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,22 @@ const formatSheets = (sheetIds, numColumnsToResize) =>
148148

149149
const sortSheets = order =>
150150
wrapPromise(
151-
promisify(
152-
sheets.spreadsheets.batchUpdate,
153-
{
154-
spreadsheetId: process.env.SHEETS_SHEET_ID,
155-
resource: {
156-
requests: _.flatten(
157-
_.map(order, sheetId => [
158-
{
159-
updateSheetProperties: {
160-
properties: { sheetId: sheetId[0], index: sheetId[1] },
161-
fields: 'index'
162-
}
151+
promisify(sheets.spreadsheets.batchUpdate, {
152+
spreadsheetId: process.env.SHEETS_SHEET_ID,
153+
resource: {
154+
requests: _.flatten(
155+
_.map(order, sheetId => [
156+
{
157+
updateSheetProperties: {
158+
properties: { sheetId: sheetId[0], index: sheetId[1] },
159+
fields: 'index'
163160
}
164-
])
165-
)
166-
}
167-
},
168-
`Sorting sheets`
169-
)
161+
}
162+
])
163+
)
164+
}
165+
}),
166+
`Sorting sheets`
170167
)
171168

172169
const updateSheets = async (updates, options) => {
@@ -248,5 +245,6 @@ module.exports = {
248245
renameSheet,
249246
clearRanges,
250247
updateRanges,
251-
updateSheets
248+
updateSheets,
249+
formatSheets
252250
}

src/lib/plaid.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ const fetchBalances = options => {
6060

6161
const fetchBalanceForAccount = account => {
6262
return wrapPromise(
63-
PLAID_CLIENT.getBalance(account.token).then(data => {
64-
return {
65-
...data,
66-
nickname: account.nickname
67-
}
68-
}).catch(error => {
69-
return { nickname: account.nickname, error: JSON.stringify(error, null, 2) }
70-
}),
63+
PLAID_CLIENT.getBalance(account.token)
64+
.then(data => {
65+
return {
66+
...data,
67+
nickname: account.nickname
68+
}
69+
})
70+
.catch(error => {
71+
return { nickname: account.nickname, error: JSON.stringify(error, null, 2) }
72+
}),
7173
`Fetching balance for account ${account.nickname}`,
7274
options
7375
)

src/scripts/migrate.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const dotenv = require('dotenv')
2525
'CATEGORY_OVERRIDES',
2626
'TRANSACTION_PROVIDER',
2727
'SPREADSHEET_PROVIDER',
28+
'BALANCE_COLUMNS',
2829
'TRANSACTION_COLUMNS',
2930
'REFERENCE_COLUMNS'
3031
]

0 commit comments

Comments
 (0)