chore: resolve conflicts

This commit is contained in:
ljain112
2025-07-08 13:19:03 +05:30
parent 82d03e2617
commit 00669661e5
7 changed files with 9 additions and 105 deletions

View File

@@ -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():

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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():

View File

@@ -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()