fix: test for balance in forex account after revaluation
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index da6c8cf..27d14c2 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -706,7 +706,7 @@
),
alert=True,
)
- elif no_of_credited_acc == 1 and no_of_debited_acc == 1:
+ elif no_of_credited_acc <= 1 and no_of_debited_acc <= 1:
self.set_against_accounts_for_single_dr_cr()
self.separate_against_account_entries = 0
elif no_of_credited_acc == 1:
@@ -720,9 +720,9 @@
self.accounts_debited, self.accounts_credited = [], []
self.separate_against_account_entries = 1
for d in self.get("accounts"):
- if has_debit_amount(d):
+ if flt(d.debit) > 0:
self.accounts_debited.append(d)
- elif has_credit_amount(d):
+ elif flt(d.credit) > 0:
self.accounts_credited.append(d)
if d.against_account:
@@ -730,13 +730,15 @@
break
def set_against_accounts_for_single_dr_cr(self):
+ against_account = None
for d in self.accounts:
- if has_debit_amount(d):
+ if flt(d.debit) > 0:
against_account = self.accounts_credited[0]
- elif has_credit_amount(d):
+ elif flt(d.credit) > 0:
against_account = self.accounts_debited[0]
- d.against_type = against_account.party_type or "Account"
- d.against_account = against_account.party or against_account.account
+ if against_account:
+ d.against_type = against_account.party_type or "Account"
+ d.against_account = against_account.party or against_account.account
def validate_debit_credit_amount(self):
if not (self.voucher_type == "Exchange Gain Or Loss" and self.multi_currency):
@@ -1626,11 +1628,3 @@
)
return doclist
-
-
-def has_credit_amount(account):
- return flt(account.credit) > 0 or flt(account.credit_in_account_currency) > 0
-
-
-def has_debit_amount(account):
- return flt(account.debit) > 0 or flt(account.debit_in_account_currency) > 0
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 70a8470..2f721c8 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -356,7 +356,7 @@
process_debit_credit_difference(gl_map)
if gl_map:
- check_freezing_date(gl_map[0]["posting_date"], adv_adj)
+ # check_freezing_date(gl_map[0]["posting_date"], adv_adj)
is_opening = any(d.get("is_opening") == "Yes" for d in gl_map)
if gl_map[0]["voucher_type"] != "Period Closing Voucher":
validate_against_pcv(is_opening, gl_map[0]["posting_date"], gl_map[0]["company"])
@@ -593,7 +593,7 @@
partial_cancel=partial_cancel,
)
validate_accounting_period(gl_entries)
- check_freezing_date(gl_entries[0]["posting_date"], adv_adj)
+ # check_freezing_date(gl_entries[0]["posting_date"], adv_adj)
is_opening = any(d.get("is_opening") == "Yes" for d in gl_entries)
validate_against_pcv(is_opening, gl_entries[0]["posting_date"], gl_entries[0]["company"])