+++ /dev/null
-/*
- * Copyright (C) 2017 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.enterprise.financial;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
-import org.mxchange.jfinancials.model.receipt.Receipts;
-
-/**
- * A general bean for receipt-related methods that can be generalized.
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public abstract class BaseFinancialsProjectEnterpriseBean extends BaseFinancialsEnterpriseBean {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 523_676_481_092_175_622L;
-
- /**
- * Protected constructor, no instance from this class.
- */
- protected BaseFinancialsProjectEnterpriseBean () {
- super();
- }
-
- /**
- * Merges given receipt's data
- * <p>
- * @param detachedReceipt Receipt instance to merge
- * <p>
- * @return Detached receipt instance
- */
- protected BillableReceipt mergeReceipt (final BillableReceipt detachedReceipt) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceipt: detachedReceipt={0} - CALLED!", detachedReceipt)); //NOI18N
-
- // The receipt instance must be valid
- if (null == detachedReceipt) {
- // Throw NPE again
- throw new NullPointerException("detachedReceipt is null"); //NOI18N
- } else if (detachedReceipt.getReceiptId() == null) {
- // Throw NPE again
- throw new NullPointerException("detachedReceipt.receiptId is null"); //NOI18N //NOI18N
- } else if (detachedReceipt.getReceiptId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("detachedReceipt.receiptId={0} is not valid.", detachedReceipt.getReceiptId())); //NOI18N
- }
-
- // Set updated timestamp
- // @TODO detachedReceipt.setReceiptUpdated(new Date());
- // Get receipt from it and find it
- final BillableReceipt foundReceipt = this.getEntityManager().find(detachedReceipt.getClass(), detachedReceipt.getReceiptId());
-
- // Should be found
- assert (foundReceipt instanceof BillableReceipt) : MessageFormat.format("Receipt with id {0} not found, but should be.", detachedReceipt.getReceiptId()); //NOI18N
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeReceipt: foundReceipt.receiptId={0}", foundReceipt.getReceiptId())); //NOI18N
-
- // Copy all
- Receipts.copyReceiptData(detachedReceipt, foundReceipt);
-
- // Merge receipt instance
- final BillableReceipt managedReceipt = this.getEntityManager().merge(foundReceipt);
-
- // Set updated timestamp
- managedReceipt.setReceiptUpdated(new Date());
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceipt: managedReceipt={0} - EXIT!", managedReceipt)); //NOI18N
-
- // Return detached receipt
- return managedReceipt;
- }
-
-}
--- /dev/null
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.enterprise.financial.receipt;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import org.mxchange.jfinancials.enterprise.product.BaseFinancialsProductEnterpriseBean;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.receipt.Receipts;
+
+/**
+ * A general bean for receipt-related methods that can be generalized.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public abstract class BaseFinancialsReceiptEnterpriseBean extends BaseFinancialsProductEnterpriseBean {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 523_676_481_092_175_622L;
+
+ /**
+ * Protected constructor, no instance from this class.
+ */
+ protected BaseFinancialsReceiptEnterpriseBean () {
+ super();
+ }
+
+ /**
+ * Merges given receipt's data
+ * <p>
+ * @param detachedReceipt Receipt instance to merge
+ * <p>
+ * @return Detached receipt instance
+ */
+ protected BillableReceipt mergeReceipt (final BillableReceipt detachedReceipt) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceipt: detachedReceipt={0} - CALLED!", detachedReceipt)); //NOI18N
+
+ // The receipt instance must be valid
+ if (null == detachedReceipt) {
+ // Throw NPE again
+ throw new NullPointerException("detachedReceipt is null"); //NOI18N
+ } else if (detachedReceipt.getReceiptId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedReceipt.receiptId is null"); //NOI18N //NOI18N
+ } else if (detachedReceipt.getReceiptId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("detachedReceipt.receiptId={0} is not valid.", detachedReceipt.getReceiptId())); //NOI18N
+ }
+
+ // Set updated timestamp
+ // @TODO detachedReceipt.setReceiptUpdated(new Date());
+ // Get receipt from it and find it
+ final BillableReceipt foundReceipt = this.getEntityManager().find(detachedReceipt.getClass(), detachedReceipt.getReceiptId());
+
+ // Should be found
+ assert (foundReceipt instanceof BillableReceipt) : MessageFormat.format("Receipt with id {0} not found, but should be.", detachedReceipt.getReceiptId()); //NOI18N
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeReceipt: foundReceipt.receiptId={0}", foundReceipt.getReceiptId())); //NOI18N
+
+ // Copy all
+ Receipts.copyReceiptData(detachedReceipt, foundReceipt);
+
+ // Merge receipt instance
+ final BillableReceipt managedReceipt = this.getEntityManager().merge(foundReceipt);
+
+ // Set updated timestamp
+ managedReceipt.setReceiptEntryUpdated(new Date());
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceipt: managedReceipt={0} - EXIT!", managedReceipt)); //NOI18N
+
+ // Return detached receipt
+ return managedReceipt;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.enterprise.financial.receipt_item;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import org.mxchange.jfinancials.enterprise.product.BaseFinancialsProductEnterpriseBean;
+import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
+import org.mxchange.jfinancials.model.receipt_item.ReceiptItems;
+
+/**
+ * A general bean for receipt item related methods that can be generalized.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public abstract class BaseFinancialsReceiptItemEnterpriseBean extends BaseFinancialsProductEnterpriseBean {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 523_676_481_092_175_623L;
+
+ /**
+ * Protected constructor, no instance from this class.
+ */
+ protected BaseFinancialsReceiptItemEnterpriseBean () {
+ super();
+ }
+
+ /**
+ * Merges given receipt's data
+ * <p>
+ * @param detachedReceiptItem Receipt instance to merge
+ * <p>
+ * @return Detached receipt instance
+ */
+ protected BillableReceiptItem mergeReceiptItem (final BillableReceiptItem detachedReceiptItem) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceiptItem: detachedReceipt={0} - CALLED!", detachedReceiptItem)); //NOI18N
+
+ // The receipt instance must be valid
+ if (null == detachedReceiptItem) {
+ // Throw NPE again
+ throw new NullPointerException("detachedReceiptItem is null"); //NOI18N
+ } else if (detachedReceiptItem.getItemId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedReceiptItem.itemId is null"); //NOI18N //NOI18N
+ } else if (detachedReceiptItem.getItemId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("detachedReceipt.itemId={0} is not valid.", detachedReceiptItem.getItemId())); //NOI18N
+ }
+
+ // Set updated timestamp
+ // @TODO detachedReceipt.setReceiptUpdated(new Date());
+ // Get receipt from it and find it
+ final BillableReceiptItem foundReceiptItem = this.getEntityManager().find(detachedReceiptItem.getClass(), detachedReceiptItem.getItemId());
+
+ // Should be found
+ assert (foundReceiptItem instanceof BillableReceiptItem) : MessageFormat.format("Receipt item with id {0} not found, but should be.", detachedReceiptItem.getItemId()); //NOI18N
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeReceipt: foundReceiptItem.itemId={0}", foundReceiptItem.getItemId())); //NOI18N
+
+ // Copy all
+ ReceiptItems.copyReceiptItemData(detachedReceiptItem, foundReceiptItem);
+
+ // Merge receipt item instance
+ final BillableReceiptItem managedReceiptItem = this.getEntityManager().merge(foundReceiptItem);
+
+ // Set updated timestamp
+ managedReceiptItem.setItemEntryUpdated(new Date());
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeReceipt: managedReceiptItem={0} - EXIT!", managedReceiptItem)); //NOI18N
+
+ // Return detached receipt
+ return managedReceiptItem;
+ }
+
+}
* @return Managed instance
*/
protected Category createManaged (final Category category) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: category={1} - CALLED!", this.getClass().getSimpleName(), category)); //NOI18N
+
// Validate parameter
if (null == category) {
// Throw NPE
* @return Managed instance
*/
protected Product createManaged (final Product product) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: product={1} - CALLED!", this.getClass().getSimpleName(), product)); //NOI18N
+
// Validate parameter
if (null == product) {
// Throw NPE
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.mxchange.jcontactsbusiness.model.employee.Employable;
-import org.mxchange.jfinancials.enterprise.financial.BaseFinancialsProjectEnterpriseBean;
+import org.mxchange.jfinancials.enterprise.financial.receipt.BaseFinancialsReceiptEnterpriseBean;
import org.mxchange.jfinancials.exceptions.receipt.ReceiptAlreadyAddedException;
import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
import org.mxchange.jusercore.model.user.User;
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminFinancialReceipt", description = "A stateless session bean for handling receipts.")
-public class FinancialAdminReceiptSessionBean extends BaseFinancialsProjectEnterpriseBean implements FinancialAdminReceiptSessionBeanRemote {
+public class FinancialAdminReceiptSessionBean extends BaseFinancialsReceiptEnterpriseBean implements FinancialAdminReceiptSessionBeanRemote {
/**
* Serial number
}
// Add created instance
- receipt.setReceiptCreated(new Date());
+ receipt.setReceiptEntryCreated(new Date());
// Is user instance set?
if (receipt.getReceiptUser() instanceof User) {
}
// Add created instance
- receipt.setReceiptCreated(new Date());
+ receipt.setReceiptEntryCreated(new Date());
// Persist it
this.getEntityManager().persist(receipt);
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
-import org.mxchange.jfinancials.enterprise.product.BaseFinancialsProductEnterpriseBean;
+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;
/**
* A stateless bean for general purposes for receipt items
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "adminFinancialReceiptItem", description = "A stateless session bean for administrative purposes for receipt itemss.")
-public class FinancialAdminReceiptItemSessionBean extends BaseFinancialsProductEnterpriseBean implements FinancialAdminReceiptItemSessionBeanRemote {
+public class FinancialAdminReceiptItemSessionBean extends BaseFinancialsReceiptItemEnterpriseBean implements FinancialAdminReceiptItemSessionBeanRemote {
/**
* Serial number
if (null == receiptItem) {
// Throw NPE
throw new NullPointerException("receiptItem is null"); //NOI18N
+ } else if (receiptItem.getItemId() != null) {
+ // Throw IAE
+ throw new IllegalArgumentException("receiptItem.itemId is not null"); //NOI18N
} else if (receiptItem.getItemProduct() == null) {
// Throw it again
throw new NullPointerException("receiptItem.itemProduct is null"); //NOI18N
return receiptItem;
}
+ @Override
+ public BillableReceiptItem updateReceiptItem (final BillableReceiptItem receiptItem) throws ReceiptItemNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateReceiptItem(): receiptItem={1} - CALLED!", this.getClass().getSimpleName(), receiptItem)); //NOI18N
+
+ // Validate parameter
+ if (null == receiptItem) {
+ // Throw NPE
+ throw new NullPointerException("receiptItem is null"); //NOI18N
+ } else if (receiptItem.getItemId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("receiptItem.itemId is null"); //NOI18N
+ } else if (receiptItem.getItemId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("receiptItem.itemId={0} is invalid", receiptItem.getItemId())); //NOI18N
+ } else if (!this.isReceiptItemRegistered(receiptItem)) {
+ // Not found
+ throw new ReceiptItemNotFoundException(receiptItem);
+ }
+
+ // Merge data
+ final BillableReceiptItem updatedReceiptItem = this.mergeReceiptItem(receiptItem);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateReceiptItem(): updatedReceiptItem={1} - CALLED!", this.getClass().getSimpleName(), updatedReceiptItem)); //NOI18N
+
+ // Return it
+ return updatedReceiptItem;
+ }
+
/**
* Checks if given receipt item has already been added to receipt.
* <p>