fix NullPointerException generating invoice when there is an item adjustment for a fixed item
@@ -124,11 +124,21 @@ public class SubscriptionItemTree {
Preconditions.checkState(!isBuilt);
for (final InvoiceItem item : pendingItemAdj) {
+
+ // if the linked item was ignore, ignore this adjustment too
+ final InvoiceItem ignoredLinkedItem = Iterables.tryFind(existingIgnoredItems, new Predicate<InvoiceItem>() {
+ @Override
+ public boolean apply(final InvoiceItem input) {
+ return input.getId().equals(item.getLinkedItemId());
+ }
+ }).orNull();
+ if (ignoredLinkedItem == null) {
final Item fullyAdjustedItem = root.addAdjustment(item, targetInvoiceId);
if (fullyAdjustedItem != null) {
existingFullyAdjustedItems.add(fullyAdjustedItem);
}
}
+ }
pendingItemAdj.clear();
root.buildForExistingItems(items, targetInvoiceId);
