refactor: linkage between journal as payment and gain/loss journal
This commit is contained in:
parent
cd42b26839
commit
f119a1e115
@ -58,6 +58,13 @@ class GLEntry(Document):
|
|||||||
validate_balance_type(self.account, adv_adj)
|
validate_balance_type(self.account, adv_adj)
|
||||||
validate_frozen_account(self.account, adv_adj)
|
validate_frozen_account(self.account, adv_adj)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.voucher_type == "Journal Entry"
|
||||||
|
and frappe.get_cached_value("Journal Entry", self.voucher_no, "voucher_type")
|
||||||
|
== "Exchange Gain Or Loss"
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
if frappe.get_cached_value("Account", self.account, "account_type") not in [
|
if frappe.get_cached_value("Account", self.account, "account_type") not in [
|
||||||
"Receivable",
|
"Receivable",
|
||||||
"Payable",
|
"Payable",
|
||||||
|
@ -499,11 +499,12 @@ class JournalEntry(AccountsController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not against_entries:
|
if not against_entries:
|
||||||
frappe.throw(
|
if self.voucher_type != "Exchange Gain Or Loss":
|
||||||
_(
|
frappe.throw(
|
||||||
"Journal Entry {0} does not have account {1} or already matched against other voucher"
|
_(
|
||||||
).format(d.reference_name, d.account)
|
"Journal Entry {0} does not have account {1} or already matched against other voucher"
|
||||||
)
|
).format(d.reference_name, d.account)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
dr_or_cr = "debit" if d.credit > 0 else "credit"
|
dr_or_cr = "debit" if d.credit > 0 else "credit"
|
||||||
valid = False
|
valid = False
|
||||||
|
@ -1039,9 +1039,9 @@ class AccountsController(TransactionBase):
|
|||||||
"cost_center": erpnext.get_default_cost_center(self.company),
|
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||||
# TODO: figure out a way to pass reference
|
# TODO: figure out a way to pass reference
|
||||||
# throws 'Journal Entry doesn't have {account} or doesn't have matched account'
|
# throws 'Journal Entry doesn't have {account} or doesn't have matched account'
|
||||||
# "reference_type": self.doctype,
|
"reference_type": self.doctype,
|
||||||
# "reference_name": self.name,
|
"reference_name": self.name,
|
||||||
# "reference_detail_no": arg.idx,
|
"reference_detail_no": arg.idx,
|
||||||
reverse_dr_or_cr: abs(arg.get("difference_amount")),
|
reverse_dr_or_cr: abs(arg.get("difference_amount")),
|
||||||
reverse_dr_or_cr + "_in_account_currency": 0,
|
reverse_dr_or_cr + "_in_account_currency": 0,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user