fix: only show advance payment entries where "book_advance_payments_in_separate_party_account" is true
This commit is contained in:
@@ -153,9 +153,6 @@ class PaymentReconciliation(Document):
|
|||||||
self.add_payment_entries(non_reconciled_payments)
|
self.add_payment_entries(non_reconciled_payments)
|
||||||
|
|
||||||
def get_payment_entries(self):
|
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"
|
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
|
||||||
@@ -187,6 +184,7 @@ class PaymentReconciliation(Document):
|
|||||||
self.party,
|
self.party,
|
||||||
party_account,
|
party_account,
|
||||||
order_doctype,
|
order_doctype,
|
||||||
|
default_advance_account=self.default_advance_account,
|
||||||
against_all_orders=True,
|
against_all_orders=True,
|
||||||
limit=self.payment_limit,
|
limit=self.payment_limit,
|
||||||
condition=condition,
|
condition=condition,
|
||||||
|
|||||||
@@ -2946,6 +2946,7 @@ def get_advance_payment_entries(
|
|||||||
party_account,
|
party_account,
|
||||||
order_doctype,
|
order_doctype,
|
||||||
order_list=None,
|
order_list=None,
|
||||||
|
default_advance_account=None,
|
||||||
include_unallocated=True,
|
include_unallocated=True,
|
||||||
against_all_orders=False,
|
against_all_orders=False,
|
||||||
limit=None,
|
limit=None,
|
||||||
@@ -2959,6 +2960,7 @@ def get_advance_payment_entries(
|
|||||||
party_type,
|
party_type,
|
||||||
party,
|
party,
|
||||||
party_account,
|
party_account,
|
||||||
|
default_advance_account,
|
||||||
limit,
|
limit,
|
||||||
condition,
|
condition,
|
||||||
)
|
)
|
||||||
@@ -2982,13 +2984,14 @@ def get_advance_payment_entries(
|
|||||||
party_type,
|
party_type,
|
||||||
party,
|
party,
|
||||||
party_account,
|
party_account,
|
||||||
|
default_advance_account,
|
||||||
limit,
|
limit,
|
||||||
condition,
|
condition,
|
||||||
)
|
)
|
||||||
q = q.select((payment_entry.unallocated_amount).as_("amount"))
|
q = q.select((payment_entry.unallocated_amount).as_("amount"))
|
||||||
q = q.where(payment_entry.unallocated_amount > 0)
|
q = q.where(payment_entry.unallocated_amount > 0)
|
||||||
|
|
||||||
unallocated = list(q.run(as_dict=True))
|
unallocated = list(q.run(as_dict=True, debug=True))
|
||||||
payment_entries += unallocated
|
payment_entries += unallocated
|
||||||
return payment_entries
|
return payment_entries
|
||||||
|
|
||||||
@@ -2997,6 +3000,7 @@ def get_common_query(
|
|||||||
party_type,
|
party_type,
|
||||||
party,
|
party,
|
||||||
party_account,
|
party_account,
|
||||||
|
default_advance_account,
|
||||||
limit,
|
limit,
|
||||||
condition,
|
condition,
|
||||||
):
|
):
|
||||||
@@ -3018,14 +3022,24 @@ def get_common_query(
|
|||||||
.where(payment_entry.docstatus == 1)
|
.where(payment_entry.docstatus == 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
if payment_type == "Receive":
|
field = "paid_from" if payment_type == "Receive" else "paid_to"
|
||||||
q = q.select((payment_entry.paid_from_account_currency).as_("currency"))
|
|
||||||
q = q.select(payment_entry.paid_from)
|
q = q.select((payment_entry[f"{field}_account_currency"]).as_("currency"))
|
||||||
q = q.where(payment_entry.paid_from.isin(party_account))
|
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:
|
else:
|
||||||
q = q.select((payment_entry.paid_to_account_currency).as_("currency"))
|
q = q.where(account_condition)
|
||||||
q = q.select(payment_entry.paid_to)
|
|
||||||
q = q.where(payment_entry.paid_to.isin(party_account))
|
|
||||||
|
|
||||||
if payment_type == "Receive":
|
if payment_type == "Receive":
|
||||||
q = q.select((payment_entry.source_exchange_rate).as_("exchange_rate"))
|
q = q.select((payment_entry.source_exchange_rate).as_("exchange_rate"))
|
||||||
|
|||||||
Reference in New Issue
Block a user