cjs77 / ale Goto Github PK
View Code? Open in Web Editor NEWDouble-entry accounting system based on node.js + Sequelize
License: Apache License 2.0
Double-entry accounting system based on node.js + Sequelize
License: Apache License 2.0
Thank you for this library. I would prefer this one over medici because I think the use of a relational database is more sane for accounting purposes than using a NoSQL DB.
But there is one drawback with this library which makes it not useable for my purposes: I can't store and query metadata with the journal entries like with medici.
Looking at your example makes no sense to me:
myBook.balance({ account:'Assets:Accounts Receivable' }).then((balance) => { console.log("Joe Blow owes me", balance.total); });
When I look this up in medici, it makes sense again:
.credit('Income', 1000, {client: 'Joe Blow'})
myBook.balance({ account:'Assets:Accounts Receivable', client:'Joe Blow' }).then((balance) => { console.log("Joe Blow owes me", balance); });
Another thing is the REST service. I really like the idea of having a kind of microservice for this purpose. But the drawback here: In the REST service I can't do everything which I can do with the API, e.g. Voiding Transactions.
Thanks again for this project.
Can someone please show how to set this up and in which file? I installed MySQL js then in connection.js exports.ALE_CONNECTION=mysql.createConnection({ ....... });
But i still get AleError: ALE_CONNECTION envar is not set, cannot connect to database
please advise
This error happens when synchronising the Books Model against MariaDB/ MySQL.
MySQL doesn't support indexing unlimited text fields.
I propose changing it to a STRING datatype which will limit to 255 characters in length.
I am using ale as a NPM module.
The following causes an error because the DB tbales are not created:
Book.getOrCreateBook('ACME inc', 'USD').then(book => {
console.log(book);
});
Is there a script somewhere to set up the DB? I assumed ale would do this automatically on first use.
SequelizeDatabaseError: column "id" does not exist
api_1 | 2019-06-29T13:07:03.585903400Z at Query.formatError (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:363:16)
api_1 | 2019-06-29T13:07:03.585926300Z at AbstractQuery.run.query.catch.err (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:86:18)
api_1 | 2019-06-29T13:07:03.585930000Z From previous event:
api_1 | 2019-06-29T13:07:03.585933200Z at Query.run (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:79:23)
api_1 | 2019-06-29T13:07:03.585936200Z at __dirname.query.Promise.resolve.Promise.try.then.connection (/usr/src/app/node_modules/sequelize/lib/sequelize.js:561:20)
api_1 | 2019-06-29T13:07:03.585939600Z From previous event:
api_1 | 2019-06-29T13:07:03.585942900Z at __dirname.query.Promise.resolve.retryParameters (/usr/src/app/node_modules/sequelize/lib/sequelize.js:558:8)
api_1 | 2019-06-29T13:07:03.585945900Z at module.exports (/usr/src/app/node_modules/retry-as-promised/index.js:39:21)
api_1 | 2019-06-29T13:07:03.585948900Z at retryAsPromised (/usr/src/app/node_modules/retry-as-promised/index.js:29:10)
api_1 | 2019-06-29T13:07:03.585951900Z at Sequelize.query (/usr/src/app/node_modules/sequelize/lib/sequelize.js:457:28)
api_1 | 2019-06-29T13:07:03.585955000Z at QueryInterface.select (/usr/src/app/node_modules/sequelize/lib/query-interface.js:1104:27)
api_1 | 2019-06-29T13:07:03.585958100Z at __dirname.findAll.Promise.try.then.then.then (/usr/src/app/node_modules/sequelize/lib/model.js:1598:34)
api_1 | 2019-06-29T13:07:03.585961100Z From previous event:
api_1 | 2019-06-29T13:07:03.585964000Z at Function.findAll (/usr/src/app/node_modules/sequelize/lib/model.js:1595:8)
api_1 | 2019-06-29T13:07:03.585966900Z at Function.findOne (/usr/src/app/node_modules/sequelize/lib/model.js:1752:17)
api_1 | 2019-06-29T13:07:03.585969900Z at __dirname.findOrCreate.options.sequelize.transaction.then.t (/usr/src/app/node_modules/sequelize/lib/model.js:2108:19)
api_1 | 2019-06-29T13:07:03.585972900Z at runCallback (timers.js:789:20)
api_1 | 2019-06-29T13:07:03.585975800Z at tryOnImmediate (timers.js:751:5)
api_1 | 2019-06-29T13:07:03.585978700Z at processImmediate [as _immediateCallback] (timers.js:722:5)
api_1 | 2019-06-29T13:07:03.585981700Z From previous event:
api_1 | 2019-06-29T13:07:03.585984600Z at Function.findOrCreate (/usr/src/app/node_modules/sequelize/lib/model.js:2104:48)
api_1 | 2019-06-29T13:07:03.585987500Z at Function.Book.getOrCreateBook (/usr/src/app/node_modules/a.l.e/models/book.js:280:17)
api_1 | 2019-06-29T13:07:03.585990600Z at resolve (/usr/src/app/src/schema/story/queries.js:74:17)
api_1 | 2019-06-29T13:07:03.585993600Z at resolveFieldValueOrError (/usr/src/app/node_modules/graphql/execution/execute.js:544:18)
api_1 | 2019-06-29T13:07:03.585996500Z at resolveField (/usr/src/app/node_modules/graphql/execution/execute.js:508:16)
api_1 | 2019-06-29T13:07:03.586000500Z at /usr/src/app/node_modules/graphql/execution/execute.js:357:18
api_1 | 2019-06-29T13:07:03.586003500Z at Array.reduce ()
api_1 | 2019-06-29T13:07:03.586006900Z at executeFields (/usr/src/app/node_modules/graphql/execution/execute.js:354:42)
api_1 | 2019-06-29T13:07:03.586009800Z at executeOperation (/usr/src/app/node_modules/graphql/execution/execute.js:278:122)
api_1 | 2019-06-29T13:07:03.586015600Z at executeImpl (/usr/src/app/node_modules/graphql/execution/execute.js:142:14)
api_1 | 2019-06-29T13:07:03.586019100Z at execute (/usr/src/app/node_modules/graphql/execution/execute.js:119:229)
api_1 | 2019-06-29T13:07:03.586022200Z at /usr/src/app/node_modules/express-graphql/dist/index.js:164:37
api_1 | 2019-06-29T13:07:03.586025100Z at
api_1 | 2019-06-29T13:07:03.586028100Z at process._tickCallback (internal/process/next_tick.js:188:7)
api_1 | 2019-06-29T13:07:03.586031000Z name: 'SequelizeDatabaseError',
api_1 | 2019-06-29T13:07:03.586033900Z parent:
api_1 | 2019-06-29T13:07:03.586036800Z { error: column "id" does not exist
api_1 | 2019-06-29T13:07:03.586039800Z at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:546:11)
api_1 | 2019-06-29T13:07:03.586042800Z at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:371:19)
api_1 | 2019-06-29T13:07:03.586045800Z at Socket. (/usr/src/app/node_modules/pg/lib/connection.js:114:22)
api_1 | 2019-06-29T13:07:03.586048800Z at emitOne (events.js:116:13)
api_1 | 2019-06-29T13:07:03.586051700Z at Socket.emit (events.js:211:7)
api_1 | 2019-06-29T13:07:03.586054600Z at addChunk (_stream_readable.js:263:12)
api_1 | 2019-06-29T13:07:03.586057500Z at readableAddChunk (_stream_readable.js:250:11)
api_1 | 2019-06-29T13:07:03.586060400Z at Socket.Readable.push (_stream_readable.js:208:10)
api_1 | 2019-06-29T13:07:03.586063300Z at TCP.onread (net.js:594:20)
api_1 | 2019-06-29T13:07:03.586066300Z From previous event:
api_1 | 2019-06-29T13:07:03.586069200Z at Query.run (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:65:9)
api_1 | 2019-06-29T13:07:03.586072400Z at __dirname.query.Promise.resolve.Promise.try.then.connection (/usr/src/app/node_modules/sequelize/lib/sequelize.js:561:20)
api_1 | 2019-06-29T13:07:03.586075400Z From previous event:
api_1 | 2019-06-29T13:07:03.586078300Z at __dirname.query.Promise.resolve.retryParameters (/usr/src/app/node_modules/sequelize/lib/sequelize.js:558:8)
api_1 | 2019-06-29T13:07:03.586081300Z at module.exports (/usr/src/app/node_modules/retry-as-promised/index.js:39:21)
api_1 | 2019-06-29T13:07:03.586084200Z at retryAsPromised (/usr/src/app/node_modules/retry-as-promised/index.js:29:10)
api_1 | 2019-06-29T13:07:03.586087100Z at Sequelize.query (/usr/src/app/node_modules/sequelize/lib/sequelize.js:457:28)
api_1 | 2019-06-29T13:07:03.586090100Z at QueryInterface.select (/usr/src/app/node_modules/sequelize/lib/query-interface.js:1104:27)
api_1 | 2019-06-29T13:07:03.586093100Z at __dirname.findAll.Promise.try.then.then.then (/usr/src/app/node_modules/sequelize/lib/model.js:1598:34)
api_1 | 2019-06-29T13:07:03.586096100Z From previous event:
api_1 | 2019-06-29T13:07:03.586099200Z at Function.findAll (/usr/src/app/node_modules/sequelize/lib/model.js:1595:8)
api_1 | 2019-06-29T13:07:03.586102200Z at Function.findOne (/usr/src/app/node_modules/sequelize/lib/model.js:1752:17)
api_1 | 2019-06-29T13:07:03.586105200Z at __dirname.findOrCreate.options.sequelize.transaction.then.t (/usr/src/app/node_modules/sequelize/lib/model.js:2108:19)
api_1 | 2019-06-29T13:07:03.586110600Z at runCallback (timers.js:789:20)
api_1 | 2019-06-29T13:07:03.586113600Z at tryOnImmediate (timers.js:751:5)
api_1 | 2019-06-29T13:07:03.586116500Z at processImmediate [as _immediateCallback] (timers.js:722:5)
api_1 | 2019-06-29T13:07:03.586119400Z From previous event:
api_1 | 2019-06-29T13:07:03.586122300Z at Function.findOrCreate (/usr/src/app/node_modules/sequelize/lib/model.js:2104:48)
api_1 | 2019-06-29T13:07:03.586125200Z at Function.Book.getOrCreateBook (/usr/src/app/node_modules/a.l.e/models/book.js:280:17)
api_1 | 2019-06-29T13:07:03.586128200Z at resolve (/usr/src/app/src/schema/story/queries.js:74:17)
api_1 | 2019-06-29T13:07:03.586131100Z at resolveFieldValueOrError (/usr/src/app/node_modules/graphql/execution/execute.js:544:18)
api_1 | 2019-06-29T13:07:03.586134100Z at resolveField (/usr/src/app/node_modules/graphql/execution/execute.js:508:16)
api_1 | 2019-06-29T13:07:03.586137100Z at /usr/src/app/node_modules/graphql/execution/execute.js:357:18
api_1 | 2019-06-29T13:07:03.586140000Z at Array.reduce ()
api_1 | 2019-06-29T13:07:03.586143000Z at executeFields (/usr/src/app/node_modules/graphql/execution/execute.js:354:42)
api_1 | 2019-06-29T13:07:03.586146000Z at executeOperation (/usr/src/app/node_modules/graphql/execution/execute.js:278:122)
api_1 | 2019-06-29T13:07:03.586149000Z at executeImpl (/usr/src/app/node_modules/graphql/execution/execute.js:142:14)
api_1 | 2019-06-29T13:07:03.586152000Z at execute (/usr/src/app/node_modules/graphql/execution/execute.js:119:229)
api_1 | 2019-06-29T13:07:03.586154900Z at /usr/src/app/node_modules/express-graphql/dist/index.js:164:37
api_1 | 2019-06-29T13:07:03.586157800Z at
api_1 | 2019-06-29T13:07:03.586160800Z at process._tickCallback (internal/process/next_tick.js:188:7)
api_1 | 2019-06-29T13:07:03.586163700Z name: 'error',
api_1 | 2019-06-29T13:07:03.586166600Z length: 101,
api_1 | 2019-06-29T13:07:03.586169500Z severity: 'ERROR',
api_1 | 2019-06-29T13:07:03.586172300Z code: '42703',
api_1 | 2019-06-29T13:07:03.586175200Z detail: undefined,
api_1 | 2019-06-29T13:07:03.586178000Z hint: undefined,
api_1 | 2019-06-29T13:07:03.586180900Z position: '8',
api_1 | 2019-06-29T13:07:03.586183700Z internalPosition: undefined,
api_1 | 2019-06-29T13:07:03.586186700Z internalQuery: undefined,
api_1 | 2019-06-29T13:07:03.586189500Z where: undefined,
api_1 | 2019-06-29T13:07:03.586192400Z schema: undefined,
api_1 | 2019-06-29T13:07:03.586195200Z table: undefined,
api_1 | 2019-06-29T13:07:03.586198200Z column: undefined,
api_1 | 2019-06-29T13:07:03.586201000Z dataType: undefined,
api_1 | 2019-06-29T13:07:03.586203900Z constraint: undefined,
api_1 | 2019-06-29T13:07:03.586206800Z file: 'parse_relation.c',
api_1 | 2019-06-29T13:07:03.586209600Z line: '3194',
api_1 | 2019-06-29T13:07:03.586214600Z routine: 'errorMissingColumn',
api_1 | 2019-06-29T13:07:03.586217800Z sql: 'SELECT "id", "name", "quoteCurrency", "createdAt", "updatedAt" FROM "books" AS "book" WHERE "book"."name" = 'ACME inc';' },
api_1 | 2019-06-29T13:07:03.586221700Z original:
api_1 | 2019-06-29T13:07:03.586224900Z { error: column "id" does not exist
api_1 | 2019-06-29T13:07:03.586227900Z at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:546:11)
api_1 | 2019-06-29T13:07:03.586230900Z at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:371:19)
api_1 | 2019-06-29T13:07:03.586234000Z at Socket. (/usr/src/app/node_modules/pg/lib/connection.js:114:22)
api_1 | 2019-06-29T13:07:03.586237000Z at emitOne (events.js:116:13)
api_1 | 2019-06-29T13:07:03.586239900Z at Socket.emit (events.js:211:7)
api_1 | 2019-06-29T13:07:03.586242800Z at addChunk (_stream_readable.js:263:12)
api_1 | 2019-06-29T13:07:03.586245700Z at readableAddChunk (_stream_readable.js:250:11)
api_1 | 2019-06-29T13:07:03.586248600Z at Socket.Readable.push (_stream_readable.js:208:10)
api_1 | 2019-06-29T13:07:03.586251600Z at TCP.onread (net.js:594:20)
api_1 | 2019-06-29T13:07:03.586254500Z From previous event:
api_1 | 2019-06-29T13:07:03.586284500Z at Query.run (/usr/src/app/node_modules/sequelize/lib/dialects/postgres/query.js:65:9)
api_1 | 2019-06-29T13:07:03.586294300Z at __dirname.query.Promise.resolve.Promise.try.then.connection (/usr/src/app/node_modules/sequelize/lib/sequelize.js:561:20)
api_1 | 2019-06-29T13:07:03.586297400Z From previous event:
api_1 | 2019-06-29T13:07:03.586300400Z at __dirname.query.Promise.resolve.retryParameters (/usr/src/app/node_modules/sequelize/lib/sequelize.js:558:8)
api_1 | 2019-06-29T13:07:03.586303700Z at module.exports (/usr/src/app/node_modules/retry-as-promised/index.js:39:21)
api_1 | 2019-06-29T13:07:03.586306600Z at retryAsPromised (/usr/src/app/node_modules/retry-as-promised/index.js:29:10)
api_1 | 2019-06-29T13:07:03.586309600Z at Sequelize.query (/usr/src/app/node_modules/sequelize/lib/sequelize.js:457:28)
api_1 | 2019-06-29T13:07:03.586312600Z at QueryInterface.select (/usr/src/app/node_modules/sequelize/lib/query-interface.js:1104:27)
api_1 | 2019-06-29T13:07:03.586315600Z at __dirname.findAll.Promise.try.then.then.then (/usr/src/app/node_modules/sequelize/lib/model.js:1598:34)
api_1 | 2019-06-29T13:07:03.586318600Z From previous event:
api_1 | 2019-06-29T13:07:03.586321500Z at Function.findAll (/usr/src/app/node_modules/sequelize/lib/model.js:1595:8)
api_1 | 2019-06-29T13:07:03.586324400Z at Function.findOne (/usr/src/app/node_modules/sequelize/lib/model.js:1752:17)
api_1 | 2019-06-29T13:07:03.586327400Z at __dirname.findOrCreate.options.sequelize.transaction.then.t (/usr/src/app/node_modules/sequelize/lib/model.js:2108:19)
api_1 | 2019-06-29T13:07:03.586330400Z at runCallback (timers.js:789:20)
api_1 | 2019-06-29T13:07:03.586333400Z at tryOnImmediate (timers.js:751:5)
api_1 | 2019-06-29T13:07:03.586336300Z at processImmediate [as _immediateCallback] (timers.js:722:5)
api_1 | 2019-06-29T13:07:03.586343900Z From previous event:
api_1 | 2019-06-29T13:07:03.586347000Z at Function.findOrCreate (/usr/src/app/node_modules/sequelize/lib/model.js:2104:48)
api_1 | 2019-06-29T13:07:03.586349900Z at Function.Book.getOrCreateBook (/usr/src/app/node_modules/a.l.e/models/book.js:280:17)
api_1 | 2019-06-29T13:07:03.586353600Z at resolve (/usr/src/app/src/schema/story/queries.js:74:17)
api_1 | 2019-06-29T13:07:03.586356500Z at resolveFieldValueOrError (/usr/src/app/node_modules/graphql/execution/execute.js:544:18)
api_1 | 2019-06-29T13:07:03.586359500Z at resolveField (/usr/src/app/node_modules/graphql/execution/execute.js:508:16)
api_1 | 2019-06-29T13:07:03.586362400Z at /usr/src/app/node_modules/graphql/execution/execute.js:357:18
api_1 | 2019-06-29T13:07:03.586365400Z at Array.reduce ()
api_1 | 2019-06-29T13:07:03.586368400Z at executeFields (/usr/src/app/node_modules/graphql/execution/execute.js:354:42)
api_1 | 2019-06-29T13:07:03.586371300Z at executeOperation (/usr/src/app/node_modules/graphql/execution/execute.js:278:122)
api_1 | 2019-06-29T13:07:03.586374200Z at executeImpl (/usr/src/app/node_modules/graphql/execution/execute.js:142:14)
api_1 | 2019-06-29T13:07:03.586377200Z at execute (/usr/src/app/node_modules/graphql/execution/execute.js:119:229)
api_1 | 2019-06-29T13:07:03.586380200Z at /usr/src/app/node_modules/express-graphql/dist/index.js:164:37
api_1 | 2019-06-29T13:07:03.586383100Z at
api_1 | 2019-06-29T13:07:03.586386000Z at process._tickCallback (internal/process/next_tick.js:188:7)
api_1 | 2019-06-29T13:07:03.586389000Z name: 'error',
api_1 | 2019-06-29T13:07:03.586391800Z length: 101,
api_1 | 2019-06-29T13:07:03.586394700Z severity: 'ERROR',
api_1 | 2019-06-29T13:07:03.586397600Z code: '42703',
api_1 | 2019-06-29T13:07:03.586400400Z detail: undefined,
api_1 | 2019-06-29T13:07:03.586403300Z hint: undefined,
api_1 | 2019-06-29T13:07:03.586406100Z position: '8',
api_1 | 2019-06-29T13:07:03.586409000Z internalPosition: undefined,
api_1 | 2019-06-29T13:07:03.586411900Z internalQuery: undefined,
api_1 | 2019-06-29T13:07:03.586414800Z where: undefined,
api_1 | 2019-06-29T13:07:03.586421600Z schema: undefined,
api_1 | 2019-06-29T13:07:03.586426400Z table: undefined,
api_1 | 2019-06-29T13:07:03.586434300Z column: undefined,
api_1 | 2019-06-29T13:07:03.586445500Z dataType: undefined,
api_1 | 2019-06-29T13:07:03.586453600Z constraint: undefined,
api_1 | 2019-06-29T13:07:03.586485000Z file: 'parse_relation.c',
api_1 | 2019-06-29T13:07:03.586525700Z line: '3194',
api_1 | 2019-06-29T13:07:03.586531400Z routine: 'errorMissingColumn',
api_1 | 2019-06-29T13:07:03.586535800Z sql: 'SELECT "id", "name", "quoteCurrency", "createdAt", "updatedAt" FROM "books" AS "book" WHERE "book"."name" = 'ACME inc';' },
api_1 | 2019-06-29T13:07:03.586544300Z sql: 'SELECT "id", "name", "quoteCurrency", "createdAt", "updatedAt" FROM "books" AS "book" WHERE "book"."name" = 'ACME inc';' }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.