use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class TestInvoiceHelper method verifyInvoice.
public void verifyInvoice(final UUID invoiceId, final double balance, final double cbaAmount, final InternalTenantContext context) throws InvoiceApiException {
final InvoiceModelDao invoice = invoiceDao.getById(invoiceId, context);
Assert.assertEquals(InvoiceModelDaoHelper.getRawBalanceForRegularInvoice(invoice).doubleValue(), balance);
Assert.assertEquals(InvoiceModelDaoHelper.getCBAAmount(invoice).doubleValue(), cbaAmount);
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class InvoiceOptimizerNoop method getInvoices.
@Override
public AccountInvoices getInvoices(final InternalCallContext callContext) {
logDisabledFeatureIfNeeded(callContext);
final List<Invoice> existingInvoices = new LinkedList<Invoice>();
final List<InvoiceModelDao> invoicesByAccount = invoiceDao.getInvoicesByAccount(false, callContext);
for (final InvoiceModelDao invoiceModelDao : invoicesByAccount) {
existingInvoices.add(new DefaultInvoice(invoiceModelDao));
}
return new AccountInvoices(null, null, existingInvoices);
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class DefaultInvoiceUserApi method voidInvoice.
@Override
public void voidInvoice(final UUID invoiceId, final CallContext context) throws InvoiceApiException {
final UUID accountId = getInvoiceInternal(invoiceId, context).getAccountId();
final WithAccountLock withAccountLock = new WithAccountLock() {
@Override
public Iterable<DefaultInvoice> prepareInvoices() throws InvoiceApiException {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(invoiceId, ObjectType.INVOICE, context);
final InvoiceModelDao rawInvoice = dao.getById(invoiceId, internalCallContext);
if (rawInvoice.getStatus() == InvoiceStatus.COMMITTED) {
checkInvoiceNotRepaired(rawInvoice);
checkInvoiceDoesContainUsedGeneratedCredit(accountId, rawInvoice, context);
}
final Invoice currentInvoice = new DefaultInvoice(rawInvoice, getCatalogSafelyForPrettyNames(internalCallContext));
checkInvoiceNotPaid(currentInvoice);
dao.changeInvoiceStatus(invoiceId, InvoiceStatus.VOID, internalCallContext);
final DefaultInvoice invoice = getInvoiceInternal(invoiceId, context);
return ImmutableList.of(invoice);
}
};
final LinkedList<PluginProperty> properties = new LinkedList<PluginProperty>();
properties.add(new PluginProperty(INVOICE_OPERATION, "void", false));
invoiceApiHelper.dispatchToInvoicePluginsAndInsertItems(accountId, false, withAccountLock, properties, context);
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class DefaultInvoiceUserApi method getInvoiceByPayment.
@Override
public Invoice getInvoiceByPayment(final UUID paymentId, final TenantContext context) throws InvoiceApiException {
final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(paymentId, ObjectType.PAYMENT, context);
final UUID invoiceId = dao.getInvoiceIdByPaymentId(paymentId, internalTenantContext);
if (invoiceId == null) {
throw new InvoiceApiException(ErrorCode.INVOICE_NOT_FOUND, paymentId);
}
final InvoiceModelDao invoiceModelDao = dao.getById(invoiceId, internalTenantContext);
return new DefaultInvoice(invoiceModelDao, getCatalogSafelyForPrettyNames(internalTenantContext));
}
use of org.killbill.billing.invoice.dao.InvoiceModelDao in project killbill by killbill.
the class DefaultInvoiceUserApi method getInvoicesByAccount.
@Override
public List<Invoice> getInvoicesByAccount(final UUID accountId, boolean includesMigrated, final boolean includeVoidedInvoices, final TenantContext context) {
final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(accountId, context);
final List<InvoiceModelDao> invoicesByAccount = includesMigrated ? dao.getAllInvoicesByAccount(includeVoidedInvoices, internalTenantContext) : dao.getInvoicesByAccount(includeVoidedInvoices, internalTenantContext);
return fromInvoiceModelDao(invoicesByAccount, getCatalogSafelyForPrettyNames(internalTenantContext));
}
Aggregations