mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 08:35:00 +00:00
fix: restrict advance payment entries with flag
where "book_advance_payments_in_separate_party_account" is true
This commit is contained in:
@@ -153,10 +153,7 @@ class PaymentReconciliation(Document):
|
||||
self.add_payment_entries(non_reconciled_payments)
|
||||
|
||||
def get_payment_entries(self):
|
||||
if self.default_advance_account:
|
||||
party_account = [self.receivable_payable_account, self.default_advance_account]
|
||||
else:
|
||||
party_account = [self.receivable_payable_account]
|
||||
party_account = [self.receivable_payable_account]
|
||||
|
||||
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
|
||||
condition = frappe._dict(
|
||||
@@ -187,6 +184,7 @@ class PaymentReconciliation(Document):
|
||||
self.party,
|
||||
party_account,
|
||||
order_doctype,
|
||||
default_advance_account=self.default_advance_account,
|
||||
against_all_orders=True,
|
||||
limit=self.payment_limit,
|
||||
condition=condition,
|
||||
|
||||
@@ -2916,6 +2916,7 @@ def get_advance_payment_entries(
|
||||
party_account,
|
||||
order_doctype,
|
||||
order_list=None,
|
||||
default_advance_account=None,
|
||||
include_unallocated=True,
|
||||
against_all_orders=False,
|
||||
limit=None,
|
||||
@@ -2929,6 +2930,7 @@ def get_advance_payment_entries(
|
||||
party_type,
|
||||
party,
|
||||
party_account,
|
||||
default_advance_account,
|
||||
limit,
|
||||
condition,
|
||||
)
|
||||
@@ -2952,6 +2954,7 @@ def get_advance_payment_entries(
|
||||
party_type,
|
||||
party,
|
||||
party_account,
|
||||
default_advance_account,
|
||||
limit,
|
||||
condition,
|
||||
)
|
||||
@@ -2967,6 +2970,7 @@ def get_common_query(
|
||||
party_type,
|
||||
party,
|
||||
party_account,
|
||||
default_advance_account,
|
||||
limit,
|
||||
condition,
|
||||
):
|
||||
@@ -2988,14 +2992,22 @@ def get_common_query(
|
||||
.where(payment_entry.docstatus == 1)
|
||||
)
|
||||
|
||||
if payment_type == "Receive":
|
||||
q = q.select((payment_entry.paid_from_account_currency).as_("currency"))
|
||||
q = q.select(payment_entry.paid_from)
|
||||
q = q.where(payment_entry.paid_from.isin(party_account))
|
||||
field = "paid_from" if payment_type == "Receive" else "paid_to"
|
||||
|
||||
q = q.select((payment_entry[f"{field}_account_currency"]).as_("currency"))
|
||||
q = q.select(payment_entry[field])
|
||||
account_condition = payment_entry[field].isin(party_account)
|
||||
if default_advance_account:
|
||||
q = q.where(
|
||||
account_condition
|
||||
| (
|
||||
(payment_entry[field] == default_advance_account)
|
||||
& (payment_entry.book_advance_payments_in_separate_party_account == 1)
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
q = q.select((payment_entry.paid_to_account_currency).as_("currency"))
|
||||
q = q.select(payment_entry.paid_to)
|
||||
q = q.where(payment_entry.paid_to.isin(party_account))
|
||||
q = q.where(account_condition)
|
||||
|
||||
if payment_type == "Receive":
|
||||
q = q.select((payment_entry.source_exchange_rate).as_("exchange_rate"))
|
||||
|
||||
Reference in New Issue
Block a user