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
This commit is contained in:
larryruili 2018-03-06 10:25:45 -08:00 committed by jianglai
parent 84eab90000
commit b39e6c0d7e
3 changed files with 5 additions and 2 deletions

View file

@ -239,7 +239,6 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
private OneTime createRenewBillingEvent( private OneTime createRenewBillingEvent(
HistoryEntry historyEntry, Money renewCost, DateTime now) { HistoryEntry historyEntry, Money renewCost, DateTime now) {
return prepareBillingEvent(historyEntry, renewCost, now) return prepareBillingEvent(historyEntry, renewCost, now)
.setPeriodYears(1)
.setReason(Reason.RENEW) .setReason(Reason.RENEW)
.build(); .build();
} }
@ -257,6 +256,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
.setClientId(clientId) .setClientId(clientId)
.setEventTime(now) .setEventTime(now)
.setBillingTime(now) .setBillingTime(now)
.setPeriodYears(1)
.setCost(cost) .setCost(cost)
.setParent(historyEntry); .setParent(historyEntry);
} }

View file

@ -305,10 +305,12 @@ public abstract class BillingEvent extends ImmutableObject
Sets.immutableEnumSet( Sets.immutableEnumSet(
Reason.CREATE, Reason.CREATE,
Reason.RENEW, Reason.RENEW,
Reason.RESTORE,
Reason.TRANSFER); Reason.TRANSFER);
checkState( checkState(
reasonsWithPeriods.contains(instance.reason) == (instance.periodYears != null), 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( checkState(
instance.getFlags().contains(Flag.SYNTHETIC) instance.getFlags().contains(Flag.SYNTHETIC)
== (instance.syntheticCreationTime != null), == (instance.syntheticCreationTime != null),

View file

@ -183,6 +183,7 @@ public class DomainRestoreRequestFlowTest
.setTargetId("example.tld") .setTargetId("example.tld")
.setClientId("TheRegistrar") .setClientId("TheRegistrar")
.setCost(Money.of(USD, 17)) .setCost(Money.of(USD, 17))
.setPeriodYears(1)
.setEventTime(clock.nowUtc()) .setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc()) .setBillingTime(clock.nowUtc())
.setParent(historyEntryDomainRestore) .setParent(historyEntryDomainRestore)