From 528ab503f2cd960060c13866220883d0cb2308ef Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 23 Mar 2023 15:32:24 +0530 Subject: [PATCH] fix: Don't validate if no GL Entry exists --- .../doctype/period_closing_voucher/period_closing_voucher.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 831c343071..8f1bf51a2f 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -99,6 +99,11 @@ class PeriodClosingVoucher(AccountsController): previous_fiscal_year = get_fiscal_year(last_year_closing, company=self.company, boolean=True) + if previous_fiscal_year and not frappe.db.exists( + "GL Entry", {"posting_date": ("<=", last_year_closing), "company": self.company} + ): + return + if previous_fiscal_year and not frappe.db.exists( "Period Closing Voucher", {"posting_date": ("<=", last_year_closing), "docstatus": 1, "company": self.company},