GithubHelp home page GithubHelp logo

Comments (16)

orien avatar orien commented on May 18, 2024 1

@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.

orien avatar orien commented on May 18, 2024

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.

9mm avatar 9mm commented on May 18, 2024

@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.

9mm avatar 9mm commented on May 18, 2024

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...

  1. get amount from one account
  2. 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.

zharikovpro avatar zharikovpro commented on May 18, 2024

@9mm without locking you can double spend money, for example.

from double_entry.

9mm avatar 9mm commented on May 18, 2024

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.

zharikovpro avatar zharikovpro commented on May 18, 2024

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.

9mm avatar 9mm commented on May 18, 2024

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.

zharikovpro avatar zharikovpro commented on May 18, 2024

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.

9mm avatar 9mm commented on May 18, 2024

Sorry, I meant I'm not using SELECT FOR UPDATE locks (which I haven't really used before)

Thanks for explaining

from double_entry.

9mm avatar 9mm commented on May 18, 2024

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.

swrobel avatar swrobel commented on May 18, 2024

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.

warkann avatar warkann commented on May 18, 2024

I'm interested, too

from double_entry.

orien avatar orien commented on May 18, 2024

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.

swrobel avatar swrobel commented on May 18, 2024

@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.

orien avatar orien commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.