From cee9f4949a42ef21847256bf176812771eaa9af6 Mon Sep 17 00:00:00 2001 From: Krishna Pramod Shirsath <91021227+krishna-254@users.noreply.github.com> Date: Tue, 8 Sep 2026 16:52:53 +0530 Subject: [PATCH] fix: show cost center for unmatched payments in receivables (#58453) --- .../accounts_receivable.py | 1 + .../test_accounts_receivable.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 6f5459de03e..96d8c0e71fe 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -171,6 +171,7 @@ class ReceivablePayableReport: party_account=ple.account, posting_date=ple.posting_date, account_currency=ple.account_currency, + cost_center=ple.cost_center, remarks=ple.remarks, invoiced=0.0, paid=0.0, diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index 56f1139e2a2..df6288a38f5 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -1337,6 +1337,28 @@ class TestAccountsReceivable(ERPNextTestSuite, AccountsTestMixin): row = report[1][0] self.assertEqual(expected_data_after_payment, [row.voucher_no, row.cost_center, row.outstanding]) + def test_cost_center_on_payment_before_invoice(self): + filters = { + "company": self.company, + "party_type": "Customer", + "party": [self.customer], + "report_date": today(), + "range": "30, 60, 90, 120", + } + + si = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True) + si.posting_date = add_days(today(), 1) + si.due_date = si.posting_date + si.payment_schedule[0].due_date = si.posting_date + si.save().submit() + + pe = self.create_payment_entry(si.name, do_not_submit=True) + pe.cost_center = self.cost_center + pe.save().submit() + + row = next(row for row in execute(filters)[1] if row.voucher_no == pe.name) + self.assertEqual(row.cost_center, pe.cost_center) + def test_payment_terms_template_filters(self): from erpnext.controllers.accounts_controller import get_payment_terms