Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: honour currency precision while fetching balance #38218

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

rtdany10
Copy link
Contributor

GL Balance:
photo_2023-11-20_15-14-33

GL Balance as per Bank Reco Statement:
photo_2023-11-03_09-37-13

When multi-currency is involved, entries are made with decimals containing more than currency_precision. Which in turn causes difference as shown above. We should have a validation in GL Entry to trim off extra decimals. Thoughts?

@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Nov 20, 2023
Copy link

codecov bot commented Nov 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4f1e729) 60.14% compared to head (93681cf) 60.15%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #38218   +/-   ##
========================================
  Coverage    60.14%   60.15%           
========================================
  Files          757      757           
  Lines        70696    70697    +1     
========================================
+ Hits         42523    42527    +4     
+ Misses       28173    28170    -3     
Files Coverage Δ
erpnext/accounts/utils.py 74.47% <100.00%> (+0.03%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Collaborator

@barredterra barredterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we round the output of the calculation instead of the input?

return flt(bal, precision)

This is also a bit more robust than formatting query strings.

@rtdany10
Copy link
Contributor Author

rtdany10 commented Nov 21, 2023

Shouldn't we round the output of the calculation instead of the input?

Tried that, but mismatch still occurred in GL and Bank Reco Statemaent.
Rounded sum may not always be same as sum of rounded values.

We shouldn't ideally be storing more decimals in GL Entries than required tbh.

Copy link
Collaborator

@barredterra barredterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, makes sense. In this case, let's at least use SQL parameters instead of f-strings?

@barredterra
Copy link
Collaborator

What you did is still python string formatting, not SQL params. ;)

What I meant was passsing the values here https://github.com/frappe/frappe/blob/3ed363a27dee14efa3e070bff4a57fa7c2a366bf/frappe/database/database.py#L147-L150

@rtdany10 rtdany10 force-pushed the account-balance-mismatch branch from 61f27bb to 383a4b1 Compare November 21, 2023 12:47
@rtdany10
Copy link
Contributor Author

What you did is still python string formatting, not SQL params. ;)

What I meant was passsing the values here https://github.com/frappe/frappe/blob/3ed363a27dee14efa3e070bff4a57fa7c2a366bf/frappe/database/database.py#L147-L150

Sorry my bad, rest of the code was in that structure which is why I got confused.
I've made the changes, please do check

Copy link

stale bot commented Dec 7, 2023

This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Dec 7, 2023
@rtdany10
Copy link
Contributor Author

rtdany10 commented Dec 7, 2023

@stale stale bot removed the inactive label Dec 7, 2023
Copy link

stale bot commented Dec 24, 2023

This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Dec 24, 2023
Copy link

stale bot commented Jan 8, 2024

This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Jan 8, 2024
@rtdany10
Copy link
Contributor Author

rtdany10 commented Jan 9, 2024

@deepeshgarg007

Copy link

stale bot commented Jan 25, 2024

This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Jan 25, 2024
@rtdany10
Copy link
Contributor Author

@ruthra-kumar @deepeshgarg007 🥺

@stale stale bot removed the inactive label Jan 25, 2024
@ruthra-kumar ruthra-kumar self-assigned this Jan 25, 2024
@ruthra-kumar ruthra-kumar merged commit 4f215f1 into frappe:develop Jan 25, 2024
13 of 14 checks passed
ruthra-kumar added a commit that referenced this pull request Jan 25, 2024
…-38218

fix: honour currency precision while fetching balance (backport #38218)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accounts backport version-15-hotfix needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants