// Copyright 2017 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package google.registry.model.billing; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.Registries.assertTldExists; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.collect.ComparisonChain; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Ordering; import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Parent; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; import google.registry.model.annotations.ReportedOn; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; import org.joda.money.CurrencyUnit; import org.joda.time.DateTime; /** * A per-registrar billing credit, applied toward future charges for registrar activity. * *
NOTE: While credits are tracked within the model, there is no built-in support for actually
* incorporating these credits into the generated billing data, and the model support for credits
* should be considered quasi-deprecated (it may be removed without notice).
*/
@ReportedOn
@Entity
public final class RegistrarCredit extends ImmutableObject implements Buildable {
/**
* The type of credit represented. The ordering below determines the order in which credits of
* of different types will be applied to an invoice charge.
*/
// Note: Right now the ordering is actually maintained manually via a hard-coded table in the
// relevant billing query, so if adding a credit type here, add it there as well.
// TODO(b/19031546): make the query automatically reflect the order in this enum.
public enum CreditType {
/** Credit awarded as an incentive to participate in sunrise/landrush auctions. */
AUCTION("Auction Credit"),
/** Credit awarded as part of a promotional deal. */
PROMOTION("Promotional Credit");
/** A descriptive name for a credit of this type. */
private final String descriptiveName;
CreditType(String descriptiveName) {
this.descriptiveName = descriptiveName;
}
public String getDescriptiveName() {
return descriptiveName;
}
}
@Id
long id;
/** The registrar to whom this credit belongs. */
@Parent
Key For auction credits, this is also the TLD for which the relevant auctions occurred.
*/
String tld;
public Key The resulting list sorts the credits first by type and then by creation time.
*/
public static ImmutableList