in lib/zuora-core/src/main/scala/com/gu/zuora/subscription/RatePlanChargeData.scala [74:94]
def round2Places(d: Double): Double = BigDecimal(d).setScale(2, RoundingMode.UP).toDouble
private def approximateBillingPeriodWeeksForName(
billingPeriodName: String,
optionalSpecificBillingPeriod: Option[Int],
): Either[ZuoraApiFailure, Int] = {
billingPeriodName match {
case "Annual" => Right(52)
case "Semi_Annual" => Right(26)
case "Quarter" => Right(13)
case "Month" => Right(4)
case "Specific_Weeks" =>
optionalSpecificBillingPeriod
.toRight(ZuoraApiFailure(s"specificBillingPeriod is required for $billingPeriodName billing period"))
case "Specific_Months" =>
optionalSpecificBillingPeriod
.toRight(ZuoraApiFailure(s"specificBillingPeriod is required for $billingPeriodName billing period"))
.map(numberOfMonths => numberOfMonths * 4)
case _ => Left(ZuoraApiFailure(s"Failed to determine duration of billing period: $billingPeriodName"))
}
}