in lambda/src/main/scala/pricemigrationengine/migrations/Newspaper2024Migration/Estimation.scala [35:55]
def subscriptionToMigrationProductName(subscription: ZuoraSubscription): Either[String, String] = {
// We are doing a multi product migration. This function tries and retrieve the correct product given a
// subscription.
val migrationProductNames = List("Newspaper Delivery", "Newspaper Digital Voucher", "Newspaper Voucher")
val names = subscription.ratePlans
.filter(ratePlanLastChangeTypeIsNoneOrAdd)
.map(ratePlan => ratePlan.productName)
.filter(name => migrationProductNames.contains(name))
.distinct
names match {
case Nil =>
Left(
s"[error: d5fb6922] could not determine migration product name for subscription ${subscription.subscriptionNumber}; no name to choose from"
)
case name :: Nil => Right(name)
case _ =>
Left(
s"[error: d3ecd18d] could not determine migration product name for subscription ${subscription.subscriptionNumber}; more than one name to choose from"
)
}
}