*/
package org.mxchange.jfinancials.model.receipt_item;
-import org.mxchange.jfinancials.model.utils.ReceiptItemUtils;
import java.text.MessageFormat;
import java.util.Date;
import java.util.Objects;
import org.mxchange.jfinancials.enterprise.financial.receipt_item.BaseFinancialsReceiptItemEnterpriseBean;
import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
+import org.mxchange.jfinancials.model.utils.ReceiptItemUtils;
/**
* A stateless bean for general purposes for receipt items
* @return Whether item has already been added to receipt item's receipt
*/
private boolean isReceiptItemRegistered (final BillableReceiptItem receiptItem, final boolean checkDiscountRefund, final boolean checkOnlyPrimaryKey) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isReceiptItemRegistered(): receiptItem.itemId={1},checkDiscountRefund={2},checkOnlyPrimaryKey={3} - EXIT!", this.getClass().getSimpleName(), receiptItem.getItemId(), checkDiscountRefund, checkOnlyPrimaryKey)); //NOI18N
+
// Default is not found
boolean isFound = false;
* buy the same item again and again ... ;-)
*/
for (final BillableReceiptItem currentReceiptItem : this.receiptItemBean.fetchReceiptItemsByReceipt(receiptItem.getItemReceipt())) {
+ // Debug message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isReceiptItemRegistered(): currentReceiptItem.itemId={1},receiptItem.itemId={2} - EXIT!", this.getClass().getSimpleName(), currentReceiptItem.getItemId(), receiptItem.getItemId()));
+
// Is it the same item?
if (((checkOnlyPrimaryKey && Objects.equals(currentReceiptItem.getItemId(), receiptItem.getItemId())) || ReceiptItemUtils.isSameReceiptItem(currentReceiptItem, receiptItem)) && (checkDiscountRefund || !currentReceiptItem.getItemIsRefund())) {
// Found it
}
}
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isReceiptItemRegistered(): isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound));
+
// Return flag
return isFound;
}
*/
package org.mxchange.jfinancials.model.receipt_item;
-import org.mxchange.jfinancials.model.utils.ReceiptItemUtils;
import java.text.MessageFormat;
import java.util.Date;
import java.util.LinkedList;
import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.utils.ReceiptItemUtils;
import org.mxchange.jusercore.model.user.User;
/**
@Override
public List<BillableReceiptItem> fetchReceiptItemsByReceipt (final BillableReceipt receipt) {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceiptItems(): receipt={1} - CALLED!", this.getClass().getSimpleName(), receipt)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchReceiptItemsByReceipt(): receipt={1} - CALLED!", this.getClass().getSimpleName(), receipt)); //NOI18N
// Init list
final List<BillableReceiptItem> receiptItems = new LinkedList<>();
// Iterate over all records
for (final BillableReceiptItem currentReceiptItem : this.fetchAllReceiptItems()) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.fetchReceiptItemsByReceipt(): receipt.receiptId={1},currentReceiptItem.itemReceipt.receiptId={2}", this.getClass().getSimpleName(), receipt.getReceiptId(), currentReceiptItem.getItemReceipt().getReceiptId()));
+
// Does the receipt match?
if (Objects.equals(receipt, currentReceiptItem.getItemReceipt())) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.fetchReceiptItemsByReceipt(): Adding currentReceiptItem.itemId={1}", this.getClass().getSimpleName(), currentReceiptItem.getItemId()));
+
// Yes, then add to list
receiptItems.add(currentReceiptItem);
}
}
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceiptItems(): receiptItems()={1} EXIT!", this.getClass().getSimpleName(), receiptItems.size())); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchReceiptItemsByReceipt(): receiptItems()={1} EXIT!", this.getClass().getSimpleName(), receiptItems.size())); //NOI18N
// Return it
return receiptItems;