use of org.killbill.billing.catalog.api.PlanPhase in project killbill by killbill.
the class TestXMLReader method getUsages.
private Usage[] getUsages(final StandaloneCatalog catalog, final String planName) throws CatalogApiException {
final Plan plan = catalog.findCurrentPlan(planName);
assertNotNull(plan);
final PlanPhase phase = plan.getFinalPhase();
assertNotNull(phase);
final Usage[] usages = phase.getUsages();
return usages;
}
use of org.killbill.billing.catalog.api.PlanPhase in project killbill by killbill.
the class TestDefaultSubscriptionBundleTimeline method createTransition.
private SubscriptionBaseTransition createTransition(final UUID entitlementId, final EventType eventType, final ApiEventType apiEventType, final DateTime effectiveDate, final DateTime createdDate, final String prevPhaseName, final String nextPhaseName) throws CatalogApiException {
final PlanPhase prevPhase;
final Plan prevPlan;
final Product prevProduct;
final PriceList prevPriceList;
if (prevPhaseName == null) {
prevPhase = null;
prevPlan = null;
prevProduct = null;
prevPriceList = null;
} else {
prevPhase = Mockito.mock(PlanPhase.class);
Mockito.when(prevPhase.getName()).thenReturn(prevPhaseName);
prevProduct = Mockito.mock(Product.class);
Mockito.when(prevProduct.getName()).thenReturn("product");
prevPlan = Mockito.mock(Plan.class);
Mockito.when(prevPlan.getName()).thenReturn("plan");
Mockito.when(prevPlan.getProduct()).thenReturn(prevProduct);
prevPriceList = Mockito.mock(PriceList.class);
Mockito.when(prevPriceList.getName()).thenReturn("pricelist");
}
final PlanPhase nextPhase;
final Plan nextPlan;
final Product nextProduct;
final PriceList nextPriceList;
if (nextPhaseName == null) {
nextPhase = null;
nextPlan = null;
nextProduct = null;
nextPriceList = null;
} else {
nextPhase = Mockito.mock(PlanPhase.class);
Mockito.when(nextPhase.getName()).thenReturn(nextPhaseName);
nextProduct = Mockito.mock(Product.class);
Mockito.when(nextProduct.getName()).thenReturn("product");
nextPlan = Mockito.mock(Plan.class);
Mockito.when(nextPlan.getName()).thenReturn("plan");
Mockito.when(nextPlan.getProduct()).thenReturn(nextProduct);
nextPriceList = Mockito.mock(PriceList.class);
Mockito.when(nextPriceList.getName()).thenReturn("pricelist");
}
return new SubscriptionBaseTransitionData(UUID.randomUUID(), entitlementId, bundleId, bundleExternalKey, eventType, apiEventType, effectiveDate, null, null, null, prevPlan, prevPhase, prevPriceList, null, null, null, null, nextPlan, nextPhase, nextPriceList, null, 1L, createdDate, UUID.randomUUID(), true);
}
use of org.killbill.billing.catalog.api.PlanPhase in project killbill by killbill.
the class TestBillingApi method testBillingEventsAutoInvoicingOffAccount.
@Test(groups = "fast")
public void testBillingEventsAutoInvoicingOffAccount() throws CatalogApiException, AccountApiException, TagApiException, SubscriptionBaseApiException {
final Plan nextPlan = catalog.findPlan("3-PickupTrialEvergreen10USD", clock.getUTCNow());
final PlanPhase nextPhase = nextPlan.getAllPhases()[1];
createSubscriptionCreationEvent(nextPlan, nextPhase);
final Account account = createAccount(32);
tagInternalApi.addTag(account.getId(), ObjectType.ACCOUNT, ControlTagType.AUTO_INVOICING_OFF.getId(), internalCallContext);
final BillingEventSet events = billingInternalApi.getBillingEventsForAccountAndUpdateAccountBCD(account.getId(), null, internalCallContext);
assertEquals(events.isAccountAutoInvoiceOff(), true);
assertEquals(events.size(), 0);
}
use of org.killbill.billing.catalog.api.PlanPhase in project killbill by killbill.
the class TestDefaultBillingEvent method createEvent.
private BillingEvent createEvent(final SubscriptionBase sub, final DateTime effectiveDate, final SubscriptionBaseTransitionType type, final long totalOrdering) {
final int billCycleDay = 1;
final Plan shotgun = new MockPlan();
final PlanPhase shotgunMonthly = createMockMonthlyPlanPhase(null, BigDecimal.ZERO, PhaseType.TRIAL);
final Account account = new MockAccountBuilder().build();
return new DefaultBillingEvent(sub, effectiveDate, true, shotgun, shotgunMonthly, BigDecimal.ZERO, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, billCycleDay, "Test Event 1", totalOrdering, type, DateTimeZone.UTC, null, false);
}
use of org.killbill.billing.catalog.api.PlanPhase in project killbill by killbill.
the class DefaultInternalBillingApi method getPlanPhaseSpecifierFromTransition.
private PlanPhaseSpecifier getPlanPhaseSpecifierFromTransition(final Catalog catalog, final EffectiveSubscriptionInternalEvent transition) throws CatalogApiException {
final Plan prevPlan = (transition.getPreviousPlan() != null) ? catalog.findPlan(transition.getPreviousPlan(), transition.getEffectiveTransitionTime(), transition.getSubscriptionStartDate()) : null;
final Plan nextPlan = (transition.getNextPlan() != null) ? catalog.findPlan(transition.getNextPlan(), transition.getEffectiveTransitionTime(), transition.getSubscriptionStartDate()) : null;
final Plan plan = (transition.getTransitionType() != SubscriptionBaseTransitionType.CANCEL) ? nextPlan : prevPlan;
final PlanPhase prevPhase = (transition.getPreviousPhase() != null) ? catalog.findPhase(transition.getPreviousPhase(), transition.getEffectiveTransitionTime(), transition.getSubscriptionStartDate()) : null;
final PlanPhase nextPhase = (transition.getNextPhase() != null) ? catalog.findPhase(transition.getNextPhase(), transition.getEffectiveTransitionTime(), transition.getSubscriptionStartDate()) : null;
final PlanPhase phase = (transition.getTransitionType() != SubscriptionBaseTransitionType.CANCEL) ? nextPhase : prevPhase;
return new PlanPhaseSpecifier(plan.getName(), phase.getPhaseType());
}
Aggregations