mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 18:45:20 +00:00
refactor(postgres): port Cashier Closing doctype queries to the query builder
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.query_builder.functions import Sum
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
|
||||||
@@ -43,13 +44,17 @@ class CashierClosing(Document):
|
|||||||
self.make_calculations()
|
self.make_calculations()
|
||||||
|
|
||||||
def get_outstanding(self):
|
def get_outstanding(self):
|
||||||
values = frappe.db.sql(
|
si = frappe.qb.DocType("Sales Invoice")
|
||||||
"""
|
values = (
|
||||||
select sum(outstanding_amount)
|
frappe.qb.from_(si)
|
||||||
from `tabSales Invoice`
|
.select(Sum(si.outstanding_amount))
|
||||||
where posting_date=%s and posting_time>=%s and posting_time<=%s and owner=%s
|
.where(
|
||||||
""",
|
(si.posting_date == self.date)
|
||||||
(self.date, self.from_time, self.time, self.user),
|
& (si.posting_time >= self.from_time)
|
||||||
|
& (si.posting_time <= self.time)
|
||||||
|
& (si.owner == self.user)
|
||||||
|
)
|
||||||
|
.run()
|
||||||
)
|
)
|
||||||
self.outstanding_amount = flt(values[0][0] if values else 0)
|
self.outstanding_amount = flt(values[0][0] if values else 0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user