From 56f03aee027486897a4ed4e327473bf957895112 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Mon, 17 Nov 2025 13:42:43 +0530 Subject: [PATCH 1/3] fix(ledger-summary-report): show party group and territory (cherry picked from commit 231479a6e2e6b8ca97d4c58036c6ac4755c83c63) # Conflicts: # erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py --- .../customer_ledger_summary.py | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py index 6f5fe349dd2..5b669ba5826 100644 --- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py @@ -69,12 +69,18 @@ class PartyLedgerSummaryReport: party_type = self.filters.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) - query = ( - qb.from_(doctype) - .select(doctype.name.as_("party"), f"{scrub(party_type)}_name") - .where(Criterion.all(conditions)) - ) + query = qb.from_(doctype).select(*party_details_fields).where(Criterion.all(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" + 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 += [ { "label": _("Opening Balance"), @@ -213,6 +244,7 @@ class PartyLedgerSummaryReport: }, ] +<<<<<<< HEAD # Hidden columns for handling 'User Permissions' if self.filters.party_type == "Customer": columns += [ @@ -242,6 +274,9 @@ class PartyLedgerSummaryReport: } ] +======= + columns.append({"label": _("Dr/Cr"), "fieldname": "dr_or_cr", "fieldtype": "Data", "width": 100}) +>>>>>>> 231479a6e2 (fix(ledger-summary-report): show party group and territory) return columns def get_data(self): From 56cf5382f0285c27482f9d67306d1dac2766c407 Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 18 Nov 2025 13:42:45 +0530 Subject: [PATCH 2/3] test: add party_group, territory in json (cherry picked from commit 8f91919933e5c7ada6e10152e98d9fbcd57c9b63) # Conflicts: # erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py --- .../test_customer_ledger_summary.py | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py index ca9c62dac6c..2c91717eabc 100644 --- a/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py @@ -151,6 +151,96 @@ class TestCustomerLedgerSummary(FrappeTestCase, AccountsTestMixin): with self.subTest(field=field): self.assertEqual(report[0].get(field), expected_after_cr_and_payment.get(field)) +<<<<<<< HEAD +======= + def test_customer_ledger_ignore_cr_dr_filter(self): + si = create_sales_invoice() + + cr_note = make_return_doc(si.doctype, si.name) + cr_note.submit() + + pr = frappe.get_doc("Payment Reconciliation") + pr.company = si.company + pr.party_type = "Customer" + pr.party = si.customer + pr.receivable_payable_account = si.debit_to + + pr.get_unreconciled_entries() + + invoices = [invoice.as_dict() for invoice in pr.invoices if invoice.invoice_number == si.name] + payments = [payment.as_dict() for payment in pr.payments if payment.reference_name == cr_note.name] + pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments})) + pr.reconcile() + + system_generated_journal = frappe.db.get_all( + "Journal Entry", + filters={ + "docstatus": 1, + "reference_type": si.doctype, + "reference_name": si.name, + "voucher_type": "Credit Note", + "is_system_generated": True, + }, + fields=["name"], + ) + self.assertEqual(len(system_generated_journal), 1) + expected = { + "party": "_Test Customer", + "customer_name": "_Test Customer", + "customer_group": "_Test Customer Group", + "territory": "_Test Territory", + "party_name": "_Test Customer", + "opening_balance": 0, + "invoiced_amount": 100.0, + "paid_amount": 0.0, + "return_amount": 100.0, + "closing_balance": 0.0, + "currency": "INR", + "dr_or_cr": "", + } + # Without ignore_cr_dr_notes + columns, data = execute( + frappe._dict( + { + "company": si.company, + "from_date": si.posting_date, + "to_date": si.posting_date, + "ignore_cr_dr_notes": False, + } + ) + ) + self.assertEqual(len(data), 1) + self.assertDictEqual(expected, data[0]) + + # With ignore_cr_dr_notes + expected = { + "party": "_Test Customer", + "customer_name": "_Test Customer", + "customer_group": "_Test Customer Group", + "territory": "_Test Territory", + "party_name": "_Test Customer", + "opening_balance": 0, + "invoiced_amount": 100.0, + "paid_amount": 0.0, + "return_amount": 100.0, + "closing_balance": 0.0, + "currency": "INR", + "dr_or_cr": "", + } + columns, data = execute( + frappe._dict( + { + "company": si.company, + "from_date": si.posting_date, + "to_date": si.posting_date, + "ignore_cr_dr_notes": True, + } + ) + ) + self.assertEqual(len(data), 1) + self.assertEqual(expected, data[0]) + +>>>>>>> 8f91919933 (test: add party_group, territory in json) def test_journal_voucher_against_return_invoice(self): filters = {"company": self.company, "from_date": today(), "to_date": today()} From 38124a7616aac1a9c8b2ae37b45250fea3cd9234 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 25 Nov 2025 12:01:37 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../customer_ledger_summary.py | 33 ------- .../test_customer_ledger_summary.py | 90 ------------------- 2 files changed, 123 deletions(-) diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py index 5b669ba5826..e56081280ef 100644 --- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py @@ -244,39 +244,6 @@ class PartyLedgerSummaryReport: }, ] -<<<<<<< HEAD - # 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}) ->>>>>>> 231479a6e2 (fix(ledger-summary-report): show party group and territory) return columns def get_data(self): diff --git a/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py index 2c91717eabc..ca9c62dac6c 100644 --- a/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py +++ b/erpnext/accounts/report/customer_ledger_summary/test_customer_ledger_summary.py @@ -151,96 +151,6 @@ class TestCustomerLedgerSummary(FrappeTestCase, AccountsTestMixin): with self.subTest(field=field): self.assertEqual(report[0].get(field), expected_after_cr_and_payment.get(field)) -<<<<<<< HEAD -======= - def test_customer_ledger_ignore_cr_dr_filter(self): - si = create_sales_invoice() - - cr_note = make_return_doc(si.doctype, si.name) - cr_note.submit() - - pr = frappe.get_doc("Payment Reconciliation") - pr.company = si.company - pr.party_type = "Customer" - pr.party = si.customer - pr.receivable_payable_account = si.debit_to - - pr.get_unreconciled_entries() - - invoices = [invoice.as_dict() for invoice in pr.invoices if invoice.invoice_number == si.name] - payments = [payment.as_dict() for payment in pr.payments if payment.reference_name == cr_note.name] - pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments})) - pr.reconcile() - - system_generated_journal = frappe.db.get_all( - "Journal Entry", - filters={ - "docstatus": 1, - "reference_type": si.doctype, - "reference_name": si.name, - "voucher_type": "Credit Note", - "is_system_generated": True, - }, - fields=["name"], - ) - self.assertEqual(len(system_generated_journal), 1) - expected = { - "party": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "party_name": "_Test Customer", - "opening_balance": 0, - "invoiced_amount": 100.0, - "paid_amount": 0.0, - "return_amount": 100.0, - "closing_balance": 0.0, - "currency": "INR", - "dr_or_cr": "", - } - # Without ignore_cr_dr_notes - columns, data = execute( - frappe._dict( - { - "company": si.company, - "from_date": si.posting_date, - "to_date": si.posting_date, - "ignore_cr_dr_notes": False, - } - ) - ) - self.assertEqual(len(data), 1) - self.assertDictEqual(expected, data[0]) - - # With ignore_cr_dr_notes - expected = { - "party": "_Test Customer", - "customer_name": "_Test Customer", - "customer_group": "_Test Customer Group", - "territory": "_Test Territory", - "party_name": "_Test Customer", - "opening_balance": 0, - "invoiced_amount": 100.0, - "paid_amount": 0.0, - "return_amount": 100.0, - "closing_balance": 0.0, - "currency": "INR", - "dr_or_cr": "", - } - columns, data = execute( - frappe._dict( - { - "company": si.company, - "from_date": si.posting_date, - "to_date": si.posting_date, - "ignore_cr_dr_notes": True, - } - ) - ) - self.assertEqual(len(data), 1) - self.assertEqual(expected, data[0]) - ->>>>>>> 8f91919933 (test: add party_group, territory in json) def test_journal_voucher_against_return_invoice(self): filters = {"company": self.company, "from_date": today(), "to_date": today()}