fix: add multicurrency support in number card and dashboard chart (#31079)
* fix: support display currency in number card * fix: support multi currency for display in dashboard chart * fix: add python files
This commit is contained in:
parent
5731f448c9
commit
561e3727aa
6 changed files with 37 additions and 11 deletions
|
|
@ -33,6 +33,7 @@
|
|||
"time_interval",
|
||||
"timeseries",
|
||||
"type",
|
||||
"currency",
|
||||
"filters_section",
|
||||
"filters_json",
|
||||
"dynamic_filters_section",
|
||||
|
|
@ -286,10 +287,16 @@
|
|||
"fieldtype": "Table",
|
||||
"label": "Roles",
|
||||
"options": "Has Role"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"label": "Currency",
|
||||
"options": "Currency"
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2024-06-03 13:29:57.960271",
|
||||
"modified": "2025-02-01 21:06:05.808591",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Dashboard Chart",
|
||||
|
|
|
|||
|
|
@ -349,6 +349,7 @@ class DashboardChart(Document):
|
|||
chart_name: DF.Data
|
||||
chart_type: DF.Literal["Count", "Sum", "Average", "Group By", "Custom", "Report"]
|
||||
color: DF.Color | None
|
||||
currency: DF.Link | None
|
||||
custom_options: DF.Code | None
|
||||
document_type: DF.Link | None
|
||||
dynamic_filters_json: DF.Code | None
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
"report_field",
|
||||
"report_function",
|
||||
"is_public",
|
||||
"currency",
|
||||
"custom_configuration_section",
|
||||
"filters_config",
|
||||
"stats_section",
|
||||
|
|
@ -200,10 +201,16 @@
|
|||
"fieldtype": "Link",
|
||||
"label": "Parent Document Type",
|
||||
"options": "DocType"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"label": "Currency",
|
||||
"options": "Currency"
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2024-03-23 16:03:32.189147",
|
||||
"modified": "2025-01-28 18:22:27.268239",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Number Card",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class NumberCard(Document):
|
|||
|
||||
aggregate_function_based_on: DF.Literal[None]
|
||||
color: DF.Color | None
|
||||
currency: DF.Link | None
|
||||
document_type: DF.Link | None
|
||||
dynamic_filters_json: DF.Code | None
|
||||
filters_config: DF.Code | None
|
||||
|
|
|
|||
|
|
@ -605,14 +605,20 @@ export default class ChartWidget extends Widget {
|
|||
options = chart_options.options;
|
||||
}
|
||||
|
||||
chart_args.tooltipOptions = {
|
||||
formatTooltipY: (value) =>
|
||||
frappe.format(
|
||||
value,
|
||||
{ fieldtype, options },
|
||||
{ always_show_decimals: true, inline: true }
|
||||
),
|
||||
};
|
||||
if (this.chart_doc.currency) {
|
||||
chart_args.tooltipOptions = {
|
||||
formatTooltipY: (value) => format_currency(value, this.chart_doc.currency),
|
||||
};
|
||||
} else {
|
||||
chart_args.tooltipOptions = {
|
||||
formatTooltipY: (value) =>
|
||||
frappe.format(
|
||||
value,
|
||||
{ fieldtype, options },
|
||||
{ always_show_decimals: true, inline: true }
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (this.chart_doc.type == "Heatmap") {
|
||||
const heatmap_year = parseInt(
|
||||
|
|
|
|||
|
|
@ -220,7 +220,11 @@ export default class NumberCardWidget extends Widget {
|
|||
const default_country = frappe.sys_defaults.country;
|
||||
const shortened_number = frappe.utils.shorten_number(this.number, default_country, 5);
|
||||
let number_parts = shortened_number.split(" ");
|
||||
|
||||
// done to add multicurrency support in number card
|
||||
if (this.card_doc.currency) {
|
||||
this.formatted_number = format_currency(number_parts[0], this.card_doc.currency);
|
||||
return;
|
||||
}
|
||||
const symbol = number_parts[1] || "";
|
||||
number_parts[0] = window.convert_old_to_new_number_format(number_parts[0]);
|
||||
const formatted_number = frappe.format(number_parts[0], df, null, doc);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue