Search in sources :

Example 1 with DefaultBillingEvent

use of org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent in project killbill by killbill.

the class TestFixedAndRecurringInvoiceItemGenerator method createDefaultBillingEvent.

private BillingEvent createDefaultBillingEvent(final LocalDate eventDate, final BigDecimal fixedAmount, final BigDecimal recurringPrice, final SubscriptionBaseTransitionType eventType, final int billCycleDay, final long ordering, final BillingMode billingMode) {
    final MockInternationalPrice price = new MockInternationalPrice(new DefaultPrice(recurringPrice, account.getCurrency()));
    final MockPlan plan = new MockPlan("my-plan");
    plan.setRecurringBillingMode(billingMode);
    final PlanPhase planPhase = new MockPlanPhase(price, null, BillingPeriod.MONTHLY, PhaseType.EVERGREEN);
    final boolean isDisabledOrBlocked = (eventType == SubscriptionBaseTransitionType.CANCEL || eventType == SubscriptionBaseTransitionType.START_BILLING_DISABLED);
    final BillingPeriod billingPeriod = recurringPrice == null ? BillingPeriod.NO_BILLING_PERIOD : BillingPeriod.MONTHLY;
    // Rely on real (junction) BillingEvent instead of MockBillingEvent to test the real behavior
    return new DefaultBillingEvent(subscription.getId(), subscription.getBundleId(), eventDate.toDateTimeAtStartOfDay(), plan, planPhase, fixedAmount, recurringPrice, ImmutableList.of(), account.getCurrency(), billingPeriod, billCycleDay, "desc", ordering, eventType, isDisabledOrBlocked);
}
Also used : MockPlan(org.killbill.billing.catalog.MockPlan) BillingPeriod(org.killbill.billing.catalog.api.BillingPeriod) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent)

Example 2 with DefaultBillingEvent

use of org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent in project killbill by killbill.

the class JunctionTestSuiteNoDB method createEvent.

protected BillingEvent createEvent(final SubscriptionBase sub, final DateTime effectiveDate, final SubscriptionBaseTransitionType type, final long totalOrdering) throws CatalogApiException {
    final int billCycleDay = 1;
    final Plan shotgun = new MockPlan();
    final PlanPhase shotgunMonthly = createMockMonthlyPlanPhase(null, BigDecimal.ZERO, PhaseType.TRIAL);
    return new DefaultBillingEvent(sub.getId(), sub.getBundleId(), effectiveDate, shotgun, shotgunMonthly, BigDecimal.ZERO, BigDecimal.ZERO, ImmutableList.of(), Currency.USD, BillingPeriod.NO_BILLING_PERIOD, billCycleDay, "Test Event 1", totalOrdering, type, false);
}
Also used : 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) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent)

Example 3 with DefaultBillingEvent

use of org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent in project killbill by killbill.

the class TestInvoiceHelper method createMockBillingEvent.

