mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
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:
parent
414781e79b
commit
add9474e9a
4 changed files with 16 additions and 20 deletions
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package google.registry.flows.domain;
|
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.flows.domain.DomainFlowUtils.validateFeeChallenge;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
@ -167,15 +166,13 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
|
||||||
if (!commandOperations.getEapCost().isZero()) {
|
if (!commandOperations.getEapCost().isZero()) {
|
||||||
BillingEvent.OneTime eapEvent =
|
BillingEvent.OneTime eapEvent =
|
||||||
new BillingEvent.OneTime.Builder()
|
new BillingEvent.OneTime.Builder()
|
||||||
.setReason(createEvent.getReason())
|
.setReason(Reason.FEE_EARLY_ACCESS)
|
||||||
.setTargetId(createEvent.getTargetId())
|
.setTargetId(createEvent.getTargetId())
|
||||||
.setClientId(createEvent.getClientId())
|
.setClientId(createEvent.getClientId())
|
||||||
.setPeriodYears(createEvent.getPeriodYears())
|
|
||||||
.setCost(commandOperations.getEapCost())
|
.setCost(commandOperations.getEapCost())
|
||||||
.setEventTime(createEvent.getEventTime())
|
.setEventTime(createEvent.getEventTime())
|
||||||
.setBillingTime(createEvent.getBillingTime())
|
.setBillingTime(createEvent.getBillingTime())
|
||||||
.setFlags(union(createEvent.getFlags(),
|
.setFlags(createEvent.getFlags())
|
||||||
ImmutableSet.of(BillingEvent.Flag.EAP)).immutableCopy())
|
|
||||||
.setParent(createEvent.getParentKey())
|
.setParent(createEvent.getParentKey())
|
||||||
.build();
|
.build();
|
||||||
ofy().save().entity(eapEvent);
|
ofy().save().entity(eapEvent);
|
||||||
|
|
|
@ -54,16 +54,18 @@ import org.joda.time.DateTime;
|
||||||
public abstract class BillingEvent extends ImmutableObject
|
public abstract class BillingEvent extends ImmutableObject
|
||||||
implements Buildable, TransferServerApproveEntity {
|
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 {
|
public enum Reason {
|
||||||
CREATE,
|
|
||||||
TRANSFER,
|
|
||||||
RENEW,
|
|
||||||
// TODO(b/27777398): Drop Reason.AUTO_RENEW after migration to Flag.AUTO_RENEW.
|
// TODO(b/27777398): Drop Reason.AUTO_RENEW after migration to Flag.AUTO_RENEW.
|
||||||
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,
|
RESTORE,
|
||||||
SERVER_STATUS,
|
SERVER_STATUS,
|
||||||
ERROR
|
TRANSFER
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set of flags that can be applied to billing events. */
|
/** Set of flags that can be applied to billing events. */
|
||||||
|
@ -71,7 +73,6 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
ALLOCATION,
|
ALLOCATION,
|
||||||
ANCHOR_TENANT,
|
ANCHOR_TENANT,
|
||||||
AUTO_RENEW,
|
AUTO_RENEW,
|
||||||
EAP,
|
|
||||||
LANDRUSH,
|
LANDRUSH,
|
||||||
SUNRISE,
|
SUNRISE,
|
||||||
/**
|
/**
|
||||||
|
@ -302,7 +303,10 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
checkNotNull(instance.cost);
|
checkNotNull(instance.cost);
|
||||||
checkState(!instance.cost.isNegative(), "Costs should be non-negative.");
|
checkState(!instance.cost.isNegative(), "Costs should be non-negative.");
|
||||||
ImmutableSet<Reason> reasonsWithPeriods =
|
ImmutableSet<Reason> reasonsWithPeriods =
|
||||||
Sets.immutableEnumSet(Reason.CREATE, Reason.RENEW, Reason.TRANSFER);
|
Sets.immutableEnumSet(
|
||||||
|
Reason.CREATE,
|
||||||
|
Reason.RENEW,
|
||||||
|
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, or TRANSFER.");
|
||||||
|
|
|
@ -217,20 +217,15 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
|
|
||||||
// If EAP is applied, a billing event for EAP should be present.
|
// If EAP is applied, a billing event for EAP should be present.
|
||||||
if (!eapFee.isZero()) {
|
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 =
|
BillingEvent.OneTime eapBillingEvent =
|
||||||
new BillingEvent.OneTime.Builder()
|
new BillingEvent.OneTime.Builder()
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.FEE_EARLY_ACCESS)
|
||||||
.setTargetId(getUniqueIdFromCommand())
|
.setTargetId(getUniqueIdFromCommand())
|
||||||
.setClientId("TheRegistrar")
|
.setClientId("TheRegistrar")
|
||||||
.setCost(eapFee)
|
.setCost(eapFee)
|
||||||
.setPeriodYears(2)
|
|
||||||
.setEventTime(clock.nowUtc())
|
.setEventTime(clock.nowUtc())
|
||||||
.setBillingTime(billingTime)
|
.setBillingTime(billingTime)
|
||||||
.setFlags(eapFlags)
|
.setFlags(billingFlags)
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
billingEvents = ImmutableSet.<BillingEvent>builder()
|
billingEvents = ImmutableSet.<BillingEvent>builder()
|
||||||
|
|
|
@ -24,7 +24,6 @@ enum google.registry.model.billing.BillingEvent$Flag {
|
||||||
ALLOCATION;
|
ALLOCATION;
|
||||||
ANCHOR_TENANT;
|
ANCHOR_TENANT;
|
||||||
AUTO_RENEW;
|
AUTO_RENEW;
|
||||||
EAP;
|
|
||||||
LANDRUSH;
|
LANDRUSH;
|
||||||
SUNRISE;
|
SUNRISE;
|
||||||
SYNTHETIC;
|
SYNTHETIC;
|
||||||
|
@ -59,6 +58,7 @@ enum google.registry.model.billing.BillingEvent$Reason {
|
||||||
AUTO_RENEW;
|
AUTO_RENEW;
|
||||||
CREATE;
|
CREATE;
|
||||||
ERROR;
|
ERROR;
|
||||||
|
FEE_EARLY_ACCESS;
|
||||||
RENEW;
|
RENEW;
|
||||||
RESTORE;
|
RESTORE;
|
||||||
SERVER_STATUS;
|
SERVER_STATUS;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue