git ssb

0+

bencevans / starling-to-beancount



Commit dbca04e9f509c2791256e4f5b36a2e2c53f26e9f

init

Ben Evans committed on 10/29/2018, 5:07:29 PM

Files changed

.gitignoreadded
index.jsadded
package-lock.jsonadded
package.jsonadded
.gitignoreView
@@ -1,0 +1,1 @@
1 +node_modules/
index.jsView
@@ -1,0 +1,28 @@
1 +const numeral = require('numeral')
2 +const Starling = require('starling-developer-sdk')
3 +const moment = require('moment')
4 +
5 +const client = new Starling({
6 + accessToken: process.env.STARLING_TOKEN
7 +})
8 +
9 +const main = async () => {
10 + const balance = await client.getBalance()
11 + const account = await client.getAccount()
12 +
13 + console.log(`${account.data.createdAt.substring(0, 10)} open Assets:GB:Starling:Checking ${account.data.currency}\n`)
14 +
15 + const transactions = await client.getTransactions(process.env.STARLING_TOKEN, account.data.createdAt.substring(0, 10), '2018-10-22')
16 +
17 + transactions.data._embedded.transactions.reverse().forEach(t => {
18 + console.log([
19 + `${t.created.substring(0, 10)} * "${t.narrative}"`,
20 + ` ${t.direction === 'OUTBOUND' ? 'Assets:GB:Starling:Checking' : 'Income:Unknown'} ${numeral(t.direction === 'OUTBOUND' ? t.amount : -t.amount).format('0.00')} ${t.currency}`,
21 + ` ${t.direction === 'OUTBOUND' ? 'Expenses:Unknown' : 'Assets:GB:Starling:Checking'} ${numeral(t.direction === 'OUTBOUND' ? -t.amount : t.amount).format('0.00')} GBP`
22 + ].join('\n') + '\n')
23 + })
24 +
25 + console.log(`${moment().format('YYYY-MM-DD')} balance Assets:GB:Starling:Checking ${balance.data.amount} ${account.data.currency}\n`)
26 +}
27 +
28 +main().catch(console.error)
package-lock.jsonView
@@ -1,0 +1,97 @@
1 +{
2 + "name": "starling-to-beancount",
3 + "version": "0.0.0",
4 + "lockfileVersion": 1,
5 + "requires": true,
6 + "dependencies": {
7 + "axios": {
8 + "version": "0.18.0",
9 + "resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
10 + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
11 + "requires": {
12 + "follow-redirects": "^1.3.0",
13 + "is-buffer": "^1.1.5"
14 + }
15 + },
16 + "debug": {
17 + "version": "3.2.6",
18 + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
19 + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
20 + "requires": {
21 + "ms": "^2.1.1"
22 + },
23 + "dependencies": {
24 + "ms": {
25 + "version": "2.1.1",
26 + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
27 + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
28 + }
29 + }
30 + },
31 + "es6-promise": {
32 + "version": "4.2.5",
33 + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz",
34 + "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg=="
35 + },
36 + "follow-redirects": {
37 + "version": "1.5.9",
38 + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.9.tgz",
39 + "integrity": "sha512-Bh65EZI/RU8nx0wbYF9shkFZlqLP+6WT/5FnA3cE/djNSuKNHJEinGGZgu/cQEkeeb2GdFOgenAmn8qaqYke2w==",
40 + "requires": {
41 + "debug": "=3.1.0"
42 + },
43 + "dependencies": {
44 + "debug": {
45 + "version": "3.1.0",
46 + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
47 + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
48 + "requires": {
49 + "ms": "2.0.0"
50 + }
51 + }
52 + }
53 + },
54 + "is-buffer": {
55 + "version": "1.1.6",
56 + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
57 + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
58 + },
59 + "js-base64": {
60 + "version": "2.4.9",
61 + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz",
62 + "integrity": "sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ=="
63 + },
64 + "moment": {
65 + "version": "2.22.2",
66 + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
67 + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
68 + },
69 + "ms": {
70 + "version": "2.0.0",
71 + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
72 + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
73 + },
74 + "numeral": {
75 + "version": "2.0.6",
76 + "resolved": "https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz",
77 + "integrity": "sha1-StCAk21EPCVhrtnyGX7//iX05QY="
78 + },
79 + "starling-developer-sdk": {
80 + "version": "0.1.17",
81 + "resolved": "https://registry.npmjs.org/starling-developer-sdk/-/starling-developer-sdk-0.1.17.tgz",
82 + "integrity": "sha512-YbQAkJ7CYNzilXcuPBD4w/UahIVcBJLvuB+gHvHk60npXuLP1BJRHrp+cRFw1rlI+pRhC+pUeGV4m7Ehj7PblQ==",
83 + "requires": {
84 + "axios": "^0.18.0",
85 + "debug": "^3.1.0",
86 + "es6-promise": "^4.2.4",
87 + "js-base64": "^2.1.9",
88 + "utf8": "^3.0.0"
89 + }
90 + },
91 + "utf8": {
92 + "version": "3.0.0",
93 + "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
94 + "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ=="
95 + }
96 + }
97 +}
package.jsonView
@@ -1,0 +1,29 @@
1 +{
2 + "name": "starling-to-beancount",
3 + "version": "0.0.0",
4 + "description": "Pull Starling Bank records into Beancount format ",
5 + "main": "index.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "repository": {
10 + "type": "git",
11 + "url": "git+https://github.com/bencevans/starling-to-beancount.git"
12 + },
13 + "keywords": [
14 + "starling",
15 + "beancount",
16 + "banking"
17 + ],
18 + "author": "Ben Evans <ben@bluechimp.io> (https://bencevans.io)",
19 + "license": "MIT",
20 + "bugs": {
21 + "url": "https://github.com/bencevans/starling-to-beancount/issues"
22 + },
23 + "homepage": "https://github.com/bencevans/starling-to-beancount#readme",
24 + "dependencies": {
25 + "moment": "^2.22.2",
26 + "numeral": "^2.0.6",
27 + "starling-developer-sdk": "^0.1.17"
28 + }
29 +}

Built with git-ssb-web