Comments (14)
I have currently being using
.credit('Alice', 10, {currency: 'USD'})
.debit('Alice', 9, {currency: 'EUR'})
.credit('Bob', 9, {currency: 'EUR'})
.debit('Bob', 10, {currency: 'USD'})
with no issue so far. as long as every balance() call includes currency the balance seems correctly fetch with the currency flag.
closing this for now.
from medici.
Just proposed a PR to remove what I believe is not correct in the README
from medici.
Hm... Having multiple currencies in a same book? That doesn't sound like a double-entry accounting system. I'd recommend creating a separate book for a new currency. That the only safe way to go. Otherwise you can get yourself into a lot of troubles.
Medici checks every commit is zero balanced. See source code: https://github.com/koresar/medici/blob/a1d43c3cee03f0d2f84badad29324bef678c67de/src/entry.js#L130
Every commit must balance out to zero.
I would discourage the two following solutions because adding dollars to euros is plain wrong.
The Medici module have a feature of "sub accounts".
You can have a "USD" account and then sub accounts for Alice and Bob.
.credit('USD:Alice', 10)
.debit('USD:Bob", 10)
.debit('EUR:Alice', 12)
.credit('EUR:Alice', 12)
Or Alice and Bob can have a USD wallet sub account.
.credit('Alice:USD', 10)
.debit('Bob:USD", 10)
.debit('Alice:EUR', 12)
.credit('Alice:EUR', 12)
from medici.
Thanks for the quick feedback!
Hm... Having multiple currencies in the same book? That doesn't sound like a double-entry accounting system. I'd recommend creating a separate book for a new currency. That the only safe way to go.
The issue is if you do cross-currency transactions. I don't think you could do such transaction atomically if you have them in 2 books?
Ledger has a useful wiki on it.
Would there be some constraint to have more than 3 sub accounts (performance?). If accounts need to finish with currency, there 3 may not be enough.
But as shown on the ledger page and their -X option, there could be a need to convert between currency as well.
from medici.
Can be done in one book.
Alice converting AUD->EUR within her multicurrency wallet:
books
.credit("AUD:Expenses:Marketing", 2000.00, { client: 'Alice' })
.debit("AUD:Equity:Trading:Currency:AUD:EUR", 2000.00, { client: 'Alice' })
.credit("EUR:Equity:Trading:Currency:AUD:EUR", 1000.00, { client: 'Alice' })
.debit("EUR:Liabilities:Accounts Payable:EUR", 1000.00, { client: 'Alice' })
Just make sure that the sum for AUD is always 0. And for EUR.
To get total AUD balance:
const balance = await myBook.balance({
account: "AUD",
client: "Alice"
});
Not sure if that's helpful.
from medici.
Let me play with it and see. Just a question to understand the behavior or Medici.
The documentation says:
Accounts are divided into up to three levels, separated by a colon
But after skimming through the code I have not seen this limitation. Ie: AUD:Equity:Trading:Currency:AUD:EUR
will have 6 sub-accounts (and not be limited by 3) in total.
Is that correct?
from medici.
from medici.
actually I might have talked too quickly: https://github.com/koresar/medici/blob/e6a2c27fa28fd748bb7c349b16a9e4ccc0f943d5/src/entry.js#L38
from medici.
will continue seeing how to integrate multi-currency and will try to pull a PR if I find a good way forward
from medici.
from medici.
Thinking out loud, maybe we should just remove this limitation?
from medici.
probably. do you know why it was here in the first place? to limit index size?
from medici.
I don't know exactly. But I suspect that the first version of the medici API allowed to pass
account, subaccount, subsubaccount
.
The newer (current) API let you pass these as a concatenated string
"Assets:Something:Somethingelse"
from medici.
thank you for the thread!
from medici.
Related Issues (20)
- Mongoose connection string HOT 1
- Missing changelog for 6.0.0 HOT 2
- Value Added Tax HOT 4
- Question: Future Posting Date HOT 5
- v5 Discussion Thread HOT 35
- FastBalance approaches and solutions HOT 23
- Timestamp HOT 3
- After upgrading to 5.1.0 retrieving balance using custom properties as keys returns 0 HOT 11
- NIIF Support HOT 5
- Database independent - using ORM https://www.prisma.io/ HOT 3
- Mongoose Specify Connection HOT 4
- Set Timestamp for Journal Entry HOT 7
- Question: do you have an UI for this or do you plan to build one? HOT 3
- last version not released? HOT 3
- new release HOT 3
- Questions on the implementation HOT 10
- Question: Why MongoDB? Have you considered iterating to a relational db? HOT 1
- How we can update custom field after entry is done HOT 3
- demo or sample
- Failing to get started HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from medici.