Added custom scroll bars and separated the table header from the tables for Sales and the Graphs tables.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { Logger } from 'meteor/ostrio:logger';
|
||||
import { LoggerMongo } from 'meteor/ostrio:loggermongo';
|
||||
|
||||
// The logging tool is primarily for managing administrative functions such that administrators can view the app logs and issue commands that might generate administrative logging.
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ import {SimpleSchema} from 'meteor/aldeed:simple-schema';
|
||||
* The Product object has a prices field which is an object whose fields names are Measure ID's. Each field value (for each Measure ID) is an object that has a 'price', 'effectiveDate', and 'previousPrice'.
|
||||
* The effectiveDate field stores the date as a number in the format YYYYMMDD. Converting this number into a local date is done with moment(sale.date.toString(), "YYYYMMDD").toDate(), and converting it to a number from a date can be accomplished with ~~(moment(date).format("YYYYMMDD")), where the ~~ is a bitwise not and converts a string to a number quickly and reliably.
|
||||
* Because the structure of the Product object is so complicated, the normal checking that is done by the framework cannot be used.
|
||||
*
|
||||
* A product is first deactivated, then hidden.
|
||||
* A deactivated product is one that is no longer intended to be used (produced), but needs to show up in some lists because there may be some still floating around in inventory (needing to be sold). It should show with a yellow indicator if displayed.
|
||||
* A product that is hidden is one that exists in the system as a historical artifact due to there still being data attached to it (sales for example). It should not normally show in lists, and should show up with a red indicator if it is displayed.
|
||||
*/
|
||||
|
||||
Products = new Mongo.Collection('Products');
|
||||
@@ -190,6 +194,15 @@ if(Meteor.isServer) {
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
},
|
||||
convertProduct: function(productId, alternateProductId) {
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
check(productId, String);
|
||||
check(alternateProductId, String);
|
||||
// Replace all sale references to the given ID with the provided alternate product ID.
|
||||
Meteor.collections.Sales.update({productId: productId}, {$set: {productId: alternateProductId}}, {multi: true});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
},
|
||||
deactivateProduct: function(id) {
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
//Products.remove(id);
|
||||
|
||||
@@ -16,6 +16,16 @@ let SalesSchema = new SimpleSchema({
|
||||
optional: false,
|
||||
index: 1
|
||||
},
|
||||
timestamp: {
|
||||
type: Date,
|
||||
label: "Timestamp",
|
||||
optional: true
|
||||
},
|
||||
weekOfYear: {
|
||||
type: Number,
|
||||
label: "Week Of Year",
|
||||
optional: true
|
||||
},
|
||||
amount: {
|
||||
type: Number,
|
||||
label: "Amount",
|
||||
@@ -189,7 +199,8 @@ if(Meteor.isServer) {
|
||||
let group = {
|
||||
$group: {
|
||||
_id: {
|
||||
year: {$dateToString: {format: '%Y', date: '$date'}}//{$year: '$date'}
|
||||
//year: {$dateToString: {format: '%Y', date: '$date'}}//{$year: '$date'}
|
||||
year: {$substr: ['$date', 0, 4]}
|
||||
},
|
||||
'total': {
|
||||
$sum: {
|
||||
@@ -212,13 +223,13 @@ if(Meteor.isServer) {
|
||||
|
||||
//Annual is assumed if not week or month.
|
||||
if(time === 'weekly') {
|
||||
group.$group._id.week = {$dateToString: {format: '%U', date: '$date'}}; //{$week: '$date'};
|
||||
group.$group._id.week = '$weekOfYear'; //{$dateToString: {format: '%U', date: new Date({$concat: [{$substr: ['$date', 0, 4]}, '-', {$substr: ['$date', 4, 2]}, '-', {$substr: ['$date', 6, 2]}]}) }}; //{$week: '$date'};
|
||||
project.$project.week = '$_id.week';
|
||||
project.$project.date = {$concat: ['$_id.week', '-', '$_id.year']};
|
||||
project.$project._id.$concat.push('$_id.week');
|
||||
project.$project.date = {$concat: [{$substr: ['$_id.week', 0, 2]}, '-', '$_id.year']};
|
||||
project.$project._id.$concat.push({$substr: ['$_id.week', 0, 2]});
|
||||
}
|
||||
else if(time === 'monthly') {
|
||||
group.$group._id.month = {$dateToString: {format: '%m', date: '$date'}}; //{$month: '$date'};
|
||||
group.$group._id.month = {$substr: ['$date', 4, 6]}; //{$dateToString: {format: '%m', date: new Date({$concat: [{$substr: ['$date', 0, 4]}, '-', {$substr: ['$date', 4, 2]}, '-', {$substr: ['$date', 6, 2]}]}) }}; //{$month: '$date'};
|
||||
project.$project.month = '$_id.month';
|
||||
project.$project.date = {$concat: ['$_id.month', '-', '$_id.year']};
|
||||
project.$project._id.$concat.push('$_id.month');
|
||||
@@ -285,7 +296,11 @@ if(Meteor.isServer) {
|
||||
comment: Match.Optional(String)
|
||||
});
|
||||
|
||||
let dateString = date.toString();
|
||||
|
||||
sale.createdAt = new Date();
|
||||
sale.timestamp = new Date(dateString.substring(0, 4) + "-" + dateString.substring(4, 6) + "-" + dateString.substring(6, 8) + "T00:00:00Z");
|
||||
sale.weekOfYear = sale.timestamp.getWeek().toString();
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
Sales.insert(sale, function(err, id) {
|
||||
@@ -332,8 +347,12 @@ if(Meteor.isServer) {
|
||||
check(price, Number);
|
||||
check(amount, Number);
|
||||
|
||||
let dateString = date.toString();
|
||||
let timestamp = new Date(dateString.substring(0, 4) + "-" + dateString.substring(4, 6) + "-" + dateString.substring(6, 8) + "T00:00:00Z");
|
||||
let weekOfYear = sale.timestamp.getWeek().toString();
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
Sales.update(id, {$set: {date, venueId, price, amount}}, function(err, id) {
|
||||
Sales.update(id, {$set: {date, venueId, price, amount, timestamp, weekOfYear}}, function(err, id) {
|
||||
if(err) console.log(err);
|
||||
}, {bypassCollection2: true});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user