Set domain create fee cost to be 0 for anchor tenants

We already properly remove EAP fees for anchor tenants.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=235529469
This commit is contained in:
gbrodman 2019-02-25 07:56:07 -08:00 committed by Weimin Yu
parent 53cda35265
commit 4d9db4ac8c
2 changed files with 14 additions and 10 deletions

View file

@ -31,6 +31,7 @@ import google.registry.model.domain.fee.BaseFee;
import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Fee; import google.registry.model.domain.fee.Fee;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import java.math.BigDecimal;
import java.util.Optional; import java.util.Optional;
import javax.inject.Inject; import javax.inject.Inject;
import org.joda.money.CurrencyUnit; import org.joda.money.CurrencyUnit;
@ -56,9 +57,10 @@ public final class DomainPricingLogic {
throws EppException { throws EppException {
CurrencyUnit currency = registry.getCurrency(); CurrencyUnit currency = registry.getCurrency();
// Get the vanilla create cost. // Get the vanilla create cost, or 0 for anchor tenants.
BaseFee createFeeOrCredit = BigDecimal domainCreateCost =
Fee.create(getDomainCreateCost(domainName, date, years).getAmount(), FeeType.CREATE); isAnchorTenant ? BigDecimal.ZERO : getDomainCreateCost(domainName, date, years).getAmount();
BaseFee createFeeOrCredit = Fee.create(domainCreateCost, FeeType.CREATE);
// Create fees for the cost and the EAP fee, if any. // Create fees for the cost and the EAP fee, if any.
Fee eapFee = registry.getEapFeeFor(date); Fee eapFee = registry.getEapFeeFor(date);

View file

@ -214,16 +214,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
String domainTld, ImmutableSet<BillingEvent.Flag> expectedBillingFlags) throws Exception { String domainTld, ImmutableSet<BillingEvent.Flag> expectedBillingFlags) throws Exception {
DomainBase domain = reloadResourceByForeignKey(); DomainBase domain = reloadResourceByForeignKey();
// Calculate the total cost. boolean isAnchorTenant = expectedBillingFlags.contains(ANCHOR_TENANT);
Money cost = // Calculate the total creation cost.
isDomainPremium(getUniqueIdFromCommand(), clock.nowUtc()) Money creationCost =
? Money.of(USD, 200) isAnchorTenant
: Money.of(USD, 26); ? Money.of(USD, 0)
: isDomainPremium(getUniqueIdFromCommand(), clock.nowUtc())
? Money.of(USD, 200)
: Money.of(USD, 26);
Money eapFee = Money eapFee =
Money.of( Money.of(
Registry.get(domainTld).getCurrency(), Registry.get(domainTld).getCurrency(),
Registry.get(domainTld).getEapFeeFor(clock.nowUtc()).getCost()); Registry.get(domainTld).getEapFeeFor(clock.nowUtc()).getCost());
boolean isAnchorTenant = expectedBillingFlags.contains(ANCHOR_TENANT);
DateTime billingTime = DateTime billingTime =
isAnchorTenant isAnchorTenant
? clock.nowUtc().plus(Registry.get(domainTld).getAnchorTenantAddGracePeriodLength()) ? clock.nowUtc().plus(Registry.get(domainTld).getAnchorTenantAddGracePeriodLength())
@ -244,7 +246,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setReason(Reason.CREATE) .setReason(Reason.CREATE)
.setTargetId(getUniqueIdFromCommand()) .setTargetId(getUniqueIdFromCommand())
.setClientId("TheRegistrar") .setClientId("TheRegistrar")
.setCost(cost) .setCost(creationCost)
.setPeriodYears(2) .setPeriodYears(2)
.setEventTime(clock.nowUtc()) .setEventTime(clock.nowUtc())
.setBillingTime(billingTime) .setBillingTime(billingTime)