@positivegrid/pg-mongoose-schema 27.6.1 → 27.6.2

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/models/payment.js CHANGED
@@ -82,7 +82,7 @@ module.exports = (mongoose) => {
82
82
  }, { collection: 'jamup_product', toJSON: { virtuals: true }, toObject: { virtuals: true } })
83
83
  ProductSchema.index({ sku: 1 }, { unique: true })
84
84
 
85
- let LicenseSchema = new Schema({
85
+ const LicenseSchema = new Schema({
86
86
  user_id: { type: ObjectId, ref: 'User', required: true },
87
87
  product_id: { type: ObjectId, ref: 'Product', required: true },
88
88
  bc_order_id: { type: Number, default: null },
@@ -725,11 +725,16 @@ module.exports = (mongoose) => {
725
725
  ? 'id name sku product_type display_name extra_payment_fields created_on'
726
726
  : 'id name sku product_type display_name addition created_on'
727
727
 
728
+ const freeTrialQuery = (productType === 'free_trial')
729
+ ? { $and: [{ from_free_trial: { $ne: null } }, { from_free_trial: { $exists: true } }] }
730
+ : { $or: [{ from_free_trial: null }, { from_free_trial: { $exists: false } }] }
731
+
728
732
  // Always check license status & due_date
729
733
  const queryObj = _.assign({}, {
730
734
  status: { '$in': [1, 4] },
731
735
  '$or': [{ 'due_date': null }, { 'due_date': { $gt: new Date() } }]
732
- }, query)
736
+ }, freeTrialQuery, query)
737
+ debug('getUserPurchasePromise %o', queryObj)
733
738
 
734
739
  const result = (_.has(opts, 'isLean') && opts.isLean === true)
735
740
  ? await this.find(queryObj)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "27.6.1",
3
+ "version": "27.6.2",
4
4
  "description": "Positive Grid mongoose schema",
5
5
  "author": "Ferrari Lee <shiyung@positivegrid.com>",
6
6
  "homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",