From b2c3da135ea85fe245ec9c6066a8e68b42b64f7f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 23 Jan 2025 14:10:15 +0530 Subject: [PATCH] refactor: only apply configuration on normal payments patch to update default value --- .../payment_reconciliation/payment_reconciliation.py | 10 ++++++---- erpnext/controllers/accounts_controller.py | 2 ++ erpnext/patches.txt | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index d3d89a1c1cc..72aa4905900 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -335,6 +335,7 @@ class PaymentReconciliation(Document): for payment in non_reconciled_payments: row = self.append("payments", {}) row.update(payment) + row.is_advance = payment.book_advance_payments_in_separate_party_account def get_invoice_entries(self): # Fetch JVs, Sales and Purchase Invoices for 'invoices' to reconcile against @@ -453,10 +454,11 @@ class PaymentReconciliation(Document): 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 exc_gain_loss_posting_date == "Invoice": - res.update({"gain_loss_posting_date": inv.get("invoice_date")}) - elif exc_gain_loss_posting_date == "Reconciliation Date": - res.update({"gain_loss_posting_date": nowdate()}) + if not pay.get("is_advance"): + if exc_gain_loss_posting_date == "Invoice": + res.update({"gain_loss_posting_date": inv.get("invoice_date")}) + elif exc_gain_loss_posting_date == "Reconciliation Date": + res.update({"gain_loss_posting_date": nowdate()}) if pay.get("amount") == 0: entries.append(res) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 8628fe647bf..edd1f16e1da 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2993,6 +2993,7 @@ def get_advance_payment_entries( (payment_ref.allocated_amount).as_("amount"), (payment_ref.name).as_("reference_row"), (payment_ref.reference_name).as_("against_order"), + (payment_entry.book_advance_payments_in_separate_party_account), ) q = q.where(payment_ref.reference_doctype == order_doctype) @@ -3037,6 +3038,7 @@ def get_common_query( (payment_entry.name).as_("reference_name"), payment_entry.posting_date, (payment_entry.remarks).as_("remarks"), + (payment_entry.book_advance_payments_in_separate_party_account), ) .where(payment_entry.payment_type == payment_type) .where(payment_entry.party_type == party_type) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 6eaffff2f9f..098000b0b03 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -398,3 +398,4 @@ erpnext.patches.v15_0.update_asset_status_to_work_in_progress erpnext.patches.v15_0.rename_manufacturing_settings_field erpnext.patches.v15_0.migrate_checkbox_to_select_for_reconciliation_effect erpnext.patches.v15_0.sync_auto_reconcile_config +execute:frappe.db.set_single_value("Accounts Settings", "exchange_gain_loss_posting_date", "Payment")