@dhyasama/totem-models 9.16.0 → 9.17.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.
Files changed (2) hide show
  1. package/lib/Financials.js +12 -5
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -70,6 +70,8 @@ module.exports = function(mongoose, config) {
70
70
  // Not Scheduled to be removed
71
71
  // Scheduled to be removed
72
72
  status: { type: String, enum: ['Delivered', 'Opened', 'Overdue', 'In Review', 'Completed', 'Archived', 'In Progress', 'Not Scheduled', 'Scheduled'] },
73
+
74
+ // to be removed
73
75
  action: { type: String },
74
76
 
75
77
  year: { type: Number, default: 0 },
@@ -786,18 +788,23 @@ module.exports = function(mongoose, config) {
786
788
  var isReviewed = snapshot.reviewedOn;
787
789
  var isRejected = snapshot.rejection;
788
790
  var isArchived = snapshot.archivedOn;
789
- var isOverdue = moment(snapshot.dueOn).isBefore(new Date());
790
- var isOpened = snapshot.action == 'Opened' || snapshot.action == 'Clicked';
791
- var isDelivered = snapshot.action == 'Delivered';
791
+ var isOverdue = moment(new Date()).isAfter(moment(snapshot.dueOn));
792
+
793
+ var isOpened = false;
794
+ var isDelivered = false;
795
+ if(snapshot.notifications && snapshot.notifications.company && snapshot.notifications.company.initial) {
796
+ isOpened = snapshot.notifications.company.initial.status && snapshot.notifications.company.initial.status == 'Opened' || snapshot.notifications.company.initial.status == 'Clicked';
797
+ isDelivered = snapshot.notifications.company.initial.sentOn;
798
+ }
792
799
 
793
800
  if(!snapshot.uuid) snapshot.status = 'Completed'; // no uuid means the snapshot was created from the google sheet and should always be completed
794
801
  else if(needsReview && isReviewed) snapshot.status = 'Completed';
795
802
  else if(!needsReview && isSubmitted) snapshot.status = 'Completed';
796
- else if(needsReview && isSubmitted && !isReviewed) snapshot.status = 'In Review';
797
803
  else if(isArchived) snapshot.status = 'Archived';
804
+ else if(needsReview && isSubmitted && !isReviewed) snapshot.status = 'In Review';
798
805
  else if(isOverdue) snapshot.status = 'Overdue';
799
806
  else if(isDelivered && isOpened) snapshot.status = 'Opened';
800
- else snapshot.status = 'Delivered';
807
+ else if(isDelivered) snapshot.status = 'Delivered';
801
808
 
802
809
  });
803
810
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "9.16.0",
3
+ "version": "9.17.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",