From 00669661e50b78ce34c8fbc1355baa4beecd6217 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 8 Jul 2025 13:19:03 +0530 Subject: [PATCH] chore: resolve conflicts --- .../doctype/journal_entry/journal_entry.py | 5 +- .../doctype/payment_entry/payment_entry.py | 25 +--------- .../payment_request/payment_request.py | 10 +--- .../unreconcile_payment.py | 4 -- .../accounts_receivable.py | 4 +- erpnext/accounts/utils.py | 18 ++----- erpnext/controllers/accounts_controller.py | 48 +------------------ 7 files changed, 9 insertions(+), 105 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 3e33ad58f34..6c7fb5f5744 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -239,13 +239,10 @@ class JournalEntry(AccountsController): def update_advance_paid(self): advance_paid = frappe._dict() -<<<<<<< HEAD -======= advance_payment_doctypes = get_advance_payment_doctypes() ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) for d in self.get("accounts"): if d.is_advance: - if d.reference_type in frappe.get_hooks("advance_payment_doctypes"): + if d.reference_type in advance_payment_doctypes: advance_paid.setdefault(d.reference_type, []).append(d.reference_name) for voucher_type, order_list in advance_paid.items(): diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index f74fafd6c4f..739eda70cbb 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -46,11 +46,8 @@ from erpnext.accounts.party import ( from erpnext.accounts.utils import ( cancel_exchange_gain_loss_journal, get_account_currency, -<<<<<<< HEAD - get_balance_on, -======= get_advance_payment_doctypes, ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) + get_balance_on, get_outstanding_invoices, ) from erpnext.controllers.accounts_controller import ( @@ -1032,11 +1029,7 @@ class PaymentEntry(AccountsController): def calculate_base_allocated_amount_for_reference(self, d) -> float: base_allocated_amount = 0 -<<<<<<< HEAD - if d.reference_doctype in frappe.get_hooks("advance_payment_doctypes"): -======= if d.reference_doctype in get_advance_payment_doctypes(): ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) # When referencing Sales/Purchase Order, use the source/target exchange rate depending on payment type. # This is so there are no Exchange Gain/Loss generated for such doctypes @@ -1316,12 +1309,7 @@ class PaymentEntry(AccountsController): if not self.party_account: return -<<<<<<< HEAD - advance_payment_doctypes = frappe.get_hooks("advance_payment_doctypes") - -======= advance_payment_doctypes = get_advance_payment_doctypes() ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) if self.payment_type == "Receive": against_account = self.paid_to else: @@ -1711,24 +1699,15 @@ class PaymentEntry(AccountsController): return flt(gl_dict.get(field, 0) / (conversion_rate or 1)) def update_advance_paid(self): -<<<<<<< HEAD - if self.payment_type in ("Receive", "Pay") and self.party: - for d in self.get("references"): - if d.allocated_amount and d.reference_doctype in frappe.get_hooks("advance_payment_doctypes"): - frappe.get_doc( - d.reference_doctype, d.reference_name, for_update=True - ).set_total_advance_paid() -======= if self.payment_type not in ("Receive", "Pay") or not self.party: return advance_payment_doctypes = get_advance_payment_doctypes() for d in self.get("references"): if d.allocated_amount and d.reference_doctype in advance_payment_doctypes: - frappe.get_lazy_doc( + frappe.get_doc( d.reference_doctype, d.reference_name, for_update=True ).set_total_advance_paid() ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) def on_recurring(self, reference_doc, auto_repeat_doc): self.reference_no = reference_doc.name diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index b465fd47867..8bb120f1ab5 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -16,7 +16,7 @@ from erpnext.accounts.doctype.payment_entry.payment_entry import ( ) from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate from erpnext.accounts.party import get_party_account, get_party_bank_account -from erpnext.accounts.utils import get_account_currency, get_advance_payment_doctypes, get_currency_precision +from erpnext.accounts.utils import get_account_currency, get_currency_precision from erpnext.utilities import payment_app_import_guard ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [ @@ -473,14 +473,6 @@ class PaymentRequest(Document): return create_stripe_subscription(gateway_controller, data) -<<<<<<< HEAD -======= - def update_reference_advance_payment_status(self): - if self.reference_doctype in get_advance_payment_doctypes(): - ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) - ref_doc.set_advance_payment_status() - ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) def _allocate_payment_request_to_pe_references(self, references): """ Allocate the Payment Request to the Payment Entry references based on\n diff --git a/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py b/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py index fec45fe5642..e57b90f11f7 100644 --- a/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py +++ b/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py @@ -85,11 +85,7 @@ class UnreconcilePayment(Document): update_voucher_outstanding( alloc.reference_doctype, alloc.reference_name, alloc.account, alloc.party_type, alloc.party ) -<<<<<<< HEAD - if doc.doctype in frappe.get_hooks("advance_payment_doctypes"): -======= if doc.doctype in get_advance_payment_doctypes(): ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) doc.set_total_advance_paid() frappe.db.set_value("Unreconcile Payment Entries", alloc.name, "unlinked", True) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 9b5b91277ef..a2237ea9ac2 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -66,9 +66,7 @@ class ReceivablePayableReport: frappe.db.get_single_value("Accounts Settings", "receivable_payable_fetch_method") or "Buffered Cursor" ) # Fail Safe - self.advance_payment_doctypes = frappe.get_hooks( - "advance_payment_receivable_doctypes" - ) + frappe.get_hooks("advance_payment_payable_doctypes") + self.advance_payment_doctypes = get_advance_payment_doctypes() def run(self, args): self.filters.update(args) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 9b3ac7b1ed6..2acd83dcc4f 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -629,12 +629,8 @@ def update_reference_in_journal_entry(d, journal_entry, do_not_save=False): # Update Advance Paid in SO/PO since they might be getting unlinked update_advance_paid = [] -<<<<<<< HEAD - if jv_detail.get("reference_type") in ["Sales Order", "Purchase Order"]: -======= - if jv_detail.get("reference_type") in get_advance_payment_doctypes(): ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) + if jv_detail.get("reference_type") in ["Sales Order", "Purchase Order"]: update_advance_paid.append((jv_detail.reference_type, jv_detail.reference_name)) rev_dr_or_cr = ( @@ -741,11 +737,7 @@ def update_reference_in_payment_entry( existing_row = payment_entry.get("references", {"name": d["voucher_detail_no"]})[0] # Update Advance Paid in SO/PO since they are getting unlinked -<<<<<<< HEAD if existing_row.get("reference_doctype") in ["Sales Order", "Purchase Order"]: -======= - if existing_row.get("reference_doctype") in get_advance_payment_doctypes(): ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) update_advance_paid.append((existing_row.reference_doctype, existing_row.reference_name)) if d.allocated_amount <= existing_row.allocated_amount: @@ -2265,17 +2257,13 @@ def get_party_types_from_account_type(account_type): return frappe.db.get_all("Party Type", {"account_type": account_type}, pluck="name") -def get_advance_payment_doctypes(payment_type=None): +def get_advance_payment_doctypes(): """ Get list of advance payment doctypes based on type. :param type: Optional, can be "receivable" or "payable". If not provided, returns both. """ - if payment_type: - return frappe.get_hooks(f"advance_payment_{payment_type}_doctypes") or [] - return (frappe.get_hooks("advance_payment_receivable_doctypes") or []) + ( - frappe.get_hooks("advance_payment_payable_doctypes") or [] - ) + return frappe.get_hooks("advance_payment_doctypes") def run_ledger_health_checks(): diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1941de5841b..d4a3facbacc 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -389,13 +389,7 @@ class AccountsController(TransactionBase): adv = qb.DocType("Advance Payment Ledger Entry") qb.from_(adv).delete().where(adv.voucher_type.eq(self.doctype) & adv.voucher_no.eq(self.name)).run() -<<<<<<< HEAD - advance_payment_doctypes = frappe.get_hooks("advance_payment_doctypes") - - if self.doctype in advance_payment_doctypes: -======= if self.doctype in self.get_advance_payment_doctypes(): ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) qb.from_(adv).delete().where( adv.against_voucher_type.eq(self.doctype) & adv.against_voucher_no.eq(self.name) ).run() @@ -2279,41 +2273,6 @@ class AccountsController(TransactionBase): self.db_set("advance_paid", advance_paid) -<<<<<<< HEAD -======= - self.set_advance_payment_status() - - def set_advance_payment_status(self): - new_status = None - - PaymentRequest = frappe.qb.DocType("Payment Request") - paid_amount = frappe.get_value( - doctype="Payment Request", - filters={ - "reference_doctype": self.doctype, - "reference_name": self.name, - "docstatus": 1, - }, - fieldname=Sum(PaymentRequest.grand_total - PaymentRequest.outstanding_amount), - ) - - if not paid_amount: - if self.doctype in self.get_advance_payment_doctypes(payment_type="receivable"): - new_status = "Not Requested" if paid_amount is None else "Requested" - elif self.doctype in self.get_advance_payment_doctypes(payment_type="payable"): - new_status = "Not Initiated" if paid_amount is None else "Initiated" - else: - total_amount = self.get("rounded_total") or self.get("grand_total") - new_status = "Fully Paid" if paid_amount == total_amount else "Partially Paid" - - if new_status == self.advance_payment_status: - return - - self.db_set("advance_payment_status", new_status, update_modified=False) - self.set_status(update=True) - self.notify_update() - ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) @property def company_abbr(self): if not hasattr(self, "_abbr"): @@ -2953,13 +2912,8 @@ class AccountsController(TransactionBase): repost_ledger.insert() repost_ledger.submit() -<<<<<<< HEAD def get_advance_payment_doctypes(self) -> list: - return frappe.get_hooks("advance_payment_doctypes") -======= - def get_advance_payment_doctypes(self, payment_type=None) -> list: - return _get_advance_payment_doctypes(payment_type=payment_type) ->>>>>>> 48e8e85617 (refactor: function to fetch advance payment doctypes) + return _get_advance_payment_doctypes() def make_advance_payment_ledger_for_journal(self): advance_payment_doctypes = self.get_advance_payment_doctypes()