From 3739e2ca5a3d8c205ce094d3cc53a3fb6508c376 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Sat, 26 Jul 2025 12:56:10 +0530 Subject: [PATCH] fix: attribute error in payment entry (cherry picked from commit dc841fe6618ba3e967b91b14758aa830ed93f185) --- .../doctype/payment_entry/payment_entry.py | 5 +++-- erpnext/accounts/utils.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index de4305f86e0..6e8e5e02451 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1487,13 +1487,14 @@ class PaymentEntry(AccountsController): "voucher_no": self.name, "voucher_detail_no": invoice.name, } - if invoice.reconcile_effect_on: posting_date = invoice.reconcile_effect_on else: # For backwards compatibility # Supporting reposting on payment entries reconciled before select field introduction - posting_date = get_reconciliation_effect_date(invoice, self.company, self.posting_date) + posting_date = get_reconciliation_effect_date( + invoice.reference_doctype, invoice.reference_name, self.company, self.posting_date + ) frappe.db.set_value("Payment Entry Reference", invoice.name, "reconcile_effect_on", posting_date) dr_or_cr, account = self.get_dr_and_account_for_advances(invoice) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 30081e275ff..ca1108f9340 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -717,7 +717,9 @@ def update_reference_in_payment_entry( # Update Reconciliation effect date in reference if payment_entry.book_advance_payments_in_separate_party_account: - reconcile_on = get_reconciliation_effect_date(d, payment_entry.company, payment_entry.posting_date) + reconcile_on = get_reconciliation_effect_date( + d.against_voucher_type, d.against_voucher, payment_entry.company, payment_entry.posting_date + ) reference_details.update({"reconcile_effect_on": reconcile_on}) if d.voucher_detail_no: @@ -771,20 +773,21 @@ def update_reference_in_payment_entry( return row, update_advance_paid -def get_reconciliation_effect_date(reference, company, posting_date): +def get_reconciliation_effect_date(against_voucher_type, against_voucher, company, posting_date): reconciliation_takes_effect_on = frappe.get_cached_value( "Company", company, "reconciliation_takes_effect_on" ) + # default + reconcile_on = posting_date + if reconciliation_takes_effect_on == "Advance Payment Date": reconcile_on = posting_date elif reconciliation_takes_effect_on == "Oldest Of Invoice Or Advance": date_field = "posting_date" - if reference.against_voucher_type in ["Sales Order", "Purchase Order"]: + if against_voucher_type in ["Sales Order", "Purchase Order"]: date_field = "transaction_date" - reconcile_on = frappe.db.get_value( - reference.against_voucher_type, reference.against_voucher, date_field - ) + reconcile_on = frappe.db.get_value(against_voucher_type, against_voucher, date_field) if getdate(reconcile_on) < getdate(posting_date): reconcile_on = posting_date elif reconciliation_takes_effect_on == "Reconciliation Date":