fix: allow gain/loss for Journals against Journals
(cherry picked from commit 5b67631d40)
# Conflicts:
# erpnext/accounts/doctype/journal_entry/journal_entry.py
This commit is contained in:
@@ -475,17 +475,33 @@ class JournalEntry(AccountsController):
|
|||||||
elif d.party_type == "Supplier" and flt(d.credit) > 0:
|
elif d.party_type == "Supplier" and flt(d.credit) > 0:
|
||||||
frappe.throw(_("Row {0}: Advance against Supplier must be debit").format(d.idx))
|
frappe.throw(_("Row {0}: Advance against Supplier must be debit").format(d.idx))
|
||||||
|
|
||||||
|
def system_generated_gain_loss(self):
|
||||||
|
return (
|
||||||
|
self.voucher_type == "Exchange Gain Or Loss"
|
||||||
|
and self.multi_currency
|
||||||
|
and self.is_system_generated
|
||||||
|
)
|
||||||
|
|
||||||
def validate_against_jv(self):
|
def validate_against_jv(self):
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if d.reference_type == "Journal Entry":
|
if d.reference_type == "Journal Entry":
|
||||||
|
<<<<<<< HEAD
|
||||||
account_root_type = frappe.db.get_value("Account", d.account, "root_type")
|
account_root_type = frappe.db.get_value("Account", d.account, "root_type")
|
||||||
if account_root_type == "Asset" and flt(d.debit) > 0:
|
if account_root_type == "Asset" and flt(d.debit) > 0:
|
||||||
|
=======
|
||||||
|
account_root_type = frappe.get_cached_value("Account", d.account, "root_type")
|
||||||
|
if account_root_type == "Asset" and flt(d.debit) > 0 and not self.system_generated_gain_loss():
|
||||||
|
>>>>>>> 5b67631d40 (fix: allow gain/loss for Journals against Journals)
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Row #{0}: For {1}, you can select reference document only if account gets credited"
|
"Row #{0}: For {1}, you can select reference document only if account gets credited"
|
||||||
).format(d.idx, d.account)
|
).format(d.idx, d.account)
|
||||||
)
|
)
|
||||||
elif account_root_type == "Liability" and flt(d.credit) > 0:
|
elif (
|
||||||
|
account_root_type == "Liability"
|
||||||
|
and flt(d.credit) > 0
|
||||||
|
and not self.system_generated_gain_loss()
|
||||||
|
):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Row #{0}: For {1}, you can select reference document only if account gets debited"
|
"Row #{0}: For {1}, you can select reference document only if account gets debited"
|
||||||
@@ -517,7 +533,7 @@ class JournalEntry(AccountsController):
|
|||||||
for jvd in against_entries:
|
for jvd in against_entries:
|
||||||
if flt(jvd[dr_or_cr]) > 0:
|
if flt(jvd[dr_or_cr]) > 0:
|
||||||
valid = True
|
valid = True
|
||||||
if not valid:
|
if not valid and not self.system_generated_gain_loss():
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Against Journal Entry {0} does not have any unmatched {1} entry").format(
|
_("Against Journal Entry {0} does not have any unmatched {1} entry").format(
|
||||||
d.reference_name, dr_or_cr
|
d.reference_name, dr_or_cr
|
||||||
|
|||||||
Reference in New Issue
Block a user