@dhyasama/totem-models 12.33.0 → 12.35.0
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.
- package/lib/Financials.js +12 -0
- package/package.json +1 -1
- package/test/Financials.js +23 -0
package/lib/Financials.js
CHANGED
|
@@ -128,6 +128,12 @@ module.exports = function(mongoose, config) {
|
|
|
128
128
|
group: { type: String, trim: true },
|
|
129
129
|
position: {
|
|
130
130
|
_id: false,
|
|
131
|
+
text: {
|
|
132
|
+
_id: false,
|
|
133
|
+
quote: { type: String, maxlength: 4096 },
|
|
134
|
+
prefix: { type: String, maxlength: 256 },
|
|
135
|
+
suffix: { type: String, maxlength: 256 }
|
|
136
|
+
},
|
|
131
137
|
page: { type: Number },
|
|
132
138
|
bbox: {
|
|
133
139
|
_id: false,
|
|
@@ -173,6 +179,12 @@ module.exports = function(mongoose, config) {
|
|
|
173
179
|
group: { type: String, trim: true },
|
|
174
180
|
position: {
|
|
175
181
|
_id: false,
|
|
182
|
+
text: {
|
|
183
|
+
_id: false,
|
|
184
|
+
quote: { type: String, maxlength: 4096 },
|
|
185
|
+
prefix: { type: String, maxlength: 256 },
|
|
186
|
+
suffix: { type: String, maxlength: 256 }
|
|
187
|
+
},
|
|
176
188
|
page: { type: Number },
|
|
177
189
|
bbox: {
|
|
178
190
|
_id: false,
|
package/package.json
CHANGED
package/test/Financials.js
CHANGED
|
@@ -40,6 +40,29 @@ describe('Financials', function() {
|
|
|
40
40
|
snapshot.metrics[0].scale.should.equal(1000);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
it('preserves narrative text evidence on current and previous metric sources', function() {
|
|
44
|
+
var position = { text: {
|
|
45
|
+
quote: 'Revenue was $1.2m in July.', prefix: 'Intro\n', suffix: '\nThanks'
|
|
46
|
+
} };
|
|
47
|
+
var source = { model: 'Message', ref: new mongoose.Types.ObjectId(), position: position };
|
|
48
|
+
var f = new Financials({
|
|
49
|
+
organization: orgA,
|
|
50
|
+
customer: customerA,
|
|
51
|
+
snapshots: [{
|
|
52
|
+
uuid: 'narrative-source-evidence', year: 2026, period: 'FY',
|
|
53
|
+
metrics: [{
|
|
54
|
+
name: 'Revenue', scenario: 'actual', value: 1200000,
|
|
55
|
+
sources: [source],
|
|
56
|
+
previous: { value: 1000000, sources: [source] }
|
|
57
|
+
}]
|
|
58
|
+
}]
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var metric = f.snapshots[0].metrics[0].toObject();
|
|
62
|
+
metric.sources[0].position.should.deepEqual(position);
|
|
63
|
+
metric.previous.sources[0].position.should.deepEqual(position);
|
|
64
|
+
});
|
|
65
|
+
|
|
43
66
|
before(function(done) {
|
|
44
67
|
databaseHelpers.connect(mongoose, done);
|
|
45
68
|
});
|