Closed elct9620 closed 1 year ago
Hi, the LineCheck can find the accounts which scope: nil but the AccountFixer didn't fix it correctly.
LineCheck
scope: nil
AccountFixer
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.
scope: account.scope_identity.to_s
nil
""
Possible Options:
scope: account.scope_identity&.to_s
scope
We may consider to the unscoped account in this case if we set all scope to "" instead of nil
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.
scope = NULL
My database is PostgreSQL and not sure how MySQL works in this case.
Sometimes one of my accounts which without scope will reset the balance to 0 after the transfer (eg. from 100.0 to 1.0)
0
100.0
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?
Hi, the
LineCheck
can find the accounts whichscope: nil
but theAccountFixer
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 convertnil
to""
(empty string) that it unable find correct account lines to update balance.Possible Options:
scope: account.scope_identity.to_s
toscope: account.scope_identity&.to_s
scope
column default to""
instead acceptnil
Updated
Due to the
LineCheck
SQL, option 1 will unable to find any Line in this casehttps://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.Note
Sometimes one of my accounts which without scope will reset the balance to
0
after the transfer (eg. from100.0
to1.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 isnil
?