From b39e6c0d7e9bb11de626e6035760348f2365e609 Mon Sep 17 00:00:00 2001 From: larryruili Date: Tue, 6 Mar 2018 10:25:45 -0800 Subject: [PATCH] Change RESTORE BillingEvents to have 1-year periods This simplifies calculating the overall invoice by giving RESTORE fees a period equal to the period of the associated RENEW (1 year). Older BillingEvents will not be backfilled, and will have periodYears = null. Invoicing and business both agree this is a valid representation, since RESTORE fees are intrinsically tied to the 1-year RENEW it's associated with. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188041777 --- .../registry/flows/domain/DomainRestoreRequestFlow.java | 2 +- java/google/registry/model/billing/BillingEvent.java | 4 +++- .../registry/flows/domain/DomainRestoreRequestFlowTest.java | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index a516127ce..f109feaa8 100644 --- a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -239,7 +239,6 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { private OneTime createRenewBillingEvent( HistoryEntry historyEntry, Money renewCost, DateTime now) { return prepareBillingEvent(historyEntry, renewCost, now) - .setPeriodYears(1) .setReason(Reason.RENEW) .build(); } @@ -257,6 +256,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { .setClientId(clientId) .setEventTime(now) .setBillingTime(now) + .setPeriodYears(1) .setCost(cost) .setParent(historyEntry); } diff --git a/java/google/registry/model/billing/BillingEvent.java b/java/google/registry/model/billing/BillingEvent.java index d0cfcfeb6..f64deef29 100644 --- a/java/google/registry/model/billing/BillingEvent.java +++ b/java/google/registry/model/billing/BillingEvent.java @@ -305,10 +305,12 @@ public abstract class BillingEvent extends ImmutableObject Sets.immutableEnumSet( Reason.CREATE, Reason.RENEW, + Reason.RESTORE, 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."); + "Period years must be set if and only if reason is " + + "CREATE, RENEW, RESTORE or TRANSFER."); checkState( instance.getFlags().contains(Flag.SYNTHETIC) == (instance.syntheticCreationTime != null), diff --git a/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java b/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java index 21494bc55..4f51018c9 100644 --- a/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainRestoreRequestFlowTest.java @@ -183,6 +183,7 @@ public class DomainRestoreRequestFlowTest .setTargetId("example.tld") .setClientId("TheRegistrar") .setCost(Money.of(USD, 17)) + .setPeriodYears(1) .setEventTime(clock.nowUtc()) .setBillingTime(clock.nowUtc()) .setParent(historyEntryDomainRestore)