Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added a customer name and supplier name columns #37433 issue #37557

Merged
merged 14 commits into from
Nov 12, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def get_columns(filters):
party_type = filters.get("party_type")
party_type_value = get_party_group(party_type)
return [
columns = [

Check warning on line 29 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L29

Added line #L29 was not covered by tests
"{party_type}:Link/{party_type}".format(party_type=party_type),
"{party_value_type}::150".format(party_value_type=frappe.unscrub(str(party_type_value))),
"Address Line 1",
Expand All @@ -43,34 +43,49 @@
"Email Id",
"Is Primary Contact:Check",
]
if filters.get("party_type") == "Supplier" and frappe.db.get_single_value(

Check warning on line 46 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L46

Added line #L46 was not covered by tests
"Buying Settings", "supp_master_name"
) == ["Naming Series", "Auto Name"]:
columns.insert(1, "Supplier Name:Data:150")
if filters.get("party_type") == "Customer" and frappe.db.get_single_value(

Check warning on line 50 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L49-L50

Added lines #L49 - L50 were not covered by tests
"Selling Settings", "cust_master_name"
) == ["Naming Series", "Auto Name"]:
columns.insert(1, "Customer Name:Data:150")
return columns

Check warning on line 54 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L53-L54

Added lines #L53 - L54 were not covered by tests


def get_data(filters):
party_type = filters.get("party_type")
party = filters.get("party_name")
party_group = get_party_group(party_type)

return get_party_addresses_and_contact(party_type, party, party_group)
return get_party_addresses_and_contact(party_type, party, party_group, filters)

Check warning on line 62 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L62

Added line #L62 was not covered by tests


def get_party_addresses_and_contact(party_type, party, party_group):
def get_party_addresses_and_contact(party_type, party, party_group, filters):

Check warning on line 65 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L65

Added line #L65 was not covered by tests
data = []
filters = None
query_filters = None

Check warning on line 67 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L67

Added line #L67 was not covered by tests
party_details = frappe._dict()

if not party_type:
return []

if party:
filters = {"name": party}
query_filters = {"name": party}
if filters.get("party_type") in ["Customer", "Supplier"]:
field = filters.get("party_type").lower() + "_name"

Check warning on line 76 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L74-L76

Added lines #L74 - L76 were not covered by tests
else:
field = "partner_name"

Check warning on line 78 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L78

Added line #L78 was not covered by tests

fetch_party_list = frappe.get_list(
party_type, filters=filters, fields=["name", party_group], as_list=True
party_type, filters=query_filters, fields=["name", party_group, field], as_list=True
)
party_list = [d[0] for d in fetch_party_list]
party_groups = {}
party_name_map = {}

Check warning on line 85 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L85

Added line #L85 was not covered by tests
for d in fetch_party_list:
party_groups[d[0]] = d[1]
party_name_map[d[0]] = d[2]

Check warning on line 88 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L88

Added line #L88 was not covered by tests

for d in party_list:
party_details.setdefault(d, frappe._dict())
Expand All @@ -84,6 +99,8 @@
if not any([addresses, contacts]):
result = [party]
result.append(party_groups[party])
if filters.get("party_type") in ["Customer", "Supplier"]:
result.append(party_name_map[party])

Check warning on line 103 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L102-L103

Added lines #L102 - L103 were not covered by tests
result.extend(add_blank_columns_for("Contact"))
result.extend(add_blank_columns_for("Address"))
data.append(result)
Expand All @@ -95,11 +112,12 @@
for idx in range(0, max_length):
result = [party]
result.append(party_groups[party])
if filters.get("party_type") in ["Customer", "Supplier"]:
result.append(party_name_map[party])

Check warning on line 116 in erpnext/selling/report/address_and_contacts/address_and_contacts.py

View check run for this annotation

Codecov / codecov/patch

erpnext/selling/report/address_and_contacts/address_and_contacts.py#L115-L116

Added lines #L115 - L116 were not covered by tests
address = addresses[idx] if idx < len(addresses) else add_blank_columns_for("Address")
contact = contacts[idx] if idx < len(contacts) else add_blank_columns_for("Contact")
result.extend(address)
result.extend(contact)

data.append(result)
return data

Expand All @@ -115,7 +133,6 @@
for d in records:
details = party_details.get(d[0])
details.setdefault(frappe.scrub(doctype), []).append(d[1:])

return party_details


Expand Down
Loading