@dhyasama/totem-models 8.3.0 → 8.5.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/Financials.js +6 -6
- package/lib/Fund.js +18 -3
- package/lib/Investment.js +6 -1
- package/lib/LimitedPartner.js +126 -39
- package/lib/Organization.js +2 -0
- package/lib/Person.js +1 -1
- package/lib/Round.js +3 -2
- package/lib/Sync.js +47 -0
- package/package.json +1 -1
- package/test/LimitedPartner.js +18 -3
package/index.js
CHANGED
|
@@ -64,6 +64,7 @@ var bootstrap = function(mongoose, config) {
|
|
|
64
64
|
require('./lib/Message.js')(mongoose, config);
|
|
65
65
|
require('./lib/News.js')(mongoose, config);
|
|
66
66
|
require('./lib/Snapshot.js')(mongoose, config);
|
|
67
|
+
require('./lib/Sync.js')(mongoose, config);
|
|
67
68
|
require('./lib/Webhook.js')(mongoose, config);
|
|
68
69
|
|
|
69
70
|
};
|
package/lib/Financials.js
CHANGED
|
@@ -121,10 +121,10 @@ module.exports = function(mongoose, config) {
|
|
|
121
121
|
|
|
122
122
|
company: {
|
|
123
123
|
|
|
124
|
-
sendTo: {
|
|
124
|
+
sendTo: [{
|
|
125
125
|
email: { type: String, trim: true },
|
|
126
126
|
name: { type: String, trim: true }
|
|
127
|
-
},
|
|
127
|
+
}],
|
|
128
128
|
|
|
129
129
|
initial: {
|
|
130
130
|
sendOn: { type: Date, required: false },
|
|
@@ -343,7 +343,7 @@ module.exports = function(mongoose, config) {
|
|
|
343
343
|
let query = self.find({
|
|
344
344
|
'snapshots': {
|
|
345
345
|
$elemMatch: {
|
|
346
|
-
'notifications.company.sendTo
|
|
346
|
+
'notifications.company.sendTo': { $gt: [] },
|
|
347
347
|
'notifications.company.initial.sendOn': { $lte: now },
|
|
348
348
|
'notifications.company.initial.sentOn': null,
|
|
349
349
|
'submittedOn': null
|
|
@@ -363,7 +363,7 @@ module.exports = function(mongoose, config) {
|
|
|
363
363
|
|
|
364
364
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
365
365
|
|
|
366
|
-
let bool = !!snapshot.notifications.company.sendTo.
|
|
366
|
+
let bool = !!snapshot.notifications.company.sendTo.length > 0;
|
|
367
367
|
bool = bool && snapshot.notifications.company.initial.sendOn < now;
|
|
368
368
|
bool = bool && !snapshot.notifications.company.initial.sentOn;
|
|
369
369
|
|
|
@@ -385,7 +385,7 @@ module.exports = function(mongoose, config) {
|
|
|
385
385
|
let query = self.find({
|
|
386
386
|
'snapshots': {
|
|
387
387
|
$elemMatch: {
|
|
388
|
-
'notifications.company.sendTo
|
|
388
|
+
'notifications.company.sendTo': { $gt: [] },
|
|
389
389
|
'notifications.company.reminder.sendOn': { $lte: now },
|
|
390
390
|
'notifications.company.reminder.sentOn': null,
|
|
391
391
|
'submittedOn': null
|
|
@@ -405,7 +405,7 @@ module.exports = function(mongoose, config) {
|
|
|
405
405
|
|
|
406
406
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
407
407
|
|
|
408
|
-
let bool = !!snapshot.notifications.company.sendTo.
|
|
408
|
+
let bool = !!snapshot.notifications.company.sendTo.length > 0;
|
|
409
409
|
bool = bool && snapshot.notifications.company.reminder.sendOn < now;
|
|
410
410
|
bool = bool && !snapshot.notifications.company.reminder.sentOn;
|
|
411
411
|
|
package/lib/Fund.js
CHANGED
|
@@ -7,7 +7,6 @@ module.exports = function(mongoose, config) {
|
|
|
7
7
|
var _ = require('underscore');
|
|
8
8
|
|
|
9
9
|
var Fund = new Schema({
|
|
10
|
-
|
|
11
10
|
name: { type: String, required: true, unique: true },
|
|
12
11
|
slug: { type: String, required: true, unique: true },
|
|
13
12
|
shortName: { type: String, required: true },
|
|
@@ -16,8 +15,12 @@ module.exports = function(mongoose, config) {
|
|
|
16
15
|
hexColorCode: { type: String, required: true, default: '#cccccc' },
|
|
17
16
|
closeDate: { type: Date },
|
|
18
17
|
amount: { type: Number },
|
|
19
|
-
crunchbase: { uuid: { type: String, default: '', unique: true } }
|
|
20
|
-
|
|
18
|
+
crunchbase: { uuid: { type: String, default: '', unique: true } },
|
|
19
|
+
transactions: [{
|
|
20
|
+
type: { type: String, enum: ['fees', 'expenses', 'carry'] },
|
|
21
|
+
amount: { type: Number, default: 0 },
|
|
22
|
+
date: { type: Date, default: null },
|
|
23
|
+
}],
|
|
21
24
|
});
|
|
22
25
|
|
|
23
26
|
/************* BASIC FIELDS **********************/
|
|
@@ -175,6 +178,18 @@ module.exports = function(mongoose, config) {
|
|
|
175
178
|
|
|
176
179
|
};
|
|
177
180
|
|
|
181
|
+
Fund.statics.removeTransactions = function removeTransactions(cb) {
|
|
182
|
+
|
|
183
|
+
const self = this;
|
|
184
|
+
|
|
185
|
+
let query = self.update(
|
|
186
|
+
{ $set: { transactions: [] } },
|
|
187
|
+
{ multi : true }
|
|
188
|
+
);
|
|
189
|
+
query.exec(cb);
|
|
190
|
+
|
|
191
|
+
};
|
|
192
|
+
|
|
178
193
|
Fund.set('autoIndex', false);
|
|
179
194
|
Fund.on('index', function(err) { console.log('error building fund indexes: ' + err); });
|
|
180
195
|
|
package/lib/Investment.js
CHANGED
|
@@ -63,7 +63,8 @@ module.exports = function(mongoose, config) {
|
|
|
63
63
|
// Catch-all for customer specific key-value pairs from sheet that aren't supported by our schema
|
|
64
64
|
details: [{
|
|
65
65
|
key: { type: String, trim: true, required: true },
|
|
66
|
-
value: { type:
|
|
66
|
+
value: { type: Schema.Types.Mixed, required: true },
|
|
67
|
+
format: { type: String, enum: [null, 'number', 'decimal', 'money', 'percentage', 'date']},
|
|
67
68
|
_id: false
|
|
68
69
|
}],
|
|
69
70
|
|
|
@@ -129,6 +130,10 @@ module.exports = function(mongoose, config) {
|
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
Investment.statics.upsert = function upsert(investment, cb) {
|
|
133
|
+
|
|
134
|
+
// Required for mixed types
|
|
135
|
+
investment.markModified('details');
|
|
136
|
+
|
|
132
137
|
if (!investment) { return cb(new Error('investment is required'), null); }
|
|
133
138
|
investment.save(cb);
|
|
134
139
|
};
|
package/lib/LimitedPartner.js
CHANGED
|
@@ -37,10 +37,11 @@ module.exports = function(mongoose, config) {
|
|
|
37
37
|
quarterlyAccountStatement: { type: String, default: '' }
|
|
38
38
|
},
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
transactions: [{
|
|
41
41
|
fund: {type: Schema.ObjectId, ref: 'Fund'},
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
type: { type: String, enum: ['commitment', 'contribution', 'distribution'] },
|
|
43
|
+
amount: { type: Number, default: 0 },
|
|
44
|
+
date: { type: Date, default: null },
|
|
44
45
|
}],
|
|
45
46
|
|
|
46
47
|
contact: {
|
|
@@ -98,7 +99,61 @@ module.exports = function(mongoose, config) {
|
|
|
98
99
|
|
|
99
100
|
LimitedPartner.virtual('totalCommitted').get(function () {
|
|
100
101
|
const self = this;
|
|
101
|
-
return _.reduce(self.fundsInvested, function(memo, fund) {
|
|
102
|
+
return _.reduce(self.fundsInvested, function (memo, fund) {
|
|
103
|
+
return memo + (fund.committed > 0 ? fund.committed : 0);
|
|
104
|
+
}, 0);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
LimitedPartner.virtual('totalCommitment').get(function () {
|
|
108
|
+
var self = this;
|
|
109
|
+
return _.reduce(self.transactions, function(memo, transaction) {
|
|
110
|
+
return memo + ((transaction.type === 'commitment' && transaction.amount > 0) ? transaction.amount : 0);
|
|
111
|
+
}, 0);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
LimitedPartner.virtual('totalContribution').get(function () {
|
|
115
|
+
var self = this;
|
|
116
|
+
return _.reduce(self.transactions, function(memo, transaction) {
|
|
117
|
+
return memo + ((transaction.type === 'contribution' && transaction.amount > 0) ? transaction.amount : 0);
|
|
118
|
+
}, 0);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
LimitedPartner.virtual('totalDistribution').get(function () {
|
|
122
|
+
var self = this;
|
|
123
|
+
return _.reduce(self.transactions, function(memo, transaction) {
|
|
124
|
+
return memo + ((transaction.type === 'distribution' && transaction.amount > 0) ? transaction.amount : 0);
|
|
125
|
+
}, 0);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
LimitedPartner.virtual('fundsInvested').get(function () {
|
|
129
|
+
|
|
130
|
+
var self = this;
|
|
131
|
+
var fundsInvested = [];
|
|
132
|
+
|
|
133
|
+
_.each(self.transactions, function(transaction) {
|
|
134
|
+
|
|
135
|
+
var fundMatch = _.find(fundsInvested, function(fund) { return fund._id === transaction.fund._id; });
|
|
136
|
+
|
|
137
|
+
if(!fundMatch) {
|
|
138
|
+
fundsInvested.push({
|
|
139
|
+
_id: transaction.fund._id,
|
|
140
|
+
name: transaction.fund.name,
|
|
141
|
+
shortName: transaction.fund.shortName,
|
|
142
|
+
abbreviation: transaction.fund.abbreviation,
|
|
143
|
+
commitment: 0,
|
|
144
|
+
contribution: 0,
|
|
145
|
+
distribution: 0
|
|
146
|
+
});
|
|
147
|
+
fundMatch = _.last(fundsInvested);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// and increment the transaction type by the transaction amount
|
|
151
|
+
fundMatch[transaction.type] += transaction.amount;
|
|
152
|
+
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return fundsInvested;
|
|
156
|
+
|
|
102
157
|
});
|
|
103
158
|
|
|
104
159
|
LimitedPartner.virtual('email.primary').get(function () {
|
|
@@ -300,7 +355,7 @@ module.exports = function(mongoose, config) {
|
|
|
300
355
|
query = self.findOne({ '_id': id, customer: options.CUSTOMER_ID }, self.getReadFilterKeys(options.role));
|
|
301
356
|
}
|
|
302
357
|
|
|
303
|
-
query.populate('
|
|
358
|
+
query.populate('transactions.fund');
|
|
304
359
|
query.populate('people');
|
|
305
360
|
query.populate({
|
|
306
361
|
path: 'notes',
|
|
@@ -350,7 +405,8 @@ module.exports = function(mongoose, config) {
|
|
|
350
405
|
if (!options.isWorkerProcess) { return cb(null, []); }
|
|
351
406
|
|
|
352
407
|
let query = self.findOne({'name': lpName}, this.getReadFilterKeys(options.role));
|
|
353
|
-
|
|
408
|
+
|
|
409
|
+
query.populate('transactions.fund');
|
|
354
410
|
query.exec(cb);
|
|
355
411
|
|
|
356
412
|
};
|
|
@@ -377,7 +433,7 @@ module.exports = function(mongoose, config) {
|
|
|
377
433
|
query = self.find({'people': personId, customer: options.CUSTOMER_ID }, self.getReadFilterKeys(options.role));
|
|
378
434
|
}
|
|
379
435
|
|
|
380
|
-
query.populate('
|
|
436
|
+
query.populate('transactions.fund');
|
|
381
437
|
query.populate('people', 'name');
|
|
382
438
|
|
|
383
439
|
query.exec(function (err, lps) {
|
|
@@ -453,7 +509,7 @@ module.exports = function(mongoose, config) {
|
|
|
453
509
|
LimitedPartner.statics.getSources = function(lpid, options, cb) {
|
|
454
510
|
|
|
455
511
|
const self = this;
|
|
456
|
-
|
|
512
|
+
|
|
457
513
|
if (!cb) { throw new Error('cb is required'); }
|
|
458
514
|
if (!lpid) { return cb(new Error('lpid is required'), null); }
|
|
459
515
|
if (!mongoose.Types.ObjectId.isValid(lpid)) { return cb(new Error('lpid is not a valid ObjectId'), null); }
|
|
@@ -474,44 +530,70 @@ module.exports = function(mongoose, config) {
|
|
|
474
530
|
|
|
475
531
|
query.exec(function(err, lp) {
|
|
476
532
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
Organization.collection.findById(options.CUSTOMER_ID, function(err, customer) {
|
|
533
|
+
if (err) { return cb(err, null); }
|
|
534
|
+
if (!lp) { return cb(null, null); }
|
|
481
535
|
|
|
482
|
-
|
|
483
|
-
if (!customer) { return cb(null, null); }
|
|
536
|
+
Organization.collection.findById(options.CUSTOMER_ID, function(err, customer) {
|
|
484
537
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
let all = [];
|
|
488
|
-
let lpSources = helpers.getPeopleSources(lp.people);
|
|
538
|
+
if (err) { return cb(err, null); }
|
|
539
|
+
if (!customer) { return cb(null, null); }
|
|
489
540
|
|
|
490
|
-
|
|
541
|
+
let current = [];
|
|
542
|
+
let past = [];
|
|
543
|
+
let all = [];
|
|
544
|
+
let lpSources = helpers.getPeopleSources(lp.people);
|
|
491
545
|
|
|
492
|
-
|
|
493
|
-
if (!ls || !ls.person || !ls.person._id) return false;
|
|
494
|
-
return ls.person._id.toString() === p.person.toString();
|
|
495
|
-
});
|
|
546
|
+
_.each(customer.people, function(p) {
|
|
496
547
|
|
|
497
|
-
|
|
548
|
+
let source = _.find(lpSources, function(ls) {
|
|
549
|
+
if (!ls || !ls.person || !ls.person._id) return false;
|
|
550
|
+
return ls.person._id.toString() === p.person.toString();
|
|
551
|
+
});
|
|
498
552
|
|
|
499
|
-
|
|
500
|
-
if (!p.current) { past.push(source); }
|
|
501
|
-
all.push(source);
|
|
553
|
+
if (!source) { return; }
|
|
502
554
|
|
|
503
|
-
|
|
555
|
+
if (p.current) { current.push(source); }
|
|
556
|
+
if (!p.current) { past.push(source); }
|
|
557
|
+
all.push(source);
|
|
504
558
|
|
|
505
|
-
|
|
506
|
-
all: helpers.sortPeopleSources(all, options.CUSTOMER_ID),
|
|
507
|
-
current: helpers.sortPeopleSources(current, options.CUSTOMER_ID),
|
|
508
|
-
past: helpers.sortPeopleSources(past, options.CUSTOMER_ID)
|
|
509
|
-
});
|
|
559
|
+
});
|
|
510
560
|
|
|
561
|
+
return cb(null, {
|
|
562
|
+
all: helpers.sortPeopleSources(all, options.CUSTOMER_ID),
|
|
563
|
+
current: helpers.sortPeopleSources(current, options.CUSTOMER_ID),
|
|
564
|
+
past: helpers.sortPeopleSources(past, options.CUSTOMER_ID)
|
|
511
565
|
});
|
|
512
566
|
|
|
513
567
|
});
|
|
514
568
|
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
LimitedPartner.statics.list = function (customerId, options, cb) {
|
|
574
|
+
|
|
575
|
+
const self = this;
|
|
576
|
+
|
|
577
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
578
|
+
if (!customerId) { return cb(new Error('customerId is required'), null); }
|
|
579
|
+
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
580
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
581
|
+
|
|
582
|
+
options = helpers.getDefaultOptions(options);
|
|
583
|
+
|
|
584
|
+
let query;
|
|
585
|
+
|
|
586
|
+
if (options.isWorkerProcess) {
|
|
587
|
+
query = self.find({}, self.getReadFilterKeys(options.role));
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
query = self.find({ 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(options.role));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
query.populate('fundsInvested.fund');
|
|
594
|
+
query.sort({ 'name': -1 });
|
|
595
|
+
query.exec(cb);
|
|
596
|
+
|
|
515
597
|
};
|
|
516
598
|
|
|
517
599
|
LimitedPartner.statics.listByFund = function (fundId, options, cb) {
|
|
@@ -527,9 +609,9 @@ module.exports = function(mongoose, config) {
|
|
|
527
609
|
|
|
528
610
|
options = helpers.getDefaultOptions(options);
|
|
529
611
|
|
|
530
|
-
let query = self.find({ '
|
|
612
|
+
let query = self.find({ 'transactions.fund': fundId, customer: options.CUSTOMER_ID }, self.getReadFilterKeys(options.role));
|
|
531
613
|
|
|
532
|
-
query.populate('
|
|
614
|
+
query.populate('transactions.fund');
|
|
533
615
|
query.sort({ 'name': -1 });
|
|
534
616
|
query.exec(cb);
|
|
535
617
|
|
|
@@ -555,15 +637,20 @@ module.exports = function(mongoose, config) {
|
|
|
555
637
|
|
|
556
638
|
};
|
|
557
639
|
|
|
558
|
-
LimitedPartner.statics.
|
|
640
|
+
LimitedPartner.statics.removeCustomerTransactions = function removeCustomerTransactions(customerId, cb) {
|
|
559
641
|
|
|
560
642
|
const self = this;
|
|
561
643
|
|
|
644
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
645
|
+
if (!customerId) { return cb(new Error('customerId is required'), null); }
|
|
646
|
+
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
647
|
+
|
|
562
648
|
let query = self.update(
|
|
563
649
|
{ 'customer': customerId },
|
|
564
|
-
{ $set: {
|
|
650
|
+
{ $set: { transactions: [] } },
|
|
565
651
|
{ multi : true }
|
|
566
652
|
);
|
|
653
|
+
|
|
567
654
|
query.exec(cb);
|
|
568
655
|
|
|
569
656
|
};
|
|
@@ -591,7 +678,7 @@ module.exports = function(mongoose, config) {
|
|
|
591
678
|
query = self.find({ 'name': new RegExp(terms, 'i'), customer: options.CUSTOMER_ID }, self.getReadFilterKeys(options.role));
|
|
592
679
|
}
|
|
593
680
|
|
|
594
|
-
query.populate('
|
|
681
|
+
query.populate('transactions.fund');
|
|
595
682
|
query.sort({ 'name': -1 });
|
|
596
683
|
query.exec(cb);
|
|
597
684
|
|
|
@@ -649,4 +736,4 @@ module.exports = function(mongoose, config) {
|
|
|
649
736
|
|
|
650
737
|
mongoose.model('LimitedPartner', LimitedPartner);
|
|
651
738
|
|
|
652
|
-
};
|
|
739
|
+
};
|
package/lib/Organization.js
CHANGED
package/lib/Person.js
CHANGED
|
@@ -314,7 +314,7 @@ module.exports = function(mongoose, config) {
|
|
|
314
314
|
|
|
315
315
|
this
|
|
316
316
|
.find({ 'contact.email.email': { $in : emails }, 'deleted': {$ne: true}})
|
|
317
|
-
.select('name avatarUrl title doNotDisplay')
|
|
317
|
+
.select('name avatarUrl title doNotDisplay contact')
|
|
318
318
|
.sort('name.full')
|
|
319
319
|
.exec(cb);
|
|
320
320
|
|
package/lib/Round.js
CHANGED
|
@@ -147,6 +147,7 @@ module.exports = function(mongoose, config) {
|
|
|
147
147
|
// construct the org
|
|
148
148
|
var org = {
|
|
149
149
|
_id: rounds[0].organization._id,
|
|
150
|
+
slug: rounds[0].organization.slug,
|
|
150
151
|
name: rounds[0].organization.name,
|
|
151
152
|
logoUrl: rounds[0].organization.logoUrl,
|
|
152
153
|
description: rounds[0].organization.description,
|
|
@@ -650,7 +651,7 @@ module.exports = function(mongoose, config) {
|
|
|
650
651
|
let query = self.find({ 'vehicles.fund': fundId });
|
|
651
652
|
|
|
652
653
|
query.select('organization vehicles preMoneyValuation');
|
|
653
|
-
query.populate('organization', 'name logoUrl description contact filters status ipo closed acquired operating website websiteAliases');
|
|
654
|
+
query.populate('organization', 'name slug logoUrl description contact filters status ipo closed acquired operating website websiteAliases');
|
|
654
655
|
query.populate('vehicles.fund');
|
|
655
656
|
|
|
656
657
|
if (options.isWorkerProcess) {
|
|
@@ -698,7 +699,7 @@ module.exports = function(mongoose, config) {
|
|
|
698
699
|
let query = self.find({ 'vehicles.fund': { $in: fundIds } });
|
|
699
700
|
|
|
700
701
|
query.select('organization vehicles preMoneyValuation');
|
|
701
|
-
query.populate('organization', 'name logoUrl description contact chairs filters status ipo closed acquired operating website websiteAliases');
|
|
702
|
+
query.populate('organization', 'name slug logoUrl description contact chairs filters status ipo closed acquired operating website websiteAliases');
|
|
702
703
|
query.deepPopulate([
|
|
703
704
|
'organization.chairs.first',
|
|
704
705
|
'organization.chairs.second',
|
package/lib/Sync.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(mongoose, config) {
|
|
4
|
+
|
|
5
|
+
var
|
|
6
|
+
|
|
7
|
+
Schema = mongoose.Schema,
|
|
8
|
+
env = process.env.NODE_ENV || 'development',
|
|
9
|
+
_ = require('underscore');
|
|
10
|
+
|
|
11
|
+
var Sync = new Schema({
|
|
12
|
+
customer: { type: String, required: true },
|
|
13
|
+
syncedOn: { type: Date, required: true },
|
|
14
|
+
completedOn: { type: Date },
|
|
15
|
+
syncedBy: { type: String, trim: true },
|
|
16
|
+
steps: [{
|
|
17
|
+
_id: false,
|
|
18
|
+
name: { type: String, trim: true },
|
|
19
|
+
tasks: [{
|
|
20
|
+
_id: false,
|
|
21
|
+
name: { type: String, trim: true },
|
|
22
|
+
issues: [{ type: String, trim: true }],
|
|
23
|
+
}]
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Sync.statics.getById = function (id, customerId, cb) {
|
|
28
|
+
|
|
29
|
+
var self = this;
|
|
30
|
+
|
|
31
|
+
self.findOne({
|
|
32
|
+
'_id': id,
|
|
33
|
+
'customer': customerId
|
|
34
|
+
}).exec(cb);
|
|
35
|
+
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Sync.statics.upsert = function(sync, cb) {
|
|
39
|
+
sync.syncedOn = new Date();
|
|
40
|
+
sync.save(cb);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Sync.set('autoIndex', false);
|
|
44
|
+
|
|
45
|
+
mongoose.model('Sync', Sync, 'syncs');
|
|
46
|
+
|
|
47
|
+
};
|
package/package.json
CHANGED
package/test/LimitedPartner.js
CHANGED
|
@@ -116,10 +116,25 @@ describe('Limited Partner', function() {
|
|
|
116
116
|
lp.name = 'United Testers';
|
|
117
117
|
lp.customer = organization;
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
// transactions: [{
|
|
120
|
+
// fund: {type: Schema.ObjectId, ref: 'Fund'},
|
|
121
|
+
// type: { type: String, enum: ['commitment', 'contribution', 'distribution'] },
|
|
122
|
+
// amount: { type: Number, default: 0 },
|
|
123
|
+
// date: { type: Date, default: null },
|
|
124
|
+
// }],
|
|
125
|
+
|
|
126
|
+
lp.transactions.push({
|
|
120
127
|
fund: fund,
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
type: 'commitment',
|
|
129
|
+
amount: 100000,
|
|
130
|
+
date: new Date()
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
lp.transactions.push({
|
|
134
|
+
fund: fund,
|
|
135
|
+
type: 'contribution',
|
|
136
|
+
amount: 400000,
|
|
137
|
+
date: new Date()
|
|
123
138
|
});
|
|
124
139
|
|
|
125
140
|
lp.contact.phone.push({
|