Change EAP fee billing event reason to EARLY_ACCESS

The reason field is 1:1 mapped to skus in billing reports. Need to add a new reason for EAP for this type of billing event for reporting to work correctly. Also map that reason to the correct SKU.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134005364
This commit is contained in:
jianglai 2016-09-22 15:07:07 -07:00 committed by Ben McIlwain
parent 414781e79b
commit add9474e9a
4 changed files with 16 additions and 20 deletions

View file

@ -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);

View file

@ -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<Reason> 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.");

View file

@ -217,20 +217,15 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
// If EAP is applied, a billing event for EAP should be present.
if (!eapFee.isZero()) {
ImmutableSet<BillingEvent.Flag> 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.<BillingEvent>builder()

View file

@ -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;