From 6607c8bd82a70965d9c2f63bcc08218bf6dd3573 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 26 Feb 2023 16:05:26 +0530 Subject: [PATCH] fix: Order by issue in aggregation query --- erpnext/accounts/doctype/closing_balance/closing_balance.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/closing_balance/closing_balance.py b/erpnext/accounts/doctype/closing_balance/closing_balance.py index 572553d808..d49459d004 100644 --- a/erpnext/accounts/doctype/closing_balance/closing_balance.py +++ b/erpnext/accounts/doctype/closing_balance/closing_balance.py @@ -1,6 +1,8 @@ # Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +from typing import List + import frappe from frappe.model.document import Document @@ -10,7 +12,7 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( class ClosingBalance(Document): - def aggregate_with_last_closing_balance(self, accounting_dimensions): + def aggregate_with_last_closing_balance(self, accounting_dimensions: List[str]): closing_balance = frappe.qb.DocType("Closing Balance") query = ( @@ -24,7 +26,7 @@ class ClosingBalance(Document): for dimension in accounting_dimensions: query = query.where(closing_balance[dimension] == self.get(dimension)) - query.orderby(closing_balance.closing_date, order=frappe.qb.desc).limit(1) + query = query.orderby(closing_balance.closing_date, order=frappe.qb.desc).limit(1) last_closing_balance = query.run(as_dict=1)