envato / double_entry

A double-entry accounting system for Ruby applications.

Home Page:https://rubygems.org/gems/double_entry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need more understand to run LineCheck.perform!

helmiItsavirus opened this issue · comments

Hi, I still don't know what the function of LineCheck.perform!, I know if the documentation already complete but I still don't get it when and where this function is needed.

So let say I'm a hacker and I run in rails console, and I manipulate the transaction directly to the database and The system will automaticly fix that? or something else?

Please, anyone, tell the simple case to use this function?

# Check all accounts & write the results to the double_entry_line_checks table
DoubleEntry::Validation::LineCheck.perform!

# Check & fix accounts (results will also be written to the table)
DoubleEntry::Validation::LineCheck.perform!(fixer: DoubleEntry::Validation::AccountFixer.new)

For now, I haven't created a background scheduler yet to use that function, I think It isn't complete yet

Hi @helmiItsavirus , thanks for asking the question and sorry it's taken so long to reply.

These classes are there as a bit of a safety check just in case something goes wrong. It's less about providing safety from hackers and more about providing safety in case e.g. a database transaction fails in a non-atomic way or some other process modifies the stored account balance. If someone malicious gets access to your database all bets are off, they could delete or modify the underlying lines in which case there's not much the gem could do to recover, it would be up to your disaster recovery process at that point.

I've tried to flesh out the docs in #208, have a look there and see if that helps.