@dhyasama/totem-models 9.77.0 → 9.79.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/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var bootstrap = function(mongoose, config) {
|
|
|
59
59
|
require('./lib/LimitedPartnerCampaign.js')(mongoose, config);
|
|
60
60
|
require('./lib/LimitedPartnerContactGroup.js')(mongoose, config);
|
|
61
61
|
require('./lib/LimitedPartnerCommunication.js')(mongoose, config);
|
|
62
|
+
require('./lib/LimitedPartnerReportGenerator.js')(mongoose, config);
|
|
62
63
|
require('./lib/Message.js')(mongoose, config);
|
|
63
64
|
require('./lib/MessageRecipient.js')(mongoose, config);
|
|
64
65
|
require('./lib/News.js')(mongoose, config);
|
|
@@ -23,6 +23,9 @@ module.exports = function(mongoose, config) {
|
|
|
23
23
|
// email body
|
|
24
24
|
body: { type: String, trim: true, required: true },
|
|
25
25
|
|
|
26
|
+
// whether the campaign is partially completed
|
|
27
|
+
draft: { type: Boolean, required: true, default: false },
|
|
28
|
+
|
|
26
29
|
// sent all emails to queue
|
|
27
30
|
sentEmailsToQueue: { type: Boolean, required: true, default: false },
|
|
28
31
|
|
|
@@ -48,7 +51,7 @@ module.exports = function(mongoose, config) {
|
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
// Scheduled but not sent
|
|
51
|
-
LimitedPartnerCampaign.statics.
|
|
54
|
+
LimitedPartnerCampaign.statics.getUpcoming = function getUpcoming(customerId, options, cb) {
|
|
52
55
|
|
|
53
56
|
const self = this;
|
|
54
57
|
const now = new Date();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('underscore');
|
|
4
|
+
|
|
5
|
+
module.exports = function(mongoose, config) {
|
|
6
|
+
|
|
7
|
+
const Schema = mongoose.Schema;
|
|
8
|
+
|
|
9
|
+
const LimitedPartnerReportGenerator = new Schema({
|
|
10
|
+
|
|
11
|
+
// the campaign id
|
|
12
|
+
campaign: { type: Schema.ObjectId, ref: 'LimitedPartnerCampaign', required: true },
|
|
13
|
+
|
|
14
|
+
// the fund the files are associated to
|
|
15
|
+
fund: { type: Schema.ObjectId, ref: 'Fund', required: true },
|
|
16
|
+
|
|
17
|
+
// the year the files are associated to
|
|
18
|
+
year: { type: String, trim: true, required: true },
|
|
19
|
+
|
|
20
|
+
// the period the files are associated to
|
|
21
|
+
period: { type: String, trim: true, required: true },
|
|
22
|
+
|
|
23
|
+
// the documents included in this communication
|
|
24
|
+
documents: [{
|
|
25
|
+
|
|
26
|
+
// the lp id
|
|
27
|
+
limitedPartner: { type: Schema.ObjectId, ref: 'LimitedPartner', required: true },
|
|
28
|
+
|
|
29
|
+
// the file name
|
|
30
|
+
fileName: { type: String, trim: true, required: true },
|
|
31
|
+
|
|
32
|
+
// file contents, base64 encoded for postmark
|
|
33
|
+
content: { type: String, trim: true, required: false },
|
|
34
|
+
|
|
35
|
+
// file type
|
|
36
|
+
contentType: { type: String, trim: true, required: true },
|
|
37
|
+
|
|
38
|
+
// file size
|
|
39
|
+
contentLength: { type: String, trim: true, required: true },
|
|
40
|
+
|
|
41
|
+
// where to find in s3
|
|
42
|
+
s3: {
|
|
43
|
+
bucket: { type: String, required: true, trim: true },
|
|
44
|
+
key: { type: String, required: true, trim: true }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}],
|
|
48
|
+
|
|
49
|
+
// the date the request was started
|
|
50
|
+
requestedOn: { type: Date, required: true },
|
|
51
|
+
|
|
52
|
+
// the date the request was completed
|
|
53
|
+
completedOn: { type: Date }
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
LimitedPartnerReportGenerator.statics.getByCampaign = function (campaignId, options, cb) {
|
|
58
|
+
|
|
59
|
+
const self = this;
|
|
60
|
+
|
|
61
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
62
|
+
if (!campaignId) { return cb(new Error('campaignId is required'), null); }
|
|
63
|
+
if (!mongoose.Types.ObjectId.isValid(campaignId)) { return cb(new Error('campaignId is not a valid ObjectId'), null); }
|
|
64
|
+
|
|
65
|
+
self.findOne({
|
|
66
|
+
'campaign': campaignId
|
|
67
|
+
}).exec(cb);
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
LimitedPartnerReportGenerator.statics.upsert = function upsert(doc, options, cb) {
|
|
72
|
+
|
|
73
|
+
if (!doc) { return cb(new Error('doc is required'), null); }
|
|
74
|
+
|
|
75
|
+
doc.save(cb);
|
|
76
|
+
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
LimitedPartnerReportGenerator.set('usePushEach', true);
|
|
80
|
+
LimitedPartnerReportGenerator.set('autoIndex', false);
|
|
81
|
+
LimitedPartnerReportGenerator.set('usePushEach', true);
|
|
82
|
+
|
|
83
|
+
mongoose.model('LimitedPartnerReportGenerator', LimitedPartnerReportGenerator);
|
|
84
|
+
|
|
85
|
+
};
|