@Override public String getPlanName() { return Strings.nullToEmpty(translator.getTranslation(item.getPlanName())); }
/** * Compare two items to check whether there are the same kind; that is whether or not they build for the same product/plan. * * @param other item to compare with * @return */ public boolean isSameKind(final Item other) { final InvoiceItem otherItem = other.toInvoiceItem(); // See https://github.com/killbill/killbill/issues/286 return otherItem != null && !id.equals(otherItem.getId()) && // Finally, for the tricky part... In case of complete repairs, the new invoiceItem will always meet all of the // following conditions: same type, subscription, start date. Depending on the catalog configuration, the end // date check could also match (e.g. repair from annual to monthly). For that scenario, we need to default // to catalog checks (the rate check is a lame check for versioned catalogs). MoreObjects.firstNonNull(planName, "").equals(MoreObjects.firstNonNull(otherItem.getPlanName(), "")) && MoreObjects.firstNonNull(phaseName, "").equals(MoreObjects.firstNonNull(otherItem.getPhaseName(), "")) && MoreObjects.firstNonNull(rate, BigDecimal.ZERO).compareTo(MoreObjects.firstNonNull(otherItem.getRate(), BigDecimal.ZERO)) == 0; }
private InvoiceItem createInvoiceItem(final BigDecimal amount, final String networkName, final LocalDate startDate, final LocalDate endDate, final String planName) { final InvoiceItem item = Mockito.mock(InvoiceItem.class); Mockito.when(item.getAmount()).thenReturn(amount); Mockito.when(item.getStartDate()).thenReturn(startDate); Mockito.when(item.getEndDate()).thenReturn(endDate); Mockito.when(item.getPlanName()).thenReturn(planName); Mockito.when(item.getDescription()).thenReturn(networkName); return item; } }
public static InvoiceItem buildInvoiceItem(final Invoice invoice, final InvoiceItemType invoiceItemType, final BigDecimal amount, @Nullable final UUID linkedItemID) { final InvoiceItem invoiceItem = Mockito.mock(InvoiceItem.class); Mockito.when(invoiceItem.getId()).thenReturn(UUID.randomUUID()); Mockito.when(invoiceItem.getInvoiceItemType()).thenReturn(invoiceItemType); // To work-around org.mockito.exceptions.misusing.UnfinishedStubbingException final UUID accountId = invoice.getAccountId(); final UUID invoiceId = invoice.getId(); final Currency currency = invoice.getCurrency(); Mockito.when(invoiceItem.getAccountId()).thenReturn(accountId); Mockito.when(invoiceItem.getInvoiceId()).thenReturn(invoiceId); Mockito.when(invoiceItem.getLinkedItemId()).thenReturn(linkedItemID); Mockito.when(invoiceItem.getBundleId()).thenReturn(UUID.randomUUID()); Mockito.when(invoiceItem.getSubscriptionId()).thenReturn(UUID.randomUUID()); Mockito.when(invoiceItem.getPlanName()).thenReturn(UUID.randomUUID().toString()); Mockito.when(invoiceItem.getPhaseName()).thenReturn(UUID.randomUUID().toString()); Mockito.when(invoiceItem.getUsageName()).thenReturn(UUID.randomUUID().toString()); Mockito.when(invoiceItem.getAmount()).thenReturn(amount); Mockito.when(invoiceItem.getCurrency()).thenReturn(currency); return invoiceItem; }
protected Plan getPlanFromInvoiceItem(final InvoiceItem invoiceItem, final TenantContext context) throws OSGIServiceNotAvailable { try { final Catalog catalog = getCatalog(context); return catalog.findPlan(invoiceItem.getPlanName(), invoiceItem.getStartDate().toDateTimeAtStartOfDay()); } catch (final CatalogApiException e) { logService.log(LogService.LOG_INFO, "Unable to retrieve plan for invoice item " + invoiceItem.getId(), e); return null; } }
@Test(groups = "fast") public void testBuildTaxItem() throws Exception { // Overrides Assert.assertEquals(invoice1TaxItem.getInvoiceItemType(), InvoiceItemType.TAX); Assert.assertEquals(invoice1TaxItem.getStartDate(), invoice1TaxableItem.getStartDate()); Assert.assertNull(invoice1TaxItem.getEndDate()); Assert.assertEquals(invoice1TaxItem.getAmount().compareTo(BigDecimal.ONE), 0); Assert.assertEquals(invoice1TaxItem.getDescription(), "TestNG tax"); Assert.assertEquals(invoice1TaxItem.getLinkedItemId(), invoice1TaxableItem.getId()); Assert.assertNull(invoice1TaxItem.getRate()); // Copies Assert.assertEquals(invoice1TaxItem.getInvoiceId(), invoice1TaxableItem.getInvoiceId()); Assert.assertEquals(invoice1TaxItem.getAccountId(), invoice1TaxableItem.getAccountId()); Assert.assertEquals(invoice1TaxItem.getCurrency(), invoice1TaxableItem.getCurrency()); Assert.assertEquals(invoice1TaxItem.getBundleId(), invoice1TaxableItem.getBundleId()); Assert.assertEquals(invoice1TaxItem.getSubscriptionId(), invoice1TaxableItem.getSubscriptionId()); Assert.assertEquals(invoice1TaxItem.getPlanName(), invoice1TaxableItem.getPlanName()); Assert.assertEquals(invoice1TaxItem.getPhaseName(), invoice1TaxableItem.getPhaseName()); Assert.assertEquals(invoice1TaxItem.getUsageName(), invoice1TaxableItem.getUsageName()); } }
assertEquals(result.get(0).getBundleId(), bundleId); assertEquals(result.get(0).getSubscriptionId(), subscriptionId); assertEquals(result.get(0).getPlanName(), planName); assertEquals(result.get(0).getPhaseName(), phaseName); assertEquals(result.get(0).getUsageName(), usage.getName()); assertEquals(result.get(1).getBundleId(), bundleId); assertEquals(result.get(1).getSubscriptionId(), subscriptionId); assertEquals(result.get(1).getPlanName(), planName); assertEquals(result.get(1).getPhaseName(), phaseName); assertEquals(result.get(1).getUsageName(), usage.getName());
assertEquals(firstInvoice.getInvoiceItems().get(0).getAmount().compareTo(new BigDecimal("19.95")), 0); assertEquals(firstInvoice.getInvoiceItems().get(0).getStartDate(), futureStartDate); assertEquals(firstInvoice.getInvoiceItems().get(0).getPlanName(), "pistol-monthly-notrial");
assertEquals(result.get(0).getBundleId(), bundleId); assertEquals(result.get(0).getSubscriptionId(), subscriptionId); assertEquals(result.get(0).getPlanName(), planName); assertEquals(result.get(0).getPhaseName(), phaseName); assertEquals(result.get(0).getUsageName(), usage.getName()); assertEquals(result.get(1).getBundleId(), bundleId); assertEquals(result.get(1).getSubscriptionId(), subscriptionId); assertEquals(result.get(1).getPlanName(), planName); assertEquals(result.get(1).getPhaseName(), phaseName); assertEquals(result.get(1).getUsageName(), usage.getName());
public Item(final InvoiceItem item, final LocalDate startDate, final LocalDate endDate, final UUID targetInvoiceId, final ItemAction action) { this.id = item.getId(); this.accountId = item.getAccountId(); this.bundleId = item.getBundleId(); this.subscriptionId = item.getSubscriptionId(); this.targetInvoiceId = targetInvoiceId; this.invoiceId = item.getInvoiceId(); this.productName = item.getProductName(); this.planName = item.getPlanName(); this.phaseName = item.getPhaseName(); this.startDate = startDate; this.endDate = endDate; this.amount = item.getAmount().abs(); this.rate = item.getRate(); this.currency = item.getCurrency(); this.linkedId = item.getLinkedItemId(); this.createdDate = item.getCreatedDate(); this.action = action; this.currentRepairedAmount = BigDecimal.ZERO; this.adjustedAmount = BigDecimal.ZERO; }
assertEquals(item.getBundleId(), bundleId); assertEquals(item.getSubscriptionId(), subscriptionId); assertEquals(item.getPlanName(), planName); assertEquals(item.getPhaseName(), phaseName); assertEquals(item.getUsageName(), usage.getName());
assertEquals(dryRunInvoice1.getInvoiceItems().get(0).getAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(dryRunInvoice1.getInvoiceItems().get(0).getStartDate(), futureDate); assertEquals(dryRunInvoice1.getInvoiceItems().get(0).getPlanName(), "shotgun-annual"); assertEquals(dryRunInvoice2.getInvoiceItems().get(0).getAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(dryRunInvoice2.getInvoiceItems().get(0).getStartDate(), futureDate); assertEquals(dryRunInvoice2.getInvoiceItems().get(0).getPlanName(), "pistol-monthly"); assertEquals(realInvoice.getInvoiceItems().get(0).getAmount().compareTo(BigDecimal.ZERO), 0); assertEquals(realInvoice.getInvoiceItems().get(0).getStartDate(), futureDate); assertEquals(realInvoice.getInvoiceItems().get(0).getPlanName(), "shotgun-annual");
assertEquals(invoices.size(), 4); for (final Invoice invoice : invoices) { assertEquals(invoice.getInvoiceItems().get(0).getPlanName(), "pistol-monthly");
assertEquals(invoices.size(), 4); for (final Invoice invoice : invoices) { assertEquals(invoice.getInvoiceItems().get(0).getPlanName(), "pistol-monthly");
public InvoiceItemJson(final InvoiceItem item, final List<InvoiceItem> childItems, @Nullable final List<AuditLog> auditLogs) { this(item.getId(), item.getInvoiceId(), item.getLinkedItemId(), item.getAccountId(), item.getChildAccountId(), item.getBundleId(), item.getSubscriptionId(), item.getProductName(), item.getPlanName(), item.getPhaseName(), item.getUsageName(), item.getPrettyProductName(), item.getPrettyPlanName(), item.getPrettyPhaseName(), item.getPrettyUsageName(), item.getInvoiceItemType(), item.getDescription(), item.getStartDate(), item.getEndDate(), item.getAmount(), item.getRate(), item.getCurrency(), item.getQuantity(), item.getItemDetails(), toInvoiceItemJson(childItems), toAuditLogJson(auditLogs)); }
public InvoiceItemModelDao(final InvoiceItem invoiceItem) { this(invoiceItem.getId(), invoiceItem.getCreatedDate(), invoiceItem.getInvoiceItemType(), invoiceItem.getInvoiceId(), invoiceItem.getAccountId(), invoiceItem.getChildAccountId(), invoiceItem.getBundleId(), invoiceItem.getSubscriptionId(), invoiceItem.getDescription(), invoiceItem.getProductName(), invoiceItem.getPlanName(), invoiceItem.getPhaseName(), invoiceItem.getUsageName(), invoiceItem.getStartDate(), invoiceItem.getEndDate(), invoiceItem.getAmount(), invoiceItem.getRate(), invoiceItem.getCurrency(), invoiceItem.getLinkedItemId(), invoiceItem.getQuantity(), invoiceItem.getItemDetails()); }
model.getProductName(), model.getPrettyProductName(), model.getPlanName(), model.getPrettyPlanName(), model.getPhaseName(),
assertEquals(item.getBundleId(), bundleId); assertEquals(item.getSubscriptionId(), subscriptionId); assertEquals(item.getPlanName(), planName); assertEquals(item.getPhaseName(), phaseName); assertEquals(item.getUsageName(), usage.getName());
@Override public InvoiceItemModelDao apply(final InvoiceItem input) { return new InvoiceItemModelDao(internalCallContext.getCreatedDate(), input.getInvoiceItemType(), migrationInvoice.getId(), accountId, input.getBundleId(), input.getSubscriptionId(), input.getDescription(), input.getProductName(), input.getPlanName(), input.getPhaseName(), input.getUsageName(), input.getStartDate(), input.getEndDate(), input.getAmount(), input.getRate(), input.getCurrency(), input.getLinkedItemId()); } }));
mutableField("description", existingItem != null ? existingItem.getDescription() : null, additionalInvoiceItem.getDescription(), invoicePlugin), immutableField("productName", existingItem, existingItem != null ? existingItem.getProductName() : null, additionalInvoiceItem.getProductName(), invoicePlugin), immutableField("planName", existingItem, existingItem != null ? existingItem.getPlanName() : null, additionalInvoiceItem.getPlanName(), invoicePlugin), immutableField("phaseName", existingItem, existingItem != null ? existingItem.getPhaseName() : null, additionalInvoiceItem.getPhaseName(), invoicePlugin), immutableField("usageName", existingItem, existingItem != null ? existingItem.getUsageName() : null, additionalInvoiceItem.getUsageName(), invoicePlugin),