erpnext icon indicating copy to clipboard operation
erpnext copied to clipboard

refactor: Exchange rate revaluation to handle accounts with zero account balance

Open ruthra-kumar opened this issue 2 years ago • 1 comments

Exchange Rate Revaluation will handle Foreign accounts with zero balance on account currency but has balance on company currency.

Changes in this PR:

  1. New Journal type Exchange Gain/Loss. This type skips validations: validate_debit_and_credit_amount and set_amounts_in_company_currency which helps to submit GL's with '0' debit/credit value in either currencies.
  2. https://github.com/frappe/erpnext/blob/66dbf94151ca15d1911b2133f5d05dc3c6593f72/erpnext/accounts/report/utils.py#L81 has been modified to handle GL's from [1].
  3. Exchange Rate Revaluation will now create 2 Journals. Screenshot 2022-12-02 at 9 43 16 PM

Discussion thread: https://discuss.erpnext.com/t/how-to-maintain-correct-account-balance-in-multiple-currencies-in-case-of-foreign-bank-account/96839

Solution: https://discuss.erpnext.com/t/how-to-maintain-correct-account-balance-in-multiple-currencies-in-case-of-foreign-bank-account/96839/9?u=ruthra

Conder a scenario where a Foreign currency accounts has balance in company currency but not in account currency. 'HDFC USD - TC' in the below screenshot. Screenshot 2022-12-02 at 9 41 15 PM

ERR can submit a journal to move only the company balance to Exchange Gain/Loss account. Screenshot 2022-12-02 at 9 43 16 PM

Screenshot 2022-12-02 at 9 43 31 PM Screenshot 2022-12-02 at 9 43 43 PM

General Ledger: Company/Base Currency: Screenshot 2022-12-03 at 7 23 24 AM

Account Currency: Screenshot 2022-12-03 at 7 23 29 AM

ruthra-kumar avatar Nov 29 '22 11:11 ruthra-kumar

Codecov Report

Merging #33165 (8a730dd) into develop (4076999) will decrease coverage by 0.05%. The diff coverage is 52.02%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #33165      +/-   ##
===========================================
- Coverage    64.10%   64.04%   -0.06%     
===========================================
  Files          818      818              
  Lines        58670    58834     +164     
===========================================
+ Hits         37609    37681      +72     
- Misses       21061    21153      +92     
Impacted Files Coverage Δ
erpnext/accounts/general_ledger.py 94.31% <0.00%> (-0.72%) :arrow_down:
...ange_rate_revaluation/exchange_rate_revaluation.py 55.60% <49.34%> (-14.09%) :arrow_down:
...xt/accounts/doctype/journal_entry/journal_entry.py 68.30% <85.71%> (+0.14%) :arrow_up:
erpnext/accounts/doctype/gl_entry/gl_entry.py 69.10% <100.00%> (ø)
erpnext/accounts/report/utils.py 80.59% <100.00%> (-0.57%) :arrow_down:
erpnext/erpnext_integrations/exotel_integration.py 68.04% <0.00%> (-3.73%) :arrow_down:
erpnext/stock/doctype/stock_entry/stock_entry.py 82.23% <0.00%> (-0.26%) :arrow_down:
erpnext/stock/doctype/pick_list/pick_list.py 76.53% <0.00%> (-0.21%) :arrow_down:
erpnext/selling/doctype/sales_order/sales_order.py 80.10% <0.00%> (-0.18%) :arrow_down:
erpnext/hooks.py 100.00% <0.00%> (ø)
... and 11 more

codecov[bot] avatar Nov 29 '22 16:11 codecov[bot]

@ruthra-kumar @deepeshgarg007 is it possible to backport to version-13?

mohsinalimat avatar Apr 15 '23 06:04 mohsinalimat

@mohsinalimat There are no plans to backport this refactor to v13 at the moment.

ruthra-kumar avatar Aug 02 '23 11:08 ruthra-kumar