Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
shtukas committed Jan 23, 2024
1 parent 924e9f1 commit 7ed8195
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import pricemigrationengine.migrations._
import pricemigrationengine.services._
import zio.{Clock, ZIO}
import java.time.{LocalDate, LocalDateTime, ZoneOffset}
import pricemigrationengine.migrations.newspaper2024migration
import pricemigrationengine.migrations.newspaper2024Migration

/** Carries out price-rise amendments in Zuora.
*/
Expand Down Expand Up @@ -211,7 +211,7 @@ object AmendmentHandler extends CohortHandler {
)
case Newspaper2024 =>
ZIO.fromEither(
newspaper2024migration.Amendment.subscriptionToZuoraSubscriptionUpdate(
newspaper2024Migration.Amendment.subscriptionToZuoraSubscriptionUpdate(
subscriptionBeforeUpdate,
startDate,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pricemigrationengine.handlers

import pricemigrationengine.migrations.newspaper2024migration
import pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.model.CohortTableFilter._
import pricemigrationengine.model._
import pricemigrationengine.services._
Expand Down Expand Up @@ -96,11 +96,11 @@ object EstimationHandler extends CohortHandler {
} yield result
}

def startDateGeneralLowerbound(
def startDateGeneralLowerBound(
cohortSpec: CohortSpec,
today: LocalDate
): LocalDate = {
// The startDateGeneralLowerbound is a function of the cohort spec and the notification min time.
// The startDateGeneralLowerBound is a function of the cohort spec and the notification min time.
// The cohort spec carries the lowest date we specify there can be a price migration, and the notification min
// time ensures the legally required lead time for customer communication. The max of those two dates is the date
// from which we can realistically perform a price increase. With that said, other policies can apply, for
Expand Down Expand Up @@ -145,7 +145,7 @@ object EstimationHandler extends CohortHandler {
MigrationType(cohortSpec) match {
case Membership2023Monthlies => 1
case Membership2023Annuals => 1
case Newspaper2024 => newspaper2024migration.Estimation.startDateSpreadPeriod(subscription)
case Newspaper2024 => newspaper2024Migration.Estimation.startDateSpreadPeriod(subscription)
case _ => 3
}
} else 1
Expand All @@ -167,8 +167,8 @@ object EstimationHandler extends CohortHandler {

val startDateLowerBound1 = MigrationType(cohortSpec) match {
case Newspaper2024 =>
newspaper2024migration.Estimation.startDateGeneralLowerbound(cohortSpec, today, subscription)
case _ => startDateGeneralLowerbound(cohortSpec, today)
newspaper2024Migration.Estimation.startDateGeneralLowerbound(cohortSpec, today, subscription)
case _ => startDateGeneralLowerBound(cohortSpec, today)
}

// We now respect the policy of not increasing members during their first year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pricemigrationengine.model.membershipworkflow._
import pricemigrationengine.services._
import zio.{Clock, ZIO}
import com.gu.i18n
import pricemigrationengine.migrations.newspaper2024migration
import pricemigrationengine.migrations.newspaper2024Migration

import java.time.LocalDate
import java.time.format.DateTimeFormatter
Expand Down Expand Up @@ -34,7 +34,7 @@ object NotificationHandler extends CohortHandler {
case Membership2023Annuals => 33
case SupporterPlus2023V1V2MA => 33
case DigiSubs2023 => 33
case Newspaper2024 => newspaper2024migration.StaticData.maxLeadTime
case Newspaper2024 => newspaper2024Migration.StaticData.maxLeadTime
case Legacy => 49
}
}
Expand All @@ -45,7 +45,7 @@ object NotificationHandler extends CohortHandler {
case Membership2023Annuals => 31
case SupporterPlus2023V1V2MA => 31
case DigiSubs2023 => 31
case Newspaper2024 => newspaper2024migration.StaticData.minLeadTime
case Newspaper2024 => newspaper2024Migration.StaticData.minLeadTime
case Legacy => 35
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pricemigrationengine.migrations.newspaper2024migration
package pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.model._
import pricemigrationengine.migrations.newspaper2024migration.StaticData._
import pricemigrationengine.migrations.newspaper2024migration.Estimation._
import pricemigrationengine.migrations.newspaper2024Migration.StaticData._
import pricemigrationengine.migrations.newspaper2024Migration.Estimation._

import java.time.LocalDate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pricemigrationengine.migrations.newspaper2024migration
package pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.model._

import java.time.LocalDate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pricemigrationengine.migrations.newspaper2024migration
package pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.model._

import java.time.LocalDate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pricemigrationengine.migrations.newspaper2024migration
package pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.model._

import java.time.LocalDate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pricemigrationengine.model

import pricemigrationengine.migrations.newspaper2024migration
import pricemigrationengine.migrations.newspaper2024Migration
import pricemigrationengine.migrations.{DigiSubs2023Migration, GuardianWeeklyMigration, Membership2023Migration}
import pricemigrationengine.model.ZuoraProductCatalogue.{homeDeliveryRatePlans, productPricingMap}

Expand Down Expand Up @@ -339,7 +339,7 @@ object AmendmentData {
subscription
)
case Newspaper2024 =>
newspaper2024migration.Estimation.priceData(
newspaper2024Migration.Estimation.priceData(
subscription
)
case Legacy => priceDataWithRatePlanMatching(account, catalogue, subscription, invoiceList, nextServiceStartDate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pricemigrationengine.Fixtures.{invoiceListFromJson, subscriptionFromJson}
import pricemigrationengine.handlers.EstimationHandler.{
decideStartDateLowerboundWithRandomAddition,
oneYearPolicy,
startDateGeneralLowerbound
startDateGeneralLowerBound
}
import pricemigrationengine.model.CohortTableFilter.{EstimationComplete, NoPriceIncrease, ReadyForEstimation}
import pricemigrationengine.model._
Expand Down Expand Up @@ -168,7 +168,7 @@ object EstimationHandlerSpec extends ZIOSpecDefault {
// The cohort earliestMigrationStartDate is 2022-11-14 (2)
// The max date of (1) and (2) is 2022-11-14 (3)

assert(startDateGeneralLowerbound(cohortSpec, today))(equalTo(LocalDate.of(2022, 12, 14)))
assert(startDateGeneralLowerBound(cohortSpec, today))(equalTo(LocalDate.of(2022, 12, 14)))

// The subscription acceptance date is: 2021-11-15
// The subscription acceptance date plus a year is 2022-11-15 (4)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pricemigrationengine.handlers

import pricemigrationengine.Fixtures
import pricemigrationengine.handlers.EstimationHandler.startDateGeneralLowerbound
import pricemigrationengine.handlers.EstimationHandler.startDateGeneralLowerBound
import pricemigrationengine.model.{CohortSpec, EstimationResult, SuccessfulEstimationResult}
import zio.test._
import pricemigrationengine.util.Date
Expand Down Expand Up @@ -143,7 +143,7 @@ object EstimationHandlerTest extends ZIOSpecDefault {
// (Today + 36 days) is after earliestPriceMigrationStartDate
// The earliest start date needs to be 36 days ahead of today (35 days min time + 1) -> 2023-05-07

assertTrue(startDateGeneralLowerbound(cohortSpec, today) == LocalDate.of(2023, 5, 7))
assertTrue(startDateGeneralLowerBound(cohortSpec, today) == LocalDate.of(2023, 5, 7))
},
test(
"during estimation, we correctly prevent start dates that are too close: decideEarliestStartDate (legacy case, part 2)"
Expand All @@ -157,7 +157,7 @@ object EstimationHandlerTest extends ZIOSpecDefault {
// earliestPriceMigrationStartDate is after (today + 36 days)
// The earliest start date can be earliestPriceMigrationStartDate

assertTrue(startDateGeneralLowerbound(cohortSpec, today) == cohortSpec.earliestPriceMigrationStartDate)
assertTrue(startDateGeneralLowerBound(cohortSpec, today) == cohortSpec.earliestPriceMigrationStartDate)
},
test(
"during estimation, we correctly prevent start dates that are too close: decideEarliestStartDate (membership)"
Expand All @@ -172,7 +172,7 @@ object EstimationHandlerTest extends ZIOSpecDefault {
// (Today + 32 days) is after earliestPriceMigrationStartDate
// The earliest start date needs to be 32 days ahead of today -> 2023-05-05

assertTrue(startDateGeneralLowerbound(cohortSpec, today) == LocalDate.of(2023, 5, 3))
assertTrue(startDateGeneralLowerBound(cohortSpec, today) == LocalDate.of(2023, 5, 3))
},
test("EstimationResult is correct for SupporterPlus2023V1V2 (monthly standard)") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package pricemigrationengine.migrations
import pricemigrationengine.model._
import java.time.LocalDate
import pricemigrationengine.Fixtures
import pricemigrationengine.migrations.newspaper2024migration.Estimation._
import pricemigrationengine.migrations.newspaper2024migration.Amendment._
import pricemigrationengine.migrations.newspaper2024migration.{Estimation, StaticData}
import pricemigrationengine.migrations.newspaper2024migration.StaticData.{ChargeDistribution2024, IndividualCharge2024}
import pricemigrationengine.migrations.newspaper2024Migration.Estimation._
import pricemigrationengine.migrations.newspaper2024Migration.Amendment._
import pricemigrationengine.migrations.newspaper2024Migration.{Estimation, StaticData}
import pricemigrationengine.migrations.newspaper2024Migration.StaticData.{ChargeDistribution2024, IndividualCharge2024}

/*
Correspondence between product names in Salesforce versus Zuora
Expand Down

0 comments on commit 7ed8195

Please sign in to comment.