Skip to content

Commit

Permalink
fix: Fiscal Year exception on demo data setup
Browse files Browse the repository at this point in the history
(cherry picked from commit 3c3c57c)
  • Loading branch information
ruthra-kumar authored and mergify[bot] committed Feb 25, 2024
1 parent 383dfdd commit 56ee843
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion erpnext/setup/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ def create_demo_record(doctype):

def make_transactions(company):
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
start_date = get_fiscal_year(date=getdate())[1]
from erpnext.accounts.utils import FiscalYearError

try:
start_date = get_fiscal_year(date=getdate())[1]
except FiscalYearError:
# User might have setup fiscal year for previous or upcoming years
active_fiscal_years = frappe.db.get_all("Fiscal Year", filters={"disabled": 0}, as_list=1)
if active_fiscal_years:
start_date = frappe.db.get_value("Fiscal Year", active_fiscal_years[0][0], "year_start_date")
else:
frappe.throw(_("There are no active Fiscal Years for which Demo Data can be generated."))

for doctype in frappe.get_hooks("demo_transaction_doctypes"):
data = read_data_file_using_hooks(doctype)
Expand Down Expand Up @@ -159,6 +169,7 @@ def convert_order_to_invoices():

if i % 2 != 0:
payment = get_payment_entry(invoice.doctype, invoice.name)
payment.posting_date = order.transaction_date
payment.reference_no = invoice.name
payment.submit()

Expand Down

0 comments on commit 56ee843

Please sign in to comment.