Search in sources :

Example 46 with PlanPhase

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;
}
Also used : Usage(org.killbill.billing.catalog.api.Usage) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) Plan(org.killbill.billing.catalog.api.Plan)

Example 47 with PlanPhase

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);
}
Also used : SubscriptionBaseTransitionData(org.killbill.billing.subscription.api.user.SubscriptionBaseTransitionData) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) Product(org.killbill.billing.catalog.api.Product) Plan(org.killbill.billing.catalog.api.Plan) PriceList(org.killbill.billing.catalog.api.PriceList)

Example 48 with PlanPhase

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);
}
Also used : Account(org.killbill.billing.account.api.Account) BillingEventSet(org.killbill.billing.junction.BillingEventSet) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) Plan(org.killbill.billing.catalog.api.Plan) Test(org.testng.annotations.Test)

Example 49 with PlanPhase

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);
}
Also used : Account(org.killbill.billing.account.api.Account) MockAccountBuilder(org.killbill.billing.mock.MockAccountBuilder) MockPlan(org.killbill.billing.catalog.MockPlan) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) MockPlan(org.killbill.billing.catalog.MockPlan) Plan(org.killbill.billing.catalog.api.Plan)

Example 50 with PlanPhase

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());
}
Also used : PlanPhaseSpecifier(org.killbill.billing.catalog.api.PlanPhaseSpecifier) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) Plan(org.killbill.billing.catalog.api.Plan)

Aggregations

PlanPhase (org.killbill.billing.catalog.api.PlanPhase)98 Plan (org.killbill.billing.catalog.api.Plan)77 Test (org.testng.annotations.Test)71 MockPlan (org.killbill.billing.catalog.MockPlan)50 MockPlanPhase (org.killbill.billing.catalog.MockPlanPhase)49 LocalDate (org.joda.time.LocalDate)47 DateTime (org.joda.time.DateTime)43 BillingEventSet (org.killbill.billing.junction.BillingEventSet)43 BigDecimal (java.math.BigDecimal)42 BillingEvent (org.killbill.billing.junction.BillingEvent)41 MockBillingEventSet (org.killbill.billing.invoice.MockBillingEventSet)40 Invoice (org.killbill.billing.invoice.api.Invoice)39 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)36 UUID (java.util.UUID)34 DefaultPrice (org.killbill.billing.catalog.DefaultPrice)22 MockInternationalPrice (org.killbill.billing.catalog.MockInternationalPrice)22 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)22 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)22 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)21 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)21