From e7b135b51e259ab329cf2f66137e8f309a4959e8 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 18 Jun 2026 21:29:00 +0530 Subject: [PATCH] fix(postgres): aggregate bare account in pos_closing payments; explicit limit on gl-entry fetch Address review (#56111): - pos_closing get_payments grouped by mode_of_payment but selected a bare account -> Postgres GroupingError. Wrap in Max() (deterministic, both engines agree; account is consumed downstream for the change-amount adjustment). test_pos_closing_entry 9/9 both engines. - get_voucherwise_gl_entries: add limit=0 to make the unbounded fetch explicit. Co-Authored-By: Claude Opus 4.8 (1M context) --- erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py | 2 +- erpnext/accounts/utils.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py index fff99369ef0..f697b0ab0af 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py @@ -295,7 +295,7 @@ def get_payments(invoices): .groupby(SalesInvoicePayment.mode_of_payment) .select( SalesInvoicePayment.mode_of_payment, - SalesInvoicePayment.account.as_("account"), + fn.Max(SalesInvoicePayment.account).as_("account"), fn.Sum(SalesInvoicePayment.amount).as_("amount"), ) ) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index d9974cf8c71..beabadda2bf 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -1835,6 +1835,7 @@ def get_voucherwise_gl_entries(future_stock_vouchers, posting_date): "GL Entry", filters={"posting_date": [">=", posting_date], "voucher_no": ["in", voucher_nos]}, fields=["name", "account", "credit", "debit", "cost_center", "project", "voucher_type", "voucher_no"], + limit=0, ) for d in gles: