mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 05:59:18 +00:00
Merge pull request #55081 from frappe/mergify/bp/version-15/pr-55072
perf: faster opening balance range calculation in process period closing voucher (backport #55072)
This commit is contained in:
@@ -69,8 +69,8 @@ class ProcessPeriodClosingVoucher(Document):
|
|||||||
pcv = frappe.get_doc("Period Closing Voucher", self.parent_pcv)
|
pcv = frappe.get_doc("Period Closing Voucher", self.parent_pcv)
|
||||||
if pcv.is_first_period_closing_voucher():
|
if pcv.is_first_period_closing_voucher():
|
||||||
gl = qb.DocType("GL Entry")
|
gl = qb.DocType("GL Entry")
|
||||||
min = qb.from_(gl).select(Min(gl.posting_date)).where(gl.company.eq(pcv.company)).run()[0][0]
|
min = qb.from_(gl).select(Min(gl.posting_date)).run()[0][0]
|
||||||
max = qb.from_(gl).select(Max(gl.posting_date)).where(gl.company.eq(pcv.company)).run()[0][0]
|
max = qb.from_(gl).select(Max(gl.posting_date)).run()[0][0]
|
||||||
|
|
||||||
dates = self.get_dates(get_datetime(min), get_datetime(max))
|
dates = self.get_dates(get_datetime(min), get_datetime(max))
|
||||||
for x in dates:
|
for x in dates:
|
||||||
@@ -90,12 +90,16 @@ class ProcessPeriodClosingVoucher(Document):
|
|||||||
def start_pcv_processing(docname: str):
|
def start_pcv_processing(docname: str):
|
||||||
if frappe.db.get_value("Process Period Closing Voucher", docname, "status") in ["Queued", "Running"]:
|
if frappe.db.get_value("Process Period Closing Voucher", docname, "status") in ["Queued", "Running"]:
|
||||||
frappe.db.set_value("Process Period Closing Voucher", docname, "status", "Running")
|
frappe.db.set_value("Process Period Closing Voucher", docname, "status", "Running")
|
||||||
if normal_balances := frappe.db.get_all(
|
|
||||||
"Process Period Closing Voucher Detail",
|
ppcvd = qb.DocType("Process Period Closing Voucher Detail")
|
||||||
filters={"parent": docname, "status": "Queued"},
|
if normal_balances := (
|
||||||
fields=["processing_date", "report_type", "parentfield"],
|
qb.from_(ppcvd)
|
||||||
order_by="parentfield, idx, processing_date",
|
.select(ppcvd.processing_date, ppcvd.report_type, ppcvd.parentfield)
|
||||||
limit=4,
|
.where(ppcvd.parent.eq(docname) & ppcvd.status.eq("Queued"))
|
||||||
|
.orderby(ppcvd.parentfield, ppcvd.idx, ppcvd.processing_date)
|
||||||
|
.limit(4)
|
||||||
|
.for_update(skip_locked=True)
|
||||||
|
.run(as_dict=True)
|
||||||
):
|
):
|
||||||
if not is_scheduler_inactive():
|
if not is_scheduler_inactive():
|
||||||
for x in normal_balances:
|
for x in normal_balances:
|
||||||
@@ -235,12 +239,15 @@ def get_gle_for_closing_account(pcv, dimension_balance, dimensions):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def schedule_next_date(docname: str):
|
def schedule_next_date(docname: str):
|
||||||
if to_process := frappe.db.get_all(
|
ppcvd = qb.DocType("Process Period Closing Voucher Detail")
|
||||||
"Process Period Closing Voucher Detail",
|
if to_process := (
|
||||||
filters={"parent": docname, "status": "Queued"},
|
qb.from_(ppcvd)
|
||||||
fields=["processing_date", "report_type", "parentfield"],
|
.select(ppcvd.processing_date, ppcvd.report_type, ppcvd.parentfield)
|
||||||
order_by="parentfield, idx, processing_date",
|
.where(ppcvd.parent.eq(docname) & ppcvd.status.eq("Queued"))
|
||||||
limit=1,
|
.orderby(ppcvd.parentfield, ppcvd.idx, ppcvd.processing_date)
|
||||||
|
.limit(1)
|
||||||
|
.for_update(skip_locked=True)
|
||||||
|
.run(as_dict=True)
|
||||||
):
|
):
|
||||||
if not is_scheduler_inactive():
|
if not is_scheduler_inactive():
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
|
|||||||
Reference in New Issue
Block a user