JSFiddle - React, Tailwind, and code Playground
by runjep
JavaScript
Schema.Adviser = new SimpleSchema({
"firstName": {
type: String,
label: "First Name",
regEx: /^[a-zA-Z- ]+$/,
max: 200
},
"lastName": {
type: String,
label: "Last Name",
regEx: /^[a-zA-Z- ]+$/,
max: 200
},
"diaryStatus": {
type: Boolean,
autoValue: function() {
if (this.isInsert) {
return true;
}
}
},
"credit": {
type: Number,
min: 0,
defaultValue: 0,
optional: true
},
"creditNoDate": {
type: Number,
min: 0,
defaultValue: 0,
optional: true
},
"status": {
type: String,
allowedValues: statuses,
defaultValue: 'Waiting'
},
"leads": {
type: String,
allowedValues: leads,
defaultValue: 'Both'
},
"types": {
type: String,
allowedValues: types,
defaultValue: 'Pensions'
},
"active": {
type: Boolean,
autoValue: function() {
if (this.isInsert) {
return true;
}
}
},
"priority": {
type: Boolean,
autoValue: function() {
if (this.isInsert) {
return false;
}
}
},
"createdAt": {
type: Date,
label: "Date Adviser Added to System",
autoValue: function() {
if (this.isInsert) {
return new Date;
} else {
this.unset();
}
}
}
});
Schema.Account = new SimpleSchema({
"adviserId": {
type: Object,
},
period: {
type: Date,
},
order: {
type: Number,
min: 0
},
outstanding: {
type: Number,
min: 0,
defaultValue: 0
}
});
var fromMonth=5;
var toMonth=6;
var emptyMonthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
Template.adviser.helpers({
advisers: function() {
return Advisers.find({}, {
sort: {
priority: -1
},
limit: 1
});
},
monthData: function() {
var orders = Account.find({
adviserId: this._id
}, {
sort: {
period: 1
},
limit:...