mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
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:
parent
969d9483ae
commit
6641f105b7
12 changed files with 196 additions and 72 deletions
|
@ -169,9 +169,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
? Money.of(USD, 200)
|
||||
: Money.of(USD, 26);
|
||||
Money eapFee = Registry.get(domainTld).getEapFeeFor(clock.nowUtc()).getCost();
|
||||
if (!eapFee.isZero()) {
|
||||
cost = Money.total(cost, eapFee);
|
||||
}
|
||||
|
||||
DateTime billingTime = isAnchorTenant
|
||||
? clock.nowUtc().plus(Registry.get(domainTld).getAnchorTenantAddGracePeriodLength())
|
||||
|
@ -186,20 +183,21 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
|
||||
.hasPeriodYears(2);
|
||||
// There should be a bill for the create and a recurring autorenew event.
|
||||
BillingEvent.OneTime createBillingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(cost)
|
||||
.setPeriodYears(2)
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(billingTime)
|
||||
.setFlags(billingFlags)
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
assertBillingEvents(
|
||||
createBillingEvent,
|
||||
// There should be one bill for the create and one for the recurring autorenew event.
|
||||
BillingEvent.OneTime createBillingEvent =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(cost)
|
||||
.setPeriodYears(2)
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(billingTime)
|
||||
.setFlags(billingFlags)
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
|
||||
BillingEvent.Recurring renewBillingEvent =
|
||||
new BillingEvent.Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
|
@ -208,7 +206,36 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
.setEventTime(domain.getRegistrationExpirationTime())
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setParent(historyEntry)
|
||||
.build());
|
||||
.build();
|
||||
|
||||
ImmutableSet<BillingEvent> billingEvents = ImmutableSet.of(
|
||||
createBillingEvent, renewBillingEvent);
|
||||
|
||||
// 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)
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(eapFee)
|
||||
.setPeriodYears(2)
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(billingTime)
|
||||
.setFlags(eapFlags)
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
billingEvents = ImmutableSet.<BillingEvent>builder()
|
||||
.addAll(billingEvents)
|
||||
.add(eapBillingEvent)
|
||||
.build();
|
||||
}
|
||||
assertBillingEvents(billingEvents);
|
||||
|
||||
assertGracePeriods(
|
||||
domain.getGracePeriods(),
|
||||
ImmutableMap.of(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue