diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json index df9508793a7..5f191e4800a 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.json +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json @@ -789,7 +789,9 @@ "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" } ], @@ -804,7 +806,7 @@ "table_fieldname": "payment_entries" } ], - "modified": "2025-01-09 20:02:33.402163", + "modified": "2025-01-13 16:03:47.169699", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 48ed975cf37..a7a3aeda84b 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1493,19 +1493,7 @@ class PaymentEntry(AccountsController): "voucher_detail_no": invoice.name, } - if self.advance_reconciliation_takes_effect_on == "Advance Payment Date": - posting_date = self.posting_date - elif self.advance_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" - posting_date = frappe.db.get_value(invoice.reference_doctype, invoice.reference_name, date_field) - - if getdate(posting_date) < getdate(self.posting_date): - posting_date = self.posting_date - elif self.advance_reconciliation_takes_effect_on == "Reconciliation Date": - posting_date = nowdate() - + posting_date = invoice.reconcile_effect_on dr_or_cr, account = self.get_dr_and_account_for_advances(invoice) args_dict["account"] = account args_dict[dr_or_cr] = self.calculate_base_allocated_amount_for_reference(invoice) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 51b4ed248ce..bbf911083a9 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -712,6 +712,22 @@ def update_reference_in_payment_entry( } update_advance_paid = [] + # Update Reconciliation effect date in reference + if payment_entry.advance_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": + date_field = "posting_date" + if d.against_voucher_type in ["Sales Order", "Purchase Order"]: + date_field = "transaction_date" + reconcile_on = frappe.db.get_value(d.against_voucher_type, d.against_voucher, date_field) + + 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": + reconcile_on = nowdate() + + reference_details.update({"reconcile_effect_on": reconcile_on}) + if d.voucher_detail_no: existing_row = payment_entry.get("references", {"name": d["voucher_detail_no"]})[0]