mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
Merge pull request #50561 from aerele/hidden-fields-ledger-summary
fix(ledger-summary-report): show party group and territory
This commit is contained in:
@@ -69,12 +69,18 @@ class PartyLedgerSummaryReport:
|
|||||||
party_type = self.filters.party_type
|
party_type = self.filters.party_type
|
||||||
|
|
||||||
doctype = qb.DocType(party_type)
|
doctype = qb.DocType(party_type)
|
||||||
|
|
||||||
|
party_details_fields = [
|
||||||
|
doctype.name.as_("party"),
|
||||||
|
f"{scrub(party_type)}_name",
|
||||||
|
f"{scrub(party_type)}_group",
|
||||||
|
]
|
||||||
|
|
||||||
|
if party_type == "Customer":
|
||||||
|
party_details_fields.append(doctype.territory)
|
||||||
|
|
||||||
conditions = self.get_party_conditions(doctype)
|
conditions = self.get_party_conditions(doctype)
|
||||||
query = (
|
query = qb.from_(doctype).select(*party_details_fields).where(Criterion.all(conditions))
|
||||||
qb.from_(doctype)
|
|
||||||
.select(doctype.name.as_("party"), f"{scrub(party_type)}_name")
|
|
||||||
.where(Criterion.all(conditions))
|
|
||||||
)
|
|
||||||
|
|
||||||
from frappe.desk.reportview import build_match_conditions
|
from frappe.desk.reportview import build_match_conditions
|
||||||
|
|
||||||
@@ -153,6 +159,31 @@ class PartyLedgerSummaryReport:
|
|||||||
|
|
||||||
credit_or_debit_note = "Credit Note" if self.filters.party_type == "Customer" else "Debit Note"
|
credit_or_debit_note = "Credit Note" if self.filters.party_type == "Customer" else "Debit Note"
|
||||||
|
|
||||||
|
if self.filters.party_type == "Customer":
|
||||||
|
columns += [
|
||||||
|
{
|
||||||
|
"label": _("Customer Group"),
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Customer Group",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Territory"),
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Territory",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
columns += [
|
||||||
|
{
|
||||||
|
"label": _("Supplier Group"),
|
||||||
|
"fieldname": "supplier_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Supplier Group",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
columns += [
|
columns += [
|
||||||
{
|
{
|
||||||
"label": _("Opening Balance"),
|
"label": _("Opening Balance"),
|
||||||
@@ -214,35 +245,6 @@ class PartyLedgerSummaryReport:
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
# Hidden columns for handling 'User Permissions'
|
|
||||||
if self.filters.party_type == "Customer":
|
|
||||||
columns += [
|
|
||||||
{
|
|
||||||
"label": _("Territory"),
|
|
||||||
"fieldname": "territory",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Territory",
|
|
||||||
"hidden": 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Customer Group"),
|
|
||||||
"fieldname": "customer_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Customer Group",
|
|
||||||
"hidden": 1,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
columns += [
|
|
||||||
{
|
|
||||||
"label": _("Supplier Group"),
|
|
||||||
"fieldname": "supplier_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Supplier Group",
|
|
||||||
"hidden": 1,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
columns.append({"label": _("Dr/Cr"), "fieldname": "dr_or_cr", "fieldtype": "Data", "width": 100})
|
columns.append({"label": _("Dr/Cr"), "fieldname": "dr_or_cr", "fieldtype": "Data", "width": 100})
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,8 @@ class TestCustomerLedgerSummary(AccountsTestMixin, IntegrationTestCase):
|
|||||||
expected = {
|
expected = {
|
||||||
"party": "_Test Customer",
|
"party": "_Test Customer",
|
||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
|
"customer_group": "_Test Customer Group",
|
||||||
|
"territory": "_Test Territory",
|
||||||
"party_name": "_Test Customer",
|
"party_name": "_Test Customer",
|
||||||
"opening_balance": 0,
|
"opening_balance": 0,
|
||||||
"invoiced_amount": 100.0,
|
"invoiced_amount": 100.0,
|
||||||
@@ -213,6 +215,8 @@ class TestCustomerLedgerSummary(AccountsTestMixin, IntegrationTestCase):
|
|||||||
expected = {
|
expected = {
|
||||||
"party": "_Test Customer",
|
"party": "_Test Customer",
|
||||||
"customer_name": "_Test Customer",
|
"customer_name": "_Test Customer",
|
||||||
|
"customer_group": "_Test Customer Group",
|
||||||
|
"territory": "_Test Territory",
|
||||||
"party_name": "_Test Customer",
|
"party_name": "_Test Customer",
|
||||||
"opening_balance": 0,
|
"opening_balance": 0,
|
||||||
"invoiced_amount": 100.0,
|
"invoiced_amount": 100.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user