Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error while loading Financial Ratios report #37613

Merged
merged 1 commit into from
Oct 21, 2023
Merged

fix: error while loading Financial Ratios report #37613

merged 1 commit into from
Oct 21, 2023

Conversation

Vishnu7025
Copy link
Contributor

App Versions

{
	"erpnext": "15.0.0-dev",
	"frappe": "15.0.0-dev"
}

Route

query-report/Financial Ratios

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1682, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 847, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 221, in run
    result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 847, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 81, in generate_report_result
    res = get_report_result(report, filters) or []
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 62, in get_report_result
    res = report.execute_script_report(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 164, in execute_script_report
    res = self.execute_module(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 181, in execute_module
    return frappe.get_attr(method_name)(frappe._dict(filters))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/financial_ratios/financial_ratios.py", line 29, in execute
    data = get_ratios_data(filters, period_list, years)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/financial_ratios/financial_ratios.py", line 113, in get_ratios_data
    add_solvency_ratios(
  File "apps/erpnext/erpnext/accounts/report/financial_ratios/financial_ratios.py", line 180, in add_solvency_ratios
    profit_after_tax = total_income[year] + total_expense[year]
                       ~~~~~~~~~~~~^^^^^^
KeyError: 'mar_2024'

Request Data

{
	"type": "GET",
	"args": {
		"report_name": "Financial Ratios",
		"filters": "{\"company\":\"whani\",\"from_fiscal_year\":\"2023-2024\",\"to_fiscal_year\":\"2023-2024\",\"periodicity\":\"Yearly\",\"period_start_date\":\"2023-04-01\",\"period_end_date\":\"2024-03-31\"}",
		"ignore_prepared_report": false,
		"are_default_filters": true
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.query_report.run",
	"request_id": null
}

Response Data

{
	"exception": "KeyError: 'mar_2024'",
	"exc_type": "KeyError",
	"_exc_source": "erpnext (app)"
}

no-docs

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Oct 20, 2023
@Vishnu7025
Copy link
Contributor Author

@deepeshgarg007

@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #37613 (e9908df) into develop (38ca164) will increase coverage by 0.48%.
Report is 110 commits behind head on develop.
The diff coverage is 76.65%.

@@             Coverage Diff             @@
##           develop   #37613      +/-   ##
===========================================
+ Coverage    66.86%   67.35%   +0.48%     
===========================================
  Files          791      757      -34     
  Lines        62519    60132    -2387     
===========================================
- Hits         41805    40503    -1302     
+ Misses       20714    19629    -1085     
Files Coverage Δ
...account_closing_balance/account_closing_balance.py 97.91% <100.00%> (+4.29%) ⬆️
...xt/accounts/doctype/payment_entry/payment_entry.py 83.77% <100.00%> (+0.08%) ⬆️
...ounts/doctype/purchase_invoice/purchase_invoice.py 83.97% <100.00%> (+0.02%) ⬆️
...xt/accounts/doctype/sales_invoice/sales_invoice.py 83.88% <100.00%> (-0.08%) ⬇️
...nts/doctype/subscription_plan/subscription_plan.py 40.47% <ø> (ø)
erpnext/accounts/doctype/tax_rule/tax_rule.py 93.10% <100.00%> (+1.36%) ⬆️
.../report/accounts_receivable/accounts_receivable.py 90.56% <100.00%> (ø)
...omparison/general_and_payment_ledger_comparison.py 100.00% <100.00%> (ø)
erpnext/controllers/selling_controller.py 80.75% <100.00%> (ø)
erpnext/erpnext_integrations/utils.py 0.00% <ø> (-42.23%) ⬇️
... and 36 more

... and 13 files with indirect coverage changes

@deepeshgarg007 deepeshgarg007 merged commit 35020a9 into frappe:develop Oct 21, 2023
12 of 13 checks passed
@GursheenK
Copy link
Member

@RitvikSardana The changes didn't get backported ig. Similar issue #39081 in v15.

@ruthra-kumar
Copy link
Member

@mergify backport version-15-hotfix

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-15-hotfix needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants