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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user