use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestExportAccount method testExportAccount.
@Test(groups = "slow")
public void testExportAccount() throws Exception {
final Account emptyAccount = new Account();
final Account account = accountApi.createAccount(emptyAccount, requestOptions);
final OutputStream outputStream = new ByteArrayOutputStream();
final int statusCode = exportApi.exportDataForAccount(account.getAccountId(), outputStream, requestOptions);
outputStream.flush();
Assert.assertEquals(statusCode, 200);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestInvoice method testExternalChargesWithSameInvoice.
@Test(groups = "slow", description = "Can create multiple external charges with same invoice and external keys")
public void testExternalChargesWithSameInvoice() throws Exception {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, false, false, false, null, AuditLevel.NONE, requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
final InvoiceItems externalCharges = new InvoiceItems();
// Does not pass currency to test on purpose that we will default to account currency
final InvoiceItem externalCharge1 = new InvoiceItem();
externalCharge1.setAccountId(accountJson.getAccountId());
externalCharge1.setAmount(chargeAmount);
externalCharge1.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge1);
final InvoiceItem externalCharge2 = new InvoiceItem();
externalCharge2.setAccountId(accountJson.getAccountId());
externalCharge2.setAmount(chargeAmount);
externalCharge2.setCurrency(accountJson.getCurrency());
externalCharge2.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge2);
final List<InvoiceItem> createdExternalCharges = invoiceApi.createExternalCharges(accountJson.getAccountId(), externalCharges, clock.getUTCToday(), true, NULL_PLUGIN_PROPERTIES, requestOptions);
assertEquals(createdExternalCharges.size(), 2);
assertEquals(createdExternalCharges.get(0).getCurrency(), accountJson.getCurrency());
assertEquals(createdExternalCharges.get(1).getCurrency(), accountJson.getCurrency());
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestInvoice method testExternalChargeOnNewInvoice.
@Test(groups = "slow", description = "Can create an external charge")
public void testExternalChargeOnNewInvoice() throws Exception {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
final Invoices originalInvoices = accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, false, false, false, null, AuditLevel.NONE, requestOptions);
assertEquals(originalInvoices.size(), 2);
final UUID firstInvoiceItemId = originalInvoices.get(0).getItems().get(0).getInvoiceItemId();
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
final InvoiceItem externalCharge = new InvoiceItem();
externalCharge.setAccountId(accountJson.getAccountId());
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setPlanName("SomePlan");
externalCharge.setProductName("SomeProduct");
externalCharge.setDescription(UUID.randomUUID().toString());
externalCharge.setItemDetails("Item Details");
externalCharge.setLinkedInvoiceItemId(firstInvoiceItemId);
final LocalDate startDate = clock.getUTCToday();
externalCharge.setStartDate(startDate);
final LocalDate endDate = startDate.plusDays(10);
externalCharge.setEndDate(endDate);
final InvoiceItems itemsForCharge = new InvoiceItems();
itemsForCharge.add(externalCharge);
final List<InvoiceItem> createdExternalCharges = invoiceApi.createExternalCharges(accountJson.getAccountId(), itemsForCharge, clock.getUTCToday(), true, NULL_PLUGIN_PROPERTIES, requestOptions);
assertEquals(createdExternalCharges.size(), 1);
final Invoice invoiceWithItems = invoiceApi.getInvoice(createdExternalCharges.get(0).getInvoiceId(), false, AuditLevel.NONE, requestOptions);
assertEquals(invoiceWithItems.getBalance().compareTo(chargeAmount), 0);
assertEquals(invoiceWithItems.getItems().size(), 1);
assertEquals(invoiceWithItems.getItems().get(0).getDescription(), externalCharge.getDescription());
assertNull(invoiceWithItems.getItems().get(0).getBundleId());
assertEquals(invoiceWithItems.getItems().get(0).getStartDate().compareTo(startDate), 0);
assertEquals(invoiceWithItems.getItems().get(0).getEndDate().compareTo(endDate), 0);
assertEquals(invoiceWithItems.getItems().get(0).getItemDetails(), "Item Details");
assertEquals(invoiceWithItems.getItems().get(0).getLinkedInvoiceItemId(), firstInvoiceItemId);
assertEquals(invoiceWithItems.getItems().get(0).getPlanName().compareTo("SomePlan"), 0);
assertEquals(invoiceWithItems.getItems().get(0).getProductName().compareTo("SomeProduct"), 0);
// Verify the total number of invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, null, requestOptions).size(), 3);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestInvoice method testExternalCharges.
@Test(groups = "slow", description = "Can create multiple external charges")
public void testExternalCharges() throws Exception {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, false, false, false, null, AuditLevel.NONE, requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
final InvoiceItems externalCharges = new InvoiceItems();
// Does not pass currency to test on purpose that we will default to account currency
final InvoiceItem externalCharge1 = new InvoiceItem();
externalCharge1.setAccountId(accountJson.getAccountId());
externalCharge1.setAmount(chargeAmount);
externalCharge1.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge1);
final InvoiceItem externalCharge2 = new InvoiceItem();
externalCharge2.setAccountId(accountJson.getAccountId());
externalCharge2.setAmount(chargeAmount);
externalCharge2.setCurrency(accountJson.getCurrency());
externalCharge2.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge2);
final List<InvoiceItem> createdExternalCharges = invoiceApi.createExternalCharges(accountJson.getAccountId(), externalCharges, clock.getUTCToday(), true, NULL_PLUGIN_PROPERTIES, requestOptions);
assertEquals(createdExternalCharges.size(), 2);
assertEquals(createdExternalCharges.get(0).getCurrency(), accountJson.getCurrency());
assertEquals(createdExternalCharges.get(1).getCurrency(), accountJson.getCurrency());
// Verify the total number of invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, null, requestOptions).size(), 3);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestInvoice method testAddTaxItemsOnNewInvoice.
@Test(groups = "slow", description = "Can create tax items for a bundle")
public void testAddTaxItemsOnNewInvoice() throws Exception {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, false, false, false, null, AuditLevel.NONE, requestOptions).size(), 2);
// Post an external charge
final BigDecimal taxAmount = BigDecimal.TEN;
final UUID bundleId = UUID.randomUUID();
final InvoiceItem taxItem = new InvoiceItem();
taxItem.setAccountId(accountJson.getAccountId());
taxItem.setAmount(taxAmount);
taxItem.setCurrency(accountJson.getCurrency());
taxItem.setBundleId(bundleId);
final InvoiceItems input = new InvoiceItems();
input.add(taxItem);
final List<InvoiceItem> createdTaxItems = invoiceApi.createTaxItems(accountJson.getAccountId(), input, true, clock.getUTCToday(), NULL_PLUGIN_PROPERTIES, requestOptions);
assertEquals(createdTaxItems.size(), 1);
final Invoice invoiceWithItems = invoiceApi.getInvoice(createdTaxItems.get(0).getInvoiceId(), null, AuditLevel.NONE, requestOptions);
assertEquals(invoiceWithItems.getBalance().compareTo(taxAmount), 0);
assertEquals(invoiceWithItems.getItems().size(), 1);
assertEquals(invoiceWithItems.getItems().get(0).getBundleId(), bundleId);
assertEquals(invoiceWithItems.getItems().get(0).getItemType(), InvoiceItemType.TAX);
// Verify the total number of invoices
assertEquals(accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, null, requestOptions).size(), 3);
}
Aggregations