ixbrl-viewer 1.4.9__py3-none-any.whl → 1.4.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ixbrl-viewer might be problematic. Click here for more details.
- iXBRLViewerPlugin/_version.py +2 -2
- iXBRLViewerPlugin/iXBRLViewer.py +47 -52
- iXBRLViewerPlugin/viewer/dist/ixbrlviewer.js +1 -1
- iXBRLViewerPlugin/viewer/src/html/inspector.html +2 -2
- iXBRLViewerPlugin/viewer/src/i18n/en/translation.json +1 -1
- iXBRLViewerPlugin/viewer/src/i18n/es/translation.json +1 -1
- iXBRLViewerPlugin/viewer/src/js/aspect.js +1 -1
- iXBRLViewerPlugin/viewer/src/js/aspect.test.js +2 -1
- iXBRLViewerPlugin/viewer/src/js/chart.js +1 -1
- iXBRLViewerPlugin/viewer/src/js/chart.test.js +2 -2
- iXBRLViewerPlugin/viewer/src/js/concept.test.js +2 -2
- iXBRLViewerPlugin/viewer/src/js/fact.js +11 -24
- iXBRLViewerPlugin/viewer/src/js/fact.test.js +6 -11
- iXBRLViewerPlugin/viewer/src/js/factset.test.js +2 -4
- iXBRLViewerPlugin/viewer/src/js/inspector.js +3 -3
- iXBRLViewerPlugin/viewer/src/js/inspector.test.js +2 -3
- iXBRLViewerPlugin/viewer/src/js/outline.test.js +3 -3
- iXBRLViewerPlugin/viewer/src/js/report.js +7 -3
- iXBRLViewerPlugin/viewer/src/js/report.test.js +2 -1
- iXBRLViewerPlugin/viewer/src/js/reportset.test.js +3 -3
- iXBRLViewerPlugin/viewer/src/js/unit.js +15 -33
- iXBRLViewerPlugin/viewer/src/js/unit.test.js +17 -24
- iXBRLViewerPlugin/viewer/src/js/util.js +21 -0
- iXBRLViewerPlugin/viewer/src/js/viewer.js +58 -53
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/METADATA +8 -4
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/RECORD +32 -32
- tests/unit_tests/iXBRLViewerPlugin/test_iXBRLViewer.py +17 -12
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/LICENSE +0 -0
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/NOTICE +0 -0
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/WHEEL +0 -0
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/entry_points.txt +0 -0
- {ixbrl_viewer-1.4.9.dist-info → ixbrl_viewer-1.4.11.dist-info}/top_level.txt +0 -0
|
@@ -169,8 +169,8 @@ See COPYRIGHT.md for copyright information
|
|
|
169
169
|
</div>
|
|
170
170
|
|
|
171
171
|
<div class="filter-info">
|
|
172
|
-
<span id="matching-
|
|
173
|
-
<span data-i18n="inspector.
|
|
172
|
+
<span id="matching-facts-count">?</span>
|
|
173
|
+
<span data-i18n="inspector.matchingFacts"> matching facts(s)</span>
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
</div>
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"highlight": "Highlight",
|
|
48
48
|
"initializing": "Initializing",
|
|
49
49
|
"loadingViewer": "Loading iXBRL Viewer",
|
|
50
|
-
"
|
|
50
|
+
"matchingFacts": " matching facts(s)",
|
|
51
51
|
"namespaces": "Namespaces",
|
|
52
52
|
"narrowerAnchor": "Narrower anchors",
|
|
53
53
|
"negative": "Negative",
|
|
@@ -56,7 +56,7 @@ export class Aspect {
|
|
|
56
56
|
return this._report.getLabel(this._value, rolePrefix) || this._value;
|
|
57
57
|
}
|
|
58
58
|
else if (this._aspect === 'u') {
|
|
59
|
-
return this._report.reportSet.getUnit(this._value).
|
|
59
|
+
return this._report.reportSet.getUnit(this._value).label();
|
|
60
60
|
}
|
|
61
61
|
else if (this._aspect === 'p') {
|
|
62
62
|
const p = new Period(this._value);
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import { Aspect, AspectSet } from "./aspect.js";
|
|
4
4
|
import { ReportSet } from "./reportset.js";
|
|
5
5
|
import { TestInspector } from "./test-utils.js";
|
|
6
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
6
7
|
|
|
7
8
|
const testReportData = {
|
|
8
9
|
"prefixes": {
|
|
9
10
|
"eg": "http://www.example.com",
|
|
10
|
-
"iso4217":
|
|
11
|
+
"iso4217": NAMESPACE_ISO4217
|
|
11
12
|
},
|
|
12
13
|
"facts" : {},
|
|
13
14
|
"concepts": {
|
|
@@ -97,7 +97,7 @@ export class IXBRLChart extends Dialog {
|
|
|
97
97
|
const uv2 = set2av.uniqueValues();
|
|
98
98
|
|
|
99
99
|
const scale = this._chooseMultiplier(facts);
|
|
100
|
-
const yLabel = fact.
|
|
100
|
+
const yLabel = fact.unitLabel() + " " + this._multiplierDescription(scale);
|
|
101
101
|
const labels = [];
|
|
102
102
|
|
|
103
103
|
const dataSets = [];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
|
-
import { Fact } from "./fact.js";
|
|
4
3
|
import { IXBRLChart } from "./chart.js";
|
|
5
4
|
import { ReportSet } from "./reportset.js";
|
|
6
5
|
import { TestInspector } from "./test-utils.js";
|
|
6
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
7
7
|
|
|
8
8
|
var testReportData = {
|
|
9
9
|
"prefixes": {
|
|
10
10
|
"eg": "http://www.example.com",
|
|
11
|
-
"iso4217":
|
|
11
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
12
12
|
"e": "http://example.com/entity",
|
|
13
13
|
},
|
|
14
14
|
"concepts": {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
|
-
import { XBRLReport } from "./report.js";
|
|
4
3
|
import { ReportSet } from "./reportset.js";
|
|
4
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
5
5
|
|
|
6
6
|
const testReportData = {
|
|
7
7
|
"prefixes": {
|
|
8
8
|
"eg": "http://www.example.com",
|
|
9
|
-
"iso4217":
|
|
9
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
10
10
|
"e": "http://example.com/entity",
|
|
11
11
|
},
|
|
12
12
|
"concepts": {
|
|
@@ -78,10 +78,10 @@ export class Fact {
|
|
|
78
78
|
formattedNumber = formatNumber(v, d);
|
|
79
79
|
}
|
|
80
80
|
if (this.isMonetaryValue()) {
|
|
81
|
-
v = this.
|
|
81
|
+
v = this.unitLabel() + " " + formattedNumber;
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
v = formattedNumber + " " + this.
|
|
84
|
+
v = formattedNumber + " " + this.unitLabel();
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
else if (this.isNil()) {
|
|
@@ -108,22 +108,6 @@ export class Fact {
|
|
|
108
108
|
return v;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
/**
|
|
112
|
-
* Returns the qname of the first numerator in the fact's unit
|
|
113
|
-
* @return {String} QName string of a measure
|
|
114
|
-
*/
|
|
115
|
-
measure() {
|
|
116
|
-
return this.unit()?.measure();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Returns a readable label representing the first numerator in the fact's unit
|
|
121
|
-
* @return {String} Label representing measure
|
|
122
|
-
*/
|
|
123
|
-
measureLabel() {
|
|
124
|
-
return this.unit()?.measureLabel() ?? i18next.t("factDetails.noUnit");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
111
|
/**
|
|
128
112
|
* Returns details about this fact's unit
|
|
129
113
|
* @return {Unit} Unit instance
|
|
@@ -139,6 +123,14 @@ export class Fact {
|
|
|
139
123
|
return this._unit;
|
|
140
124
|
}
|
|
141
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Returns a readable label representing the fact's unit
|
|
128
|
+
* @return {String} Label representing unit
|
|
129
|
+
*/
|
|
130
|
+
unitLabel() {
|
|
131
|
+
return this.unit()?.label() ?? i18next.t("factDetails.noUnit");
|
|
132
|
+
}
|
|
133
|
+
|
|
142
134
|
getConceptPrefix() {
|
|
143
135
|
return this.conceptName().split(':')[0];
|
|
144
136
|
}
|
|
@@ -264,17 +256,12 @@ export class Fact {
|
|
|
264
256
|
}
|
|
265
257
|
|
|
266
258
|
getScaleLabel(value, isAccuracy=false) {
|
|
267
|
-
let measure = this.measure() ?? '';
|
|
268
|
-
if (measure) {
|
|
269
|
-
measure = this.report.qname(measure).localname;
|
|
270
|
-
}
|
|
271
259
|
return this.report.getScaleLabel(
|
|
272
260
|
// We use the same table of labels for scale and accuracy,
|
|
273
261
|
// but decimals means "accurate to 10^-N" whereas scale means 10^N,
|
|
274
262
|
// so invert N for accuracy.
|
|
275
263
|
isAccuracy ? -value : value,
|
|
276
|
-
this.
|
|
277
|
-
measure
|
|
264
|
+
this.unit()
|
|
278
265
|
);
|
|
279
266
|
}
|
|
280
267
|
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import { Fact } from "./fact.js";
|
|
4
4
|
import { ReportSet } from "./reportset.js";
|
|
5
5
|
import { TestInspector } from "./test-utils.js";
|
|
6
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
6
7
|
|
|
7
8
|
var testReportData = {
|
|
8
9
|
"prefixes": {
|
|
9
10
|
"eg": "http://www.example.com",
|
|
10
|
-
"iso4217":
|
|
11
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
11
12
|
"e": "http://example.com/entity",
|
|
12
13
|
},
|
|
13
14
|
"concepts": {
|
|
@@ -108,7 +109,6 @@ describe("Simple fact properties", () => {
|
|
|
108
109
|
expect(f.isMonetaryValue()).toBeTruthy();
|
|
109
110
|
expect(f.readableValue()).toEqual("US $ 1,000");
|
|
110
111
|
expect(f.unit().value()).toEqual("iso4217:USD");
|
|
111
|
-
expect(f.measure()).toEqual("iso4217:USD");
|
|
112
112
|
expect(f.conceptQName().prefix).toEqual("eg");
|
|
113
113
|
expect(f.conceptQName().localname).toEqual("Concept1");
|
|
114
114
|
expect(f.conceptQName().namespace).toEqual("http://www.example.com");
|
|
@@ -128,9 +128,8 @@ describe("Simple fact properties", () => {
|
|
|
128
128
|
expect(f.isNumeric()).toBeTruthy();
|
|
129
129
|
expect(f.decimals()).toEqual(-3);
|
|
130
130
|
expect(f.isMonetaryValue()).toBeFalsy();
|
|
131
|
-
expect(f.readableValue()).toEqual("1,000
|
|
131
|
+
expect(f.readableValue()).toEqual("1,000 USD");
|
|
132
132
|
expect(f.unit().value()).toEqual("eg:USD");
|
|
133
|
-
expect(f.measure()).toEqual("eg:USD");
|
|
134
133
|
expect(f.conceptQName().prefix).toEqual("eg");
|
|
135
134
|
expect(f.conceptQName().localname).toEqual("Concept1");
|
|
136
135
|
expect(f.conceptQName().namespace).toEqual("http://www.example.com");
|
|
@@ -149,9 +148,8 @@ describe("Simple fact properties", () => {
|
|
|
149
148
|
expect(f.decimals()).toBeUndefined();
|
|
150
149
|
expect(f.isNumeric()).toBeTruthy();
|
|
151
150
|
expect(f.isMonetaryValue()).toBeFalsy();
|
|
152
|
-
expect(f.readableValue()).toEqual("1,000,000.0125
|
|
151
|
+
expect(f.readableValue()).toEqual("1,000,000.0125 USD");
|
|
153
152
|
expect(f.unit().value()).toEqual("eg:USD");
|
|
154
|
-
expect(f.measure()).toEqual("eg:USD");
|
|
155
153
|
expect(f.conceptQName().prefix).toEqual("eg");
|
|
156
154
|
expect(f.conceptQName().localname).toEqual("Concept1");
|
|
157
155
|
expect(f.conceptQName().namespace).toEqual("http://www.example.com");
|
|
@@ -539,7 +537,7 @@ describe("Readable value", () => {
|
|
|
539
537
|
test("Other numeric", () => {
|
|
540
538
|
|
|
541
539
|
expect(testFact({ "v": "10", d: -2, a: { u: "xbrli:foo" } }).readableValue())
|
|
542
|
-
.toBe("10
|
|
540
|
+
.toBe("10 foo");
|
|
543
541
|
|
|
544
542
|
});
|
|
545
543
|
|
|
@@ -635,8 +633,7 @@ describe("Unit aspect handling", () => {
|
|
|
635
633
|
expect(f.isNumeric()).toBeTruthy();
|
|
636
634
|
expect(f.isMonetaryValue()).toBeFalsy();
|
|
637
635
|
expect(f.unit()).toBeUndefined();
|
|
638
|
-
expect(f.
|
|
639
|
-
expect(f.measureLabel()).toBe("<NOUNIT>");
|
|
636
|
+
expect(f.unitLabel()).toBe("<NOUNIT>");
|
|
640
637
|
});
|
|
641
638
|
|
|
642
639
|
test("Non-numeric, no unit", () => {
|
|
@@ -647,7 +644,6 @@ describe("Unit aspect handling", () => {
|
|
|
647
644
|
});
|
|
648
645
|
expect(f.isNumeric()).toBeFalsy();
|
|
649
646
|
expect(f.unit()).toBeUndefined();
|
|
650
|
-
expect(f.measure()).toBeUndefined();
|
|
651
647
|
});
|
|
652
648
|
});
|
|
653
649
|
|
|
@@ -707,7 +703,6 @@ describe("Fact errors", () => {
|
|
|
707
703
|
expect(f.isMonetaryValue()).toBeTruthy();
|
|
708
704
|
expect(f.readableValue()).toEqual("Invalid value");
|
|
709
705
|
expect(f.unit().value()).toEqual("iso4217:USD");
|
|
710
|
-
expect(f.measure()).toEqual("iso4217:USD");
|
|
711
706
|
expect(f.conceptQName().prefix).toEqual("eg");
|
|
712
707
|
expect(f.conceptQName().localname).toEqual("Concept1");
|
|
713
708
|
expect(f.conceptQName().namespace).toEqual("http://www.example.com");
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
|
-
import { Fact } from "./fact.js";
|
|
4
3
|
import { FactSet } from "./factset.js";
|
|
5
|
-
import { viewerUniqueId } from "./util.js";
|
|
6
|
-
import { XBRLReport } from "./report.js";
|
|
4
|
+
import { NAMESPACE_ISO4217, viewerUniqueId } from "./util.js";
|
|
7
5
|
import { ReportSet } from "./reportset.js";
|
|
8
6
|
|
|
9
7
|
var i = 0;
|
|
@@ -11,7 +9,7 @@ var i = 0;
|
|
|
11
9
|
var testReportData = {
|
|
12
10
|
"prefixes": {
|
|
13
11
|
"eg": "http://www.example.com",
|
|
14
|
-
"iso4217":
|
|
12
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
15
13
|
"e": "http://example.com/entity",
|
|
16
14
|
},
|
|
17
15
|
"concepts": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
3
|
import $ from 'jquery'
|
|
4
|
-
import { formatNumber, wrapLabel, truncateLabel, runGenerator, SHOW_FACT, viewerUniqueId } from "./util.js";
|
|
4
|
+
import { formatNumber, wrapLabel, truncateLabel, runGenerator, SHOW_FACT, HIGHLIGHT_COLORS, viewerUniqueId } from "./util.js";
|
|
5
5
|
import { ReportSearch } from "./search.js";
|
|
6
6
|
import { Calculation } from "./calculations.js";
|
|
7
7
|
import { IXBRLChart } from './chart.js';
|
|
@@ -256,7 +256,7 @@ export class Inspector {
|
|
|
256
256
|
for (const [i, name] of key.entries()) {
|
|
257
257
|
$("<div>")
|
|
258
258
|
.addClass("item")
|
|
259
|
-
.append($("<span></span>").addClass("sample").addClass("sample-" + i))
|
|
259
|
+
.append($("<span></span>").addClass("sample").addClass("sample-" + (i % HIGHLIGHT_COLORS)))
|
|
260
260
|
.append($("<span></span>").text(name))
|
|
261
261
|
.appendTo($(".highlight-key .items"));
|
|
262
262
|
}
|
|
@@ -436,7 +436,7 @@ export class Inspector {
|
|
|
436
436
|
$(".text", overlay).text(i18next.t("search.tryAgainDifferentKeywords"));
|
|
437
437
|
overlay.show();
|
|
438
438
|
}
|
|
439
|
-
$("#matching-
|
|
439
|
+
$("#matching-facts-count").text(results.length);
|
|
440
440
|
/* Don't highlight search results if there's no search string */
|
|
441
441
|
if (spec.searchString != "") {
|
|
442
442
|
this._viewer.highlightRelatedFacts(results.map(r => r.fact));
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
|
-
import { Fact } from "./fact.js";
|
|
4
3
|
import { ReportSet } from "./reportset.js";
|
|
5
4
|
import { TestInspector } from "./test-utils.js";
|
|
6
|
-
import { SHOW_FACT, viewerUniqueId } from "./util.js";
|
|
5
|
+
import { NAMESPACE_ISO4217, SHOW_FACT, viewerUniqueId } from "./util.js";
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
const testReportData = {
|
|
10
9
|
"prefixes": {
|
|
11
10
|
"eg": "http://www.example.com",
|
|
12
|
-
"iso4217":
|
|
11
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
13
12
|
"e": "http://example.com/entity",
|
|
14
13
|
},
|
|
15
14
|
"concepts": {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import $ from 'jquery'
|
|
4
4
|
import { ReportSet } from "./reportset.js";
|
|
5
|
-
import {
|
|
5
|
+
import { DocumentOutline } from "./outline.js";
|
|
6
6
|
import { IXNode } from "./ixnode.js";
|
|
7
|
-
import { viewerUniqueId } from "./util.js";
|
|
7
|
+
import { NAMESPACE_ISO4217, viewerUniqueId } from "./util.js";
|
|
8
8
|
|
|
9
9
|
const testReportData = {
|
|
10
10
|
prefixes: {
|
|
11
11
|
eg: "http://www.example.com",
|
|
12
|
-
iso4217:
|
|
12
|
+
iso4217: NAMESPACE_ISO4217,
|
|
13
13
|
e: "http://example.com/entity",
|
|
14
14
|
},
|
|
15
15
|
roles: {
|
|
@@ -179,10 +179,14 @@ export class XBRLReport {
|
|
|
179
179
|
return this.reportSet.qname(v);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
getScaleLabel(scale,
|
|
182
|
+
getScaleLabel(scale, unit) {
|
|
183
183
|
let label = i18next.t(`scale.${scale}`, {defaultValue:"noName"});
|
|
184
|
-
if (
|
|
185
|
-
|
|
184
|
+
if (unit && unit.isMonetary() && scale === -2) {
|
|
185
|
+
let measure = unit.value() ?? '';
|
|
186
|
+
if (measure) {
|
|
187
|
+
measure = this.qname(measure).localname;
|
|
188
|
+
}
|
|
189
|
+
label = i18next.t(`currencies:cents${measure}`, {defaultValue: label});
|
|
186
190
|
}
|
|
187
191
|
if (label === "noName") {
|
|
188
192
|
return null;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { ReportSet } from "./reportset.js";
|
|
4
4
|
import { ViewerOptions } from "./viewerOptions.js";
|
|
5
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
5
6
|
|
|
6
7
|
var testReportData = {
|
|
7
8
|
"languages": {
|
|
@@ -10,7 +11,7 @@ var testReportData = {
|
|
|
10
11
|
},
|
|
11
12
|
"prefixes": {
|
|
12
13
|
"eg": "http://www.example.com",
|
|
13
|
-
"iso4217":
|
|
14
|
+
"iso4217": NAMESPACE_ISO4217
|
|
14
15
|
},
|
|
15
16
|
"roles": {
|
|
16
17
|
"role1": "https://www.example.com/role1",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { ReportSet } from "./reportset.js";
|
|
4
4
|
import { ViewerOptions } from "./viewerOptions.js";
|
|
5
|
-
import { viewerUniqueId } from "./util.js";
|
|
5
|
+
import { NAMESPACE_ISO4217, viewerUniqueId } from "./util.js";
|
|
6
6
|
import { createNumericFact } from "./test-utils.js";
|
|
7
7
|
|
|
8
8
|
function anchoringRelationShips(include) {
|
|
@@ -28,7 +28,7 @@ function multiReportTestData(withAnchoring) {
|
|
|
28
28
|
},
|
|
29
29
|
"prefixes": {
|
|
30
30
|
"eg": "http://www.example.com",
|
|
31
|
-
"iso4217":
|
|
31
|
+
"iso4217": NAMESPACE_ISO4217
|
|
32
32
|
},
|
|
33
33
|
"roles": {
|
|
34
34
|
"role1": "https://www.example.com/role1",
|
|
@@ -131,7 +131,7 @@ function singleReportTestData() {
|
|
|
131
131
|
},
|
|
132
132
|
"prefixes": {
|
|
133
133
|
"eg": "http://www.example.com",
|
|
134
|
-
"iso4217":
|
|
134
|
+
"iso4217": NAMESPACE_ISO4217
|
|
135
135
|
},
|
|
136
136
|
"roles": {
|
|
137
137
|
"role1": "https://www.example.com/role1",
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
// See COPYRIGHT.md for copyright information
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {titleCase} from "./util";
|
|
3
|
+
import { measureLabel, NAMESPACE_ISO4217 } from "./util";
|
|
5
4
|
|
|
6
5
|
export class Unit {
|
|
7
6
|
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
7
|
+
constructor(reportSet, unitKey) {
|
|
8
|
+
this._reportSet = reportSet;
|
|
10
9
|
this._value = unitKey;
|
|
11
10
|
const split = unitKey
|
|
12
11
|
.split(/[()]/ig).join('') // TODO: replace with .replaceAll(/[()]/ig,'') when no longer supporting node 14
|
|
13
12
|
.split('/');
|
|
14
13
|
this._numerators = split[0].split('*');
|
|
15
14
|
this._denominators = split.length > 1 ? split[1].split('*') : [];
|
|
16
|
-
this._isMonetary =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
this._isMonetary =
|
|
16
|
+
this._denominators.length === 0 &&
|
|
17
|
+
this._numerators.length === 1 &&
|
|
18
|
+
this._reportSet.qname(this._numerators[0]).namespace === NAMESPACE_ISO4217;
|
|
19
|
+
this._label = split
|
|
20
|
+
.map(measure => {
|
|
21
|
+
const part = measure
|
|
22
|
+
.split('*')
|
|
23
|
+
.map(x => measureLabel(this._reportSet, x))
|
|
24
|
+
.join('*');
|
|
21
25
|
return part.includes('*') ? `(${part})` : part;
|
|
22
|
-
})
|
|
23
|
-
|
|
26
|
+
})
|
|
27
|
+
.join('/');
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
27
30
|
/**
|
|
28
31
|
* Returns whether any of the numerators are an iso4217 monetary measure.
|
|
29
32
|
* @return {Boolean}
|
|
@@ -40,27 +43,6 @@ export class Unit {
|
|
|
40
43
|
return this._label;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
/**
|
|
44
|
-
* Returns the qname of the first numerator in the unit
|
|
45
|
-
* @return {String} QName string of a measure
|
|
46
|
-
*/
|
|
47
|
-
measure() {
|
|
48
|
-
return this._measure;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns a readable label representing the first numerator in the unit
|
|
53
|
-
* @return {String} Label representing measure
|
|
54
|
-
*/
|
|
55
|
-
measureLabel() {
|
|
56
|
-
const measure = this.measure();
|
|
57
|
-
const qname = this._report.qname(measure);
|
|
58
|
-
if (qname.namespace === "http://www.xbrl.org/2003/iso4217") {
|
|
59
|
-
return i18next.t(`currencies:unitFormat${qname.localname}`, {defaultValue: qname.localname});
|
|
60
|
-
}
|
|
61
|
-
return measure;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
46
|
/**
|
|
65
47
|
* Returns the OIM format string representing the unit
|
|
66
48
|
* @return {String} OIM format unit string
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import { Unit } from "./unit.js";
|
|
4
4
|
import { ReportSet } from "./reportset.js";
|
|
5
5
|
import { TestInspector } from "./test-utils.js";
|
|
6
|
+
import { NAMESPACE_ISO4217 } from "./util";
|
|
6
7
|
|
|
7
8
|
var testReportData = {
|
|
8
9
|
"prefixes": {
|
|
9
10
|
"eg": "http://www.example.com",
|
|
10
|
-
"iso4217":
|
|
11
|
+
"iso4217": NAMESPACE_ISO4217,
|
|
11
12
|
"e": "http://example.com/entity",
|
|
12
13
|
},
|
|
13
14
|
"facts": {}
|
|
@@ -29,51 +30,39 @@ beforeAll(() => {
|
|
|
29
30
|
describe("Unit label", () => {
|
|
30
31
|
test("Unit label for simple unit", () => {
|
|
31
32
|
var unit = new Unit(testReport(), 'iso4217:USD');
|
|
32
|
-
expect(unit.label()).toEqual('
|
|
33
|
+
expect(unit.label()).toEqual('US $');
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
test("Unit label for complex unit", () => {
|
|
36
37
|
var unit = new Unit(testReport(), 'iso4217:USD/eg:share');
|
|
37
|
-
expect(unit.label()).toEqual('
|
|
38
|
+
expect(unit.label()).toEqual('US $/share');
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
test("Unit label for complex unit with numerator parentheses", () => {
|
|
41
42
|
var unit = new Unit(testReport(), '(iso4217:USD*eg:share)/eg:shareholder');
|
|
42
|
-
expect(unit.label()).toEqual('(
|
|
43
|
+
expect(unit.label()).toEqual('(US $*share)/shareholder');
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
test("Unit label for complex unit with denominator parentheses", () => {
|
|
46
47
|
var unit = new Unit(testReport(), 'iso4217:USD/(eg:share*eg:shareholder)');
|
|
47
|
-
expect(unit.label()).toEqual('
|
|
48
|
+
expect(unit.label()).toEqual('US $/(share*shareholder)');
|
|
48
49
|
});
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
describe("Unit
|
|
52
|
-
test("Unit
|
|
53
|
-
var unit = new Unit(testReport(), 'iso4217:USD');
|
|
54
|
-
expect(unit.measure()).toEqual('iso4217:USD');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("Unit measure is first numerator of complex unit", () => {
|
|
58
|
-
var unit = new Unit(testReport(), '(iso4217:USD*eg:share)/eg:shareholder');
|
|
59
|
-
expect(unit.measure()).toEqual('iso4217:USD');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("Unit measure label", () => {
|
|
64
|
-
test("Unit measure label - known currency", () => {
|
|
52
|
+
describe("Unit label", () => {
|
|
53
|
+
test("Unit label - known currency", () => {
|
|
65
54
|
var unit = new Unit(testReport(), 'eg:share');
|
|
66
|
-
expect(unit.
|
|
55
|
+
expect(unit.label()).toEqual('share');
|
|
67
56
|
});
|
|
68
57
|
|
|
69
|
-
test("Unit
|
|
58
|
+
test("Unit label - known currency", () => {
|
|
70
59
|
var unit = new Unit(testReport(), 'iso4217:USD');
|
|
71
|
-
expect(unit.
|
|
60
|
+
expect(unit.label()).toEqual('US $');
|
|
72
61
|
});
|
|
73
62
|
|
|
74
|
-
test("Unit
|
|
63
|
+
test("Unit label - unknown", () => {
|
|
75
64
|
var unit = new Unit(testReport(), 'iso4217:ZAR');
|
|
76
|
-
expect(unit.
|
|
65
|
+
expect(unit.label()).toEqual('ZAR');
|
|
77
66
|
});
|
|
78
67
|
});
|
|
79
68
|
|
|
@@ -94,4 +83,8 @@ describe("Unit value", () => {
|
|
|
94
83
|
var unit = new Unit(testReport(), '(iso4217:USD*eg:share)/eg:shareholder');
|
|
95
84
|
expect(unit.value()).toEqual('(iso4217:USD*eg:share)/eg:shareholder');
|
|
96
85
|
});
|
|
86
|
+
test("Unit value is simple unit", () => {
|
|
87
|
+
var unit = new Unit(testReport(), 'iso4217:USD');
|
|
88
|
+
expect(unit.value()).toEqual('iso4217:USD');
|
|
89
|
+
});
|
|
97
90
|
});
|
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import moment from "moment";
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
|
+
import i18next from "i18next";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export const SHOW_FACT = 'SHOW_FACT';
|
|
8
9
|
|
|
10
|
+
export const NAMESPACE_ISO4217 = 'http://www.xbrl.org/2003/iso4217';
|
|
11
|
+
|
|
12
|
+
// The number of distinct highlight colors defined in inspector.less
|
|
13
|
+
export const HIGHLIGHT_COLORS = 3;
|
|
14
|
+
|
|
9
15
|
/*
|
|
10
16
|
* Takes a moment.js oject and converts it to a human readable date, or date
|
|
11
17
|
* and time if the time component is not midnight. Adjust specifies that a
|
|
@@ -207,3 +213,18 @@ export function getIXHiddenLinkStyle(domNode) {
|
|
|
207
213
|
}
|
|
208
214
|
return null;
|
|
209
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Transforms measure qname into title case label (or currency symbol, if applicable).
|
|
219
|
+
* @return {String} Measure Label
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
export function measureLabel(report, measure) {
|
|
223
|
+
const qname = report.qname(measure);
|
|
224
|
+
if (qname.namespace === NAMESPACE_ISO4217) {
|
|
225
|
+
measure = i18next.t(`currencies:unitFormat${qname.localname}`, {defaultValue: qname.localname});
|
|
226
|
+
} else if (measure.includes(':')) {
|
|
227
|
+
measure = measure.split(':')[1];
|
|
228
|
+
}
|
|
229
|
+
return measure;
|
|
230
|
+
}
|