]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Fri, 28 Oct 2022 21:36:36 +0000 (23:36 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 28 Oct 2022 21:36:36 +0000 (23:36 +0200)
- added extensive logging

src/java/org/mxchange/jfinancials/model/receipt_item/FinancialAdminReceiptItemSessionBean.java
src/java/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItemSessionBean.java

index 5fae61e1d15a38cd26e0114df985acfbf5d99ecc..681923bd6c37c74886183a60f2458e0c97d4b0b8 100644 (file)
@@ -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;
        }
index 83daf93194ad019f246af8126831b3eb99ebf9f5..3d4bd60aafd618a53d2315fe25a51899bb96992a 100644 (file)
@@ -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<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;