mirror of
https://github.com/google/nomulus
synced 2026-01-06 21:47:31 +00:00
Adding synthetic source ID to BillingEvent.OneTime
Synthetic BillingEvent.OneTimes need to have a pointer to their source Recurring event, in order to match up properly against Cancellations. Also improving the exception message for mismatched Flag.SYNTHETIC and syntheticCreationTime. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122155636
This commit is contained in:
@@ -225,6 +225,13 @@ public abstract class BillingEvent extends ImmutableObject
|
||||
@Index
|
||||
DateTime syntheticCreationTime;
|
||||
|
||||
/**
|
||||
* For {@link Flag#SYNTHETIC} events, the {@link BillingEvent} from which this OneTime was
|
||||
* created. This is needed in order to properly match billing events against
|
||||
* {@link Cancellation}s.
|
||||
*/
|
||||
Long cancellationTargetId;
|
||||
|
||||
public Money getCost() {
|
||||
return cost;
|
||||
}
|
||||
@@ -241,6 +248,10 @@ public abstract class BillingEvent extends ImmutableObject
|
||||
return syntheticCreationTime;
|
||||
}
|
||||
|
||||
public Long getCancellationTargetId() {
|
||||
return cancellationTargetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder asBuilder() {
|
||||
return new Builder(clone(this));
|
||||
@@ -277,6 +288,11 @@ public abstract class BillingEvent extends ImmutableObject
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCancellationTargetId(Long cancellationTargetId) {
|
||||
getInstance().cancellationTargetId = cancellationTargetId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OneTime build() {
|
||||
OneTime instance = getInstance();
|
||||
@@ -291,7 +307,11 @@ public abstract class BillingEvent extends ImmutableObject
|
||||
checkState(
|
||||
instance.getFlags().contains(Flag.SYNTHETIC)
|
||||
== (instance.syntheticCreationTime != null),
|
||||
"Billing events with SYNTHETIC flag set must have a synthetic creation time.");
|
||||
"Synthetic creation time must be set if and only if the SYNTHETIC flag is set.");
|
||||
checkState(
|
||||
instance.getFlags().contains(Flag.SYNTHETIC)
|
||||
== (instance.cancellationTargetId != null),
|
||||
"Cancellation target ID must be set if and only if the SYNTHETIC flag is set.");
|
||||
return super.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user