private[handlers] def estimate()

in lambda/src/main/scala/pricemigrationengine/handlers/EstimationHandler.scala [65:88]


  private[handlers] def estimate(
      catalogue: ZuoraProductCatalogue,
      cohortSpec: CohortSpec
  )(
      today: LocalDate,
      item: CohortItem,
  ): ZIO[CohortTable with Zuora, Failure, EstimationResult] =
    doEstimation(catalogue, item, cohortSpec, today).foldZIO(
      failure = {
        case failure: DataExtractionFailure =>
          val result = FailedEstimationResult(item.subscriptionName, failure.reason)
          CohortTable.update(CohortItem.fromFailedEstimationResult(result)).as(result)
        case _: CancelledSubscriptionFailure =>
          val result = CancelledEstimationResult(item.subscriptionName)
          CohortTable
            .update(
              CohortItem.fromCancelledEstimationResult(
                result,
                s"(reason: b6829dd30) subscription ${item.subscriptionName} has been cancelled in Zuora"
              )
            )
            .as(result)
        case e => ZIO.fail(e)
      },