@dhyasama/totem-models 10.52.0 → 10.54.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/index.js +1 -0
- package/lib/Currency.js +49 -0
- package/lib/Financials.js +1 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,6 +61,7 @@ var bootstrap = function(mongoose, config) {
|
|
|
61
61
|
require('./lib/Activity.js')(mongoose, config);
|
|
62
62
|
require('./lib/CalendarEvent.js')(mongoose, config);
|
|
63
63
|
require('./lib/CapTable.js')(mongoose, config);
|
|
64
|
+
require('./lib/Currency.js')(mongoose, config);
|
|
64
65
|
require('./lib/Document.js')(mongoose, config);
|
|
65
66
|
require('./lib/Event.js')(mongoose, config);
|
|
66
67
|
require('./lib/EventAttendee.js')(mongoose, config);
|
package/lib/Currency.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(mongoose, config) {
|
|
4
|
+
|
|
5
|
+
let
|
|
6
|
+
|
|
7
|
+
Schema = mongoose.Schema,
|
|
8
|
+
_ = require('underscore'),
|
|
9
|
+
|
|
10
|
+
Currency = new Schema({
|
|
11
|
+
|
|
12
|
+
date: { type: Date, required: true },
|
|
13
|
+
|
|
14
|
+
currency: { type: String, required: true },
|
|
15
|
+
|
|
16
|
+
conversions: [{
|
|
17
|
+
_id: false,
|
|
18
|
+
currency: { type: String },
|
|
19
|
+
rate: { type: Number }
|
|
20
|
+
}]
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
Currency.statics.getByDate = function getByDate(options, cb) {
|
|
25
|
+
|
|
26
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
27
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
28
|
+
|
|
29
|
+
const self = this;
|
|
30
|
+
let query = self.find({ customer: options.CUSTOMER_ID });
|
|
31
|
+
|
|
32
|
+
self
|
|
33
|
+
.find({date: options.date, currency: options.currency})
|
|
34
|
+
.exec(cb);
|
|
35
|
+
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Currency.statics.upsert = function (currency, cb) {
|
|
39
|
+
currency.save(cb);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
Currency.set('usePushEach', true);
|
|
43
|
+
Currency.set('autoIndex', false);
|
|
44
|
+
Currency.set('usePushEach', true);
|
|
45
|
+
Currency.on('index', function(err) { console.log('error building currency indexes: ' + err); });
|
|
46
|
+
|
|
47
|
+
mongoose.model('Currency', Currency);
|
|
48
|
+
|
|
49
|
+
};
|
package/lib/Financials.js
CHANGED
|
@@ -70,14 +70,7 @@ module.exports = function(mongoose, config) {
|
|
|
70
70
|
|
|
71
71
|
uuid: { type: String },
|
|
72
72
|
|
|
73
|
-
currency: {
|
|
74
|
-
code: { type: String, default: 'USD' },
|
|
75
|
-
conversion: [{
|
|
76
|
-
_id: false,
|
|
77
|
-
code: { type: String },
|
|
78
|
-
rate: { type: Number }
|
|
79
|
-
}]
|
|
80
|
-
},
|
|
73
|
+
currency: { type: String, default: 'USD' },
|
|
81
74
|
|
|
82
75
|
review: { type: Boolean, default: false },
|
|
83
76
|
|