Create a separate billing event when EAP is applied

When EAP is involed we current have one billing event for domain create that
has the create fee and EAP fee lumped together. Change it to record two
separate billing events for each.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132335349
This commit is contained in:
jianglai 2016-09-06 10:28:56 -07:00 committed by Ben McIlwain
parent 969d9483ae
commit 6641f105b7
12 changed files with 196 additions and 72 deletions

View file

@ -71,6 +71,7 @@ public abstract class BillingEvent extends ImmutableObject
ALLOCATION,
ANCHOR_TENANT,
AUTO_RENEW,
EAP,
LANDRUSH,
SUNRISE,
/**

View file

@ -15,6 +15,7 @@
package google.registry.model.domain.fee;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkState;
import google.registry.model.ImmutableObject;
import google.registry.xml.PeriodAdapter;
@ -38,6 +39,24 @@ public abstract class BaseFee extends ImmutableObject {
@XmlEnumValue("delayed")
DELAYED
}
/** Enum for the type of the fee. */
public enum FeeType {
CREATE("create"),
EAP("Early Access Period, fee expires: %s"),
RENEW("renew"),
RESTORE("restore");
private final String formatString;
FeeType(String formatString) {
this.formatString = formatString;
}
String renderDescription(Object... args) {
return String.format(formatString, args);
}
}
@XmlAttribute
String description;
@ -54,6 +73,9 @@ public abstract class BaseFee extends ImmutableObject {
@XmlValue
BigDecimal cost;
@XmlTransient
FeeType type;
public String getDescription() {
return description;
@ -81,6 +103,15 @@ public abstract class BaseFee extends ImmutableObject {
public BigDecimal getCost() {
return cost;
}
public FeeType getType() {
return type;
}
protected void generateDescription(Object... args) {
checkState(type != null);
description = type.renderDescription(args);
}
public boolean hasDefaultAttributes() {
return getGracePeriod().equals(Period.ZERO)

View file

@ -37,13 +37,17 @@ import google.registry.model.domain.fee12.FeeUpdateCommandExtensionV12;
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
import java.math.BigDecimal;
/** A fee, in currency units specified elsewhere in the xml, and with an optional description. */
/**
* A fee, in currency units specified elsewhere in the xml, with type of the fee an optional fee
* description.
*/
public class Fee extends BaseFee {
public static Fee create(BigDecimal cost, String description) {
public static Fee create(BigDecimal cost, FeeType type, Object... descriptionArgs) {
Fee instance = new Fee();
instance.cost = checkNotNull(cost);
checkArgument(instance.cost.signum() >= 0);
instance.description = description;
instance.type = checkNotNull(type);
instance.generateDescription(descriptionArgs);
return instance;
}