diff --git a/java/google/registry/flows/domain/DomainCreateFlow.java b/java/google/registry/flows/domain/DomainCreateFlow.java index c8925a975..0860b3b48 100644 --- a/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/java/google/registry/flows/domain/DomainCreateFlow.java @@ -14,7 +14,6 @@ package google.registry.flows.domain; -import static com.google.common.collect.Sets.union; import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge; import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -167,15 +166,13 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow { if (!commandOperations.getEapCost().isZero()) { BillingEvent.OneTime eapEvent = new BillingEvent.OneTime.Builder() - .setReason(createEvent.getReason()) + .setReason(Reason.FEE_EARLY_ACCESS) .setTargetId(createEvent.getTargetId()) .setClientId(createEvent.getClientId()) - .setPeriodYears(createEvent.getPeriodYears()) .setCost(commandOperations.getEapCost()) .setEventTime(createEvent.getEventTime()) .setBillingTime(createEvent.getBillingTime()) - .setFlags(union(createEvent.getFlags(), - ImmutableSet.of(BillingEvent.Flag.EAP)).immutableCopy()) + .setFlags(createEvent.getFlags()) .setParent(createEvent.getParentKey()) .build(); ofy().save().entity(eapEvent); diff --git a/java/google/registry/model/billing/BillingEvent.java b/java/google/registry/model/billing/BillingEvent.java index 245ff3943..ac3f4b711 100644 --- a/java/google/registry/model/billing/BillingEvent.java +++ b/java/google/registry/model/billing/BillingEvent.java @@ -54,16 +54,18 @@ import org.joda.time.DateTime; public abstract class BillingEvent extends ImmutableObject implements Buildable, TransferServerApproveEntity { - /** The reason for the bill. */ + /** The reason for the bill, which maps 1:1 to skus in go/registry-billing-skus. */ public enum Reason { - CREATE, - TRANSFER, - RENEW, // TODO(b/27777398): Drop Reason.AUTO_RENEW after migration to Flag.AUTO_RENEW. AUTO_RENEW, + CREATE, + @Deprecated // TODO(b/31676071): remove this legacy value once old data is cleaned up. + ERROR, + FEE_EARLY_ACCESS, + RENEW, RESTORE, SERVER_STATUS, - ERROR + TRANSFER } /** Set of flags that can be applied to billing events. */ @@ -71,7 +73,6 @@ public abstract class BillingEvent extends ImmutableObject ALLOCATION, ANCHOR_TENANT, AUTO_RENEW, - EAP, LANDRUSH, SUNRISE, /** @@ -302,7 +303,10 @@ public abstract class BillingEvent extends ImmutableObject checkNotNull(instance.cost); checkState(!instance.cost.isNegative(), "Costs should be non-negative."); ImmutableSet reasonsWithPeriods = - Sets.immutableEnumSet(Reason.CREATE, Reason.RENEW, Reason.TRANSFER); + Sets.immutableEnumSet( + Reason.CREATE, + Reason.RENEW, + Reason.TRANSFER); checkState( reasonsWithPeriods.contains(instance.reason) == (instance.periodYears != null), "Period years must be set if and only if reason is CREATE, RENEW, or TRANSFER."); diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index 56a4e2a34..6794b7248 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -217,20 +217,15 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase eapFlags = - isAnchorTenant - ? ImmutableSet.of(BillingEvent.Flag.ANCHOR_TENANT, BillingEvent.Flag.EAP) - : ImmutableSet.of(BillingEvent.Flag.EAP); BillingEvent.OneTime eapBillingEvent = new BillingEvent.OneTime.Builder() - .setReason(Reason.CREATE) + .setReason(Reason.FEE_EARLY_ACCESS) .setTargetId(getUniqueIdFromCommand()) .setClientId("TheRegistrar") .setCost(eapFee) - .setPeriodYears(2) .setEventTime(clock.nowUtc()) .setBillingTime(billingTime) - .setFlags(eapFlags) + .setFlags(billingFlags) .setParent(historyEntry) .build(); billingEvents = ImmutableSet.builder() diff --git a/javatests/google/registry/model/schema.txt b/javatests/google/registry/model/schema.txt index 249634e6b..0509e4c82 100644 --- a/javatests/google/registry/model/schema.txt +++ b/javatests/google/registry/model/schema.txt @@ -24,7 +24,6 @@ enum google.registry.model.billing.BillingEvent$Flag { ALLOCATION; ANCHOR_TENANT; AUTO_RENEW; - EAP; LANDRUSH; SUNRISE; SYNTHETIC; @@ -59,6 +58,7 @@ enum google.registry.model.billing.BillingEvent$Reason { AUTO_RENEW; CREATE; ERROR; + FEE_EARLY_ACCESS; RENEW; RESTORE; SERVER_STATUS;