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) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-18 21:29:00 +05:30
parent d8a2f53a29
commit e7b135b51e
2 changed files with 2 additions and 1 deletions

View File

@@ -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"),
)
)

View File

@@ -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: