From 19f1ffbdc2ee986a65089f82fa9bd05805afaae1 Mon Sep 17 00:00:00 2001 From: Bhavan23 Date: Thu, 8 May 2025 13:53:51 +0530 Subject: [PATCH] fix(payment-reconciliation): use reconciliation_takes_effect_on from company --- .../doctype/payment_entry/payment_entry.json | 15 +++------------ .../doctype/payment_entry/payment_entry.py | 18 ++++++++++++------ erpnext/accounts/utils.py | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index 776c1b1b10a..551c70cab38 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -21,7 +21,6 @@ "party_name", "book_advance_payments_in_separate_party_account", "reconcile_on_advance_payment_date", - "advance_reconciliation_takes_effect_on", "column_break_11", "bank_account", "party_bank_account", @@ -754,18 +753,9 @@ "options": "No\nYes", "print_hide": 1, "search_index": 1 - }, - { - "default": "Oldest Of Invoice Or Advance", - "fetch_from": "company.reconciliation_takes_effect_on", - "fieldname": "advance_reconciliation_takes_effect_on", - "fieldtype": "Select", - "hidden": 1, - "label": "Advance Reconciliation Takes Effect On", - "no_copy": 1, - "options": "Advance Payment Date\nOldest Of Invoice Or Advance\nReconciliation Date" } ], + "grid_page_length": 50, "index_web_pages_for_search": 1, "is_submittable": 1, "links": [ @@ -777,7 +767,7 @@ "table_fieldname": "payment_entries" } ], - "modified": "2025-03-24 16:18:19.920701", + "modified": "2025-05-08 11:18:10.238085", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry", @@ -817,6 +807,7 @@ "write": 1 } ], + "row_format": "Dynamic", "show_name_in_global_search": 1, "sort_field": "creation", "sort_order": "DESC", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index d991cb128e0..f16dfda4594 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -80,9 +80,6 @@ class PaymentEntry(AccountsController): PaymentEntryReference, ) - advance_reconciliation_takes_effect_on: DF.Literal[ - "Advance Payment Date", "Oldest Of Invoice Or Advance", "Reconciliation Date" - ] amended_from: DF.Link | None apply_tax_withholding_amount: DF.Check auto_repeat: DF.Link | None @@ -1574,9 +1571,15 @@ class PaymentEntry(AccountsController): else: # For backwards compatibility # Supporting reposting on payment entries reconciled before select field introduction - if self.advance_reconciliation_takes_effect_on == "Advance Payment Date": + if ( + frappe.get_cached_value("Company", self.company, "reconciliation_takes_effect_on") + == "Advance Payment Date" + ): posting_date = self.posting_date - elif self.advance_reconciliation_takes_effect_on == "Oldest Of Invoice Or Advance": + elif ( + frappe.get_cached_value("Company", self.company, "reconciliation_takes_effect_on") + == "Oldest Of Invoice Or Advance" + ): date_field = "posting_date" if invoice.reference_doctype in ["Sales Order", "Purchase Order"]: date_field = "transaction_date" @@ -1586,7 +1589,10 @@ class PaymentEntry(AccountsController): if getdate(posting_date) < getdate(self.posting_date): posting_date = self.posting_date - elif self.advance_reconciliation_takes_effect_on == "Reconciliation Date": + elif ( + frappe.get_cached_value("Company", self.company, "reconciliation_takes_effect_on") + == "Reconciliation Date" + ): posting_date = nowdate() frappe.db.set_value("Payment Entry Reference", invoice.name, "reconcile_effect_on", posting_date) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index f117adb1f8f..37bd5e90ae8 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -732,9 +732,15 @@ def update_reference_in_payment_entry( # Update Reconciliation effect date in reference if payment_entry.book_advance_payments_in_separate_party_account: - if payment_entry.advance_reconciliation_takes_effect_on == "Advance Payment Date": + if ( + frappe.get_cached_value("Company", payment_entry.company, "reconciliation_takes_effect_on") + == "Advance Payment Date" + ): reconcile_on = payment_entry.posting_date - elif payment_entry.advance_reconciliation_takes_effect_on == "Oldest Of Invoice Or Advance": + elif ( + frappe.get_cached_value("Company", payment_entry.company, "reconciliation_takes_effect_on") + == "Oldest Of Invoice Or Advance" + ): date_field = "posting_date" if d.against_voucher_type in ["Sales Order", "Purchase Order"]: date_field = "transaction_date" @@ -742,7 +748,10 @@ def update_reference_in_payment_entry( if getdate(reconcile_on) < getdate(payment_entry.posting_date): reconcile_on = payment_entry.posting_date - elif payment_entry.advance_reconciliation_takes_effect_on == "Reconciliation Date": + elif ( + frappe.get_cached_value("Company", payment_entry.company, "reconciliation_takes_effect_on") + == "Reconciliation Date" + ): reconcile_on = nowdate() reference_details.update({"reconcile_effect_on": reconcile_on})