refactor: pass gain loss posting date to controller

(cherry picked from commit 7e600a6494)

# Conflicts:
#	erpnext/accounts/utils.py
(cherry picked from commit 125722ae41)
This commit is contained in:
ruthra kumar
2023-10-22 20:26:45 +05:30
committed by Mergify
parent 63c3f51ffa
commit 22d352e875
5 changed files with 13 additions and 2 deletions

View File

@@ -368,6 +368,8 @@ erpnext.accounts.PaymentReconciliationController = class PaymentReconciliationCo
args.forEach(d => {
frappe.model.set_value("Payment Reconciliation Allocation", d.docname,
"difference_account", d.difference_account);
frappe.model.set_value("Payment Reconciliation Allocation", d.docname,
"gain_loss_posting_date", d.gain_loss_posting_date);
>>>>>>> 5323bb7bee (refactor: introduce fields in popup)
});

View File

@@ -446,6 +446,7 @@ class PaymentReconciliation(Document):
res.difference_amount = self.get_difference_amount(pay, inv, res["allocated_amount"])
res.difference_account = default_exchange_gain_loss_account
res.exchange_rate = inv.get("exchange_rate")
res.update({"gain_loss_posting_date": pay.get("posting_date")})
if pay.get("amount") == 0:
entries.append(res)
@@ -562,6 +563,7 @@ class PaymentReconciliation(Document):
"allocated_amount": flt(row.get("allocated_amount")),
"difference_amount": flt(row.get("difference_amount")),
"difference_account": row.get("difference_account"),
"difference_posting_date": row.get("gain_loss_posting_date"),
"cost_center": row.get("cost_center"),
}
)

View File

@@ -19,6 +19,7 @@
"is_advance",
"section_break_5",
"difference_amount",
"gain_loss_posting_date",
"column_break_7",
"difference_account",
"exchange_rate",

View File

@@ -726,7 +726,11 @@ def update_reference_in_payment_entry(
payment_entry.set_missing_ref_details(ref_exchange_rate=d.exchange_rate or None)
payment_entry.set_amounts()
payment_entry.make_exchange_gain_loss_journal(
<<<<<<< HEAD
frappe._dict({"difference_posting_date": d.difference_posting_date}), dimensions_dict
=======
frappe._dict({"difference_posting_date": d.difference_posting_date})
>>>>>>> 7e600a6494 (refactor: pass gain loss posting date to controller)
)
if not do_not_save:

View File

@@ -1360,7 +1360,9 @@ class AccountsController(TransactionBase):
self.name,
arg.get("referenced_row"),
):
posting_date = frappe.db.get_value(arg.voucher_type, arg.voucher_no, "posting_date")
posting_date = arg.get("difference_posting_date") or frappe.db.get_value(
arg.voucher_type, arg.voucher_no, "posting_date"
)
je = create_gain_loss_journal(
self.company,
posting_date,
@@ -1444,7 +1446,7 @@ class AccountsController(TransactionBase):
je = create_gain_loss_journal(
self.company,
self.posting_date,
args.get("difference_posting_date") if args else self.posting_date,
self.party_type,
self.party,
party_account,