use of org.killbill.billing.catalog.api.Currency in project killbill by killbill.
the class TestDefaultInvoiceGenerator method createBillingEvent.
private BillingEvent createBillingEvent(final UUID subscriptionId, final UUID bundleId, final LocalDate startDate, final Plan plan, final PlanPhase planPhase, final int billCycleDayLocal) throws CatalogApiException {
final SubscriptionBase sub = createSubscription(subscriptionId, bundleId);
final Currency currency = Currency.USD;
return invoiceUtil.createMockBillingEvent(null, sub, startDate.toDateTimeAtStartOfDay(), plan, planPhase, planPhase.getFixed().getPrice() == null ? null : planPhase.getFixed().getPrice().getPrice(currency), planPhase.getRecurring().getRecurringPrice() == null ? null : planPhase.getRecurring().getRecurringPrice().getPrice(currency), currency, planPhase.getRecurring().getBillingPeriod(), billCycleDayLocal, BillingMode.IN_ADVANCE, "Test", totalOrdering++, SubscriptionBaseTransitionType.CREATE);
}
use of org.killbill.billing.catalog.api.Currency in project killbill by killbill.
the class TestInvoiceDao method testMixedModeInvoicePersistence.
@Test(groups = "slow")
public void testMixedModeInvoicePersistence() throws InvoiceApiException, CatalogApiException, EntityPersistenceException {
final Currency currency = Currency.USD;
final DefaultPrice zeroPrice = new DefaultPrice(BigDecimal.ZERO, Currency.USD);
final MockInternationalPrice fixedPrice = new MockInternationalPrice(zeroPrice);
final MockPlanPhase phase1 = new MockPlanPhase(null, fixedPrice);
final BigDecimal cheapAmount = new BigDecimal("24.95");
final DefaultPrice cheapPrice = new DefaultPrice(cheapAmount, Currency.USD);
final MockInternationalPrice recurringPrice = new MockInternationalPrice(cheapPrice);
final MockPlanPhase phase2 = new MockPlanPhase(recurringPrice, null);
final MockPlan plan = new MockPlan();
final SubscriptionBase subscription = getZombieSubscription();
final DateTime effectiveDate1 = invoiceUtil.buildDate(2011, 1, 1).toDateTimeAtStartOfDay();
final BillingEvent event1 = invoiceUtil.createMockBillingEvent(null, subscription, effectiveDate1, plan, phase1, fixedPrice.getPrice(currency), null, currency, BillingPeriod.MONTHLY, 1, BillingMode.IN_ADVANCE, "testEvent1", 1L, SubscriptionBaseTransitionType.CREATE);
final BillingEventSet events = new MockBillingEventSet();
events.add(event1);
final DateTime effectiveDate2 = effectiveDate1.plusDays(30);
final BillingEvent event2 = invoiceUtil.createMockBillingEvent(null, subscription, effectiveDate2, plan, phase2, null, recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingMode.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CHANGE);
events.add(event2);
final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, new LocalDate(effectiveDate2), Currency.USD, context);
final Invoice invoice = invoiceWithMetadata.getInvoice();
assertNotNull(invoice);
assertEquals(invoice.getNumberOfItems(), 2);
assertEquals(invoice.getBalance().compareTo(cheapAmount), 0);
invoiceUtil.createInvoice(invoice, context);
final InvoiceModelDao savedInvoice = invoiceDao.getById(invoice.getId(), context);
assertNotNull(savedInvoice);
assertEquals(savedInvoice.getInvoiceItems().size(), 2);
assertEquals(InvoiceModelDaoHelper.getBalance(savedInvoice).compareTo(cheapAmount), 0);
}
use of org.killbill.billing.catalog.api.Currency in project killbill by killbill.
the class TestControlPluginRunner method testPriorCallWithUnknownPlugin.
@Test(groups = "fast")
public void testPriorCallWithUnknownPlugin() throws Exception {
final Account account = Mockito.mock(Account.class);
final UUID paymentMethodId = UUIDs.randomUUID();
final UUID paymentId = UUIDs.randomUUID();
final String paymentExternalKey = UUIDs.randomUUID().toString();
final UUID paymentTransactionId = UUIDs.randomUUID();
final String paymentTransactionExternalKey = UUIDs.randomUUID().toString();
final BigDecimal amount = BigDecimal.ONE;
final Currency currency = Currency.USD;
final ImmutableList<String> paymentControlPluginNames = ImmutableList.<String>of("not-registered");
final ImmutableList<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of();
final ControlPluginRunner controlPluginRunner = new ControlPluginRunner(new DefaultPaymentControlProviderPluginRegistry());
final PriorPaymentControlResult paymentControlResult = controlPluginRunner.executePluginPriorCalls(account, paymentMethodId, null, paymentId, paymentExternalKey, paymentTransactionId, paymentTransactionExternalKey, PaymentApiType.PAYMENT_TRANSACTION, TransactionType.AUTHORIZE, null, amount, currency, null, null, true, paymentControlPluginNames, pluginProperties, callContext);
Assert.assertEquals(paymentControlResult.getAdjustedAmount(), amount);
Assert.assertEquals(paymentControlResult.getAdjustedCurrency(), currency);
Assert.assertEquals(paymentControlResult.getAdjustedPaymentMethodId(), paymentMethodId);
Assert.assertEquals(paymentControlResult.getAdjustedPluginProperties(), pluginProperties);
Assert.assertFalse(paymentControlResult.isAborted());
}
Aggregations