mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-31 10:52:41 +02:00
perf: check PCV (smaller) table before checking GL Entries
(cherry picked from commit 4d3ddeae8d)
This commit is contained in:
@@ -75,6 +75,17 @@ class PeriodClosingVoucher(AccountsController):
|
|||||||
return
|
return
|
||||||
|
|
||||||
previous_fiscal_year_start_date = previous_fiscal_year[0][1]
|
previous_fiscal_year_start_date = previous_fiscal_year[0][1]
|
||||||
|
previous_fiscal_year_closed = frappe.db.exists(
|
||||||
|
"Period Closing Voucher",
|
||||||
|
{
|
||||||
|
"period_end_date": ("between", [previous_fiscal_year_start_date, last_year_closing]),
|
||||||
|
"docstatus": 1,
|
||||||
|
"company": self.company,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if previous_fiscal_year_closed:
|
||||||
|
return
|
||||||
|
|
||||||
gle_exists_in_previous_year = frappe.db.exists(
|
gle_exists_in_previous_year = frappe.db.exists(
|
||||||
"GL Entry",
|
"GL Entry",
|
||||||
{
|
{
|
||||||
@@ -86,15 +97,6 @@ class PeriodClosingVoucher(AccountsController):
|
|||||||
if not gle_exists_in_previous_year:
|
if not gle_exists_in_previous_year:
|
||||||
return
|
return
|
||||||
|
|
||||||
previous_fiscal_year_closed = frappe.db.exists(
|
|
||||||
"Period Closing Voucher",
|
|
||||||
{
|
|
||||||
"period_end_date": ("between", [previous_fiscal_year_start_date, last_year_closing]),
|
|
||||||
"docstatus": 1,
|
|
||||||
"company": self.company,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if not previous_fiscal_year_closed:
|
|
||||||
frappe.throw(_("Previous Year is not closed, please close it first"))
|
frappe.throw(_("Previous Year is not closed, please close it first"))
|
||||||
|
|
||||||
def block_if_future_closing_voucher_exists(self):
|
def block_if_future_closing_voucher_exists(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user