Merge pull request #40220 from ruthra-kumar/exc_gain_loss_on_journal_against_journals

refactor: Gain/Loss Journal creation for Journals against Journals
This commit is contained in:
ruthra kumar
2024-03-02 15:36:27 +05:30
committed by GitHub
3 changed files with 91 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ from erpnext.accounts.party import (
from erpnext.accounts.utils import (
create_gain_loss_journal,
get_account_currency,
get_currency_precision,
get_fiscal_years,
validate_fiscal_year,
)
@@ -1301,10 +1302,12 @@ class AccountsController(TransactionBase):
# These are generated by Sales/Purchase Invoice during reconciliation and advance allocation.
# and below logic is only for such scenarios
if args:
precision = get_currency_precision()
for arg in args:
# Advance section uses `exchange_gain_loss` and reconciliation uses `difference_amount`
if (
arg.get("difference_amount", 0) != 0 or arg.get("exchange_gain_loss", 0) != 0
flt(arg.get("difference_amount", 0), precision) != 0
or flt(arg.get("exchange_gain_loss", 0), precision) != 0
) and arg.get("difference_account"):
party_account = arg.get("account")