envato / double_entry

A double-entry accounting system for Ruby applications.
https://rubygems.org/gems/double_entry
MIT License
422 stars 68 forks source link

Add credit/debit scopes to Line #192

Closed swrobel closed 2 years ago

swrobel commented 4 years ago

I've overridden locally in the past & found these scopes useful, so I thought they might be a welcome addition to 2.0

ricobl commented 2 years ago

Hey @swrobel, thanks for the contribution! I'll merge this shortly and we'll bundle this up with other changes before issuing a release.

In the meantime, would you mind sharing a bit of your use case for this?

The migration doesn't include an index for the amount on the lines table, did you add an index on your app? Or is it querying against a subset of records?

swrobel commented 2 years ago

I'm always using it against a subset of records, so I didn't think adding another index would be useful, but I suppose maybe there are some cases for others where it could be?

ricobl commented 2 years ago

Fair enough! Thanks for sharing.

I guess the best approach is leaving the index out for now. Anyone with performance issues using those scopes can add the index to their app. In our experience the lines table can get pretty big so it's best to avoid non essential indexes.