public BillingEvent createMockBillingEvent(@Nullable final Account account, final SubscriptionBase subscription, final DateTime effectiveDate, final Plan plan, final PlanPhase planPhase, @Nullable final BigDecimal fixedPrice, @Nullable final BigDecimal recurringPrice, final Currency currency, final BillingPeriod billingPeriod, final int billCycleDayLocal, final BillingMode billingMode, final String description, final long totalOrdering, final SubscriptionBaseTransitionType type) {
    final Account mockAccount = Mockito.mock(Account.class);
    Mockito.when(mockAccount.getTimeZone()).thenReturn(DateTimeZone.UTC);
    return new BillingEvent() {

        @Override
        public UUID getSubscriptionId() {
            return subscription.getId();
        }

        @Override
        public UUID getBundleId() {
            return subscription.getBundleId();
        }

        @Override
        public int getBillCycleDayLocal() {
            return billCycleDayLocal;
        }

        @Override
        public BillingAlignment getBillingAlignment() {
            return null;
        }

        @Override
        public DateTime getEffectiveDate() {
            return effectiveDate;
        }

        @Override
        public PlanPhase getPlanPhase() {
            return planPhase;
        }

        @Override
        public Plan getPlan() {
            return plan;
        }

        @Override
        public BillingPeriod getBillingPeriod() {
            return billingPeriod;
        }

        @Override
        public String getDescription() {
            return description;
        }

        @Override
        public BigDecimal getFixedPrice() {
            return fixedPrice;
        }

        @Override
        public BigDecimal getRecurringPrice() {
            return recurringPrice;
        }

        @Override
        public Currency getCurrency() {
            return currency;
        }

        @Override
        public SubscriptionBaseTransitionType getTransitionType() {
            return type;
        }

        @Override
        public Long getTotalOrdering() {
            return totalOrdering;
        }

        @Override
        public List<Usage> getUsages() {
            return Collections.emptyList();
        }

        @Override
        public DateTime getCatalogEffectiveDate() {
            return null;
        }

        @Override
        public int compareTo(final BillingEvent e1) {
            if (!getSubscriptionId().equals(e1.getSubscriptionId())) {
                // First order by subscription
                return getSubscriptionId().compareTo(e1.getSubscriptionId());
            } else {
                // subscriptions are the same
                if (!getEffectiveDate().equals(e1.getEffectiveDate())) {
                    // Secondly order by date
                    return getEffectiveDate().compareTo(e1.getEffectiveDate());
                } else {
                    // dates and subscriptions are the same
                    return getTotalOrdering().compareTo(e1.getTotalOrdering());
                }
            }
        }

        @Override
        public boolean equals(final Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            final DefaultBillingEvent that = (DefaultBillingEvent) o;
            if (getSubscriptionId() != null ? !getSubscriptionId().equals(that.getSubscriptionId()) : that.getSubscriptionId() != null) {
                return false;
            }
            if (getBundleId() != null ? !getBundleId().equals(that.getBundleId()) : that.getBundleId() != null) {
                return false;
            }
            if (billCycleDayLocal != that.getBillCycleDayLocal()) {
                return false;
            }
            if (billingPeriod != that.getBillingPeriod()) {
                return false;
            }
            if (currency != that.getCurrency()) {
                return false;
            }
            if (fixedPrice != null ? !fixedPrice.equals(that.getFixedPrice()) : that.getFixedPrice() != null) {
                return false;
            }
            if (description != null ? !description.equals(that.getDescription()) : that.getDescription() != null) {
                return false;
            }
            if (effectiveDate != null ? !effectiveDate.equals(that.getEffectiveDate()) : that.getEffectiveDate() != null) {
                return false;
            }
            if (plan != null ? !plan.equals(that.getPlan()) : that.getPlan() != null) {
                return false;
            }
            if (planPhase != null ? !planPhase.equals(that.getPlanPhase()) : that.getPlanPhase() != null) {
                return false;
            }
            if (getTotalOrdering() != null ? !getTotalOrdering().equals(that.getTotalOrdering()) : that.getTotalOrdering() != null) {
                return false;
            }
            if (type != that.getTransitionType()) {
                return false;
            }
            return true;
        }
    };
}
Also used : Account(org.killbill.billing.account.api.Account) Usage(org.killbill.billing.catalog.api.Usage) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent) BillingEvent(org.killbill.billing.junction.BillingEvent) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent)

Aggregations

DefaultBillingEvent (org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent)3 MockPlan (org.killbill.billing.catalog.MockPlan)2 MockPlanPhase (org.killbill.billing.catalog.MockPlanPhase)2 PlanPhase (org.killbill.billing.catalog.api.PlanPhase)2 Account (org.killbill.billing.account.api.Account)1 DefaultPrice (org.killbill.billing.catalog.DefaultPrice)1 MockInternationalPrice (org.killbill.billing.catalog.MockInternationalPrice)1 BillingPeriod (org.killbill.billing.catalog.api.BillingPeriod)1 Plan (org.killbill.billing.catalog.api.Plan)1 Usage (org.killbill.billing.catalog.api.Usage)1 BillingEvent (org.killbill.billing.junction.BillingEvent)1