From 038e0256b4647a88cdae12f45259483554983cc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 28 Oct 2022 23:36:36 +0200 Subject: [PATCH] Don't cherry-pick: - added extensive logging --- .../FinancialAdminReceiptItemSessionBean.java | 11 ++++++++++- .../FinancialReceiptItemSessionBean.java | 12 +++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialAdminReceiptItemSessionBean.java b/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialAdminReceiptItemSessionBean.java index 5fae61e..681923b 100644 --- a/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialAdminReceiptItemSessionBean.java +++ b/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialAdminReceiptItemSessionBean.java @@ -16,7 +16,6 @@ */ 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; @@ -26,6 +25,7 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; 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 @@ -155,6 +155,9 @@ public class FinancialAdminReceiptItemSessionBean extends BaseFinancialsReceiptI * @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; @@ -169,6 +172,9 @@ public class FinancialAdminReceiptItemSessionBean extends BaseFinancialsReceiptI * 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 @@ -177,6 +183,9 @@ public class FinancialAdminReceiptItemSessionBean extends BaseFinancialsReceiptI } } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isReceiptItemRegistered(): isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); + // Return flag return isFound; } diff --git a/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItemSessionBean.java b/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItemSessionBean.java index 83daf93..3d4bd60 100644 --- a/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItemSessionBean.java +++ b/src/java/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItemSessionBean.java @@ -16,7 +16,6 @@ */ 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; @@ -27,6 +26,7 @@ import javax.persistence.Query; 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; /** @@ -115,22 +115,28 @@ public class FinancialReceiptItemSessionBean extends BaseFinancialsEnterpriseBea @Override public List 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 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; -- 2.39.5