Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute the doNotProcessUntil timespan for cancellation saves #1099

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ object NotificationHandler extends CohortHandler {
cancellationDate <- ZIO
.fromOption(SupporterPlus2024Migration.cancellationSaveDiscountEffectiveDate(subscription))
.orElseFail(DataExtractionFailure(s"Could not extract cancellation date for item ${item}"))
billingPeriod <- ZIO
.fromOption(item.billingPeriod)
.orElseFail(DataExtractionFailure(s"Could not extract billing period for item ${item}"))
months <- ZIO.succeed(CohortItem.billingPeriodToInt(billingPeriod))
_ <- CohortTable
.update(
CohortItem(
subscriptionName = item.subscriptionName,
processingStage = DoNotProcessUntil,
doNotProcessUntil = Some(cancellationDate.plusMonths(6))
doNotProcessUntil = Some(cancellationDate.plusMonths(months * 2))
)
)
} yield ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,15 @@ object CohortItem {
}
}
}

def billingPeriodToInt(period: String): Int = {
// This function is used to convert a CohortItem's billingPeriod in to the number of months
// that the billing period represents.
BillingPeriod.fromString(period) match {
case Monthly => 1
case Quarterly => 3
case SemiAnnual => 6
case Annual => 12
}
}
}