Skip to content

Commit

Permalink
fix: add parenttype condition for item table in Purchase Register Report
Browse files Browse the repository at this point in the history
  • Loading branch information
ljain112 committed Sep 25, 2024
1 parent 9998aa2 commit 28abf19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def get_account_columns(invoice_list, include_payments):
"""select distinct expense_account
from `tabPurchase Invoice Item` where docstatus = 1
and (expense_account is not null and expense_account != '')
and parenttype='Purchase Invoice'
and parent in (%s) order by expense_account"""
% ", ".join(["%s"] * len(invoice_list)),
tuple([inv.name for inv in invoice_list]),
Expand Down Expand Up @@ -451,7 +452,7 @@ def get_invoice_expense_map(invoice_list):
"""
select parent, expense_account, sum(base_net_amount) as amount
from `tabPurchase Invoice Item`
where parent in (%s)
where parent in (%s) and parenttype='Purchase Invoice'
group by parent, expense_account
"""
% ", ".join(["%s"] * len(invoice_list)),
Expand Down Expand Up @@ -522,7 +523,7 @@ def get_invoice_po_pr_map(invoice_list):
"""
select parent, purchase_order, purchase_receipt, po_detail, project
from `tabPurchase Invoice Item`
where parent in (%s)
where parent in (%s) and parenttype='Purchase Invoice'
"""
% ", ".join(["%s"] * len(invoice_list)),
tuple(inv.name for inv in invoice_list),
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/report/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def apply_common_conditions(filters, query, doctype, child_doctype=None, payment

if join_required:
query = query.inner_join(child_doc).on(parent_doc.name == child_doc.parent)
query = query.where(child_doc.parenttype == doctype)
query = query.distinct()

if parent_doc.get_table_name() != "tabJournal Entry":
Expand Down

0 comments on commit 28abf19

Please sign in to comment.