Fixed creating stripe subscriptions for complimentary members in data generator

ref PROD-244
This commit is contained in:
Simon Backx 2023-12-13 15:23:21 +01:00 committed by Simon Backx
parent 58d1412d9b
commit e1ef7c44d8
2 changed files with 5 additions and 2 deletions

View File

@ -10,7 +10,7 @@ class MembersStripeCustomersImporter extends TableImporter {
} }
async import(quantity) { async import(quantity) {
const members = await this.transaction.select('id', 'name', 'email', 'created_at').from('members'); const members = await this.transaction.select('id', 'name', 'email', 'created_at').from('members').where('status', 'paid');
await this.importForEach(members, quantity ? quantity / members.length : 1); await this.importForEach(members, quantity ? quantity / members.length : 1);
} }

View File

@ -13,7 +13,7 @@ class SubscriptionsImporter extends TableImporter {
async import() { async import() {
const membersProducts = await this.transaction.select('member_id', 'product_id').from('members_products'); const membersProducts = await this.transaction.select('member_id', 'product_id').from('members_products');
this.members = await this.transaction.select('id', 'status', 'created_at').from('members'); this.members = await this.transaction.select('id', 'status', 'created_at').from('members').where('status', 'paid');
this.stripeProducts = await this.transaction.select('product_id', 'stripe_product_id').from('stripe_products'); this.stripeProducts = await this.transaction.select('product_id', 'stripe_product_id').from('stripe_products');
this.stripePrices = await this.transaction.select('stripe_product_id', 'currency', 'amount', 'interval').from('stripe_prices'); this.stripePrices = await this.transaction.select('stripe_product_id', 'currency', 'amount', 'interval').from('stripe_prices');
await this.importForEach(membersProducts, 1); await this.importForEach(membersProducts, 1);
@ -21,6 +21,9 @@ class SubscriptionsImporter extends TableImporter {
generate() { generate() {
const member = this.members.find(m => m.id === this.model.member_id); const member = this.members.find(m => m.id === this.model.member_id);
if (!member) {
return;
}
const status = member.status; const status = member.status;
const billingInfo = {}; const billingInfo = {};
const isMonthly = faker.datatype.boolean(); const isMonthly = faker.datatype.boolean();