Skip to content

Commit

Permalink
Merge pull request #1076 from guardian/jd-rename-sub-types
Browse files Browse the repository at this point in the history
rename data types to reflect zuora's naming better
  • Loading branch information
johnduffell committed May 21, 2024
2 parents 48168de + 04cd96f commit aed658c
Show file tree
Hide file tree
Showing 32 changed files with 193 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.gu.memsub.Product.Contribution
import com.gu.memsub.subsv2.reads.ChargeListReads._
import com.gu.memsub.subsv2.reads.SubPlanReads
import com.gu.memsub.subsv2.reads.SubPlanReads._
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.monitoring.SafeLogging
import com.gu.salesforce.Contact
Expand Down Expand Up @@ -306,7 +306,7 @@ class AccountController(
private def sendSubscriptionCancelledEmail(
email: String,
contact: Contact,
plan: SubscriptionPlan,
plan: RatePlan,
cancellationEffectiveDate: Option[LocalDate],
)(implicit logPrefix: LogPrefix) =
SimpleEitherT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.gu.memsub._
import com.gu.memsub.subsv2.reads.ChargeListReads._
import com.gu.memsub.subsv2.reads.SubPlanReads._
import com.gu.memsub.subsv2.services.SubscriptionService
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.monitoring.SafeLogging
import components.TouchpointComponents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import actions.{CommonActions, Return401IfNotSignedInRecently}
import com.gu.memsub
import com.gu.memsub.subsv2.SubscriptionPlan
import com.gu.memsub.subsv2.RatePlan
import com.gu.memsub.{CardUpdateFailure, CardUpdateSuccess, GoCardless, PaymentMethod}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.monitoring.SafeLogging
Expand Down Expand Up @@ -90,7 +90,7 @@ class PaymentUpdateController(
emailAddress: String,
contact: Contact,
paymentMethod: PaymentType,
plan: SubscriptionPlan,
plan: RatePlan,
)(implicit logPrefix: LogPrefix): SimpleEitherT[Unit] =
SimpleEitherT.rightT(sendEmail.send(paymentMethodChangedEmail(emailAddress, contact, paymentMethod, plan)))

Expand Down
4 changes: 2 additions & 2 deletions membership-attribute-service/app/models/AccountDetails.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ object AccountDetails {
case _ => Json.obj()
}

def externalisePlanName(plan: SubscriptionPlan): Option[String] = plan.product match {
def externalisePlanName(plan: RatePlan): Option[String] = plan.product match {
case _: Product.Weekly => if (plan.name.contains("Six for Six")) Some("currently on '6 for 6'") else None
case _: Product.Paper => Some(plan.name.replace("+", " plus Digital Subscription"))
case _ => None
}

def jsonifyPlan(plan: SubscriptionPlan) = Json.obj(
def jsonifyPlan(plan: RatePlan) = Json.obj(
"name" -> externalisePlanName(plan),
"start" -> plan.start,
"end" -> plan.end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package models

import _root_.services.zuora.rest.ZuoraRestService.ObjectAccount
import com.gu.memsub._
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.monitoring.SafeLogging
import org.joda.time.LocalDate.now
import play.api.libs.json.Json
Expand All @@ -20,7 +20,7 @@ object ExistingPaymentOption {

import existingPaymentOption._

private def getSubscriptionFriendlyName(plan: SubscriptionPlan): String = plan.product match {
private def getSubscriptionFriendlyName(plan: RatePlan): String = plan.product match {
case _: Product.Weekly => "Guardian Weekly"
case _: Product.Membership => plan.productName + " Membership"
case _: Product.Contribution => plan.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.gu.memsub.Product.GuardianPatron
import com.gu.memsub.Subscription._
import com.gu.memsub._
import com.gu.memsub.subsv2.ReaderType.Direct
import com.gu.memsub.subsv2.{CovariantNonEmptyList, SingleCharge, Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, RatePlanCharge, Subscription, RatePlan}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.services.model.PaymentDetails
import com.gu.services.model.PaymentDetails.PersonalPlan
Expand Down Expand Up @@ -86,7 +86,7 @@ class GuardianPatronService(
promoCode = None,
isCancelled = subscription.isCancelled,
plans = CovariantNonEmptyList(
SubscriptionPlan(
RatePlan(
id = RatePlanId(guardianPatronProductRatePlanId),
productRatePlanId = ProductRatePlanId(guardianPatronProductRatePlanId),
name = subscription.plan.id,
Expand All @@ -96,7 +96,7 @@ class GuardianPatronService(
productType = "Membership",
product = GuardianPatron,
features = Nil,
charges = SingleCharge(
charges = RatePlanCharge(
benefit = Benefit.GuardianPatron,
billingPeriod = billingPeriodFromInterval(subscription.plan.interval),
price = PricingSummary(Map(subscription.plan.currency -> price)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package services

import com.gu.memsub.promo.LogImplicit.LoggableFuture
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.memsub.{BillingPeriod, Price}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.monitoring.SafeLogging
Expand Down
6 changes: 3 additions & 3 deletions membership-attribute-service/app/services/mail/Emails.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package services.mail

import com.gu.i18n.Currency
import com.gu.memsub.BillingPeriod.RecurringPeriod
import com.gu.memsub.subsv2.SubscriptionPlan
import com.gu.memsub.subsv2.RatePlan
import com.gu.salesforce.Contact
import org.joda.time.LocalDate
import org.joda.time.format.DateTimeFormat
Expand All @@ -12,7 +12,7 @@ import java.text.DecimalFormat
object Emails {
private val dateFormat = DateTimeFormat.forPattern("d MMMM yyyy")

def paymentMethodChangedEmail(emailAddress: String, contact: Contact, paymentMethod: PaymentType, plan: SubscriptionPlan): EmailData = {
def paymentMethodChangedEmail(emailAddress: String, contact: Contact, paymentMethod: PaymentType, plan: RatePlan): EmailData = {
EmailData(
emailAddress = emailAddress,
salesforceContactId = contact.salesforceContactId,
Expand All @@ -29,7 +29,7 @@ object Emails {
def subscriptionCancelledEmail(
emailAddress: String,
contact: Contact,
plan: SubscriptionPlan,
plan: RatePlan,
cancellationEffectiveDate: Option[LocalDate],
): EmailData = {
EmailData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package services.subscription

import com.gu.memsub
import com.gu.memsub.Subscription.Name
import com.gu.memsub.subsv2.SubscriptionPlan
import com.gu.memsub.subsv2.RatePlan
import com.gu.memsub.subsv2.reads.SubPlanReads
import com.gu.memsub.subsv2.services.SubscriptionService
import com.gu.monitoring.SafeLogger.LogPrefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package services.zuora.payment
import com.gu.memsub.BillingSchedule.Bill
import com.gu.memsub.Subscription._
import com.gu.memsub.promo.LogImplicit._
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.memsub.{BillingSchedule, Subscription => _, _}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.monitoring.SafeLogging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.gu.i18n.Currency
import com.gu.memsub.Product.Contribution
import com.gu.memsub.Subscription.Name
import com.gu.memsub.subsv2.services.{CatalogService, SubscriptionService}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, SubscriptionPlan}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, RatePlan}
import com.gu.memsub.{Product, Subscription}
import com.gu.monitoring.SafeLogger.LogPrefix
import com.gu.zuora.ZuoraSoapService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import acceptance.data.stripe.{TestStripeCard, TestStripeCustomer}
import com.gu.i18n.Country
import com.gu.memsub.Subscription
import com.gu.memsub.subsv2.services.{CatalogService, SubscriptionService}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, SubscriptionPlan}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, RatePlan}
import com.gu.zuora.ZuoraSoapService
import com.gu.zuora.api.{GoCardlessZuoraInstance, PaymentGateway}
import com.gu.zuora.soap.models.Commands.{BankTransfer, CreatePaymentMethod}
Expand Down
32 changes: 16 additions & 16 deletions membership-attribute-service/test/acceptance/data/TestCatalog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ import scalaz.NonEmptyList
object TestCatalogPlan {
def randomPlanId(): ProductRatePlanId = ProductRatePlanId(randomId("productRatePlanId"))

def apply[P <: Product, C <: ChargeList, S <: Status](
def apply[P <: Product, C <: RatePlanChargeList, S <: Status](
product: P,
name: String,
charges: C,
status: S,
id: ProductRatePlanId = randomPlanId(),
description: String = "",
saving: Option[Int] = None,
): CatalogPlan[P, C, S] =
CatalogPlan[P, C, S](id, product, name, description, saving, charges, status)
): ProductRatePlan[P, C, S] =
ProductRatePlan[P, C, S](id, product, name, description, saving, charges, status)

def paid[P <: Product, B <: Benefit, BP <: BillingPeriod](
product: P,
benefit: B,
billingPeriod: BP,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, BP], Current] =
TestCatalogPlan[P, SingleCharge[B, BP], Current](
): ProductRatePlan[P, RatePlanCharge[B, BP], Current] =
TestCatalogPlan[P, RatePlanCharge[B, BP], Current](
product = product,
name = name + "Paid",
charges = TestSingleCharge[B, BP](benefit, billingPeriod, TestPricingSummary.gbp(amount)),
Expand All @@ -44,50 +44,50 @@ object TestCatalogPlan {
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, Month.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, Month.type], Current] =
paid(product, benefit, Month, name + "Monthly", amount)

def sixWeeksPaid[P <: Product, B <: Benefit](
product: P,
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, SixWeeks.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, SixWeeks.type], Current] =
paid(product, benefit, SixWeeks, name + "SixWeeks", amount)

def quarterlyPaid[P <: Product, B <: Benefit](
product: P,
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, Quarter.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, Quarter.type], Current] =
paid(product, benefit, Quarter, name + "Quarterly", amount)

def yearlyPaid[P <: Product, B <: Benefit](
product: P,
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, Year.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, Year.type], Current] =
paid(product, benefit, Year, name + "Yearly", amount)

def threeMonthsPaid[P <: Product, B <: Benefit](
product: P,
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, ThreeMonths.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, ThreeMonths.type], Current] =
paid(product, benefit, ThreeMonths, name + "ThreeMonths", amount)

def oneYearPaid[P <: Product, B <: Benefit](
product: P,
benefit: B,
name: String,
amount: Double,
): CatalogPlan[P, SingleCharge[B, OneYear.type], Current] =
): ProductRatePlan[P, RatePlanCharge[B, OneYear.type], Current] =
paid(product, benefit, OneYear, name + "OneYear", amount)

def paperCharges[P <: Product, BP <: BillingPeriod](product: P, name: String): CatalogPlan[P, PaperCharges, Current] =
def paperCharges[P <: Product, BP <: BillingPeriod](product: P, name: String): ProductRatePlan[P, PaperCharges, Current] =
TestCatalogPlan[P, PaperCharges, Current](
product = product,
name = name + "PaperCharges",
Expand Down Expand Up @@ -192,10 +192,10 @@ object TestCatalog {
patron: MembershipPlans[Patron.type] = testPaidMembershipPlans(Patron),
digipack: DigipackPlans = testDigipackPlans(),
supporterPlus: SupporterPlusPlans = testSupporterPlusPlans(),
contributor: CatalogPlan.Contributor = monthlyPaid(Product.Contribution, Benefit.Contributor, "Contributor", 12),
voucher: NonEmptyList[CatalogPlan.Voucher] = NonEmptyList(paperCharges(Product.Voucher, "Voucher")),
digitalVoucher: NonEmptyList[CatalogPlan.DigitalVoucher] = NonEmptyList(paperCharges(Product.DigitalVoucher, "DigitalVoucher")),
delivery: NonEmptyList[CatalogPlan.Delivery] = NonEmptyList(paperCharges(Product.Delivery, "Delivery")),
contributor: ProductRatePlan.Contributor = monthlyPaid(Product.Contribution, Benefit.Contributor, "Contributor", 12),
voucher: NonEmptyList[ProductRatePlan.Voucher] = NonEmptyList(paperCharges(Product.Voucher, "Voucher")),
digitalVoucher: NonEmptyList[ProductRatePlan.DigitalVoucher] = NonEmptyList(paperCharges(Product.DigitalVoucher, "DigitalVoucher")),
delivery: NonEmptyList[ProductRatePlan.Delivery] = NonEmptyList(paperCharges(Product.Delivery, "Delivery")),
weekly: WeeklyPlans = weeklyPlans(),
map: Map[ProductRatePlanId, CatalogZuoraPlan] = Map.empty,
): Catalog = Catalog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import acceptance.data.Randoms.randomId
import com.gu.memsub.Product
import com.gu.memsub.Product.Membership
import com.gu.memsub.Subscription.{Feature, ProductRatePlanId, RatePlanId}
import com.gu.memsub.subsv2.{ChargeList, SubscriptionPlan}
import com.gu.memsub.subsv2.{RatePlanChargeList, RatePlan}
import org.joda.time.LocalDate

object TestPaidSubscriptionPlan {
Expand All @@ -18,11 +18,11 @@ object TestPaidSubscriptionPlan {
productType: String = randomId("paidSubscriptionPlanProductType"),
product: Product = Membership,
features: List[Feature] = Nil,
charges: ChargeList = TestSingleCharge(),
charges: RatePlanChargeList = TestSingleCharge(),
chargedThrough: Option[LocalDate] = None, // this is None if the sub hasn't been billed yet (on a free trial)
start: LocalDate = LocalDate.now().minusDays(13),
end: LocalDate = LocalDate.now().minusDays(13).plusYears(1),
): SubscriptionPlan = SubscriptionPlan(
): RatePlan = RatePlan(
id: RatePlanId,
productRatePlanId,
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package acceptance.data
import acceptance.data.Randoms.randomId
import com.gu.memsub.BillingPeriod.Year
import com.gu.memsub.Subscription.{ProductRatePlanChargeId, SubscriptionRatePlanChargeId}
import com.gu.memsub.subsv2.SingleCharge
import com.gu.memsub.subsv2.RatePlanCharge
import com.gu.memsub.{Benefit, BillingPeriod, PricingSummary}

object TestSingleCharge {
Expand All @@ -13,7 +13,7 @@ object TestSingleCharge {
price: PricingSummary = TestPricingSummary(),
chargeId: ProductRatePlanChargeId = randomProductRatePlanChargeId(),
subRatePlanChargeId: SubscriptionRatePlanChargeId = SubscriptionRatePlanChargeId(randomId("subscriptionRatePlanChargeId")),
): SingleCharge[B, BP] = SingleCharge[B, BP](benefit, billingPeriod, price, chargeId, subRatePlanChargeId)
): RatePlanCharge[B, BP] = RatePlanCharge[B, BP](benefit, billingPeriod, price, chargeId, subRatePlanChargeId)

def randomProductRatePlanChargeId(): ProductRatePlanChargeId = ProductRatePlanChargeId(randomId("productRatePlanChargeId"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package acceptance.data
import acceptance.data.Randoms.randomId
import com.gu.memsub
import com.gu.memsub.promo.PromoCode
import com.gu.memsub.subsv2.{CovariantNonEmptyList, ReaderType, Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{CovariantNonEmptyList, ReaderType, Subscription, RatePlan}
import org.joda.time.{DateTime, LocalDate}

object TestSubscription {
Expand All @@ -18,7 +18,7 @@ object TestSubscription {
casActivationDate: Option[DateTime] = None,
promoCode: Option[PromoCode] = None,
isCancelled: Boolean = false,
plans: CovariantNonEmptyList[SubscriptionPlan] = CovariantNonEmptyList(TestPaidSubscriptionPlan(), Nil),
plans: CovariantNonEmptyList[RatePlan] = CovariantNonEmptyList(TestPaidSubscriptionPlan(), Nil),
readerType: ReaderType = ReaderType.Direct,
gifteeIdentityId: Option[String] = None,
autoRenew: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package services
import acceptance.data.Randoms.randomId
import acceptance.data.TestContact
import com.gu.i18n.Currency.GBP
import com.gu.memsub.subsv2.{Subscription, SubscriptionPlan}
import com.gu.memsub.subsv2.{Subscription, RatePlan}
import com.gu.memsub.{BillingPeriod, Price}
import com.gu.services.model.PaymentDetails
import com.gu.services.model.PaymentDetails.PersonalPlan
Expand Down

0 comments on commit aed658c

Please sign in to comment.