Getting current_asset and current_liabilities from accounting module through server scripts

I have set up multiple accounts in the ErpNext accounting module for different company, now I want to get the current_asset and the current_liabilities in the server script to run some calculation. But I am finding it hard to get the balance. I have tried to filter balance sheet like

report = frappe.get_doc(‘Report’, ‘Balance Sheet’)
report_filter =
{ ‘company’: ‘YOUR COMPANY NAME’, ‘from_date’: ‘01/01/2021’, ‘to_date’: ‘12/12/2022’}

report_data = report.get_data(filters=report_filter)

but I am getting the error “From Date and To Date are mandatory”

Would be very helpful if someone provides a solution

Use these two function

from erpnext.accounts.report.financial_statements import get_data, get_period_list

Update the passing args accordingly

#get the period list with passing parameters
period_list = get_period_list(
		from_fiscal_year=fiscal_year,
		to_fiscal_year=fiscal_year,
		period_start_date=from_date,
		period_end_date=to_date,
		filter_based_on="Date Range",
		periodicity="Monthly",
		company=filters.get("company"),
	)
#getting all accounts that have the root type Expense with account balance according to the period
expense = get_data(
		filters.company,
		"Expense",
		"Debit",
		period_list,
		filters=filters,
		accumulated_values=filters.accumulated_values,
		ignore_closing_entries=True,
		ignore_accumulated_values_for_fy=True,
	)