fix: test for balance in forex account after revaluation

This commit is contained in:
Gursheen Anand 2023-11-07 15:31:52 +05:30
parent ea4b6ff27b
commit 68c6ad6036
2 changed files with 11 additions and 17 deletions

View File

@ -706,7 +706,7 @@ class JournalEntry(AccountsController):
),
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 @@ class JournalEntry(AccountsController):
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 @@ class JournalEntry(AccountsController):
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 @@ def make_reverse_journal_entry(source_name, target_doc=None):
)
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

View File

@ -356,7 +356,7 @@ def save_entries(gl_map, adv_adj, update_outstanding, from_repost=False):
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 @@ def make_reverse_gl_entries(
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"])