@dhyasama/totem-models 11.17.0 → 11.19.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/CapTable.js CHANGED
@@ -149,10 +149,20 @@ module.exports = function(mongoose, config) {
149
149
  customer: customerid,
150
150
  });
151
151
 
152
+ if (options.startDate) {
153
+ var startDate = options.startDate || moment().subtract(20, 'years').startOf('day').toISOString();
154
+ query.where('asOfDate').gte(startDate);
155
+ }
156
+
157
+ if (options.endDate) {
158
+ var endDate = options.endDate || moment().toISOString();
159
+ query.where('asOfDate').lte(endDate);
160
+ }
161
+
152
162
  query.populate('organization', 'name logoUrl');
153
- query.populate('stakeholders.lp', 'name')
154
- query.populate('stakeholders.org', 'name logoUrl')
155
- query.populate('stakeholders.person', 'name avatarUrl title')
163
+ query.populate('stakeholders.lp', 'name');
164
+ query.populate('stakeholders.org', 'name logoUrl');
165
+ query.populate('stakeholders.person', 'name avatarUrl title');
156
166
 
157
167
  query.exec(cb);
158
168
 
@@ -1703,6 +1703,51 @@ module.exports = function(mongoose, config) {
1703
1703
 
1704
1704
  };
1705
1705
 
1706
+ Organization.statics.getValuationsForOrgs = function getValuationForOrgs(orgIds, customerId, startDate, endDate, options, cb) {
1707
+
1708
+ const self = this;
1709
+
1710
+ if (!cb) {
1711
+ throw new Error('cb is required');
1712
+ }
1713
+ if (!orgIds) {
1714
+ return cb(new Error('orgIds is required'), null);
1715
+ }
1716
+ if (!options) {
1717
+ return cb(new Error('options is required'), null);
1718
+ }
1719
+ if (!customerId) {
1720
+ return cb(new Error('customerId is required'), null);
1721
+ }
1722
+ if (!startDate) {
1723
+ return cb(new Error('startDate is required'), null);
1724
+ }
1725
+ if (!endDate) {
1726
+ return cb(new Error('endDate is required'), null);
1727
+ }
1728
+
1729
+ let query = self
1730
+ .find({
1731
+ '_id': { $in: orgIds },
1732
+ 'valuations': {
1733
+ $elemMatch: {
1734
+ 'date': { $gte: startDate, $lte: endDate },
1735
+ 'customer': customerId
1736
+ }
1737
+ }
1738
+ })
1739
+ .select('_id valuations');
1740
+
1741
+ query.exec(function(err, orgs) {
1742
+
1743
+ if (err) { return cb(err, null); }
1744
+
1745
+ return cb(null, orgs);
1746
+
1747
+ });
1748
+
1749
+ };
1750
+
1706
1751
  Organization.statics.getFlags = function getFlags(orgid, options, cb) {
1707
1752
 
1708
1753
  const self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "11.17.0",
3
+ "version": "11.19.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",