mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 20:48:27 +00:00
fix: always exclude pcv entries except for closing account head
(cherry picked from commit 0349e7a0b8)
This commit is contained in:
@@ -684,11 +684,18 @@ class FinancialQueryBuilder:
|
|||||||
account_data.unaccumulate_values()
|
account_data.unaccumulate_values()
|
||||||
|
|
||||||
def _apply_standard_filters(self, query, table, doctype: str = "GL Entry"):
|
def _apply_standard_filters(self, query, table, doctype: str = "GL Entry"):
|
||||||
if self.filters.get("ignore_closing_entries"):
|
# Exclude PCV-generated entries except those posted to a closing-account-head
|
||||||
if doctype == "GL Entry":
|
# so BS retained earnings survive while P&L reversal entries are filtered out
|
||||||
query = query.where(table.voucher_type != "Period Closing Voucher")
|
pcv = frappe.qb.DocType("Period Closing Voucher")
|
||||||
else:
|
closing_heads = frappe.qb.from_(pcv).select(pcv.closing_account_head).where(pcv.docstatus == 1)
|
||||||
query = query.where(table.is_period_closing_voucher_entry == 0)
|
|
||||||
|
if doctype == "GL Entry":
|
||||||
|
is_pcv = table.voucher_type == "Period Closing Voucher"
|
||||||
|
else:
|
||||||
|
# Account Closing Balance
|
||||||
|
is_pcv = table.is_period_closing_voucher_entry == 1
|
||||||
|
|
||||||
|
query = query.where(~is_pcv | table.account.isin(closing_heads))
|
||||||
|
|
||||||
if self.filters.get("project"):
|
if self.filters.get("project"):
|
||||||
projects = self.filters.get("project")
|
projects = self.filters.get("project")
|
||||||
|
|||||||
Reference in New Issue
Block a user