*/
private BillableReceipt createReceiptInstance () {
// Init receipt instance
- final BillableReceipt receipt = new FinancialReceipt(this.getReceiptPaymentType(), this.getReceiptBranchOffice(), this.userLoginController.getLoggedInUser(), this.getReceiptIssued());
+ final BillableReceipt receipt = new FinancialReceipt(
+ this.getReceiptPaymentType(),
+ this.getReceiptBranchOffice(),
+ this.userLoginController.getLoggedInUser(),
+ this.getReceiptIssued()
+ );
// Set optional fields
receipt.setReceiptNumber(this.getReceiptNumber());
// Is current receipt instance valid?
if (this.getCurrentReceipt() == null) {
// Not set
- throw new NullPointerException("this.currentReceipt is null");
+ throw new NullPointerException("this.currentReceipt is null"); //NOI18N
}
// Copy all fields
* Updates receipt instance with new data. This copies all fields from this
* backing bean into currentReceipt instance which should be still there.
*/
- public void updateReceipt () {
+ public String updateReceipt () {
// Is current instance still there?
if (this.getCurrentReceipt() == null) {
// Throw NPE
- throw new NullPointerException("this.currentReceipt is null");
+ throw new NullPointerException("this.currentReceipt is null"); //NOI18N
} else if (this.getCurrentReceipt().getReceiptId() == null) {
// Throw NPE again
- throw new NullPointerException("this.currentReceipt.receiptId is null");
+ throw new NullPointerException("this.currentReceipt.receiptId is null"); //NOI18N
}
// Create new instance
// Is it the same?
if (Objects.equals(receipt, this.getCurrentReceipt())) {
// Yes, then abort here with message to user
- this.showFacesMessage("form-edit-receipt", "ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED", FacesMessage.SEVERITY_ERROR);
- return;
+ this.showFacesMessage("form-edit-receipt", "ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED", FacesMessage.SEVERITY_WARN); //NOI18N
+ return ""; //NOI18N
}
// Copy all data
// Clear bean
this.clear();
+
+ // Redirect to list view
+ return "admin_list_receipts"; //NOI18N
}
/**
*/
package org.mxchange.jfinancials.beans.financial.model.receipt_item;
-import java.math.BigDecimal;
-import java.text.MessageFormat;
-import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.FacesException;
-import javax.inject.Inject;
import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewController;
-import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
-import org.mxchange.jfinancials.events.receipt_item.added.ReceiptItemAddedEvent;
-import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
-import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
-import org.mxchange.jfinancials.model.receipt_item.FinancialAdminReceiptItemSessionBeanRemote;
-import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItem;
-import org.mxchange.jproduct.model.product.Product;
/**
* An administrative backing bean for receipt items
*/
private static final long serialVersionUID = 595_754_280_374_172L;
- /**
- * Event being fired when administrator has added a new receipt item
- */
- @Inject
- @Any
- private Event<ObservableReceiptItemAddedEvent> adminAddedReceiptItemEvent;
-
- /**
- * EJB for general financial receipt item purposes
- */
- @EJB (lookup = "java:global/jfinancials-ejb/adminFinancialReceiptItem!org.mxchange.jfinancials.model.receipt_item.FinancialAdminReceiptItemSessionBeanRemote")
- private FinancialAdminReceiptItemSessionBeanRemote adminReceiptItemBean;
-
- /**
- * Item brand name
- */
- private String itemBrandName;
-
- /**
- * Coupon number assigned with item
- */
- private String itemCouponNumber;
-
- /**
- * Whether the item is a discount on whole receipt or item
- */
- private Boolean itemIsDiscount;
-
- /**
- * Whether the item is a refund
- */
- private Boolean itemIsRefund;
-
- /**
- * Item manufacturer/producer
- */
- private BasicData itemManufacturer;
-
- /**
- * Item's number
- */
- private Long itemNumber;
-
- /**
- * Item product
- */
- private Product itemProduct;
-
- /**
- * Quantity of item
- */
- private BigDecimal itemQuantity;
-
- /**
- * Assigned receipt
- */
- private BillableReceipt itemReceipt;
-
- /**
- * Currency code like EUR or USD
- */
- private String productCurrencyCode;
-
- /**
- * Product's gross price
- */
- private BigDecimal productGrossPrice;
-
- /**
- * Product's net price
- */
- private BigDecimal productNetPrice;
-
- /**
- * Tax rate for this item
- */
- private BigDecimal productTaxRate;
-
- /**
- * Receipt item list controller
- */
- @Inject
- private FinancialsReceiptItemListWebViewController receiptItemListController;
-
/**
* Default constructor
*/
super();
}
- /**
- * Adds the completed receipt item to database by calling an EJB business
- * method. If not all required fields are set, a proper exception is being
- * thrown.
- * <p>
- */
- public void addReceiptItem () {
- // Are all required fields set?
-
- // Prepare receipt item instance
- final BillableReceiptItem receiptItem = this.createReceiptItemInstance();
-
- // Is the receipt already there?
- if (this.receiptItemListController.isReceiptItemAdded(receiptItem)) {
- // Receipt has already been added
- throw new FacesException(MessageFormat.format("Receipt for itemReceipt.receiptId={0},itemProduct.productId={1},itemProductQuantity={2} has already been added.", receiptItem.getItemReceipt().getReceiptId(), receiptItem.getItemProduct().getProductId(), receiptItem.getItemProductQuantity())); //NOI18N
- }
-
- // Init variable
- final BillableReceiptItem updatedReceiptItem;
-
- // All is set, then try to call EJB
- try {
- // Add it
- updatedReceiptItem = this.adminReceiptItemBean.addReceiptItem(receiptItem);
- } catch (final ReceiptItemAlreadyAddedException ex) {
- // Throw it again
- throw new FacesException(ex);
- }
-
- // Fire event with updated instance
- this.adminAddedReceiptItemEvent.fire(new ReceiptItemAddedEvent(updatedReceiptItem));
-
- // Clear bean
- this.clear();
- }
-
- /**
- * Getter for item brand name
- * <p>
- * @return Item brand name
- */
- public String getItemBrandName () {
- return this.itemBrandName;
- }
-
- /**
- * Setter for item brand name
- * <p>
- * @param itemBrandName Item brand name
- */
- public void setItemBrandName (final String itemBrandName) {
- this.itemBrandName = itemBrandName;
- }
-
- /**
- * Getter for item's coupon number
- * <p>
- * @return Item's coupon number
- */
- public String getItemCouponNumber () {
- return this.itemCouponNumber;
- }
-
- /**
- * Setter for item's coupon number
- * <p>
- * @param itemCouponNumber Item's coupon number
- */
- public void setItemCouponNumber (final String itemCouponNumber) {
- this.itemCouponNumber = itemCouponNumber;
- }
-
- /**
- * Getter for whether the item is a discount on whole receipt or item
- * <p>
- * @return Whether the item is a discount on whole receipt or item
- */
- public Boolean getItemIsDiscount () {
- return this.itemIsDiscount;
- }
-
- /**
- * Setter for whether the item is a discount on whole receipt or item
- * <p>
- * @param itemIsDiscount Whether the item is a discount on whole receipt or
- * item
- */
- public void setItemIsDiscount (final Boolean itemIsDiscount) {
- this.itemIsDiscount = itemIsDiscount;
- }
-
- /**
- * Getter for whether the item is a refund
- * <p>
- * @return Whether the item is a refund
- */
- public Boolean getItemIsRefund () {
- return this.itemIsRefund;
- }
-
- /**
- * Setter for whether the item is a refund
- * <p>
- * @param itemIsRefund Whether the item is a refund
- */
- public void setItemIsRefund (final Boolean itemIsRefund) {
- this.itemIsRefund = itemIsRefund;
- }
-
- /**
- * Getter for item manufacturer/producer
- * <p>
- * @return Item manufacturer/producer
- */
- public BasicData getItemManufacturer () {
- return this.itemManufacturer;
- }
-
- /**
- * Setter for item manufacturer/producer
- * <p>
- * @param itemManufacturer Item manufacturer/producer
- */
- public void setItemManufacturer (final BasicData itemManufacturer) {
- this.itemManufacturer = itemManufacturer;
- }
-
- /**
- * Getter for item's number
- * <p>
- * @return Item's number
- */
- public Long getItemNumber () {
- return this.itemNumber;
- }
-
- /**
- * Setter for item's number
- * <p>
- * @param itemNumber Item's number
- */
- public void setItemNumber (final Long itemNumber) {
- this.itemNumber = itemNumber;
- }
-
- /**
- * Getter for assigned product
- * <p>
- * @return Assigned product
- */
- public Product getItemProduct () {
- return this.itemProduct;
- }
-
- /**
- * Setter for assigned product
- * <p>
- * @param itemProduct Assigned product
- */
- public void setItemProduct (final Product itemProduct) {
- this.itemProduct = itemProduct;
- }
-
- /**
- * Getter for item quantity
- * <p>
- * @return Item quantity
- */
- public BigDecimal getItemQuantity () {
- return this.itemQuantity;
- }
-
- /**
- * Setter for item quantity
- * <p>
- * @param itemQuantity Item quantity
- */
- public void setItemQuantity (final BigDecimal itemQuantity) {
- this.itemQuantity = itemQuantity;
- }
-
- /**
- * Getter for assigned receipt
- * <p>
- * @return Assigned receipt
- */
- public BillableReceipt getItemReceipt () {
- return this.itemReceipt;
- }
-
- /**
- * Setter for assigned receipt
- * <p>
- * @param itemReceipt Assigned receipt
- */
- public void setItemReceipt (final BillableReceipt itemReceipt) {
- this.itemReceipt = itemReceipt;
- }
-
- /**
- * Getter for product's currency symbol
- * <p>
- * @return Product's currency symbol
- */
- public String getProductCurrencyCode () {
- return this.productCurrencyCode;
- }
-
- /**
- * Setter for product's currency symbol
- * <p>
- * @param productCurrencyCode Product's currency symbol
- */
- public void setProductCurrencyCode (final String productCurrencyCode) {
- this.productCurrencyCode = productCurrencyCode;
- }
-
- /**
- * Getter for product's gross price
- * <p>
- * @return Product's gross price
- */
- public BigDecimal getProductGrossPrice () {
- return this.productGrossPrice;
- }
-
- /**
- * Setter for product's gross price
- * <p>
- * @param productGrossPrice Product's gross price
- */
- public void setProductGrossPrice (final BigDecimal productGrossPrice) {
- this.productGrossPrice = productGrossPrice;
- }
-
- /**
- * Getter for product's net price
- * <p>
- * @return Product's net price
- */
- public BigDecimal getProductNetPrice () {
- return this.productNetPrice;
- }
-
- /**
- * Setter for product's net price
- * <p>
- * @param productNetPrice Product's net price
- */
- public void setProductNetPrice (final BigDecimal productNetPrice) {
- this.productNetPrice = productNetPrice;
- }
-
- /**
- * Getter for product's tax rate
- * <p>
- * @return Product's tax rate
- */
- public BigDecimal getProductTaxRate () {
- return this.productTaxRate;
- }
-
- /**
- * Setter for product's tax rate
- * <p>
- * @param productTaxRate Product's tax rate
- */
- public void setProductTaxRate (final BigDecimal productTaxRate) {
- this.productTaxRate = productTaxRate;
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all fields
- this.setItemBrandName(null);
- this.setItemCouponNumber(null);
- this.setItemIsDiscount(null);
- this.setItemIsRefund(null);
- this.setItemManufacturer(null);
- this.setItemNumber(null);
- this.setItemProduct(null);
- this.setItemQuantity(null);
- this.setItemReceipt(null);
- this.setProductCurrencyCode(null);
- this.setProductGrossPrice(null);
- this.setProductNetPrice(null);
- this.setProductTaxRate(null);
- }
-
- /**
- * Creates a new instance from all available data of this bean.
- * <p>
- * @return Receipt item instance
- */
- private BillableReceiptItem createReceiptItemInstance () {
- // Create new instance with minimum required data
- final BillableReceiptItem receiptItem = new FinancialReceiptItem(this.getItemProduct(), this.getItemQuantity(), this.getItemReceipt());
-
- // Set optional data
- receiptItem.setItemBrandName(this.getItemBrandName());
- receiptItem.setItemCouponNumber(this.getItemCouponNumber());
- receiptItem.setItemIsDiscount(this.getItemIsDiscount());
- receiptItem.setItemIsRefund(this.getItemIsRefund());
- receiptItem.setItemManufacturer(this.getItemManufacturer());
- receiptItem.setItemNumber(this.getItemNumber());
- receiptItem.setItemGrossPrice(this.getProductGrossPrice());
- receiptItem.setItemNetPrice(this.getProductNetPrice());
- receiptItem.setItemTaxRate(this.getProductTaxRate());
-
- // Return prepared instance
- return receiptItem;
- }
-
}
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewController;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
-import org.mxchange.jfinancials.events.receipt_item.added.ReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.AdminReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableAdminReceiptItemAddedEvent;
import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItem;
*/
@Inject
@Any
- private Event<ObservableReceiptItemAddedEvent> addedReceiptItemEvent;
+ private Event<ObservableAdminReceiptItemAddedEvent> addedReceiptItemEvent;
/**
* EJB for general financial receipt purposes
}
// Fire event with updated instance
- this.addedReceiptItemEvent.fire(new ReceiptItemAddedEvent(updatedReceiptItem));
+ this.addedReceiptItemEvent.fire(new AdminReceiptItemAddedEvent(updatedReceiptItem));
// Clear bean
this.clear();
--- /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.beans.financial.model.receipt_item.action;
+
+import java.math.BigDecimal;
+import java.text.MessageFormat;
+import java.util.Objects;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewController;
+import org.mxchange.jfinancials.events.receipt_item.added.AdminReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableAdminReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.updated.AdminReceiptItemUpdatedEvent;
+import org.mxchange.jfinancials.events.receipt_item.updated.ObservableAdminReceiptItemUpdatedEvent;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
+import org.mxchange.jfinancials.model.receipt_item.FinancialAdminReceiptItemSessionBeanRemote;
+import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItem;
+import org.mxchange.jfinancials.model.receipt_item.ReceiptItems;
+import org.mxchange.jproduct.model.product.Product;
+
+/**
+ * An administrative action backing bean for receipt items
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminReceiptItemActionController")
+@RequestScoped
+public class FinancialAdminReceiptItemActionWebRequestBean extends BaseFinancialsBean implements FinancialAdminReceiptItemActionWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 595_754_280_374_173L;
+
+ /**
+ * Event being fired when administrator has added a new receipt item
+ */
+ @Inject
+ @Any
+ private Event<ObservableAdminReceiptItemAddedEvent> adminAddedReceiptItemEvent;
+
+ /**
+ * EJB for general financial receipt item purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/adminFinancialReceiptItem!org.mxchange.jfinancials.model.receipt_item.FinancialAdminReceiptItemSessionBeanRemote")
+ private FinancialAdminReceiptItemSessionBeanRemote adminReceiptItemBean;
+
+ /**
+ * Event being fired when an administrator has updated a receipt item
+ * instance
+ */
+ @Any
+ @Inject
+ private Event<ObservableAdminReceiptItemUpdatedEvent> adminUpdatedReceiptItemEvent;
+
+ /**
+ * Currently worked on receipt item
+ */
+ private BillableReceiptItem currentReceiptItem;
+
+ /**
+ * Item brand name
+ */
+ private String itemBrandName;
+
+ /**
+ * Coupon number assigned with item
+ */
+ private String itemCouponNumber;
+
+ /**
+ * Product's gross price
+ */
+ private BigDecimal itemGrossPrice;
+
+ /**
+ * Item's primary key
+ */
+ private Long itemId;
+
+ /**
+ * Whether the item is a discount on whole receipt or item
+ */
+ private Boolean itemIsDiscount;
+
+ /**
+ * Whether the item is a refund
+ */
+ private Boolean itemIsRefund;
+
+ /**
+ * Item manufacturer/producer
+ */
+ private BasicData itemManufacturer;
+
+ /**
+ * Product's net price
+ */
+ private BigDecimal itemNetPrice;
+
+ /**
+ * Item's number
+ */
+ private Long itemNumber;
+
+ /**
+ * Item product
+ */
+ private Product itemProduct;
+
+ /**
+ * Quantity of item
+ */
+ private BigDecimal itemProductQuantity;
+
+ /**
+ * Assigned receipt
+ */
+ private BillableReceipt itemReceipt;
+
+ /**
+ * Tax rate for this item
+ */
+ private BigDecimal itemTaxRate;
+
+ /**
+ * Receipt item list controller
+ */
+ @Inject
+ private FinancialsReceiptItemListWebViewController receiptItemListController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialAdminReceiptItemActionWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Adds the completed receipt item to database by calling an EJB business
+ * method. If not all required fields are set, a proper exception is being
+ * thrown.
+ * <p>
+ */
+ public void addReceiptItem () {
+ // Are all required fields set?
+
+ // Prepare receipt item instance
+ final BillableReceiptItem receiptItem = this.createReceiptItemInstance();
+
+ // Is the receipt already there?
+ if (this.receiptItemListController.isReceiptItemAdded(receiptItem)) {
+ // Receipt has already been added
+ throw new FacesException(MessageFormat.format("Receipt for itemReceipt.receiptId={0},itemProduct.productId={1},itemProductQuantity={2} has already been added.", receiptItem.getItemReceipt().getReceiptId(), receiptItem.getItemProduct().getProductId(), receiptItem.getItemProductQuantity())); //NOI18N
+ }
+
+ // Init variable
+ final BillableReceiptItem updatedReceiptItem;
+
+ // All is set, then try to call EJB
+ try {
+ // Add it
+ updatedReceiptItem = this.adminReceiptItemBean.addReceiptItem(receiptItem);
+ } catch (final ReceiptItemAlreadyAddedException ex) {
+ // Throw it again
+ throw new FacesException(ex);
+ }
+
+ // Fire event with updated instance
+ this.adminAddedReceiptItemEvent.fire(new AdminReceiptItemAddedEvent(updatedReceiptItem));
+
+ // Clear bean
+ this.clear();
+ }
+
+ /**
+ * Copies all receipt item properties from currentReceiptItem instance
+ */
+ public void copyAllReceiptItemProperties () {
+ // Is the instance set?
+ if (this.getCurrentReceiptItem() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.currrentReceiptItem is null"); //NOI18N
+ } else if (this.getCurrentReceiptItem().getItemId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.currrentReceiptItem.itemId is null"); //NOI18N
+ } else if (this.getCurrentReceiptItem().getItemId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("this.currrentReceiptItem.itemId={0} is invalid", this.getCurrentReceiptItem().getItemId())); //NOI18N
+ }
+
+ // Copy all item fields
+ this.setItemBrandName(this.getCurrentReceiptItem().getItemBrandName());
+ this.setItemCouponNumber(this.getCurrentReceiptItem().getItemCouponNumber());
+ this.setItemGrossPrice(this.getCurrentReceiptItem().getItemGrossPrice());
+ this.setItemId(this.getCurrentReceiptItem().getItemId());
+ this.setItemIsDiscount(this.getCurrentReceiptItem().getItemIsDiscount());
+ this.setItemIsRefund(this.getCurrentReceiptItem().getItemIsRefund());
+ this.setItemManufacturer(this.getCurrentReceiptItem().getItemManufacturer());
+ this.setItemNetPrice(this.getCurrentReceiptItem().getItemNetPrice());
+ this.setItemNumber(this.getCurrentReceiptItem().getItemNumber());
+ this.setItemProduct(this.getCurrentReceiptItem().getItemProduct());
+ this.setItemProductQuantity(this.getCurrentReceiptItem().getItemProductQuantity());
+ this.setItemReceipt(this.getCurrentReceiptItem().getItemReceipt());
+ this.setItemTaxRate(this.getCurrentReceiptItem().getItemTaxRate());
+ }
+
+ /**
+ * Getter for current receipt item
+ * <p>
+ * @return Current receipt item
+ */
+ public BillableReceiptItem getCurrentReceiptItem () {
+ return this.currentReceiptItem;
+ }
+
+ /**
+ * Setter for current receipt item
+ * <p>
+ * @param currentReceiptItem Current receipt item
+ */
+ public void setCurrentReceiptItem (final BillableReceiptItem currentReceiptItem) {
+ this.currentReceiptItem = currentReceiptItem;
+ }
+
+ /**
+ * Getter for item brand name
+ * <p>
+ * @return Item brand name
+ */
+ public String getItemBrandName () {
+ return this.itemBrandName;
+ }
+
+ /**
+ * Setter for item brand name
+ * <p>
+ * @param itemBrandName Item brand name
+ */
+ public void setItemBrandName (final String itemBrandName) {
+ this.itemBrandName = itemBrandName;
+ }
+
+ /**
+ * Getter for item's coupon number
+ * <p>
+ * @return Item's coupon number
+ */
+ public String getItemCouponNumber () {
+ return this.itemCouponNumber;
+ }
+
+ /**
+ * Setter for item's coupon number
+ * <p>
+ * @param itemCouponNumber Item's coupon number
+ */
+ public void setItemCouponNumber (final String itemCouponNumber) {
+ this.itemCouponNumber = itemCouponNumber;
+ }
+
+ /**
+ * Getter for product's gross price
+ * <p>
+ * @return Product's gross price
+ */
+ public BigDecimal getItemGrossPrice () {
+ return this.itemGrossPrice;
+ }
+
+ /**
+ * Setter for product's gross price
+ * <p>
+ * @param itemGrossPrice Product's gross price
+ */
+ public void setItemGrossPrice (final BigDecimal itemGrossPrice) {
+ this.itemGrossPrice = itemGrossPrice;
+ }
+
+ /**
+ * Getter for item's primary key
+ * <p>
+ * @return Item's primary key
+ */
+ public Long getItemId () {
+ return this.itemId;
+ }
+
+ /**
+ * Setter for item's primary key
+ * <p>
+ * @param itemId Item's primary key
+ */
+ public void setItemId (final Long itemId) {
+ this.itemId = itemId;
+ }
+
+ /**
+ * Getter for whether the item is a discount on whole receipt or item
+ * <p>
+ * @return Whether the item is a discount on whole receipt or item
+ */
+ public Boolean getItemIsDiscount () {
+ return this.itemIsDiscount;
+ }
+
+ /**
+ * Setter for whether the item is a discount on whole receipt or item
+ * <p>
+ * @param itemIsDiscount Whether the item is a discount on whole receipt or
+ * item
+ */
+ public void setItemIsDiscount (final Boolean itemIsDiscount) {
+ this.itemIsDiscount = itemIsDiscount;
+ }
+
+ /**
+ * Getter for whether the item is a refund
+ * <p>
+ * @return Whether the item is a refund
+ */
+ public Boolean getItemIsRefund () {
+ return this.itemIsRefund;
+ }
+
+ /**
+ * Setter for whether the item is a refund
+ * <p>
+ * @param itemIsRefund Whether the item is a refund
+ */
+ public void setItemIsRefund (final Boolean itemIsRefund) {
+ this.itemIsRefund = itemIsRefund;
+ }
+
+ /**
+ * Getter for item manufacturer/producer
+ * <p>
+ * @return Item manufacturer/producer
+ */
+ public BasicData getItemManufacturer () {
+ return this.itemManufacturer;
+ }
+
+ /**
+ * Setter for item manufacturer/producer
+ * <p>
+ * @param itemManufacturer Item manufacturer/producer
+ */
+ public void setItemManufacturer (final BasicData itemManufacturer) {
+ this.itemManufacturer = itemManufacturer;
+ }
+
+ /**
+ * Getter for product's net price
+ * <p>
+ * @return Product's net price
+ */
+ public BigDecimal getItemNetPrice () {
+ return this.itemNetPrice;
+ }
+
+ /**
+ * Setter for product's net price
+ * <p>
+ * @param itemNetPrice Product's net price
+ */
+ public void setItemNetPrice (final BigDecimal itemNetPrice) {
+ this.itemNetPrice = itemNetPrice;
+ }
+
+ /**
+ * Getter for item's number
+ * <p>
+ * @return Item's number
+ */
+ public Long getItemNumber () {
+ return this.itemNumber;
+ }
+
+ /**
+ * Setter for item's number
+ * <p>
+ * @param itemNumber Item's number
+ */
+ public void setItemNumber (final Long itemNumber) {
+ this.itemNumber = itemNumber;
+ }
+
+ /**
+ * Getter for assigned product
+ * <p>
+ * @return Assigned product
+ */
+ public Product getItemProduct () {
+ return this.itemProduct;
+ }
+
+ /**
+ * Setter for assigned product
+ * <p>
+ * @param itemProduct Assigned product
+ */
+ public void setItemProduct (final Product itemProduct) {
+ this.itemProduct = itemProduct;
+ }
+
+ /**
+ * Getter for item product quantity
+ * <p>
+ * @return Item product quantity
+ */
+ public BigDecimal getItemProductQuantity () {
+ return this.itemProductQuantity;
+ }
+
+ /**
+ * Setter for item product quantity
+ * <p>
+ * @param itemProductQuantity Item product quantity
+ */
+ public void setItemProductQuantity (final BigDecimal itemProductQuantity) {
+ this.itemProductQuantity = itemProductQuantity;
+ }
+
+ /**
+ * Getter for assigned receipt
+ * <p>
+ * @return Assigned receipt
+ */
+ public BillableReceipt getItemReceipt () {
+ return this.itemReceipt;
+ }
+
+ /**
+ * Setter for assigned receipt
+ * <p>
+ * @param itemReceipt Assigned receipt
+ */
+ public void setItemReceipt (final BillableReceipt itemReceipt) {
+ this.itemReceipt = itemReceipt;
+ }
+
+ /**
+ * Getter for product's tax rate
+ * <p>
+ * @return Product's tax rate
+ */
+ public BigDecimal getItemTaxRate () { //NOI18N
+ return this.itemTaxRate;
+ }
+
+ /**
+ * Setter for product's tax rate
+ * <p>
+ * @param itemTaxRate Product's tax rate
+ */
+ public void setItemTaxRate (final BigDecimal itemTaxRate) { //NOI18N
+ this.itemTaxRate = itemTaxRate;
+ }
+
+ /**
+ * Updates currently worked on receipt item instance.
+ * <p>
+ * @return Redirection outcome
+ */
+ public String updateReceiptItem () {
+ // Is current instance set?
+ if (this.getCurrentReceiptItem() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.currentReceiptItem is null"); //NOI18N
+ } else if (this.getCurrentReceiptItem().getItemId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.currentReceiptItem.itemId is null"); //NOI18N
+ } else if (this.getCurrentReceiptItem().getItemId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("this.currentReceiptItem.itemId={0} is null", this.getCurrentReceiptItem().getItemId())); //NOI18N
+ }
+
+ // Init instance
+ final BillableReceiptItem receiptItem = this.createReceiptItemInstance();
+
+ // Is it the same?
+ if (Objects.equals(receiptItem, this.getCurrentReceiptItem())) {
+ // Yes, then abort here with message to user
+ this.showFacesMessage("form-edit-receipt-item", "ADMIN_ERROR_FINANCIAL_RECEIPT_ITEM_NOT_CHANGED", FacesMessage.SEVERITY_WARN); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Copy all data
+ System.out.println("receiptItem.itemEntryCreated=" + receiptItem.getItemEntryCreated());
+ ReceiptItems.copyReceiptItemData(receiptItem, this.getCurrentReceiptItem());
+
+ // Create updated receipt instance
+ final BillableReceiptItem updatedReceiptItem;
+
+ try {
+ // Invoke EJB method
+ updatedReceiptItem = this.adminReceiptItemBean.updateReceiptItem(this.getCurrentReceiptItem());
+ } catch (final ReceiptItemNotFoundException ex) {
+ // Throw as cause
+ throw new FacesException(ex);
+ }
+
+ // Fire event
+ this.adminUpdatedReceiptItemEvent.fire(new AdminReceiptItemUpdatedEvent(updatedReceiptItem));
+
+ // Clear bean
+ this.clear();
+
+ // Redirect to list view
+ return "admin_list_receipt_items"; //NOI18N
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all fields
+ this.setItemBrandName(null);
+ this.setItemCouponNumber(null);
+ this.setItemGrossPrice(null);
+ this.setItemIsDiscount(null);
+ this.setItemIsRefund(null);
+ this.setItemManufacturer(null);
+ this.setItemNetPrice(null);
+ this.setItemNumber(null);
+ this.setItemProduct(null);
+ this.setItemProductQuantity(null);
+ this.setItemReceipt(null);
+ this.setItemTaxRate(null);
+ }
+
+ /**
+ * Creates a new instance from all available data of this bean.
+ * <p>
+ * @return Receipt item instance
+ */
+ private BillableReceiptItem createReceiptItemInstance () {
+ // Create new instance with minimum required data
+ final BillableReceiptItem receiptItem = new FinancialReceiptItem(
+ this.getItemProduct(),
+ this.getItemProductQuantity(),
+ this.getItemReceipt()
+ );
+
+ // Set optional data
+ receiptItem.setItemBrandName(this.getItemBrandName());
+ receiptItem.setItemCouponNumber(this.getItemCouponNumber());
+ receiptItem.setItemGrossPrice(this.getItemGrossPrice());
+ receiptItem.setItemId(this.getItemId());
+ receiptItem.setItemIsDiscount(this.getItemIsDiscount());
+ receiptItem.setItemIsRefund(this.getItemIsRefund());
+ receiptItem.setItemManufacturer(this.getItemManufacturer());
+ receiptItem.setItemNetPrice(this.getItemNetPrice());
+ receiptItem.setItemNumber(this.getItemNumber());
+ receiptItem.setItemTaxRate(this.getItemTaxRate());
+
+ // Is current instance given?
+ if (this.getCurrentReceiptItem() instanceof BillableReceiptItem) {
+ // Yes, copy created/updated instances
+ receiptItem.setItemEntryCreated(this.getCurrentReceiptItem().getItemEntryCreated());
+ receiptItem.setItemEntryUpdated(this.getCurrentReceiptItem().getItemEntryUpdated());
+ }
+
+ // Return prepared instance
+ return receiptItem;
+ }
+
+}
--- /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.beans.financial.model.receipt_item.action;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative receipt item beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialAdminReceiptItemActionWebRequestController extends Serializable {
+
+}
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.inject.Named;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableAdminReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.updated.ObservableAdminReceiptItemUpdatedEvent;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItemSessionBeanRemote;
import org.mxchange.jfinancials.model.receipt_item.ReceiptItems;
}
/**
- * Observes events being fired when a new receipt item has been added
+ * Observes events being fired when an administrator has added a new receipt
+ * item.
* <p>
* @param event Event being fired
*/
- public void afterAddedReceiptItemEvent (@Observes final ObservableReceiptItemAddedEvent event) {
+ public void afterAdminAddedReceiptItemEvent (@Observes final ObservableAdminReceiptItemAddedEvent event) {
// Validate parameter
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedReceiptItem() == null) {
+ //Throw NPE again
+ throw new NullPointerException("event.addedReceiptItem is null"); //NOI18N
+ } else if (event.getAddedReceiptItem().getItemId() == null) {
+ //Throw NPE again
+ throw new NullPointerException("event.addedReceiptItem.itemId is null"); //NOI18N
+ } else if (event.getAddedReceiptItem().getItemId() < 1) {
+ //Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("event.addedReceiptItem.itemId={0} is not valid", event.getAddedReceiptItem().getItemId())); //NOI18N
}
// Add to cache and general list
- this.receiptItemCache.put(event.getReceiptItem().getItemId(), event.getReceiptItem());
- this.getAllReceiptItems().add(event.getReceiptItem());
+ this.receiptItemCache.put(event.getAddedReceiptItem().getItemId(), event.getAddedReceiptItem());
+ this.uniqueAddReceiptItem(event.getAddedReceiptItem());
+ }
- // Is same user?
- if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceiptItem().getItemReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
- // Same user, then add it
- this.userReceiptItems.add(event.getReceiptItem());
+ /**
+ * Observes events being fired when an administrator has updated a receipt
+ * item instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedReceiptItemEvent (final @Observes ObservableAdminReceiptItemUpdatedEvent event) {
+ // Validate parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedReceiptItem() == null) {
+ //Throw NPE again
+ throw new NullPointerException("event.updatedReceiptItem is null"); //NOI18N
+ } else if (event.getUpdatedReceiptItem().getItemId() == null) {
+ //Throw NPE again
+ throw new NullPointerException("event.updatedReceiptItem.itemId is null"); //NOI18N
+ } else if (event.getUpdatedReceiptItem().getItemId() < 1) {
+ //Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("event.updatedReceiptItem.itemId={0} is not valid", event.getUpdatedReceiptItem().getItemId())); //NOI18N
}
+
+ // Add to cache and general list
+ this.receiptItemCache.put(event.getUpdatedReceiptItem().getItemId(), event.getUpdatedReceiptItem());
+ this.uniqueAddReceiptItem(event.getUpdatedReceiptItem());
}
/**
}
}
+ @Override
+ public BillableReceiptItem findReceiptItemById (final Long receiptItemId) throws ReceiptItemNotFoundException {
+ // Validate parameter
+ if (null == receiptItemId) {
+ // Throw NPE
+ throw new NullPointerException("receiptItemId is null");
+ } else if (receiptItemId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("receiptItemId={0} is not valid.", receiptItemId));
+ }
+
+ // Init instance
+ BillableReceiptItem receiptItem = null;
+
+ // Iterate over whole list
+ for (final BillableReceiptItem currentReceiptItem : this.getAllReceiptItems()) {
+ // Is the primary key matching?
+ if (Objects.equals(currentReceiptItem.getItemId(), receiptItemId)) {
+ // Yes, then remember and exit iteration
+ receiptItem = currentReceiptItem;
+ break;
+ }
+ }
+
+ // Is found?
+ if (null == receiptItem) {
+ // Not found
+ throw new ReceiptItemNotFoundException(receiptItemId);
+ }
+
+ // Return it
+ return receiptItem;
+ }
+
@Override
@SuppressWarnings ("ReturnOfCollectionOrArrayField")
public List<BillableReceiptItem> getAllReceiptItems () {
return alreadyAdded;
}
+ /**
+ * Uniquely add a receipt item instance.
+ * <p>
+ * @param receiptItem To be added/updated receipt item instance
+ */
+ private void uniqueAddReceiptItem (final BillableReceiptItem receiptItem) {
+ // Get iterator
+ final Iterator<BillableReceiptItem> allIterator = this.getAllReceiptItems().iterator();
+
+ // Iterate over all entries
+ while (allIterator.hasNext()) {
+ // Get current item
+ final BillableReceiptItem currentReceiptItem = allIterator.next();
+
+ // It the id matching?
+ if (Objects.equals(receiptItem.getItemId(), currentReceiptItem.getItemId())) {
+ // Yes, then remove it and stop iterating
+ allIterator.remove();
+ break;
+ }
+ }
+
+ // Re-add it
+ this.getAllReceiptItems().add(receiptItem);
+
+ // Is same user?
+ if (this.userLoginController.isUserLoggedIn() && Objects.equals(receiptItem.getItemReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
+ // Get iterator
+ final Iterator<BillableReceiptItem> userIterator = this.userReceiptItems.iterator();
+
+ // Iterate over all entries
+ while (userIterator.hasNext()) {
+ // Get current item
+ final BillableReceiptItem currentReceiptItem = userIterator.next();
+
+ // It the id matching?
+ if (Objects.equals(receiptItem.getItemId(), currentReceiptItem.getItemId())) {
+ // Yes, then remove it and stop iterating
+ userIterator.remove();
+ break;
+ }
+ }
+
+ // Re-add it
+ this.userReceiptItems.add(receiptItem);
+ }
+ }
}
import java.io.Serializable;
import java.util.List;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
/**
*/
public interface FinancialsReceiptItemListWebViewController extends Serializable {
+ /**
+ * Returns the receipt item by given primary key
+ * <p>
+ * @param receiptItemId Receipt item's primary key
+ * <p>
+ * @return Receipt item instance
+ * <p>
+ * @throws ReceiptItemNotFoundException If the receipt item cannot be found
+ */
+ BillableReceiptItem findReceiptItemById (final Long receiptItemId) throws ReceiptItemNotFoundException;
+
/**
* Checks if receipt item has already been added to database
* <p>
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewController;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableAdminReceiptItemAddedEvent;
/**
* A list financial receipt item bean (controller)
* <p>
* @param event Event being fired
*/
- public void afterAddedReceiptItemEvent (@Observes final ObservableReceiptItemAddedEvent event) {
+ public void afterAddedReceiptItemEvent (@Observes final ObservableAdminReceiptItemAddedEvent event) {
// Validate parameter
if (null == event) {
// Throw NPE
}
// Is same user?
- if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceiptItem().getItemReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
+ if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getAddedReceiptItem().getItemReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
// Same user, then add it
- this.userReceiptItems.add(event.getReceiptItem());
+ this.userReceiptItems.add(event.getAddedReceiptItem());
}
}
import org.mxchange.jfinancials.model.receipt.BillableReceipt;
/**
- * Converter for category id <-> valid category instance
+ * Converter for receipt id <-> valid receipt instance
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.converter.financial.receipt_item;
+
+import javax.enterprise.inject.spi.CDI;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt_item.list.FinancialsReceiptItemListWebViewController;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
+import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
+
+/**
+ * Converter for receipt item id <-> valid receipt item instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter ("ReceiptItemConverter")
+public class FinancialsReceiptItemConverter implements Converter<BillableReceiptItem> {
+
+ /**
+ * Receipt backing bean
+ */
+ private static FinancialsReceiptItemListWebViewController RECEIPT_ITEM_LIST_CONTROLLER;
+
+ @Override
+ public BillableReceiptItem getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Init instance
+ BillableReceiptItem receiptItem = null;
+
+ // Is the instance there?
+ if (null == RECEIPT_ITEM_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ RECEIPT_ITEM_LIST_CONTROLLER = CDI.current().select(FinancialsReceiptItemListWebViewBean.class).get();
+ }
+
+ try {
+ // Try to parse the value as long
+ final Long receiptItemId = Long.valueOf(submittedValue);
+
+ // Try to get user instance from it
+ receiptItem = RECEIPT_ITEM_LIST_CONTROLLER.findReceiptItemById(receiptItemId);
+ } catch (final NumberFormatException ex) {
+ // Throw again
+ throw new ConverterException(ex);
+ } catch (final ReceiptItemNotFoundException ex) {
+ // Debug message
+ // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: Exception: {0} - Returning null ...", ex)); //NOI18N
+ }
+
+ // Return it
+ return receiptItem;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final BillableReceiptItem value) {
+ // Is the object null?
+ if ((null == value) || (String.valueOf(value).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ }
+
+ // Return id number
+ return String.valueOf(value.getItemId());
+ }
+
+}
#@TODO Please fix German umlauts!
SELECT_RECEIPT_ITEM_PRODUCT=Waehle Produkt zum Kassenboneintrag aus:
ADMIN_EDIT_RECEIPT_NUMBER_TITLE=Kassenbonnummer {0} (Id {1}) bearbeiten:
-BUTTON_ADMIN_EDIT_RECEIPT=Kassenbon bearbeiten
+#@TODO Please fix German umlauts!
+BUTTON_ADMIN_EDIT_RECEIPT=Kassenbon aendern
CONTENT_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT=Kassenbon bearbeiten:
PAGE_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT=Kassenbon bearbeiten
ADMIN_EDIT_RECEIPT_TITLE=Kassenbon mit Id {0} bearbeiten:
#@TODO Please fix German umlauts!
-ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED=Fehler: Keine Aenderungen am Kassenbon vorgenommen!
-PARAMETER_RECEIPT_ID_INVALID=Parameter "receiptId" ung\u00fcltig.
+ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED=Fehler: Sie haben den Kassenbon nicht geaendert.
+PARAMETER_RECEIPT_ID_INVALID=Kassenbon mit Id-Nummer "receiptId" nicht gefunden.
ERROR_PARAMETER_RECEIPT_ID_NOT_SET=Fehler: Parameter "receiptId" nicht gesetzt.
#@TODO Please fix German umlauts!
ADMIN_EDIT_RECEIPT_MINIMUM_DATA=Bitte waehlen Sie aus bzw. geben Sie die mit (*) markierten Daten mindestens ein.
+ERROR_PARAMETER_RECEIPT_ITEM_ID_NOT_SET=Fehler: Parameter "receiptItemId" nicht gesetzt.
+PARAMETER_RECEIPT_ITEM_ID_INVALID=Kassenboneintrag mit Id-Nummer "receiptItemId" nicht gefunden.
+PAGE_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM=Kassenboneintrag editieren
+CONTENT_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM=Kassenboneintrag editieren:
+ADMIN_EDIT_RECEIPT_ITEM_NUMBER_TITLE=Kassenboneintrag mit Bonummer {0} (Id {1}) bearbeiten:
+ADMIN_EDIT_RECEIPT_ITEM_TITLE=Kassenboneintrag Id {0} bearbeiten:
+#@TODO Please fix German umlauts!
+ADMIN_EDIT_RECEIPT_ITEM_MINIMUM_DATA=Geben Sie mindestens die mit * markierten Daten fuer diesen Kassenboneintrag an.
+#@TODO Please fix German umlauts!
+BUTTON_ADMIN_EDIT_RECEIPT_ITEM=Kassenboneintrag aendern
+#@TODO Please fix German umlauts!
+RECEIPT_ITEM_UPDATED_TITLE=Wann dieser Kassenboneintrag als letztes geaendert wurde.
+#@TODO Please fix German umlauts!
+ADMIN_ERROR_FINANCIAL_RECEIPT_ITEM_NOT_CHANGED=Fehler: Sie haben den Kassenboneintrag nicht geaendert.
AGE_GROUP_ADULT=Age group "Adult"
AGE_GROUP_SENIOR=Age group "Senior"
ADMIN_EDIT_RECEIPT_NUMBER_TITLE=Edit receipt number {0} (Id {1}):
-BUTTON_ADMIN_EDIT_RECEIPT=Edit receipt
+BUTTON_ADMIN_EDIT_RECEIPT=Change receipt
CONTENT_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT=Edit receipt:
PAGE_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT=Edit receipt
ADMIN_EDIT_RECEIPT_TITLE=Edit receipt with id {0}:
-ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED=Error: No change on receipt done.
-PARAMETER_RECEIPT_ID_INVALID=Parameter "receiptId" invalid.
+ADMIN_ERROR_FINANCIAL_RECEIPT_NOT_CHANGED=Error: You did not change the receipt.
+PARAMETER_RECEIPT_ID_INVALID=Receipt with given receiptId not found.
ERROR_PARAMETER_RECEIPT_ID_NOT_SET=Error: Parameter "receiptId" not set.
ADMIN_EDIT_RECEIPT_MINIMUM_DATA=Please select or enter at least the marked fields.
+ERROR_PARAMETER_RECEIPT_ITEM_ID_NOT_SET=Error: Parameter "receiptItemId" is not set.
+PARAMETER_RECEIPT_ITEM_ID_INVALID=Receipt item with given receiptItemId not found.
+PAGE_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM=Edit receipt item
+CONTENT_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM=Edit receipt item:
+ADMIN_EDIT_RECEIPT_ITEM_NUMBER_TITLE=Edit receipt item with number {0} (Id {1}):
+ADMIN_EDIT_RECEIPT_ITEM_TITLE=Edit receipt item id {0}:
+ADMIN_EDIT_RECEIPT_ITEM_MINIMUM_DATA=Enter minimum data, marked with (*) for this receipt item.
+BUTTON_ADMIN_EDIT_RECEIPT_ITEM=Change receipt item
+RECEIPT_ITEM_UPDATED_TITLE=Then this receipt item has been recently updated.
+ADMIN_ERROR_FINANCIAL_RECEIPT_ITEM_NOT_CHANGED=Error: You did not change the receipt item.
<to-view-id>/admin/financial/receipt/admin_assign_receipt_seller.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/admin/financial/receipt/admin_receipt_edit.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>admin_list_receipts</from-outcome>
+ <to-view-id>/admin/financial/receipt/admin_receipt_list.xhtml</to-view-id>
+ <redirect></redirect>
+ </navigation-case>
+ </navigation-rule>
<navigation-rule>
<from-view-id>/admin/financial/receipt_item/admin_receipt_item_list.xhtml</from-view-id>
<navigation-case>
<to-view-id>/admin/product_category/admin_product_category_show.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/admin/financial/receipt_item/admin_receipt_item_edit.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>admin_list_receipt_items</from-outcome>
+ <to-view-id>/admin/financial/receipt_item/admin_receipt_item_list.xhtml</to-view-id>
+ <redirect></redirect>
+ </navigation-case>
+ </navigation-rule>
<!--
<factory>
<exception-handler-factory>
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-@TODO: title="#{project.ADMIN_RECEIPT_ITEM_LEGEND_TITLE}"
-@TODO: Hard-coded values
--->
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
- xmlns:product="http://mxchange.org/jsf/jproduct/widgets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
- <p:fieldset legend="#{project.ADMIN_RECEIPT_ITEM_LEGEND}">
+ <p:fieldset
+ legend="#{project.ADMIN_RECEIPT_ITEM_LEGEND}"
+ title="#{project.ADMIN_RECEIPT_ITEM_LEGEND_TITLE}"
+ >
<p:panelGrid
layout="grid"
columns="2"
<p:inputText
id="itemBrandName"
maxlength="255"
- value="#{adminReceiptItemController.itemBrandName}"
+ value="#{adminReceiptItemActionController.itemBrandName}"
title="#{project.ENTER_RECEIPT_ITEM_BRAND_NAME_TITLE}"
/>
maxlength="20"
decimalPlaces="0"
thousandSeparator=","
- value="#{adminReceiptItemController.itemNumber}"
+ value="#{adminReceiptItemActionController.itemNumber}"
title="#{project.ENTER_RECEIPT_ITEM_NUMBER_TITLE}"
/>
<p:outputLabel for="itemProduct" value="#{project.SELECT_RECEIPT_ITEM_PRODUCT}" />
<p:selectOneMenu
id="itemProduct"
- value="#{adminReceiptItemController.itemProduct}"
+ value="#{adminReceiptItemActionController.itemProduct}"
filter="true"
filterMatchMode="contains"
required="true"
<f:converter converterId="GenericProductConverter" />
- <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+ <f:selectItem
+ itemValue="#{null}"
+ itemLabel="#{msg.PLEASE_SELECT}"
+ noSelectionOption="true"
+ itemDisabled="true"
+ />
<f:selectItems
value="#{productListController.allProducts}"
- var="product"
- itemValue="#{product}"
- itemLabel="#{productBeanHelper.renderGenericProduct(product)}"
+ var="itemProduct"
+ itemValue="#{itemProduct}"
+ itemLabel="#{productBeanHelper.renderGenericProduct(itemProduct)}"
/>
</p:selectOneMenu>
<p:outputLabel for="itemManufacturer" value="#{project.SELECT_RECEIPT_ITEM_MANUFACTURER}" />
<p:selectOneMenu
id="itemManufacturer"
- value="#{adminReceiptItemController.itemManufacturer}"
+ value="#{adminReceiptItemActionController.itemManufacturer}"
filter="true"
filterMatchMode="contains"
>
<p:outputLabel for="itemQuantity" value="#{project.ENTER_RECEIPT_ITEM_QUANTITY}" />
<p:inputNumber
id="itemQuantity"
- value="#{adminReceiptItemController.itemQuantity}"
+ value="#{adminReceiptItemActionController.itemProductQuantity}"
required="true"
decimalPlaces="3"
requiredMessage="#{project.ADMIN_RECEIPT_ITEM_QUANTITY_REQUIRED}"
title="#{project.ENTER_RECEIPT_ITEM_QUANTITY_TITLE}"
/>
- <p:outputLabel for="itemIsRefund" value="#{project.CHOOSE_RECEIPT_ITEM_IS_REFUND}" title="#{project.CHOOSE_RECEIPT_ITEM_IS_REFUND_TITLE}" />
+ <p:outputLabel
+ for="itemIsRefund"
+ value="#{project.CHOOSE_RECEIPT_ITEM_IS_REFUND}"
+ title="#{project.CHOOSE_RECEIPT_ITEM_IS_REFUND_TITLE}"
+ />
<p:selectOneRadio
id="itemIsRefund"
- value="#{adminReceiptItemController.itemIsRefund}"
+ value="#{adminReceiptItemActionController.itemIsRefund}"
required="true"
requiredMessage="#{project.CHOOSE_RECEIPT_ITEM_IS_REFUND_REQUIRED}"
>
<f:selectItem itemValue="#{true}" itemLabel="#{msg.CHOICE_YES}" />
</p:selectOneRadio>
- <p:outputLabel for="itemIsDiscount" value="#{project.CHOOSE_RECEIPT_ITEM_IS_DISCOUNT}" title="#{project.CHOOSE_RECEIPT_ITEM_IS_DISCOUNT_TITLE}" />
+ <p:outputLabel
+ for="itemIsDiscount"
+ value="#{project.CHOOSE_RECEIPT_ITEM_IS_DISCOUNT}"
+ title="#{project.CHOOSE_RECEIPT_ITEM_IS_DISCOUNT_TITLE}"
+ />
<p:selectOneRadio
id="itemIsDiscount"
- value="#{adminReceiptItemController.itemIsDiscount}"
+ value="#{adminReceiptItemActionController.itemIsDiscount}"
required="true"
requiredMessage="#{project.CHOOSE_RECEIPT_ITEM_IS_DISCOUNT_REQUIRED}"
>
id="itemCouponNumber"
size="20"
maxlength="255"
- value="#{adminReceiptItemController.itemCouponNumber}"
+ value="#{adminReceiptItemActionController.itemCouponNumber}"
title="#{project.ENTER_RECEIPT_ITEM_COUPON_NUMBER_TITLE}"
/>
<p:outputLabel for="itemReceipt" value="#{project.SELECT_ITEM_RECEIPT}" />
<p:selectOneMenu
id="itemReceipt"
- value="#{adminReceiptItemController.itemReceipt}"
+ value="#{adminReceiptItemActionController.itemReceipt}"
filter="true"
filterMatchMode="contains"
required="true"
<f:converter converterId="ReceiptConverter" />
- <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+ <f:selectItem
+ itemValue="#{null}"
+ itemLabel="#{msg.PLEASE_SELECT}"
+ noSelectionOption="true"
+ itemDisabled="true"
+ />
<f:selectItems
value="#{receiptListController.allReceipts}"
</p:selectOneMenu>
<p:outputLabel value="#{product.ADMIN_ENTER_GENERIC_PRODUCT_PRICE}" />
- <product:inputProductPricePanelGrid targetController="#{adminReceiptItemController}" />
+ <ui:include src="/WEB-INF/templates/admin/financial/receipt_item/admin_receipt_item_price_input_panel_grid.tpl" />
</p:panelGrid>
</p:fieldset>
</ui:composition>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:p="http://primefaces.org/ui"
+ >
+
+ <p:panelGrid
+ layout="grid"
+ columns="3"
+ columnClasses="ui-grid-col-3,ui-grid-col-2,ui-grid-col-3"
+ styleClass="ui-noborder"
+ rendered="#{empty rendered or rendered == true}"
+ >
+ <p:outputLabel for="itemNetPrice" value="#{product.ENTER_NET_PRICE}" />
+
+ <p:outputLabel for="itemTaxRate" value="#{product.ENTER_TAX_RATE}" />
+
+ <p:outputLabel for="itemGrossPrice" value="#{product.ENTER_GROSS_PRICE}" />
+
+ <p:inputNumber
+ id="itemNetPrice"
+ title="#{product.ENTER_PRODUCT_NET_PRICE_TITLE}"
+ value="#{adminReceiptItemActionController.itemNetPrice}"
+ symbol=" EUR"
+ symbolPosition="s"
+ />
+
+ <p:inputNumber
+ id="itemTaxRate"
+ title="#{product.ENTER_PRODUCT_TAX_RATE_TITLE}"
+ value="#{adminReceiptItemActionController.itemTaxRate}"
+ symbol="%"
+ symbolPosition="s"
+ emptyValue="focus"
+ minValue="0"
+ maxValue="100"
+ />
+
+ <p:inputNumber
+ id="itemGrossPrice"
+ title="#{product.ENTER_PRODUCT_GROSS_PRICE_TITLE}"
+ value="#{adminReceiptItemActionController.itemGrossPrice}"
+ symbol=" EUR"
+ symbolPosition="s"
+ required="true"
+ requiredMessage="#{product.PRODUCT_GROSS_PRICE_REQUIRED}"
+ />
+ </p:panelGrid>
+</ui:composition>
<h:outputText value="#{msg[receiptListController.selectedReceipt.receiptPaymentType.messageKey]}" />
<p:outputLabel value="#{msg.ENTRY_CREATED_HEADER}" title="#{project.RECEIPT_ENTRY_CREATED_TITLE}" />
- <h:outputText value="#{receiptListController.selectedReceipt.receiptCreated}">
+ <h:outputText value="#{receiptListController.selectedReceipt.receiptEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+
+ <p:outputLabel value="#{msg.ENTRY_UPDATED_HEADER}" title="#{project.RECEIPT_ENTRY_UPDATED_TITLE}" />
+ <h:outputText value="#{receiptListController.selectedReceipt.receiptEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:panelGrid>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ template="/WEB-INF/templates/admin/admin_base.tpl"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ xmlns:p="http://primefaces.org/ui"
+ >
+
+ <ui:define name="metadata">
+ <f:metadata>
+ <f:viewParam
+ name="receiptItemId"
+ value="#{adminReceiptItemActionController.currentReceiptItem}"
+ converter="ReceiptItemConverter"
+ required="true"
+ requiredMessage="#{project.ERROR_PARAMETER_RECEIPT_ITEM_ID_NOT_SET}"
+ converterMessage="#{project.PARAMETER_RECEIPT_ITEM_ID_INVALID}"
+ />
+
+ <f:viewAction
+ action="#{adminReceiptItemActionController.copyAllReceiptItemProperties()}"
+ />
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="document_admin_title">
+ <h:outputText value="#{project.PAGE_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM}" />
+ </ui:define>
+
+ <ui:define name="content_header">
+ <h:outputText value="#{project.CONTENT_TITLE_ADMIN_FINANCIALS_EDIT_RECEIPT_ITEM}" />
+ </ui:define>
+
+ <ui:define name="content">
+ <h:form
+ id="form-edit-receipt-item"
+ rendered="#{not empty adminReceiptItemActionController.currentReceiptItem}"
+ >
+ <h:inputHidden value="#{adminReceiptItemActionController.itemId}" />
+
+ <p:panelGrid
+ columns="1"
+ layout="grid"
+ >
+ <f:facet name="header">
+ <h:outputFormat
+ value="#{project.ADMIN_EDIT_RECEIPT_ITEM_NUMBER_TITLE}"
+ rendered="#{not empty adminReceiptItemActionController.itemReceipt.receiptNumber}"
+ >
+ <f:param value="#{adminReceiptItemActionController.itemReceipt.receiptNumber}" />
+ <f:param value="#{adminReceiptItemActionController.itemId}" />
+ </h:outputFormat>
+
+ <h:outputFormat
+ value="#{project.ADMIN_EDIT_RECEIPT_ITEM_TITLE}"
+ rendered="#{empty adminReceiptItemActionController.itemReceipt.receiptNumber}"
+ >
+ <f:param value="#{adminReceiptItemActionController.itemId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <h:panelGroup styleClass="para" layout="block">
+ <h:outputText value="#{project.ADMIN_EDIT_RECEIPT_ITEM_MINIMUM_DATA}" />
+ </h:panelGroup>
+
+ <ui:include src="/WEB-INF/templates/admin/financial/receipt_item/admin_form_financial_receipt_item.tpl" />
+
+ <f:facet name="footer">
+ <p:panelGrid columns="2" layout="grid">
+ <p:commandButton
+ type="reset"
+ value="#{msg.BUTTON_RESET_FORM}"
+ />
+
+ <p:commandButton
+ type="submit"
+ value="#{project.BUTTON_ADMIN_EDIT_RECEIPT_ITEM}"
+ action="#{adminReceiptItemActionController.updateReceiptItem()}"
+ />
+ </p:panelGrid>
+ </f:facet>
+ </p:panelGrid>
+ </h:form>
+ </ui:define>
+</ui:composition>
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
- sortBy="#{receipt.receiptCreated}"
+ sortBy="#{receiptItem.itemEntryCreated}"
filterable="false"
>
- <h:outputText id="itemCreated" value="#{receiptItem.itemCreated}">
+ <h:outputText value="#{receiptItem.itemEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{receiptItem.itemEntryUpdated}"
+ filterable="false"
+ >
+ <h:outputText value="#{receiptItem.itemEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
value="#{msg.ADMIN_LINK_SHOW_SHORT}"
title="#{project.ADMIN_LINK_SHOW_RECEIPT_ITEM_TITLE}"
>
- <f:param name="receiptId" value="#{receiptItem.itemId}" />
+ <f:param name="receiptItemId" value="#{receiptItem.itemId}" />
</p:menuitem>
<p:menuitem
value="#{msg.ADMIN_LINK_EDIT_SHORT}"
title="#{project.ADMIN_LINK_EDIT_RECEIPT_ITEM_TITLE}"
>
- <f:param name="receiptId" value="#{receiptItem.itemId}" />
+ <f:param name="receiptItemId" value="#{receiptItem.itemId}" />
</p:menuitem>
<p:menuitem outcome="admin_delete_receipt_item">
</p:link>
<p:outputLabel value="#{msg.ENTRY_CREATED_HEADER}" title="#{project.RECEIPT_ITEM_CREATED_TITLE}" />
- <h:outputText id="itemCreated" value="#{receiptItemListController.selectedReceiptItem.itemCreated}">
+ <h:outputText value="#{receiptItemListController.selectedReceiptItem.itemEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+
+ <p:outputLabel value="#{msg.ENTRY_UPDATED_HEADER}" title="#{project.RECEIPT_ITEM_UPDATED_TITLE}" />
+ <h:outputText value="#{receiptItemListController.selectedReceiptItem.itemEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:panelGrid>
<p:commandButton
type="submit"
value="#{project.BUTTON_ADMIN_ADD_RECEIPT_TEM}"
- action="#{adminReceiptItemController.addReceiptItem()}"
+ action="#{adminReceiptItemActionController.addReceiptItem()}"
update="form-list-financial-receipt-items:receiptItemList"
/>
</p:panelGrid>