Skip to content

Commit

Permalink
fix(members): properly check for ongoing subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
mtthp committed Apr 26, 2024
1 parent 702e9a4 commit 318ee9f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/calc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {add, sub} from 'date-fns'
import {add, isBefore, sub} from 'date-fns'
import {chain, sumBy, minBy} from 'lodash-es'

/**
Expand All @@ -13,11 +13,13 @@ export function computeSubcriptionEndDate(startDate) {
/* Legacy model functions */

export function isPresenceDuringAbo(presenceDate, abos) {
const oneMonthBefore = getDateOneMonthBefore(presenceDate)
const oneMonthBefore = new Date(getDateOneMonthBefore(presenceDate))
const presence = new Date(presenceDate)

return abos.some(
abo => oneMonthBefore < abo.aboStart && abo.aboStart <= presenceDate
)
return abos.some(abo => {
const started = new Date(abo.aboStart)
return isBefore(oneMonthBefore, started) && isBefore(started, presence)
})
}

export function computeBalance(user, memberActivity) {
Expand Down

0 comments on commit 318ee9f

Please sign in to comment.