use of org.killbill.billing.catalog.api.PlanChangeResult in project killbill by killbill.
the class DefaultSubscriptionBaseApiService method dryRunChangePlan.
@Override
public DateTime dryRunChangePlan(final DefaultSubscriptionBase subscription, final PlanSpecifier spec, @Nullable final DateTime requestedDateWithMs, @Nullable final BillingActionPolicy requestedPolicy, final TenantContext context) throws SubscriptionBaseApiException {
final DateTime now = clock.getUTCNow();
BillingActionPolicy policyMaybeNull = requestedPolicy;
if (requestedDateWithMs == null && requestedPolicy == null) {
final PlanChangeResult planChangeResult = getPlanChangeResult(subscription, spec, now, context);
policyMaybeNull = planChangeResult.getPolicy();
}
if (policyMaybeNull != null) {
return subscription.getPlanChangeEffectiveDate(policyMaybeNull, null, null, -1, null);
} else if (requestedDateWithMs != null) {
return DefaultClock.truncateMs(requestedDateWithMs);
} else {
return now;
}
}
use of org.killbill.billing.catalog.api.PlanChangeResult in project killbill by killbill.
the class DefaultSubscriptionBaseApiService method changePlan.
@Override
public DateTime changePlan(final DefaultSubscriptionBase subscription, final PlanSpecifier spec, final List<PlanPhasePriceOverride> overrides, final CallContext context) throws SubscriptionBaseApiException {
final DateTime now = clock.getUTCNow();
validateEntitlementState(subscription);
final PlanChangeResult planChangeResult = getPlanChangeResult(subscription, spec, now, context);
final DateTime effectiveDate = dryRunChangePlan(subscription, spec, null, planChangeResult.getPolicy(), context);
validateEffectiveDate(subscription, effectiveDate);
try {
doChangePlan(subscription, spec, overrides, effectiveDate, context);
} catch (final CatalogApiException e) {
throw new SubscriptionBaseApiException(e);
}
return effectiveDate;
}
Aggregations