fix: Employee name in Report trial balance for party (#20223)
* fix: Employee name in Report trial balance for party * fix: Add account filter in trial balance for party report Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
parent
1612432f45
commit
287f491f7b
@ -65,6 +65,21 @@ frappe.query_reports["Trial Balance for Party"] = {
|
|||||||
return party_type;
|
return party_type;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"label": __("Account"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"get_query": function() {
|
||||||
|
var company = frappe.query_report.get_filter_value('company');
|
||||||
|
return {
|
||||||
|
"doctype": "Account",
|
||||||
|
"filters": {
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "show_zero_values",
|
"fieldname": "show_zero_values",
|
||||||
"label": __("Show zero values"),
|
"label": __("Show zero values"),
|
||||||
|
@ -20,7 +20,7 @@ def execute(filters=None):
|
|||||||
def get_data(filters, show_party_name):
|
def get_data(filters, show_party_name):
|
||||||
if filters.get('party_type') in ('Customer', 'Supplier', 'Employee', 'Member'):
|
if filters.get('party_type') in ('Customer', 'Supplier', 'Employee', 'Member'):
|
||||||
party_name_field = "{0}_name".format(frappe.scrub(filters.get('party_type')))
|
party_name_field = "{0}_name".format(frappe.scrub(filters.get('party_type')))
|
||||||
if filters.get('party_type') == 'Student':
|
elif filters.get('party_type') == 'Student':
|
||||||
party_name_field = 'first_name'
|
party_name_field = 'first_name'
|
||||||
elif filters.get('party_type') == 'Shareholder':
|
elif filters.get('party_type') == 'Shareholder':
|
||||||
party_name_field = 'title'
|
party_name_field = 'title'
|
||||||
@ -96,13 +96,19 @@ def get_data(filters, show_party_name):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def get_opening_balances(filters):
|
def get_opening_balances(filters):
|
||||||
|
|
||||||
|
account_filter = ''
|
||||||
|
if filters.get('account'):
|
||||||
|
account_filter = "and account = %s" % (frappe.db.escape(filters.get('account')))
|
||||||
|
|
||||||
gle = frappe.db.sql("""
|
gle = frappe.db.sql("""
|
||||||
select party, sum(debit) as opening_debit, sum(credit) as opening_credit
|
select party, sum(debit) as opening_debit, sum(credit) as opening_credit
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where company=%(company)s
|
where company=%(company)s
|
||||||
and ifnull(party_type, '') = %(party_type)s and ifnull(party, '') != ''
|
and ifnull(party_type, '') = %(party_type)s and ifnull(party, '') != ''
|
||||||
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
|
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
|
||||||
group by party""", {
|
{account_filter}
|
||||||
|
group by party""".format(account_filter=account_filter), {
|
||||||
"company": filters.company,
|
"company": filters.company,
|
||||||
"from_date": filters.from_date,
|
"from_date": filters.from_date,
|
||||||
"party_type": filters.party_type
|
"party_type": filters.party_type
|
||||||
@ -116,6 +122,11 @@ def get_opening_balances(filters):
|
|||||||
return opening
|
return opening
|
||||||
|
|
||||||
def get_balances_within_period(filters):
|
def get_balances_within_period(filters):
|
||||||
|
|
||||||
|
account_filter = ''
|
||||||
|
if filters.get('account'):
|
||||||
|
account_filter = "and account = %s" % (frappe.db.escape(filters.get('account')))
|
||||||
|
|
||||||
gle = frappe.db.sql("""
|
gle = frappe.db.sql("""
|
||||||
select party, sum(debit) as debit, sum(credit) as credit
|
select party, sum(debit) as debit, sum(credit) as credit
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
@ -123,7 +134,8 @@ def get_balances_within_period(filters):
|
|||||||
and ifnull(party_type, '') = %(party_type)s and ifnull(party, '') != ''
|
and ifnull(party_type, '') = %(party_type)s and ifnull(party, '') != ''
|
||||||
and posting_date >= %(from_date)s and posting_date <= %(to_date)s
|
and posting_date >= %(from_date)s and posting_date <= %(to_date)s
|
||||||
and ifnull(is_opening, 'No') = 'No'
|
and ifnull(is_opening, 'No') = 'No'
|
||||||
group by party""", {
|
{account_filter}
|
||||||
|
group by party""".format(account_filter=account_filter), {
|
||||||
"company": filters.company,
|
"company": filters.company,
|
||||||
"from_date": filters.from_date,
|
"from_date": filters.from_date,
|
||||||
"to_date": filters.to_date,
|
"to_date": filters.to_date,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user