Search in sources :

Example 1 with InvoiceItemType

use of org.killbill.billing.invoice.api.InvoiceItemType in project killbill by killbill.

the class InvoiceItemFactory method fromModelDao.

public static InvoiceItem fromModelDao(final InvoiceItemModelDao invoiceItemModelDao) {
    if (invoiceItemModelDao == null) {
        return null;
    }
    final UUID id = invoiceItemModelDao.getId();
    final DateTime createdDate = invoiceItemModelDao.getCreatedDate();
    final UUID invoiceId = invoiceItemModelDao.getInvoiceId();
    final UUID accountId = invoiceItemModelDao.getAccountId();
    final UUID childAccountId = invoiceItemModelDao.getChildAccountId();
    final UUID bundleId = invoiceItemModelDao.getBundleId();
    final UUID subscriptionId = invoiceItemModelDao.getSubscriptionId();
    final String planName = invoiceItemModelDao.getPlanName();
    final String phaseName = invoiceItemModelDao.getPhaseName();
    final String usageName = invoiceItemModelDao.getUsageName();
    final String description = invoiceItemModelDao.getDescription();
    final LocalDate startDate = invoiceItemModelDao.getStartDate();
    final LocalDate endDate = invoiceItemModelDao.getEndDate();
    final BigDecimal amount = invoiceItemModelDao.getAmount();
    final BigDecimal rate = invoiceItemModelDao.getRate();
    final Currency currency = invoiceItemModelDao.getCurrency();
    final UUID linkedItemId = invoiceItemModelDao.getLinkedItemId();
    final InvoiceItem item;
    final InvoiceItemType type = invoiceItemModelDao.getType();
    switch(type) {
        case EXTERNAL_CHARGE:
            item = new ExternalChargeInvoiceItem(id, createdDate, invoiceId, accountId, bundleId, description, startDate, amount, currency);
            break;
        case FIXED:
            item = new FixedPriceInvoiceItem(id, createdDate, invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, description, startDate, amount, currency);
            break;
        case RECURRING:
            item = new RecurringInvoiceItem(id, createdDate, invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, description, startDate, endDate, amount, rate, currency);
            break;
        case CBA_ADJ:
            item = new CreditBalanceAdjInvoiceItem(id, createdDate, invoiceId, accountId, startDate, linkedItemId, description, amount, currency);
            break;
        case CREDIT_ADJ:
            item = new CreditAdjInvoiceItem(id, createdDate, invoiceId, accountId, startDate, description, amount, currency);
            break;
        case REPAIR_ADJ:
            item = new RepairAdjInvoiceItem(id, createdDate, invoiceId, accountId, startDate, endDate, description, amount, currency, linkedItemId);
            break;
        case ITEM_ADJ:
            item = new ItemAdjInvoiceItem(id, createdDate, invoiceId, accountId, startDate, description, amount, currency, linkedItemId);
            break;
        case USAGE:
            item = new UsageInvoiceItem(id, createdDate, invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, usageName, startDate, endDate, description, amount, currency);
            break;
        case TAX:
            item = new TaxInvoiceItem(id, createdDate, invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, usageName, startDate, description, amount, currency, linkedItemId);
            break;
        case PARENT_SUMMARY:
            item = new ParentInvoiceItem(id, createdDate, invoiceId, accountId, childAccountId, amount, currency, description);
            break;
        default:
            throw new RuntimeException("Unexpected type of event item " + type);
    }
    return item;
}
Also used : InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal) Currency(org.killbill.billing.catalog.api.Currency) UUID(java.util.UUID) InvoiceItemType(org.killbill.billing.invoice.api.InvoiceItemType)

Aggregations

BigDecimal (java.math.BigDecimal)1 UUID (java.util.UUID)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 Currency (org.killbill.billing.catalog.api.Currency)1 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)1 InvoiceItemType (org.killbill.billing.invoice.api.InvoiceItemType)1