Comments (16)
@swrobel A scheduled job is a good idea. How often depends on the rate of transaction generation. You wouldn't want the check to be working on too many transactions at a time. As a rough guide, daily to hourly.
As for impacts, the check locks accounts as it inspects balances. So would have a small impact to the rate transactions can be generated.
from double_entry.
Oh dear, that shouldn't be happening. It sounds like the account locking is not working for you. What version of DoubleEntry and Rails are you using? And on which database?
from double_entry.
@orien why would balances not be working even if locking wasnt working right? Wouldn't transactions ensure that nothing is ever partially added/removed?
from double_entry.
I'm asking because I had to build my own version of double entry accounting (yours is great but didnt fit my needs)
I'm trying to think of all possible scenarios to account for. Currently I'm not using any locks, however everything that touches multiple accounts if of course in a transaction.
I'm thinking locks would only be needed when you need to...
- get amount from one account
- modify another account based on that account
But even then wouldnt the initial select not be incorrect because anything else being added to that account is going to be in a transaction itself and would be inserted atomically
from double_entry.
@9mm without locking you can double spend money, for example.
from double_entry.
I see, so it depends on getting the balance of the account so that you know how much you can spend, and that SELECT will possibly be out of date. Right?
In my case I'm only creating transactions based on external factors (pre-set amounts), so there won't really ever be SELECTS to see the balance of something
from double_entry.
SELECT will possibly be out of date. Right?
Right.
In my case I'm only creating transactions based on external factors (pre-set amounts), so there won't really ever be SELECTS to see the balance of something
Hmm, accounting system without balance reads sounds very unusual to me. Also, without reads, it's impossible to prevent overspending, i.e. spending more money that account have?
from double_entry.
There are 2 'read balance' functions in my app:
- get current account balance (e.g. balance 'Accounts Receivable')
- get current category balance (e.g. balance the
:liability
category of accounts)
Balance category is used to calculate trial balance to ensure it equals 0.0
, but all 5 SELECT statements are in the same statement so I'm 100% sure that it will always be showing the correct amount (because you can't halfway enter a transaction's line items. they all go together in a transaction). Balance category is also not used to determine HOW MUCH to create transactions for.
Balance account is used to calculate the amount someone should pay on an invoice. However, ALL transactions which are added to the invoice are done at the same time each month from a job that uses an advisory lock to make sure only 1 instance of the job is running, and it will check a flag to see if the item has already been added. So that way I know certain transactions have only been added once. The amount added is a pre-set amount, not based on how much is in their account.
There is no spending in my app btw as if it were a bank, it's based on invoices and payments (a SAAS service where people can log in and pay a pre-set amount in their account, which gets added each month by the job)
from double_entry.
all 5 SELECT statements are in the same statement so I'm 100% sure that it will always be showing the correct amount
If you don't have parallel reads at all - i.e. one thread for one user, then yes. If not, you still need a lock, which you use. Funny enough, you use lock although in a previous comment you said you don't use locks :)
from double_entry.
Sorry, I meant I'm not using SELECT FOR UPDATE
locks (which I haven't really used before)
Thanks for explaining
from double_entry.
Can you explain this part more
If you don't have parallel reads at all - i.e. one thread for one user
Were you referring to the 5 selects in one statement part? That was for my trial balance which just sums all line items in an account category
from double_entry.
Generally speaking, why do we need to run the account fixer/checker, and how often should we run it?
Still curious as to the answer to this question
from double_entry.
I'm interested, too
from double_entry.
The account check is something of a sanity check. It's there to provide confidence that everything is working as it should be.
It shouldn't find any errors!
If it does find an error, the incident should be investigated thoroughly.
In my experience, DoubleEntry works correctly in a highly parallel environment, under high load. If others have a different experience we should explore.
from double_entry.
@orien is it recommended to run it in a scheduled job? If so, how often? Does it have any impacts on other operations?
from double_entry.
I’ll close this now as further details of the reported problem are not forthcoming.
If anyone has similar problems please create a new issue.
from double_entry.
Related Issues (20)
- Importing Legacy Transactions HOT 5
- Migration fails because of duplicate detail fields in double_entry_lines HOT 2
- Can't run tests because of SyntaxError HOT 3
- COGS, gross margin, etc. HOT 1
- Support Multiple Currencies per Account HOT 5
- Make detail association optional in DoubleEntry::Line
- ActiveRecord deprecation HOT 6
- DoubleEntry::TransferNotAllowed between accounts with different scope (but same identifier) HOT 1
- DoubleEntry.transfer returns nil
- Allow validation on transfer definition HOT 2
- Notification test
- New release with fix of details requirements? HOT 2
- Money.infinite_precision is deprecated HOT 1
- Wrong dates in changelog HOT 1
- Rails 6.1.X Compatibility?
- Need more understand to run LineCheck.perform! HOT 1
- AccountFixer not fix account which scope is nil
- Storing chart of account in database rather than an initializers file HOT 2
- Version 2.0 release HOT 13
- Support Rails 7 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 double_entry.