in lambda/src/main/scala/pricemigrationengine/migrations/SupporterPlus2024Migration.scala [167:189]
def newBaseAmount(subscription: ZuoraSubscription): Either[Failure, Option[BigDecimal]] = {
for {
ratePlan <- getSupporterPlusV2RatePlan(subscription)
billingPeriod <- ZuoraRatePlan.ratePlanToBillingPeriod(ratePlan).toRight(DataExtractionFailure(""))
ratePlanCharge <- getSupporterPlusBaseRatePlanCharge(subscription.subscriptionNumber, ratePlan)
currency = ratePlanCharge.currency
oldBaseAmountOpt <- previousBaseAmount(subscription)
oldBaseAmount <- oldBaseAmountOpt.toRight(
DataExtractionFailure(
s"(error: 164d8f1c-6dc6) could not extract base amount for subscription ${subscription.subscriptionNumber}"
)
)
newPriceFromPriceGrid <- getNewPrice(billingPeriod, currency)
.map(BigDecimal(_))
.toRight(
DataExtractionFailure(
s"(error: 611aedea-0478) could not getNewPrice for (billingPeriod, currency) and (${billingPeriod}, ${currency})"
)
)
} yield {
Some((oldBaseAmount * BigDecimal(1.27)).min(newPriceFromPriceGrid))
}
}