AccountFixer not fix account which scope is nil
Hi, the LineCheck can find the accounts which scope: nil but the AccountFixer didn't fix it correctly.
https://github.com/envato/double_entry/blob/37ea766a8f87ab72e9f4b131abd61fec85d10d62/lib/double_entry/validation/account_fixer.rb#L23-L28
The line scope: account.scope_identity.to_s always convert nil to "" (empty string) that it unable find correct account lines to update balance.
Possible Options:
- Change
scope: account.scope_identity.to_stoscope: account.scope_identity&.to_s - Set
scopecolumn default to""instead acceptnil
We may consider to the unscoped account in this case if we set all
scopeto""instead ofnil
Updated
Due to the LineCheck SQL, option 1 will unable to find any Line in this case
https://github.com/envato/double_entry/blob/37ea766a8f87ab72e9f4b131abd61fec85d10d62/lib/double_entry/validation/line_check.rb#L63-L70
In this case, the scope = NULL is not working correctly.
My database is PostgreSQL and not sure how MySQL works in this case.
Note
Sometimes one of my accounts which without scope will reset the balance to 0 after the transfer (eg. from 100.0 to 1.0)
But if the LineCheck works correctly, the balance can go back correctly value.
I am not sure the relationship between the above two issues, but it seems we have some problems when using scope if it is nil?