@dhyasama/totem-models 10.10.1 → 10.11.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/Organization.js +17 -15
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -689,8 +689,10 @@ module.exports = function(mongoose, config) {
|
|
|
689
689
|
|
|
690
690
|
var self = this;
|
|
691
691
|
|
|
692
|
+
if (!self.customer) return [];
|
|
693
|
+
|
|
692
694
|
// Backwards schema compatibility
|
|
693
|
-
if (!self.customer.deals) return [];
|
|
695
|
+
else if (!self.customer.deals) return [];
|
|
694
696
|
|
|
695
697
|
// Deals aren't on for customer
|
|
696
698
|
else if (!self.customer.deals.active) return [];
|
|
@@ -815,8 +817,8 @@ module.exports = function(mongoose, config) {
|
|
|
815
817
|
Organization.virtual('operating.closed.on').get(function () {
|
|
816
818
|
|
|
817
819
|
const self = this;
|
|
818
|
-
const publicData = self.operating.closed.public || {};
|
|
819
|
-
const privateData = self.operating.closed.private || [];
|
|
820
|
+
const publicData = self.operating && self.operating.closed && self.operating.closed.public || {};
|
|
821
|
+
const privateData = self.operating && self.operating.closed && self.operating.closed.private || [];
|
|
820
822
|
|
|
821
823
|
if (publicData.closedOn) return publicData.closedOn;
|
|
822
824
|
else if (privateData.length >= 1) {
|
|
@@ -830,8 +832,8 @@ module.exports = function(mongoose, config) {
|
|
|
830
832
|
Organization.virtual('operating.closed.hasZeroUnrealizedValue').get(function () {
|
|
831
833
|
|
|
832
834
|
const self = this;
|
|
833
|
-
const publicData = self.operating.closed.public || {};
|
|
834
|
-
const privateData = self.operating.closed.private || [];
|
|
835
|
+
const publicData = self.operating && self.operating.closed && self.operating.closed.public || {};
|
|
836
|
+
const privateData = self.operating && self.operating.closed && self.operating.closed.private || [];
|
|
835
837
|
|
|
836
838
|
if (publicData.closedOn) return false;
|
|
837
839
|
else if (privateData.length >= 1) {
|
|
@@ -845,8 +847,8 @@ module.exports = function(mongoose, config) {
|
|
|
845
847
|
Organization.virtual('operating.acquired.amount').get(function () {
|
|
846
848
|
|
|
847
849
|
const self = this;
|
|
848
|
-
const publicData = self.operating.acquired.public || {};
|
|
849
|
-
const privateData = self.operating.acquired.private || [];
|
|
850
|
+
const publicData = self.operating && self.operating.acquired && self.operating.acquired.public || {};
|
|
851
|
+
const privateData = self.operating && self.operating.acquired && self.operating.acquired.private || [];
|
|
850
852
|
|
|
851
853
|
if (publicData.amount) return publicData.amount;
|
|
852
854
|
else if (privateData.length >= 1) {
|
|
@@ -860,8 +862,8 @@ module.exports = function(mongoose, config) {
|
|
|
860
862
|
Organization.virtual('operating.acquired.by').get(function () {
|
|
861
863
|
|
|
862
864
|
const self = this;
|
|
863
|
-
const publicData = self.operating.acquired.public || {};
|
|
864
|
-
const privateData = self.operating.acquired.private || [];
|
|
865
|
+
const publicData = self.operating && self.operating.acquired && self.operating.acquired.public || {};
|
|
866
|
+
const privateData = self.operating && self.operating.acquired && self.operating.acquired.private || [];
|
|
865
867
|
|
|
866
868
|
if (publicData.by) return publicData.by;
|
|
867
869
|
else if (privateData.length >= 1) {
|
|
@@ -875,8 +877,8 @@ module.exports = function(mongoose, config) {
|
|
|
875
877
|
Organization.virtual('operating.acquired.on').get(function () {
|
|
876
878
|
|
|
877
879
|
const self = this;
|
|
878
|
-
const publicData = self.operating.acquired.public || {};
|
|
879
|
-
const privateData = self.operating.acquired.private || [];
|
|
880
|
+
const publicData = self.operating && self.operating.acquired && self.operating.acquired.public || {};
|
|
881
|
+
const privateData = self.operating && self.operating.acquired && self.operating.acquired.private || [];
|
|
880
882
|
|
|
881
883
|
if (publicData.acquiredOn) return publicData.acquiredOn;
|
|
882
884
|
else if (privateData.length >= 1) {
|
|
@@ -890,8 +892,8 @@ module.exports = function(mongoose, config) {
|
|
|
890
892
|
Organization.virtual('operating.merged.with').get(function () {
|
|
891
893
|
|
|
892
894
|
const self = this;
|
|
893
|
-
const publicData = self.operating.merged.public || {};
|
|
894
|
-
const privateData = self.operating.merged.private || [];
|
|
895
|
+
const publicData = self.operating && self.operating.merged && self.operating.merged.public || {};
|
|
896
|
+
const privateData = self.operating && self.operating.merged && self.operating.merged.private || [];
|
|
895
897
|
|
|
896
898
|
if (publicData.with) return publicData.with;
|
|
897
899
|
else if (privateData.length >= 1) {
|
|
@@ -905,8 +907,8 @@ module.exports = function(mongoose, config) {
|
|
|
905
907
|
Organization.virtual('operating.merged.on').get(function () {
|
|
906
908
|
|
|
907
909
|
const self = this;
|
|
908
|
-
const publicData = self.operating.merged.public || {};
|
|
909
|
-
const privateData = self.operating.merged.private || [];
|
|
910
|
+
const publicData = self.operating && self.operating.merged && self.operating.merged.public || {};
|
|
911
|
+
const privateData = self.operating && self.operating.merged && self.operating.merged.private || [];
|
|
910
912
|
|
|
911
913
|
if (publicData.mergedOn) return publicData.mergedOn;
|
|
912
914
|
else if (privateData.length >= 1) {
|