Comparing version 0.12.2 to 1.0.0
{ | ||
"name": "medici", | ||
"version": "0.12.2", | ||
"version": "1.0.0", | ||
"description": "Simple double-entry accounting for Node + Mongoose", | ||
"main": "index.js", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "grunt test" | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"src" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/jraede/medici" | ||
"url": "http://github.com/koresar/medici" | ||
}, | ||
"keywords": [ | ||
"double-entry", | ||
"accounting", | ||
"account", | ||
"finance" | ||
"finance", | ||
"mongodb", | ||
"mongoose" | ||
], | ||
@@ -23,22 +29,12 @@ "author": { | ||
"bugs": { | ||
"url": "https://github.com/jraede/medici/issues" | ||
"url": "https://github.com/koresar/medici/issues" | ||
}, | ||
"dependencies": { | ||
"underscore": "~1.5.2", | ||
"mongoose": "~3.8.0", | ||
"q": "*", | ||
"moment": "~2.5.1" | ||
"mongoose": "^4.11.7" | ||
}, | ||
"readme": "medici\n======\n\nDouble-entry accounting system for nodejs + mongoose\n", | ||
"readmeFilename": "README.md", | ||
"homepage": "https://github.com/jraede/medici", | ||
"homepage": "https://github.com/koresar/medici", | ||
"devDependencies": { | ||
"should": "~2.1.1", | ||
"grunt": "~0.4.2", | ||
"grunt-exec": "~0.4.3", | ||
"grunt-contrib-coffee": "~0.8.0", | ||
"grunt-sed": "~0.1.1", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"semver": "~2.2.1" | ||
"mocha": "^3.5.0", | ||
"should": "^11.2.1" | ||
} | ||
} |
194
README.md
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://travis-ci.org/jraede/medici.png?branch=master)](https://travis-ci.org/jraede/medici) | ||
[![Build Status](https://travis-ci.org/koresar/medici.png?branch=master)](https://travis-ci.org/koresar/medici) | ||
@@ -28,14 +28,19 @@ medici | ||
var medici = require('medici'); | ||
```js | ||
const {book} = require('medici'); | ||
// The first argument is the book name, which is used to determine which book the transactions and journals are queried from. | ||
var myBook = new medici.book('MyBook'); | ||
// The first argument is the book name, which is used to determine which book the transactions and journals are queried from. | ||
const myBook = new book('MyBook'); | ||
``` | ||
Now write an entry: | ||
// You can specify a Date object as the second argument in the book.entry() method if you want the transaction to be for a different date than today | ||
myBook.entry('Received payment').debit('Assets:Cash', 1000).credit('Income', 1000, { | ||
client:'Joe Blow' | ||
}).write().then(function(journal) { (do something with written journal)}); | ||
```js | ||
// You can specify a Date object as the second argument in the book.entry() method if you want the transaction to be for a different date than today | ||
myBook.entry('Received payment') | ||
.debit('Assets:Cash', 1000) | ||
.credit('Income', 1000, {client: 'Joe Blow'}) | ||
.write().then(function(journal) { }); | ||
``` | ||
You can continue to chain debits and credits to the journal object until you are finished. The `entry.debit()` and `entry.credit()` methods both have the same arguments: (account, amount, meta). | ||
@@ -49,8 +54,10 @@ | ||
myBook.balance({ | ||
account:'Assets:Accounts Receivable', | ||
client:'Joe Blow' | ||
}).then(function(balance) { | ||
console.log("Joe Blow owes me", balance); | ||
}); | ||
```js | ||
myBook.balance({ | ||
account:'Assets:Accounts Receivable', | ||
client:'Joe Blow' | ||
}).then((balance) => { | ||
console.log("Joe Blow owes me", balance); | ||
}); | ||
``` | ||
@@ -63,12 +70,14 @@ Note that the `meta` query parameters are on the same level as the default query parameters (account, _journal, start_date, end_date). Medici parses the query and automatically turns any values that do not match top-level schema properties into meta parameters. | ||
var startDate = moment().subtract('months', 1).toDate(); // One month ago | ||
var endDate = new Date(); //today | ||
```js | ||
const startDate = moment().subtract('months', 1).toDate(); // One month ago | ||
const endDate = new Date(); //today | ||
myBook.ledger({ | ||
account:'Income' | ||
start_date:startDate | ||
end_date:endDate | ||
}).then(function(transactions) { | ||
// Do something with the returned transaction documents | ||
}); | ||
myBook.ledger({ | ||
account: 'Income', | ||
start_date: startDate, | ||
end_date: endDate | ||
}).then((transactions) => { | ||
// Do something with the returned transaction documents | ||
}); | ||
``` | ||
@@ -80,10 +89,11 @@ ## Voiding Journal Entries | ||
To void a journal entry, you can either call the `void(void_reason)` method on a Medici_Journal document, or use the `book.void(journal_id, void_reason)` method if you know the journal document's ID. | ||
myBook.void("123456", "I made a mistake").then(function() { | ||
// Do something after voiding | ||
}) | ||
```js | ||
myBook.void("123456", "I made a mistake").then(() => { | ||
// Do something after voiding | ||
}) | ||
``` | ||
If you do not specify a void reason, the system will set the memo of the new journal to the original journal's memo prepended with "[VOID]". | ||
@@ -94,34 +104,46 @@ ## Document Schema | ||
datetime:Date | ||
memo: | ||
type:String | ||
default:'' | ||
_transactions:[ | ||
type:Schema.Types.ObjectId | ||
ref:'Medici_Transaction' | ||
] | ||
book:String | ||
voided: | ||
type:Boolean | ||
default:false | ||
void_reason:String | ||
```js | ||
JournalSchema = { | ||
datetime: Date, | ||
memo: { | ||
type: String, | ||
default: '' | ||
}, | ||
_transactions: [{ | ||
type: Schema.Types.ObjectId, | ||
ref: 'Medici_Transaction' | ||
}], | ||
book: String, | ||
voided: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
void_reason: String | ||
} | ||
``` | ||
Transactions are schemed as follows: | ||
credit:Number | ||
debit:Number | ||
meta:Schema.Types.Mixed | ||
datetime:Date | ||
account_path:[String] | ||
accounts:String | ||
book:String | ||
memo:String | ||
_journal: | ||
type:Schema.Types.ObjectId | ||
ref:'Medici_Journal' | ||
timestamp:Date | ||
voided: | ||
type:Boolean | ||
default:false | ||
void_reason:String | ||
```js | ||
TransactionSchema = { | ||
credit: Number, | ||
debit: Number, | ||
meta: Schema.Types.Mixed, | ||
datetime: Date, | ||
account_path: [String], | ||
accounts: String, | ||
book: String, | ||
memo: String, | ||
_journal: { | ||
type: Schema.Types.ObjectId, | ||
ref:'Medici_Journal' | ||
}, | ||
timestamp: Date, | ||
voided: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
void_reason: String | ||
} | ||
``` | ||
@@ -138,23 +160,41 @@ Note that the `book`, `datetime`, `memo`, `voided`, and `void_reason` attributes are duplicates of their counterparts on the Journal document. These attributes will pretty much be needed on every transaction search, so they are added to the Transaction document to avoid having to populate the associated Journal every time. | ||
_person: | ||
type:Schema.Types.ObjectId | ||
ref:'Person' | ||
credit:Number | ||
debit:Number | ||
meta:Schema.Types.Mixed | ||
datetime:Date | ||
account_path:[String] | ||
accounts:String | ||
book:String | ||
memo:String | ||
_journal: | ||
type:Schema.Types.ObjectId | ||
ref:'Medici_Journal' | ||
timestamp:Date | ||
voided: | ||
type:Boolean | ||
default:false | ||
void_reason:String | ||
```js | ||
MyTransactionSchema = { | ||
_person: { | ||
type:Schema.Types.ObjectId, | ||
ref:'Person' | ||
}, | ||
credit: Number, | ||
debit: Number, | ||
meta: Schema.Types.Mixed, | ||
datetime: Date, | ||
account_path: [String], | ||
accounts: String, | ||
book: String, | ||
memo: String, | ||
_journal: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Medici_Journal' | ||
}, | ||
timestamp: Date, | ||
voided: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
void_reason: String | ||
} | ||
``` | ||
Then when you query transactions using the `book.ledger()` method, you can specify the related documents to populate as the second argument. E.g., `book.ledger({account:'Assets:Accounts Receivable'}, ['_person']).then()...` | ||
## Changelog | ||
* **v1.0.0** _See [this PR](https://github.com/koresar/medici/pull/5) for more details_ | ||
* **BREAKING**: Dropped support of node.js v0.10, v0.12, v4, and io.js. Node.js >= v6 is supported only. This allowed to drop several production dependencies. Also, few bugs were automatically fixed. | ||
* **BREAKING**: Upgraded `mongoose` to v4. This allows `medici` to be used with wider mongodb versions. | ||
* Dropped production dependencies: `moment`, `q`, `underscore`. | ||
* Dropped dev dependencies: `grunt`, `grunt-exec`, `grunt-contrib-coffee`, `grunt-sed`, `grunt-contrib-watch`, `semver`. | ||
* No `.coffee` any more. Using node.js v6 compatible JavaScript only. | ||
* There are no API changes. | ||
* Fixed a [bug](https://github.com/koresar/medici/issues/4). Transaction meta data was not voided correctly. | ||
* This module maintainer is now [koresar](https://github.com/koresar) instead of the original author [jraede](http://github.com/jraede). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
2
0
1
194
25627
6
547
2
+ Addedasync@2.6.0(transitive)
+ Addedbluebird@3.5.0(transitive)
+ Addedbson@1.0.9(transitive)
+ Addedbuffer-shims@1.0.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedes6-promise@3.2.1(transitive)
+ Addedhooks-fixed@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedkareem@1.5.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedmongodb@2.2.34(transitive)
+ Addedmongodb-core@2.1.18(transitive)
+ Addedmongoose@4.13.21(transitive)
+ Addedmpath@0.5.1(transitive)
+ Addedmpromise@0.5.5(transitive)
+ Addedmquery@2.3.3(transitive)
+ Addedms@2.0.0(transitive)
+ Addedmuri@1.3.0(transitive)
+ Addedprocess-nextick-args@1.0.7(transitive)
+ Addedreadable-stream@2.2.7(transitive)
+ Addedrequire_optional@1.0.1(transitive)
+ Addedresolve-from@2.0.0(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsliced@1.0.1(transitive)
+ Addedstring_decoder@1.0.3(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedmoment@~2.5.1
- Removedq@*
- Removedunderscore@~1.5.2
- Removedabort-controller@3.0.0(transitive)
- Removedasap@2.0.6(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbluebird@2.10.2(transitive)
- Removedbson@0.2.22(transitive)
- Removedbuffer@6.0.3(transitive)
- Removeddebug@2.2.0(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedhooks@0.2.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedkerberos@0.0.11(transitive)
- Removedmoment@2.5.1(transitive)
- Removedmongodb@1.4.38(transitive)
- Removedmongoose@3.8.40(transitive)
- Removedmpath@0.1.1(transitive)
- Removedmpromise@0.4.3(transitive)
- Removedmquery@1.10.0(transitive)
- Removedms@0.1.00.7.1(transitive)
- Removedmuri@1.1.0(transitive)
- Removednan@1.8.4(transitive)
- Removedpop-iterate@1.0.1(transitive)
- Removedprocess@0.11.10(transitive)
- Removedq@2.0.3(transitive)
- Removedreadable-stream@4.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedunderscore@1.5.2(transitive)
- Removedweak-map@1.0.8(transitive)
Updatedmongoose@^4.11.7