Skip to content

Commit

Permalink
Merge pull request #113 from coworking-metz/abos-successifs
Browse files Browse the repository at this point in the history
Abos successifs
  • Loading branch information
gfra54 authored Sep 6, 2024
2 parents b20e98f + 3a983a7 commit c122344
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/models/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function getMemberSubscriptions(memberId) {
const subscriptions = await mongo.db.collection('subscriptions').find({memberId}).toArray()
return chain(subscriptions)
.map(s => formatSubscription(s))
.orderBy(['purchased'], ['desc'])
.orderBy(['purchased', 'started'], ['desc', 'desc'])
.value()
}

Expand All @@ -35,6 +35,7 @@ export async function addSubscriptionsToMember(memberId, startDate, purchase, pu
const payloads = []
for (let i = 0; i < purchaseQuantity; i++) {
payload._id = nanoid(17)
payload.startDate = add(new Date(payload.startDate), {months: i}).toISOString().slice(0, 10)
payloads.push({...payload})
}

Expand Down

0 comments on commit c122344

Please sign in to comment.