List of usage examples for org.joda.time LocalDate plus
public LocalDate plus(ReadablePeriod period)
From source file:org.killbill.billing.invoice.proRations.inAdvance.GenericProRationTestBase.java
License:Apache License
@Test(groups = "fast") public void testSinglePlan_MovingForwardThroughTime() throws InvalidDateSequenceException { final LocalDate startDate = invoiceUtil.buildDate(2011, 1, 31); BigDecimal expectedValue = ONE; for (int i = 1; i <= 12; i++) { LocalDate oneCycleLater = startDate; for (int j = 0; j < i; j++) { oneCycleLater = oneCycleLater.plus(getBillingPeriod().getPeriod()); }//from w w w.j a v a 2 s. co m // test just before the billing cycle day testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 31, expectedValue); expectedValue = expectedValue.add(ONE); // test on the billing cycle day testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 31, expectedValue); // test just after the billing cycle day testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 31, expectedValue); } }
From source file:org.killbill.billing.plugin.analytics.dao.model.BusinessSubscription.java
License:Apache License
public BusinessSubscription(@Nullable final Plan currentPlan, @Nullable final PlanPhase currentPhase, @Nullable final PriceList priceList, final Currency currency, final LocalDate startDate, final String service, final String state, final CurrencyConverter currencyConverter) { // TODO/*from w ww.ja va2 s .c om*/ businessActive = true; this.priceList = priceList == null ? null : priceList.getName(); // Record plan information if (currentPlan != null && currentPlan.getProduct() != null) { final Product product = currentPlan.getProduct(); productName = product.getName(); productCategory = product.getCategory().toString(); productType = product.getCatalogName(); } else { productName = null; productCategory = null; productType = null; } // Record phase information if (currentPhase != null) { slug = currentPhase.getName(); if (currentPhase.getPhaseType() != null) { phase = currentPhase.getPhaseType().toString(); } else { phase = null; } if (currentPhase.getRecurring() != null && currentPhase.getRecurring().getBillingPeriod() != null) { billingPeriod = currentPhase.getRecurring().getBillingPeriod().toString(); } else { billingPeriod = null; } if (currentPhase.getRecurring() != null && currentPhase.getRecurring().getRecurringPrice() != null && currency != null) { BigDecimal tmpPrice; try { tmpPrice = currentPhase.getRecurring().getRecurringPrice().getPrice(currency); } catch (CatalogApiException e) { tmpPrice = null; } price = tmpPrice; if (tmpPrice != null) { mrr = getMrrFromBillingPeriod(currentPhase.getRecurring().getBillingPeriod(), price); } else { mrr = null; } } else { price = null; mrr = null; } } else { slug = null; phase = null; billingPeriod = null; price = null; mrr = null; } if (currency != null) { this.currency = currency.toString(); } else { this.currency = null; } this.startDate = startDate; if (currentPhase != null) { final Duration duration = currentPhase.getDuration(); this.endDate = duration == null ? null : startDate.plus(duration.toJodaPeriod()); } else { this.endDate = null; } this.service = service; this.state = state; convertedPrice = currencyConverter.getConvertedValue(this.price, this.currency, startDate); convertedMrr = currencyConverter.getConvertedValue(this.mrr, this.currency, startDate); }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailFourTimeTrackerState.java
License:Open Source License
@Override protected Iterator<LocalDate> getPeriodsFirstLevelGenerator(LocalDate start) { return new LazyGenerator<LocalDate>(start) { @Override/*from w w w . j a va2 s . c om*/ protected LocalDate next(LocalDate last) { return last.plus(Months.ONE); } }; }