@dhyasama/totem-models 11.19.0 → 11.20.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/lib/Financials.js +19 -2
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -901,14 +901,31 @@ module.exports = function(mongoose, config) {
|
|
|
901
901
|
|
|
902
902
|
};
|
|
903
903
|
|
|
904
|
-
Financials.statics.getForCustomer = function getForCustomer(customerId, cb) {
|
|
905
|
-
|
|
904
|
+
Financials.statics.getForCustomer = function getForCustomer(customerId, options, cb) {
|
|
905
|
+
|
|
906
906
|
var self = this;
|
|
907
907
|
|
|
908
908
|
var query = self.find({
|
|
909
909
|
'customer': customerId
|
|
910
910
|
});
|
|
911
911
|
|
|
912
|
+
var dateRangeQuery = {};
|
|
913
|
+
if (options.startDate) {
|
|
914
|
+
var startDate = new Date(options.startDate);
|
|
915
|
+
dateRangeQuery['$gte'] = startDate;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (options.endDate) {
|
|
919
|
+
var endDate = new Date(options.endDate);
|
|
920
|
+
dateRangeQuery['$lte'] = endDate;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
if (options.startDate || options.endDate) {
|
|
924
|
+
query.where('snapshots').elemMatch({
|
|
925
|
+
submittedOn: dateRangeQuery
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
|
|
912
929
|
query.exec(cb);
|
|
913
930
|
|
|
914
931
|
};
|