@dhyasama/totem-models 10.62.0 → 10.63.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 +23 -0
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -488,6 +488,29 @@ module.exports = function(mongoose, config) {
|
|
|
488
488
|
|
|
489
489
|
};
|
|
490
490
|
|
|
491
|
+
Financials.statics.getSnapshot = function getSnapshot(snapshotUUID, cb) {
|
|
492
|
+
|
|
493
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
494
|
+
if (!snapshotUUID) { return cb(new Error('snapshotUUID is required'), null); }
|
|
495
|
+
|
|
496
|
+
const self = this;
|
|
497
|
+
|
|
498
|
+
self.aggregate([
|
|
499
|
+
{ $unwind: '$snapshots' },
|
|
500
|
+
{
|
|
501
|
+
$project: {
|
|
502
|
+
_id: 1,
|
|
503
|
+
snapshot: '$snapshots'
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
]).exec(function(err, result) {
|
|
507
|
+
if (err) return cb(err);
|
|
508
|
+
else if (!result || result.length === 0) return cb(null, null);
|
|
509
|
+
else return cb(null, result[0]);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
};
|
|
513
|
+
|
|
491
514
|
Financials.statics.getRecurringToSend = function getRecurringToSend(options, cb) {
|
|
492
515
|
|
|
493
516
|
const self = this;
|