/** * Check if the date portion of a date/time is before or equals at now (as returned by the clock). * * @param inputDate the fully qualified DateTime * @param accountTimeZone the account timezone * @param internalTenantContext the context * @return true if the inputDate, once converted into a LocalDate using account timezone is less or equals than today */ private boolean isBeforeOrEqualsToday(final DateTime inputDate, final DateTimeZone accountTimeZone, final InternalTenantContext internalTenantContext) { final LocalDate localDateNowInAccountTimezone = clock.getToday(accountTimeZone); final LocalDate targetDateInAccountTimezone = internalTenantContext.toLocalDate(inputDate); return targetDateInAccountTimezone.compareTo(localDateNowInAccountTimezone) <= 0; }
baseEntitlementChild.cancelEntitlementWithDateOverrideBillingPolicy(clock.getToday(childAccount.getTimeZone()), BillingActionPolicy.IMMEDIATE, null, callContext); assertListenerStatus();
final LocalDate date = clock.getToday(account.getTimeZone()); final List<InvoiceItem> invoiceItemList = new ArrayList<InvoiceItem>(); ExternalChargeInvoiceItem item = new ExternalChargeInvoiceItem(null, account.getId(), subscription.getBundleId(), "", date, date, BigDecimal.TEN, account.getCurrency(), null);
baseEntitlementChild.cancelEntitlementWithDateOverrideBillingPolicy(clock.getToday(childAccount.getTimeZone()), BillingActionPolicy.IMMEDIATE, null, callContext); assertListenerStatus();
private void insertInvoiceItemAdjustmentToChildInvoice(final Account childAccount, final Invoice childInvoice, BigDecimal amount) throws InvoiceApiException { busHandler.pushExpectedEvents(NextEvent.INVOICE_ADJUSTMENT, NextEvent.INVOICE_ADJUSTMENT); invoiceUserApi.insertInvoiceItemAdjustment(childAccount.getId(), childInvoice.getId(), childInvoice.getInvoiceItems().get(0).getId(), clock.getToday(childAccount.getTimeZone()), amount, childAccount.getCurrency(), "test adjustment", null, null, callContext); assertListenerStatus(); }
childInvoice.getId(), childInvoice.getInvoiceItems().get(0).getId(), clock.getToday(childAccount.getTimeZone()), BigDecimal.TEN, childAccount.getCurrency(), "test adjustment", null, null, callContext);
invoiceUserApi.insertInvoiceItemAdjustment(childAccount.getId(), childInvoice.getId(), childInvoice.getInvoiceItems().get(0).getId(), clock.getToday(childAccount.getTimeZone()), BigDecimal.TEN, childAccount.getCurrency(), "test adjustment", null, null, callContext); assertListenerStatus();
baseEntitlementChild.cancelEntitlementWithDateOverrideBillingPolicy(clock.getToday(childAccount.getTimeZone()), BillingActionPolicy.IMMEDIATE, null, callContext); assertListenerStatus();
@Test(groups = "slow") public void testUncancelEffectiveCancelledEntitlement() throws AccountApiException, EntitlementApiException, SubscriptionBaseApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); // Keep the same object for the whole test, to make sure we refresh its state before r/w calls testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), null, null, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); testListener.pushExpectedEvent(NextEvent.PHASE); clock.addDays(30); assertListenerStatus(); subscriptionInternalApi.setChargedThroughDate(entitlement.getId(), clock.getUTCNow().plusMonths(1), internalCallContext); final LocalDate entitlementCancelledDate = clock.getToday(account.getTimeZone()); testListener.pushExpectedEvent(NextEvent.BLOCK); final Entitlement cancelledEntitlement = entitlement.cancelEntitlementWithDateOverrideBillingPolicy(clock.getToday(account.getTimeZone()), BillingActionPolicy.END_OF_TERM, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); Assert.assertEquals(cancelledEntitlement.getEffectiveEndDate(), entitlementCancelledDate); testListener.pushExpectedEvent(NextEvent.UNCANCEL); cancelledEntitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement reactivatedEntitlement = entitlementApi.getEntitlementForId(cancelledEntitlement.getId(), callContext); Assert.assertNull(reactivatedEntitlement.getEffectiveEndDate()); }