import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItemSessionBeanRemote;
+import org.mxchange.jfinancials.model.receipt_item.ReceiptItems;
import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
/**
@Override
public boolean isReceiptItemAdded (final BillableReceiptItem receiptItem) {
- // Always trust the cache
- return this.getAllReceiptItems().contains(receiptItem);
+ // Does it contain the same object?
+ if (this.getAllReceiptItems().contains(receiptItem)) {
+ // Yes, skip below code
+ return true;
+ }
+
+ // Get iterator from list
+ final Iterator<BillableReceiptItem> iterator = this.getAllReceiptItems().iterator();
+
+ // Default is not the same
+ boolean alreadyAdded = false;
+
+ // Loop over all
+ while (iterator.hasNext()) {
+ // Get current item
+ final BillableReceiptItem item = iterator.next();
+
+ // Is the same?
+ if (ReceiptItems.isSameReceiptItem(item, receiptItem)) {
+ // Yes, found it
+ alreadyAdded = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return alreadyAdded;
}
}