@@ -966,9 +966,12 @@ class AccountsController(TransactionBase):
|
||||
"""
|
||||
Make Exchange Gain/Loss journal for Invoices and Payments
|
||||
"""
|
||||
# Cancelling existing exchange gain/loss journals is handled in on_cancel event in accounts/utils.py
|
||||
# Cancelling existing exchange gain/loss journals is handled during the `on_cancel` event.
|
||||
# see accounts/utils.py:cancel_exchange_gain_loss_journal()
|
||||
if self.docstatus == 1:
|
||||
if self.get("doctype") == "Journal Entry":
|
||||
# 'args' is populated with exchange gain/loss account and the amount to be booked.
|
||||
# These are generated by Sales/Purchase Invoice during reconciliation and advance allocation.
|
||||
if args:
|
||||
for arg in args:
|
||||
if arg.get("difference_amount", 0) != 0 and arg.get("difference_account"):
|
||||
@@ -1029,6 +1032,7 @@ class AccountsController(TransactionBase):
|
||||
"exchange_rate": 1,
|
||||
"cost_center": erpnext.get_default_cost_center(self.company),
|
||||
# TODO: figure out a way to pass reference
|
||||
# throws 'Journal Entry doesn't have {account} or doesn't have matched account'
|
||||
# "reference_type": self.doctype,
|
||||
# "reference_name": self.name,
|
||||
# "reference_detail_no": arg.idx,
|
||||
@@ -1043,7 +1047,7 @@ class AccountsController(TransactionBase):
|
||||
journal_entry.submit()
|
||||
|
||||
if self.get("doctype") == "Payment Entry":
|
||||
# For Payment Entry, exchange_gain_loss field in the `reference` table is the trigger for journal creation
|
||||
# For Payment Entry, exchange_gain_loss field in the `references` table is the trigger for journal creation
|
||||
gain_loss_to_book = [x for x in self.references if x.exchange_gain_loss != 0]
|
||||
booked = []
|
||||
if gain_loss_to_book:
|
||||
|
||||
Reference in New Issue
Block a user