def read()

in app/com/gu/memsub/subsv2/reads/ChargeListReads.scala [120:126]


    def read(cat: PlanChargeMap, charges: List[ZuoraCharge]): ValidationNel[String, PaidCharge[P, BP]] = charges match {
      case charge :: Nil => (product.read(cat, charge) |@| bp.read(cat, charge) |@|
        charge.pricing.prices.exists(_.amount != 0).option(charge.pricing).toSuccess(NonEmptyList("Could not read paid charge: Charge is free")))
        .apply({ case(p, b, pricing) => PaidCharge(p, b, pricing, charge.productRatePlanChargeId, charge.id) })
      case charge :: others => Validation.failureNel(s"Too many charges! I got $charge and $others")
      case Nil => Validation.failureNel(s"No charges found!")
    }