fix: Handle frozen books while handling
diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py
index 568ce6b..9e2cdff 100644
--- a/erpnext/accounts/deferred_revenue.py
+++ b/erpnext/accounts/deferred_revenue.py
@@ -254,6 +254,8 @@
 	enable_check = "enable_deferred_revenue" \
 		if doc.doctype=="Sales Invoice" else "enable_deferred_expense"
 
+	accounts_frozen_upto = frappe.get_cached_value('Accounts Settings', 'None', 'acc_frozen_upto')
+
 	def _book_deferred_revenue_or_expense(item, via_journal_entry, submit_journal_entry, book_deferred_entries_based_on):
 		start_date, end_date, last_gl_entry = get_booking_dates(doc, item, posting_date=posting_date)
 		if not (start_date and end_date): return
@@ -279,6 +281,10 @@
 		if not amount:
 			return
 
+		# check if books nor frozen till endate:
+		if getdate(end_date) >= getdate(accounts_frozen_upto):
+			end_date = get_last_day(add_days(accounts_frozen_upto, 1))
+
 		if via_journal_entry:
 			book_revenue_via_journal_entry(doc, credit_account, debit_account, against, amount,
 				base_amount, end_date, project, account_currency, item.cost_center, item, deferred_process, submit_journal_entry)
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 3fd6db8..f119e11 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -2509,6 +2509,9 @@
 		si.save()
 		si.submit()
 
+		acc_settings.acc_frozen_upto = '2019-01-31'
+		acc_settings.save()
+
 		pda1 = frappe.get_doc(dict(
 			doctype='Process Deferred Accounting',
 			posting_date=nowdate(),
@@ -2522,8 +2525,8 @@
 		pda1.submit()
 
 		expected_gle = [
-			["Sales - _TC", 0.0, 2089.89, "2019-01-31"],
-			[deferred_account, 2089.89, 0.0, "2019-01-31"],
+			["Sales - _TC", 0.0, 2089.89, "2019-01-28"],
+			[deferred_account, 2089.89, 0.0, "2019-01-28"],
 			["Sales - _TC", 0.0, 1887.64, "2019-02-28"],
 			[deferred_account, 1887.64, 0.0, "2019-02-28"],
 			["Sales - _TC", 0.0, 2022.47, "2019-03-15"],
@@ -2544,6 +2547,7 @@
 		acc_settings = frappe.get_doc('Accounts Settings', 'Accounts Settings')
 		acc_settings.book_deferred_entries_via_journal_entry = 0
 		acc_settings.submit_journal_entriessubmit_journal_entries = 0
+		acc_settings.acc_frozen_upto = None
 		acc_settings.save()
 
 def get_sales_invoice_for_e_invoice():
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index eab9e12..4775f56 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -185,8 +185,6 @@
 					frappe.throw(_("Row #{0}: Service Start Date cannot be greater than Service End Date").format(d.idx))
 				elif getdate(self.posting_date) > getdate(d.service_end_date):
 					frappe.throw(_("Row #{0}: Service End Date cannot be before Invoice Posting Date").format(d.idx))
-				elif getdate(self.posting_date) > getdate(d.service_start_date):
-					frappe.throw(_("Row #{0}: Service Start Date cannot be before Invoice Posting Date").format(d.idx))
 
 	def validate_invoice_documents_schedule(self):
 		self.validate_payment_schedule_dates()