in lambda/src/main/scala/pricemigrationengine/util/StartDates.scala [96:125]
def startDateLowerBound(
subscription: ZuoraSubscription,
invoicePreview: ZuoraInvoiceList,
cohortSpec: CohortSpec,
today: LocalDate
): IO[ConfigFailure, LocalDate] = {
// LowerBound from to the cohort spec and the notification window's end
val startDateLowerBound1 = MigrationType(cohortSpec) match {
case Newspaper2024 =>
newspaper2024Migration.Estimation.startDateLowerbound(today, subscription)
case GW2024 => cohortSpecLowerBound(cohortSpec, today)
case SupporterPlus2024 => cohortSpecLowerBound(cohortSpec, today)
case Default => cohortSpecLowerBound(cohortSpec, today)
}
// We now respect the policy of not increasing members during their first year
val startDateLowerBound2 = noPriceRiseDuringSubscriptionFirstYearPolicyUpdate(startDateLowerBound1, subscription)
// And the policy not to price rise a sub twice within 12 months of any possible price rise
val startDateLowerBound3 =
noPriceRiseWithinAYearOfLastPriceRisePolicyUpdate(cohortSpec, subscription, startDateLowerBound2)
// Decide the spread period for this migration
val spreadPeriod = decideSpreadPeriod(subscription, invoicePreview, cohortSpec)
for {
randomFactor <- Random.nextIntBetween(0, spreadPeriod)
} yield startDateLowerBound3.plusMonths(randomFactor)
}