@dhyasama/totem-models 9.69.0 → 9.70.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/Deal.js +4 -58
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -323,66 +323,12 @@ module.exports = function(mongoose, config) {
|
|
|
323
323
|
|
|
324
324
|
};
|
|
325
325
|
|
|
326
|
-
let getLastFundraiseAmount = function() {
|
|
327
|
-
|
|
328
|
-
if (!deal.history || deal.history.length === 0) return null;
|
|
329
|
-
|
|
330
|
-
let history = _.sortBy(deal.history);
|
|
331
|
-
let last = history[history.length - 1];
|
|
332
|
-
|
|
333
|
-
return last.fundraise.amount;
|
|
334
|
-
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
let getLastFundraiseValuation = function() {
|
|
338
|
-
|
|
339
|
-
if (!deal.history || deal.history.length === 0) return null;
|
|
340
|
-
|
|
341
|
-
let history = _.sortBy(deal.history);
|
|
342
|
-
let last = history[history.length - 1];
|
|
343
|
-
|
|
344
|
-
return last.fundraise.valuation;
|
|
345
|
-
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
let getLastFundraiseDetails = function () {
|
|
349
|
-
|
|
350
|
-
if (!deal.history || deal.history.length === 0 || !deal.fundraise.details) return null;
|
|
351
|
-
|
|
352
|
-
let history = _.sortBy(deal.history);
|
|
353
|
-
let last = history[history.length - 1];
|
|
354
|
-
|
|
355
|
-
return last.fundraise.details;
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
let formatMoney = function(n, c, d, t) {
|
|
360
|
-
|
|
361
|
-
var c = isNaN(c = Math.abs(c)) ? 2 : c,
|
|
362
|
-
d = d == undefined ? "." : d,
|
|
363
|
-
t = t == undefined ? "," : t,
|
|
364
|
-
s = n < 0 ? "-" : "",
|
|
365
|
-
i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))),
|
|
366
|
-
j = (j = i.length) > 3 ? j % 3 : 0;
|
|
367
|
-
|
|
368
|
-
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
|
|
369
|
-
|
|
370
|
-
};
|
|
371
|
-
|
|
372
326
|
let description = '';
|
|
373
327
|
let lastStage = getLastStage();
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (lastStage === null) { description = 'The deal was created'; }
|
|
379
|
-
else {
|
|
380
|
-
if (lastStage !== deal.stage) { description += 'The deal was updated from ' + lastStage + ' to ' + deal.stage; }
|
|
381
|
-
if (lastFundraiseAmount !== deal.fundraise.amount) { description += 'Fundraise amount was updated from $' + formatMoney(lastFundraiseAmount, 0) + ' to $' + formatMoney(deal.fundraise.amount, 0); }
|
|
382
|
-
if (lastFundraiseValuation !== deal.fundraise.valuation) { description += 'Fundraise valuation was updated from $' + formatMoney(lastFundraiseValuation, 0) + ' to $' + formatMoney(deal.fundraise.valuation, 0); }
|
|
383
|
-
if (lastFundraiseDetails && lastFundraiseDetails !== deal.fundraise.details) { description += 'Fundraise details were updated from ' + lastFundraiseDetails + ' to ' + deal.fundraise.details; }
|
|
384
|
-
if (!lastFundraiseDetails && deal.fundraise.details) { description += 'Fundraise details were added: ' + deal.fundraise.details; }
|
|
385
|
-
}
|
|
328
|
+
|
|
329
|
+
if (lastStage === null) description = 'The deal was created';
|
|
330
|
+
else if (lastStage !== deal.stage) description += 'The deal was updated from ' + lastStage + ' to ' + deal.stage;
|
|
331
|
+
else description = 'The deal details were updated';
|
|
386
332
|
|
|
387
333
|
// only add history if the description is set from the above conditions
|
|
388
334
|
if (description !== '') {
|