mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Merge pull request #48862 from khushi8112/show-party-name-in-reports
feat: show party name in reports
This commit is contained in:
@@ -209,6 +209,12 @@ def get_gl_entries(filters, accounting_dimensions):
|
|||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
party_name_map = get_party_name_map()
|
||||||
|
|
||||||
|
for gl_entry in gl_entries:
|
||||||
|
if gl_entry.party_type and gl_entry.party:
|
||||||
|
gl_entry.party_name = party_name_map.get(gl_entry.party_type, {}).get(gl_entry.party)
|
||||||
|
|
||||||
if filters.get("presentation_currency"):
|
if filters.get("presentation_currency"):
|
||||||
return convert_to_presentation_currency(gl_entries, currency_map, filters)
|
return convert_to_presentation_currency(gl_entries, currency_map, filters)
|
||||||
else:
|
else:
|
||||||
@@ -341,6 +347,20 @@ def get_conditions(filters):
|
|||||||
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
||||||
|
|
||||||
|
|
||||||
|
def get_party_name_map():
|
||||||
|
party_map = {}
|
||||||
|
|
||||||
|
customers = frappe.get_all("Customer", fields=["name", "customer_name"])
|
||||||
|
party_map["Customer"] = {c.name: c.customer_name for c in customers}
|
||||||
|
|
||||||
|
suppliers = frappe.get_all("Supplier", fields=["name", "supplier_name"])
|
||||||
|
party_map["Supplier"] = {s.name: s.supplier_name for s in suppliers}
|
||||||
|
|
||||||
|
employees = frappe.get_all("Employee", fields=["name", "employee_name"])
|
||||||
|
party_map["Employee"] = {e.name: e.employee_name for e in employees}
|
||||||
|
return party_map
|
||||||
|
|
||||||
|
|
||||||
def get_accounts_with_children(accounts):
|
def get_accounts_with_children(accounts):
|
||||||
if not isinstance(accounts, list):
|
if not isinstance(accounts, list):
|
||||||
accounts = [d.strip() for d in accounts.strip().split(",") if d]
|
accounts = [d.strip() for d in accounts.strip().split(",") if d]
|
||||||
@@ -723,6 +743,19 @@ def get_columns(filters):
|
|||||||
{"label": _("Party"), "fieldname": "party", "width": 100},
|
{"label": _("Party"), "fieldname": "party", "width": 100},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
supplier_master_name = frappe.db.get_single_value("Buying Settings", "supp_master_name")
|
||||||
|
customer_master_name = frappe.db.get_single_value("Selling Settings", "cust_master_name")
|
||||||
|
|
||||||
|
if supplier_master_name != "Supplier Name" or customer_master_name != "Customer Name":
|
||||||
|
columns.append(
|
||||||
|
{
|
||||||
|
"label": _("Party Name"),
|
||||||
|
"fieldname": "party_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 150,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if filters.get("include_dimensions"):
|
if filters.get("include_dimensions"):
|
||||||
columns.append({"label": _("Project"), "options": "Project", "fieldname": "project", "width": 100})
|
columns.append({"label": _("Project"), "options": "Project", "fieldname": "project", "width": 100})
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def execute(filters=None):
|
|||||||
"invoice_or_item",
|
"invoice_or_item",
|
||||||
"customer",
|
"customer",
|
||||||
"customer_group",
|
"customer_group",
|
||||||
|
"customer_name",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"item_code",
|
"item_code",
|
||||||
"item_name",
|
"item_name",
|
||||||
@@ -95,6 +96,7 @@ def execute(filters=None):
|
|||||||
"customer": [
|
"customer": [
|
||||||
"customer",
|
"customer",
|
||||||
"customer_group",
|
"customer_group",
|
||||||
|
"customer_name",
|
||||||
"qty",
|
"qty",
|
||||||
"base_rate",
|
"base_rate",
|
||||||
"buying_rate",
|
"buying_rate",
|
||||||
@@ -250,6 +252,10 @@ def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_
|
|||||||
|
|
||||||
def get_columns(group_wise_columns, filters):
|
def get_columns(group_wise_columns, filters):
|
||||||
columns = []
|
columns = []
|
||||||
|
|
||||||
|
supplier_master_name = frappe.db.get_single_value("Buying Settings", "supp_master_name")
|
||||||
|
customer_master_name = frappe.db.get_single_value("Selling Settings", "cust_master_name")
|
||||||
|
|
||||||
column_map = frappe._dict(
|
column_map = frappe._dict(
|
||||||
{
|
{
|
||||||
"parent": {
|
"parent": {
|
||||||
@@ -395,6 +401,12 @@ def get_columns(group_wise_columns, filters):
|
|||||||
"options": "Customer Group",
|
"options": "Customer Group",
|
||||||
"width": 100,
|
"width": 100,
|
||||||
},
|
},
|
||||||
|
"customer_name": {
|
||||||
|
"label": _("Customer Name"),
|
||||||
|
"fieldname": "customer_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 150,
|
||||||
|
},
|
||||||
"territory": {
|
"territory": {
|
||||||
"label": _("Territory"),
|
"label": _("Territory"),
|
||||||
"fieldname": "territory",
|
"fieldname": "territory",
|
||||||
@@ -419,6 +431,10 @@ def get_columns(group_wise_columns, filters):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for col in group_wise_columns.get(scrub(filters.group_by)):
|
for col in group_wise_columns.get(scrub(filters.group_by)):
|
||||||
|
if col == "customer_name" and (
|
||||||
|
supplier_master_name == "Supplier Name" and customer_master_name == "Customer Name"
|
||||||
|
):
|
||||||
|
continue
|
||||||
columns.append(column_map.get(col))
|
columns.append(column_map.get(col))
|
||||||
|
|
||||||
columns.append(
|
columns.append(
|
||||||
@@ -440,6 +456,7 @@ def get_column_names():
|
|||||||
"invoice_or_item": "sales_invoice",
|
"invoice_or_item": "sales_invoice",
|
||||||
"customer": "customer",
|
"customer": "customer",
|
||||||
"customer_group": "customer_group",
|
"customer_group": "customer_group",
|
||||||
|
"customer_name": "customer_name",
|
||||||
"posting_date": "posting_date",
|
"posting_date": "posting_date",
|
||||||
"item_code": "item_code",
|
"item_code": "item_code",
|
||||||
"item_name": "item_name",
|
"item_name": "item_name",
|
||||||
@@ -905,7 +922,7 @@ class GrossProfitGenerator:
|
|||||||
`tabSales Invoice Item`.parenttype, `tabSales Invoice Item`.parent,
|
`tabSales Invoice Item`.parenttype, `tabSales Invoice Item`.parent,
|
||||||
`tabSales Invoice`.posting_date, `tabSales Invoice`.posting_time,
|
`tabSales Invoice`.posting_date, `tabSales Invoice`.posting_time,
|
||||||
`tabSales Invoice`.project, `tabSales Invoice`.update_stock,
|
`tabSales Invoice`.project, `tabSales Invoice`.update_stock,
|
||||||
`tabSales Invoice`.customer, `tabSales Invoice`.customer_group,
|
`tabSales Invoice`.customer, `tabSales Invoice`.customer_group, `tabSales Invoice`.customer_name,
|
||||||
`tabSales Invoice`.territory, `tabSales Invoice Item`.item_code,
|
`tabSales Invoice`.territory, `tabSales Invoice Item`.item_code,
|
||||||
`tabSales Invoice`.base_net_total as "invoice_base_net_total",
|
`tabSales Invoice`.base_net_total as "invoice_base_net_total",
|
||||||
`tabSales Invoice Item`.item_name, `tabSales Invoice Item`.description,
|
`tabSales Invoice Item`.item_name, `tabSales Invoice Item`.description,
|
||||||
@@ -1003,6 +1020,7 @@ class GrossProfitGenerator:
|
|||||||
"update_stock": row.update_stock,
|
"update_stock": row.update_stock,
|
||||||
"customer": row.customer,
|
"customer": row.customer,
|
||||||
"customer_group": row.customer_group,
|
"customer_group": row.customer_group,
|
||||||
|
"customer_name": row.customer_name,
|
||||||
"item_code": None,
|
"item_code": None,
|
||||||
"item_name": None,
|
"item_name": None,
|
||||||
"description": None,
|
"description": None,
|
||||||
@@ -1032,6 +1050,7 @@ class GrossProfitGenerator:
|
|||||||
"project": row.project,
|
"project": row.project,
|
||||||
"customer": row.customer,
|
"customer": row.customer,
|
||||||
"customer_group": row.customer_group,
|
"customer_group": row.customer_group,
|
||||||
|
"customer_name": row.customer_name,
|
||||||
"item_code": item.item_code,
|
"item_code": item.item_code,
|
||||||
"item_name": item.item_name,
|
"item_name": item.item_name,
|
||||||
"description": item.description,
|
"description": item.description,
|
||||||
|
|||||||
Reference in New Issue
Block a user