Skip to content

Commit

Permalink
fix: Add party account validation for journal entry
Browse files Browse the repository at this point in the history
(cherry picked from commit f00620a)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed May 25, 2022
1 parent 228f10b commit 7f853b1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def validate(self):
self.validate_party()
self.validate_entries_for_advance()
self.validate_multi_currency()
self.validate_party_account_currency()
self.set_amounts_in_company_currency()
self.validate_debit_credit_amount()

Expand Down Expand Up @@ -655,6 +656,18 @@ def validate_multi_currency(self):

self.set_exchange_rate()

def validate_party_account_currency(self):
for d in self.get("accounts"):
if self.party_type not in ('Customer', 'Supplier'):
continue

party_gle_currency = get_party_gle_currency(self.party_type, self.party, self.company)
party_account_currency = get_account_currency(d.account)

if not party_gle_currency and (party_account_currency != self.currency):
frappe.throw(_("Row {0}: Party Account {1} currency and document currency should be same").format(
frappe.bold(d.idx), frappe.bold(d.account)))

def set_amounts_in_company_currency(self):
for d in self.get("accounts"):
d.debit_in_account_currency = flt(
Expand Down

0 comments on commit 7f853b1

Please sign in to comment.