Skip to content

Commit

Permalink
refactor: gain/loss should use same posting date as payment
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Sep 4, 2023
1 parent 6a7bdef commit f7865da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ def reconcile_dr_cr_note(dr_cr_notes, company):

create_gain_loss_journal(
company,
today(),
inv.party_type,
inv.party,
inv.account,
Expand Down
3 changes: 2 additions & 1 deletion erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,7 @@ def get_voucher_outstandings(

def create_gain_loss_journal(
company,
posting_date,
party_type,
party,
party_account,
Expand All @@ -1906,7 +1907,7 @@ def create_gain_loss_journal(
journal_entry = frappe.new_doc("Journal Entry")
journal_entry.voucher_type = "Exchange Gain Or Loss"
journal_entry.company = company
journal_entry.posting_date = nowdate()
journal_entry.posting_date = posting_date or nowdate()
journal_entry.multi_currency = 1
journal_entry.is_system_generated = True

Expand Down
3 changes: 3 additions & 0 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,10 @@ def make_exchange_gain_loss_journal(self, args: dict = None) -> None:
self.name,
arg.get("referenced_row"),
):
posting_date = frappe.db.get_value(arg.voucher_type, arg.voucher_no, "posting_date")
je = create_gain_loss_journal(
self.company,
posting_date,
arg.get("party_type"),
arg.get("party"),
party_account,
Expand Down Expand Up @@ -1177,6 +1179,7 @@ def make_exchange_gain_loss_journal(self, args: dict = None) -> None:

je = create_gain_loss_journal(
self.company,
self.posting_date,
self.party_type,
self.party,
party_account,
Expand Down

0 comments on commit f7865da

Please sign in to comment.