Redesigned the querying for the sale duplicates screen to use aggregation; Finished the styling of the sale duplicate screen; Tested the functionality of sale duplicates; Added a way to show hidden (ignored) duplicates.

This commit is contained in:
Wynne Crisman
2017-05-26 11:17:32 -07:00
parent e1b0b19589
commit 210517a5c2
42 changed files with 15153 additions and 8505 deletions

View File

@@ -3,6 +3,13 @@ import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
import {SimpleSchema} from 'meteor/aldeed:simple-schema';
/**
* Notes:
* 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.
*/
Products = new Mongo.Collection('Products');
const ProductsSchema = new SimpleSchema({
@@ -237,7 +244,7 @@ if(Meteor.isServer) {
check(measureId, String);
check(price, Number);
if(setPrevious) check(setPrevious, Boolean);
if(effectiveDate) check(effectiveDate, Date);
if(effectiveDate) check(effectiveDate, Number); // TODO: Check that the format is YYYYMMDD
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
let products = Products.find({_id: {$in: productIds}}, {fields: {prices: 1}}).fetch();