use of org.killbill.billing.catalog.api.UsagePriceOverride in project killbill by killbill.
the class SubscriptionResourceHelpers method buildPlanPhasePriceOverride.
private static PlanPhasePriceOverride buildPlanPhasePriceOverride(final PlanSpecifier spec, final Currency currency, final PhasePriceJson input, final List<UsagePriceOverride> usagePrices) {
if (input.getPhaseName() != null) {
return new PlanPhasePriceOverride() {
@Override
public String getPhaseName() {
return input.getPhaseName();
}
@Override
public PlanPhaseSpecifier getPlanPhaseSpecifier() {
return null;
}
@Override
public Currency getCurrency() {
return currency;
}
@Override
public BigDecimal getFixedPrice() {
return input.getFixedPrice();
}
@Override
public BigDecimal getRecurringPrice() {
return input.getRecurringPrice();
}
@Override
public List<UsagePriceOverride> getUsagePriceOverrides() {
return usagePrices;
}
};
}
final PhaseType phaseType = input.getPhaseType() != null ? PhaseType.valueOf(input.getPhaseType()) : null;
final PlanPhaseSpecifier planPhaseSpecifier = spec.getPlanName() != null ? new PlanPhaseSpecifier(spec.getPlanName(), phaseType) : new PlanPhaseSpecifier(spec.getProductName(), spec.getBillingPeriod(), spec.getPriceListName(), phaseType);
final Currency resolvedCurrency = input.getFixedPrice() != null || input.getRecurringPrice() != null ? currency : null;
return new PlanPhasePriceOverride() {
@Override
public String getPhaseName() {
return null;
}
@Override
public PlanPhaseSpecifier getPlanPhaseSpecifier() {
return planPhaseSpecifier;
}
@Override
public Currency getCurrency() {
return resolvedCurrency;
}
@Override
public BigDecimal getFixedPrice() {
return input.getFixedPrice();
}
@Override
public BigDecimal getRecurringPrice() {
return input.getRecurringPrice();
}
@Override
public List<UsagePriceOverride> getUsagePriceOverrides() {
return usagePrices;
}
};
}
use of org.killbill.billing.catalog.api.UsagePriceOverride in project killbill by killbill.
the class SubscriptionResourceHelpers method buildPlanPhasePriceOverrides.
public static List<PlanPhasePriceOverride> buildPlanPhasePriceOverrides(final Iterable<PhasePriceJson> priceOverrides, final Currency currency, final PlanPhaseSpecifier planPhaseSpecifier) {
final List<PlanPhasePriceOverride> overrides = new LinkedList<PlanPhasePriceOverride>();
if (priceOverrides != null) {
for (final PhasePriceJson input : priceOverrides) {
Preconditions.checkNotNull(input);
final List<UsagePriceOverride> usagePrices = new LinkedList<UsagePriceOverride>();
if (input.getUsagePrices() != null) {
buildUsagePrices(currency, input, usagePrices);
}
overrides.add(buildPlanPhasePriceOverride(planPhaseSpecifier, currency, input, usagePrices));
}
}
return overrides;
}
Aggregations