From d23677636dfacb284c57a056454936fb8591566e Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 17 Jun 2026 19:01:38 +0530 Subject: [PATCH] refactor(postgres): port Purchase Invoice GL composer queries to the query builder Co-Authored-By: Claude Opus 4.8 (1M context) --- .../doctype/purchase_invoice/services/gl_composer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/services/gl_composer.py b/erpnext/accounts/doctype/purchase_invoice/services/gl_composer.py index 1c4ea5c9e7f..60f49535cb0 100644 --- a/erpnext/accounts/doctype/purchase_invoice/services/gl_composer.py +++ b/erpnext/accounts/doctype/purchase_invoice/services/gl_composer.py @@ -395,10 +395,14 @@ class PurchaseInvoiceGLComposer(BaseGLComposer): ): # Post reverse entry for Stock-Received-But-Not-Billed if booked in Purchase Receipt if item.purchase_receipt and valuation_tax_accounts: - negative_expense_booked_in_pr = frappe.db.sql( - """select name from `tabGL Entry` - where voucher_type='Purchase Receipt' and voucher_no=%s and account in %s""", - (item.purchase_receipt, valuation_tax_accounts), + negative_expense_booked_in_pr = frappe.get_all( + "GL Entry", + filters={ + "voucher_type": "Purchase Receipt", + "voucher_no": item.purchase_receipt, + "account": ["in", valuation_tax_accounts], + }, + pluck="name", ) (