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: show chart tool tip in report currency (backport #43308) #43337

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions erpnext/accounts/report/balance_sheet/balance_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def execute(filters=None):
filters.periodicity, period_list, filters.accumulated_values, company=filters.company
)

chart = get_chart_data(filters, columns, asset, liability, equity)
chart = get_chart_data(filters, columns, asset, liability, equity, currency)

report_summary, primitive_summary = get_report_summary(
period_list, asset, liability, equity, provisional_profit_loss, currency, filters
Expand Down Expand Up @@ -219,7 +219,7 @@ def get_report_summary(
], (net_asset - net_liability + net_equity)


def get_chart_data(filters, columns, asset, liability, equity):
def get_chart_data(filters, columns, asset, liability, equity, currency):
labels = [d.get("label") for d in columns[2:]]

asset_data, liability_data, equity_data = [], [], []
Expand Down Expand Up @@ -247,4 +247,8 @@ def get_chart_data(filters, columns, asset, liability, equity):
else:
chart["type"] = "line"

chart["fieldtype"] = "Currency"
chart["options"] = "currency"
chart["currency"] = currency

return chart
6 changes: 4 additions & 2 deletions erpnext/accounts/report/cash_flow/cash_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def execute(filters=None):
)
columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)

chart = get_chart_data(columns, data)
chart = get_chart_data(columns, data, company_currency)

report_summary = get_report_summary(summary_data, company_currency)

Expand Down Expand Up @@ -257,7 +257,7 @@ def get_report_summary(summary_data, currency):
return report_summary


def get_chart_data(columns, data):
def get_chart_data(columns, data, currency):
labels = [d.get("label") for d in columns[2:]]
datasets = [
{
Expand All @@ -272,5 +272,7 @@ def get_chart_data(columns, data):
chart = {"data": {"labels": labels, "datasets": datasets}, "type": "bar"}

chart["fieldtype"] = "Currency"
chart["options"] = "currency"
chart["currency"] = currency

return chart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_balance_sheet_data(fiscal_year, companies, columns, filters):
True,
)

chart = get_chart_data(filters, columns, asset, liability, equity)
chart = get_chart_data(filters, columns, asset, liability, equity, company_currency)

return data, message, chart, report_summary

Expand Down Expand Up @@ -178,7 +178,7 @@ def get_profit_loss_data(fiscal_year, companies, columns, filters):
if net_profit_loss:
data.append(net_profit_loss)

chart = get_pl_chart_data(filters, columns, income, expense, net_profit_loss)
chart = get_pl_chart_data(filters, columns, income, expense, net_profit_loss, company_currency)

report_summary, primitive_summary = get_pl_summary(
companies, "", income, expense, net_profit_loss, company_currency, filters, True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def execute(filters=None):

columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)

chart = get_chart_data(filters, columns, income, expense, net_profit_loss)

currency = filters.presentation_currency or frappe.get_cached_value(
"Company", filters.company, "default_currency"
)
chart = get_chart_data(filters, columns, income, expense, net_profit_loss, currency)

report_summary, primitive_summary = get_report_summary(
period_list, filters.periodicity, income, expense, net_profit_loss, currency, filters
)
Expand Down Expand Up @@ -141,7 +141,7 @@ def get_net_profit_loss(income, expense, period_list, company, currency=None, co
return net_profit_loss


def get_chart_data(filters, columns, income, expense, net_profit_loss):
def get_chart_data(filters, columns, income, expense, net_profit_loss, currency):
labels = [d.get("label") for d in columns[2:]]

income_data, expense_data, net_profit = [], [], []
Expand Down Expand Up @@ -170,5 +170,7 @@ def get_chart_data(filters, columns, income, expense, net_profit_loss):
chart["type"] = "line"

chart["fieldtype"] = "Currency"
chart["options"] = "currency"
chart["currency"] = currency

return chart
Loading