Skip to content

Commit

Permalink
Merge pull request #1099 from guardian/ph-20241128-1330-splus
Browse files Browse the repository at this point in the history
compute the doNotProcessUntil timespan for cancellation saves
  • Loading branch information
shtukas authored Nov 28, 2024
2 parents 5c73415 + 1717f95 commit 373347f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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
11 changes: 11 additions & 0 deletions lambda/src/main/scala/pricemigrationengine/model/CohortItem.scala
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
}
}
}

0 comments on commit 373347f

Please sign in to comment.