@dhyasama/totem-models 8.27.0 → 8.28.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 +65 -32
- package/package.json +1 -1
- package/test/LimitedPartner.js +0 -14
package/lib/Financials.js
CHANGED
|
@@ -78,12 +78,10 @@ module.exports = function(mongoose, config) {
|
|
|
78
78
|
amount: { type: Number, default: 0 },
|
|
79
79
|
breakdown: { type: Schema.Types.Mixed }
|
|
80
80
|
},
|
|
81
|
-
|
|
82
81
|
liabilities: {
|
|
83
82
|
amount: { type: Number, default: 0 },
|
|
84
83
|
breakdown: { type: Schema.Types.Mixed }
|
|
85
84
|
},
|
|
86
|
-
|
|
87
85
|
equity: {
|
|
88
86
|
amount: { type: Number, default: 0 },
|
|
89
87
|
breakdown: { type: Schema.Types.Mixed }
|
|
@@ -94,12 +92,10 @@ module.exports = function(mongoose, config) {
|
|
|
94
92
|
amount: { type: Number, default: 0 },
|
|
95
93
|
breakdown: { type: Schema.Types.Mixed }
|
|
96
94
|
},
|
|
97
|
-
|
|
98
95
|
investingActivities: {
|
|
99
96
|
amount: { type: Number, default: 0 },
|
|
100
97
|
breakdown: { type: Schema.Types.Mixed }
|
|
101
98
|
},
|
|
102
|
-
|
|
103
99
|
financingActivities: {
|
|
104
100
|
amount: { type: Number, default: 0 },
|
|
105
101
|
breakdown: { type: Schema.Types.Mixed }
|
|
@@ -280,7 +276,7 @@ module.exports = function(mongoose, config) {
|
|
|
280
276
|
|
|
281
277
|
};
|
|
282
278
|
|
|
283
|
-
Financials.statics.
|
|
279
|
+
Financials.statics.getCompanyInitialUUIDsToSend = function getCompanyInitialUUIDsToSend(cb) {
|
|
284
280
|
|
|
285
281
|
var self = this;
|
|
286
282
|
var now = new Date();
|
|
@@ -318,7 +314,7 @@ module.exports = function(mongoose, config) {
|
|
|
318
314
|
|
|
319
315
|
};
|
|
320
316
|
|
|
321
|
-
Financials.statics.
|
|
317
|
+
Financials.statics.getCompanyReminderUUIDsToSend = function getCompanyReminderUUIDsToSend(cb) {
|
|
322
318
|
|
|
323
319
|
var self = this;
|
|
324
320
|
var now = new Date();
|
|
@@ -369,7 +365,7 @@ module.exports = function(mongoose, config) {
|
|
|
369
365
|
|
|
370
366
|
};
|
|
371
367
|
|
|
372
|
-
Financials.statics.
|
|
368
|
+
Financials.statics.getCompanyRejectionUUIDsToSend = function getCompanyRejectionUUIDsToSend(cb) {
|
|
373
369
|
|
|
374
370
|
var self = this;
|
|
375
371
|
var now = new Date();
|
|
@@ -413,63 +409,100 @@ module.exports = function(mongoose, config) {
|
|
|
413
409
|
|
|
414
410
|
};
|
|
415
411
|
|
|
416
|
-
Financials.statics.
|
|
412
|
+
Financials.statics.getStakeholderInitialUUIDsToSend = function getStakeholderInitialUUIDsToSend(cb) {
|
|
417
413
|
|
|
418
414
|
var self = this;
|
|
415
|
+
var now = new Date();
|
|
419
416
|
|
|
420
417
|
var query = self.find({
|
|
421
|
-
'
|
|
418
|
+
'snapshots': {
|
|
419
|
+
$elemMatch: {
|
|
420
|
+
'notifications.stakeholders.sendTo': { $gt: [] },
|
|
421
|
+
'notifications.stakeholders.organization': { $ne: null },
|
|
422
|
+
'notifications.stakeholders.initial.sendOn': { $lte: now },
|
|
423
|
+
'notifications.stakeholders.initial.sentOn': null
|
|
424
|
+
}
|
|
425
|
+
}
|
|
422
426
|
});
|
|
423
427
|
|
|
424
|
-
query.exec(
|
|
428
|
+
query.exec(function(err, result) {
|
|
429
|
+
|
|
430
|
+
if (err) { return cb(err, null); }
|
|
431
|
+
|
|
432
|
+
var snapshots = _.pluck(result || [], 'snapshots');
|
|
433
|
+
|
|
434
|
+
snapshots = _.flatten(snapshots);
|
|
435
|
+
|
|
436
|
+
snapshots = _.filter(snapshots, function(snapshot) {
|
|
437
|
+
|
|
438
|
+
var hasRecipients = snapshot.notifications.stakeholders.sendTo.length > 0;
|
|
439
|
+
var hasOrganization = snapshot.notifications.stakeholders.organization;
|
|
440
|
+
var hasUnsentSendOnLessThanNow = snapshot.notifications.stakeholders.initial.sendOn < now && !snapshot.notifications.stakeholders.initial.sentOn;
|
|
441
|
+
|
|
442
|
+
return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
|
|
443
|
+
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
return cb(null, _.pluck(snapshots, 'uuid'));
|
|
447
|
+
|
|
448
|
+
});
|
|
425
449
|
|
|
426
450
|
};
|
|
427
451
|
|
|
428
|
-
Financials.statics.
|
|
452
|
+
Financials.statics.getStakeholderReminderUUIDsToSend = function getStakeholderReminderUUIDsToSend(cb) {
|
|
429
453
|
|
|
430
454
|
var self = this;
|
|
455
|
+
var now = new Date();
|
|
431
456
|
|
|
432
457
|
var query = self.find({
|
|
433
|
-
'customer': customerId,
|
|
434
458
|
'snapshots': {
|
|
435
459
|
$elemMatch: {
|
|
436
|
-
'
|
|
437
|
-
'
|
|
438
|
-
'
|
|
460
|
+
'notifications.stakeholders.sendTo': { $gt: [] },
|
|
461
|
+
'notifications.stakeholders.organization': { $ne: null },
|
|
462
|
+
'notifications.stakeholders.reminders.sendOn': { $lte: now },
|
|
463
|
+
'notifications.stakeholders.reminders.sentOn': null
|
|
439
464
|
}
|
|
440
465
|
}
|
|
441
466
|
});
|
|
442
467
|
|
|
443
|
-
query.
|
|
444
|
-
|
|
445
|
-
query.exec(function(err, results) {
|
|
468
|
+
query.exec(function(err, result) {
|
|
446
469
|
|
|
447
|
-
|
|
470
|
+
if (err) { return cb(err, null); }
|
|
448
471
|
|
|
449
|
-
_.
|
|
450
|
-
_.each(result.snapshots, function(snapshot) {
|
|
472
|
+
var snapshots = _.pluck(result || [], 'snapshots');
|
|
451
473
|
|
|
452
|
-
|
|
453
|
-
var isSubmitted = snapshot.submittedOn;
|
|
454
|
-
var isNotReviewed = !snapshot.reviewedOn;
|
|
474
|
+
snapshots = _.flatten(snapshots);
|
|
455
475
|
|
|
456
|
-
|
|
457
|
-
snapshots.push({
|
|
458
|
-
organization: result.organization.name,
|
|
459
|
-
snapshot: snapshot
|
|
460
|
-
});
|
|
461
|
-
}
|
|
476
|
+
snapshots = _.filter(snapshots, function(snapshot) {
|
|
462
477
|
|
|
478
|
+
var hasRecipients = snapshot.notifications.stakeholders.sendTo.length > 0;
|
|
479
|
+
var hasOrganization = snapshot.notifications.stakeholders.organization;
|
|
480
|
+
var hasUnsentSendOnLessThanNow = _.find(snapshot.notifications.stakeholders.reminders, function(reminder) {
|
|
481
|
+
return reminder.sendOn < now && !reminder.sentOn;
|
|
463
482
|
});
|
|
483
|
+
|
|
484
|
+
return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
|
|
485
|
+
|
|
464
486
|
});
|
|
465
487
|
|
|
466
|
-
|
|
467
|
-
return cb(null, snapshots);
|
|
488
|
+
return cb(null, _.pluck(snapshots, 'uuid'));
|
|
468
489
|
|
|
469
490
|
});
|
|
470
491
|
|
|
471
492
|
};
|
|
472
493
|
|
|
494
|
+
Financials.statics.getForCustomer = function getForCustomer(customerId, cb) {
|
|
495
|
+
|
|
496
|
+
var self = this;
|
|
497
|
+
|
|
498
|
+
var query = self.find({
|
|
499
|
+
'customer': customerId
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
query.exec(cb);
|
|
503
|
+
|
|
504
|
+
};
|
|
505
|
+
|
|
473
506
|
Financials.statics.getToSend = function getToSend(uuid, cb) {
|
|
474
507
|
|
|
475
508
|
var self = this;
|
package/package.json
CHANGED
package/test/LimitedPartner.js
CHANGED
|
@@ -381,20 +381,6 @@ describe('Limited Partner', function() {
|
|
|
381
381
|
|
|
382
382
|
});
|
|
383
383
|
|
|
384
|
-
it('finds name for an lp if allowed', function(done) {
|
|
385
|
-
|
|
386
|
-
LimitedPartner.getById(lp.id, { CUSTOMER_ID: organization._id, role: 'lp-names' }, function(err, lp) {
|
|
387
|
-
|
|
388
|
-
should.not.exist(err);
|
|
389
|
-
should.exist(lp);
|
|
390
|
-
should.exist(lp.name);
|
|
391
|
-
|
|
392
|
-
done();
|
|
393
|
-
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
|
|
398
384
|
it('adds a flag', function(done) {
|
|
399
385
|
|
|
400
386
|
LimitedPartner.addFlag(lp.id, person._id, 'incorrect phone', organization._id, function(err, result) {
|