Comparing version 4.0.1 to 4.0.2
{ | ||
"name": "medici", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Simple double-entry accounting for Node + Mongoose", | ||
@@ -14,3 +14,3 @@ "main": "src/index.js", | ||
"type": "git", | ||
"url": "http://github.com/koresar/medici" | ||
"url": "http://github.com/flash-oss/medici" | ||
}, | ||
@@ -30,13 +30,17 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/koresar/medici/issues" | ||
"url": "https://github.com/flash-oss/medici/issues" | ||
}, | ||
"dependencies": { | ||
"mongoose": "^5.8.3" | ||
"mongoose": "^5.12.7" | ||
}, | ||
"homepage": "https://github.com/koresar/medici", | ||
"homepage": "https://github.com/flash-oss/medici", | ||
"devDependencies": { | ||
"mocha": "^5.2.0", | ||
"prettier": "^1.19.1", | ||
"should": "^11.2.1" | ||
"mocha": "^8.3.2", | ||
"prettier": "^1.19.1" | ||
}, | ||
"mocha": { | ||
"require": "test/_setup.js", | ||
"recursive": true, | ||
"spec": "{,!(node_modules)/**/}test/**/*.js" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://travis-ci.org/koresar/medici.png?branch=master)](https://travis-ci.org/koresar/medici) | ||
[![Build Status](https://travis-ci.org/flash-oss/medici.png?branch=master)](https://travis-ci.org/flash-oss/medici) | ||
@@ -19,3 +19,3 @@ # medici | ||
Each transaction in Medici is for one account. Accounts are divided into up to three levels, separated by a colon. Transactions to the Assets:Cash account will appear in a query for transactions in the Assets account, but will not appear in a query for transactions in the Assets:Property account. This allows you to query, for example, all expenses, or just "office overhead" expenses (Expenses:Office Overhead). | ||
Each transaction in Medici is for one account. Additionally, sub accounts can be created, and are separated by a colon. Transactions to the Assets:Cash account will appear in a query for transactions in the Assets account, but will not appear in a query for transactions in the Assets:Property account. This allows you to query, for example, all expenses, or just "office overhead" expenses (Expenses:Office Overhead). | ||
@@ -54,3 +54,3 @@ In theory, the account names are entirely arbitrary, but you will likely want to use traditional accounting sections and subsections like assets, expenses, income, accounts receivable, accounts payable, etc. But, in the end, how you structure the accounts is entirely up to you. | ||
```js | ||
const balance = await myBook.balance({ | ||
const { balance } = await myBook.balance({ | ||
account: "Assets:Accounts Receivable", | ||
@@ -72,3 +72,3 @@ client: "Joe Blow" | ||
const transactions = await myBook.ledger({ | ||
const { results, total } = await myBook.ledger({ | ||
account: "Income", | ||
@@ -87,3 +87,3 @@ start_date: startDate, | ||
```js | ||
await myBook.void("123456", "I made a mistake"); | ||
await myBook.void("5eadfd84d7d587fb794eaacb", "I made a mistake"); | ||
``` | ||
@@ -183,3 +183,3 @@ | ||
Medici is slow when number of records reach 30k. Starting from v3.0 the [following](https://github.com/koresar/medici/commit/274528ef5d1dae0beedca4a98dbf706808be53bd) indexes are auto generated on the `medici_transaction` collection: | ||
Medici v2 was slow when number of records reach 30k. Starting from v3.0 the [following](https://github.com/flash-oss/medici/commit/274528ef5d1dae0beedca4a98dbf706808be53bd) indexes are auto generated on the `medici_transaction` collection: | ||
@@ -299,3 +299,3 @@ ``` | ||
- **v1.0.0** _See [this PR](https://github.com/koresar/medici/pull/5) for more details_ | ||
- **v1.0.0** _See [this PR](https://github.com/flash-oss/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. | ||
@@ -307,3 +307,3 @@ - **BREAKING**: Upgraded `mongoose` to v4. This allows `medici` to be used with wider mongodb versions. | ||
- 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). | ||
- Fixed a [bug](https://github.com/flash-oss/medici/issues/4). Transaction meta data was not voided correctly. | ||
- This module maintainer is now [flash-oss](https://github.com/flash-oss) instead of the original author [jraede](http://github.com/jraede). |
@@ -51,4 +51,4 @@ const mongoose = require("mongoose"); | ||
if (query.start_date && query.end_date) { | ||
start_date = new Date(parseInt(query.start_date)); | ||
end_date = new Date(parseInt(query.end_date)); | ||
start_date = new Date(query.start_date); | ||
end_date = new Date(query.end_date); | ||
parsed["datetime"] = { | ||
@@ -227,19 +227,14 @@ $gte: start_date, | ||
async listAccounts() { | ||
try { | ||
let results = await this.transactionModel.find({ book: this.name }).distinct("accounts"); | ||
const final = new Set(); | ||
for (let result of results) { | ||
const paths = result.split(":"); | ||
const prev = []; | ||
for (let acct of paths) { | ||
prev.push(acct); | ||
final.add(prev.join(":")); | ||
} | ||
let results = await this.transactionModel.find({ book: this.name }).distinct("accounts"); | ||
const final = new Set(); | ||
for (let result of results) { | ||
const paths = result.split(":"); | ||
const prev = []; | ||
for (let acct of paths) { | ||
prev.push(acct); | ||
final.add(prev.join(":")); | ||
} | ||
return Array.from(final); // uniques | ||
} catch (err) { | ||
console.error("Medici error:", err); | ||
throw err; | ||
} | ||
return Array.from(final); // uniques | ||
} | ||
}; |
@@ -141,3 +141,3 @@ module.exports = class Entry { | ||
// * You can safely add values up to 1 billion and down to 0.000001. | ||
// * Anything more than 1 billion or less than 0.000001 is not guaranteed and will throw the below error. | ||
// * Anything more than 1 billion or less than 0.000001 is not guaranteed and might throw the below error. | ||
@@ -148,3 +148,2 @@ if (total !== 0) { | ||
err.total = total; | ||
console.error("Journal is invalid. Total is:", total); | ||
throw err; | ||
@@ -157,3 +156,2 @@ } | ||
} catch (err) { | ||
console.error(err); | ||
this.book.transactionModel | ||
@@ -163,3 +161,5 @@ .deleteMany({ | ||
}) | ||
.catch(e => console.error(`Can't delete transactions for journal ${this.journal._id}`, e)); | ||
.catch(e => | ||
console.error(`Can't delete txs for journal ${this.journal._id}. Medici ledger consistency got harmed.`, e) | ||
); | ||
throw new Error(`Failure to save journal: ${err.message}`); | ||
@@ -166,0 +166,0 @@ } |
@@ -88,12 +88,6 @@ const Book = require("./book"); | ||
const voidTransaction = trans_id => { | ||
return mongoose | ||
.model("Medici_Transaction") | ||
.findByIdAndUpdate(trans_id, { | ||
voided: true, | ||
void_reason: this.void_reason | ||
}) | ||
.catch(err => { | ||
console.error("Failed to void transaction:", err); | ||
throw err; | ||
}); | ||
return mongoose.model("Medici_Transaction").findByIdAndUpdate(trans_id, { | ||
voided: true, | ||
void_reason: this.void_reason | ||
}); | ||
}; | ||
@@ -181,2 +175,2 @@ | ||
module.exports = { book: Book }; | ||
module.exports = { Book, book: Book }; |
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
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
2
28155
523
Updatedmongoose@^5.12.7