use of org.killbill.billing.client.model.Credit in project killbill by killbill.
the class TestCredit method testAccountDoesNotExist.
@Test(groups = "slow", description = "Cannot add a credit if the account doesn't exist")
public void testAccountDoesNotExist() throws Exception {
final Credit credit = new Credit();
credit.setAccountId(UUID.randomUUID());
credit.setCreditAmount(BigDecimal.TEN);
// Try to create the credit
assertNull(killBillClient.createCredit(credit, true, createdBy, reason, comment));
}
use of org.killbill.billing.client.model.Credit in project killbill by killbill.
the class TestInvoice method testInvoiceTransferCreditToParentAccount.
@Test(groups = "slow", description = "Can transfer credit to parent account")
public void testInvoiceTransferCreditToParentAccount() throws Exception {
final Account parentAccount = createAccount();
final Account childAccount = createAccount(parentAccount.getAccountId());
final BigDecimal creditAmount = BigDecimal.TEN;
final Credit credit = new Credit();
credit.setAccountId(childAccount.getAccountId());
credit.setInvoiceId(null);
credit.setCreditAmount(creditAmount);
// insert credit to child account
final Credit creditJson = killBillClient.createCredit(credit, true, requestOptions);
Invoices childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false);
Assert.assertEquals(childInvoices.size(), 1);
Assert.assertEquals(childInvoices.get(0).getCreditAdj().compareTo(BigDecimal.TEN), 0);
Invoices parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false);
Assert.assertEquals(parentInvoices.size(), 0);
// transfer credit to parent account
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), requestOptions);
childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false);
Assert.assertEquals(childInvoices.size(), 2);
Assert.assertEquals(childInvoices.get(1).getCreditAdj().compareTo(BigDecimal.TEN.negate()), 0);
parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false);
Assert.assertEquals(parentInvoices.size(), 1);
Assert.assertEquals(parentInvoices.get(0).getCreditAdj().compareTo(BigDecimal.TEN), 0);
}
use of org.killbill.billing.client.model.Credit in project killbill by killbill.
the class TestInvoice method testCreateCreditInvoiceAndMoveStatus.
@Test(groups = "slow", description = "Can add a credit to a new invoice")
public void testCreateCreditInvoiceAndMoveStatus() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
final DateTime effectiveDate = clock.getUTCNow();
final BigDecimal creditAmount = BigDecimal.TEN;
final Credit credit = new Credit();
credit.setAccountId(account.getAccountId());
credit.setInvoiceId(null);
credit.setCreditAmount(creditAmount);
final Credit creditJson = killBillClient.createCredit(credit, false, createdBy, reason, comment);
Invoice invoice = killBillClient.getInvoice(creditJson.getInvoiceId());
Assert.assertEquals(invoice.getStatus(), InvoiceStatus.DRAFT.toString());
killBillClient.commitInvoice(invoice.getInvoiceId(), createdBy, reason, comment);
invoice = killBillClient.getInvoice(creditJson.getInvoiceId());
Assert.assertEquals(invoice.getStatus(), InvoiceStatus.COMMITTED.toString());
}
Aggregations