]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 25 Apr 2020 16:54:17 +0000 (18:54 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 25 Apr 2020 16:54:17 +0000 (18:54 +0200)
- introduced administrative action backing bean for receipt items
- introduced converter for receipt items
- introduced uniqueAddReceiptItem() and CDI observers for updating cache/lists
- introduced findReceiptItemById()
- let's distinguish between administrative and user events
- updateReceipt returns now a redirection outcome (back to admin-list-receipts
  view)
- reformatted Java code a bit for having all parameter of huge constructors
  in a separate line
- added missing navigation rules from edit -> list views
- added missing i18n strings

Signed-off-by: Roland Häder <roland@mxchange.org>
19 files changed:
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/action/FinancialAdminReceiptActionWebViewBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/FinancialAdminReceiptItemWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/FinancialsReceiptItemWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/list/FinancialsReceiptItemListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/list/FinancialsReceiptItemListWebViewController.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/user/FinancialsReceiptItemUserWebSessionBean.java
src/java/org/mxchange/jfinancials/converter/financial/receipt/FinancialsReceiptConverter.java
src/java/org/mxchange/jfinancials/converter/financial/receipt_item/FinancialsReceiptItemConverter.java [new file with mode: 0644]
src/java/org/mxchange/localization/project_de_DE.properties
src/java/org/mxchange/localization/project_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/financial/receipt_item/admin_form_financial_receipt_item.tpl
web/WEB-INF/templates/admin/financial/receipt_item/admin_receipt_item_price_input_panel_grid.tpl [new file with mode: 0644]
web/admin/financial/receipt/admin_receipt_list.xhtml
web/admin/financial/receipt_item/admin_receipt_item_edit.xhtml [new file with mode: 0644]
web/admin/financial/receipt_item/admin_receipt_item_list.xhtml

index 504056dfd05d1c4bd342ca8a08518bb3d0dfb454..d8ebc52b37fe4c763b6af88650ea3834e6193ba1 100644 (file)
@@ -325,7 +325,12 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
         */
        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());
index 22ea399c84efa5009bc33ccb95e3524d13ac010f..2332e2a2533004b3d5b859684f9f26d0bf69c80f 100644 (file)
@@ -222,7 +222,7 @@ public class FinancialAdminReceiptActionWebViewBean extends BaseFinancialsBean i
                // 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
@@ -480,14 +480,14 @@ public class FinancialAdminReceiptActionWebViewBean extends BaseFinancialsBean i
         * 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
@@ -496,8 +496,8 @@ public class FinancialAdminReceiptActionWebViewBean extends BaseFinancialsBean i
                // 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
@@ -519,6 +519,9 @@ public class FinancialAdminReceiptActionWebViewBean extends BaseFinancialsBean i
 
                // Clear bean
                this.clear();
+
+               // Redirect to list view
+               return "admin_list_receipts"; //NOI18N
        }
 
        /**
index aff6b0a0e32831f5d3ea65aa5a4284d5eb7ca68d..c5d0baa9ce8babeee1fa66d9bac06a5547bd2b34 100644 (file)
  */
 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
@@ -51,90 +34,6 @@ public class FinancialAdminReceiptItemWebRequestBean extends BaseFinancialsBean
         */
        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
         */
@@ -143,320 +42,4 @@ public class FinancialAdminReceiptItemWebRequestBean extends BaseFinancialsBean
                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;
-       }
-
 }
index aebad4b08d739febbf890f5228233df53c55044b..dc8c473860b609ef6104af5714d1cb6ff85ac9f1 100644 (file)
@@ -27,8 +27,8 @@ import javax.inject.Named;
 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;
@@ -53,7 +53,7 @@ public class FinancialsReceiptItemWebRequestBean extends BaseFinancialsBean impl
         */
        @Inject
        @Any
-       private Event<ObservableReceiptItemAddedEvent> addedReceiptItemEvent;
+       private Event<ObservableAdminReceiptItemAddedEvent> addedReceiptItemEvent;
 
        /**
         * EJB for general financial receipt purposes
@@ -117,7 +117,7 @@ public class FinancialsReceiptItemWebRequestBean extends BaseFinancialsBean impl
                }
 
                // Fire event with updated instance
-               this.addedReceiptItemEvent.fire(new ReceiptItemAddedEvent(updatedReceiptItem));
+               this.addedReceiptItemEvent.fire(new AdminReceiptItemAddedEvent(updatedReceiptItem));
 
                // Clear bean
                this.clear();
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestBean.java
new file mode 100644 (file)
index 0000000..f6d515d
--- /dev/null
@@ -0,0 +1,595 @@
+/*
+ * 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;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt_item/action/FinancialAdminReceiptItemActionWebRequestController.java
new file mode 100644 (file)
index 0000000..29309c2
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 {
+
+}
index 9da906a0b61ec4560fe2fe913e068f34f434b69e..0d935b70450055b591b9714fe5790675e0138c5c 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jfinancials.beans.financial.model.receipt_item.list;
 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;
@@ -31,7 +32,9 @@ import javax.inject.Inject;
 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;
@@ -104,26 +107,57 @@ public class FinancialsReceiptItemListWebViewBean extends BaseFinancialsBean imp
        }
 
        /**
-        * 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());
        }
 
        /**
@@ -157,6 +191,40 @@ public class FinancialsReceiptItemListWebViewBean extends BaseFinancialsBean imp
                }
        }
 
+       @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 () {
@@ -256,4 +324,51 @@ public class FinancialsReceiptItemListWebViewBean extends BaseFinancialsBean imp
                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);
+               }
+       }
 }
index c0458468343d44b7d1c910e534749faa69cb9a0b..2be532f8a4f3204b2eeb1ec461961bba24b93fae 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.financial.model.receipt_item.list;
 
 import java.io.Serializable;
 import java.util.List;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemNotFoundException;
 import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem;
 
 /**
@@ -27,6 +28,17 @@ 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>
index 26af5364382f9badcb0a19f2458ac93d49d2a44f..e00d01157c68c45c2ae00713ba64e9de516c73e3 100644 (file)
@@ -27,9 +27,9 @@ import javax.inject.Named;
 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)
@@ -79,7 +79,7 @@ public class FinancialsReceiptItemUserWebSessionBean extends BaseFinancialsBean
         * <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
@@ -87,9 +87,9 @@ public class FinancialsReceiptItemUserWebSessionBean extends BaseFinancialsBean
                }
 
                // 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());
                }
        }
 
index 37686d9ff91d686b82cf1c6b77362e6c941ba03e..a915952b62d8e1031edd43dc349dbcd497a8039d 100644 (file)
@@ -28,7 +28,7 @@ import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
 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>
  */
diff --git a/src/java/org/mxchange/jfinancials/converter/financial/receipt_item/FinancialsReceiptItemConverter.java b/src/java/org/mxchange/jfinancials/converter/financial/receipt_item/FinancialsReceiptItemConverter.java
new file mode 100644 (file)
index 0000000..e289b02
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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());
+       }
+
+}
index f33359caee1c9b9736deac89d23fe3ed7c5833d5..b55de5ed7b777d5f4d56405a2221e85aca92b2a7 100644 (file)
@@ -167,13 +167,28 @@ AGE_GROUP_SENIOR=Altersgruppe "Senior"
 #@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.
index 67c7355501dc479b08a9d71a54f4f74da1c9f055..1140fa17f66cafd3aa67242c271f23d39a6f1082 100644 (file)
@@ -141,11 +141,21 @@ AGE_GROUP_YOUTH=Age group "Youth"
 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.
index 9245b55082d0dba783df1eb137f99edb45bca767..532c3a14b3a0e7785e553d604fcee461b429f4f7 100644 (file)
                        <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>
index 18ff60bec389892dedd9f5d4af98b00669f5e484..2f4e8eec5aa33a0c13e876e83932f48a4a84454d 100644 (file)
@@ -1,17 +1,15 @@
 <?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"
@@ -22,7 +20,7 @@
                        <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>
diff --git a/web/WEB-INF/templates/admin/financial/receipt_item/admin_receipt_item_price_input_panel_grid.tpl b/web/WEB-INF/templates/admin/financial/receipt_item/admin_receipt_item_price_input_panel_grid.tpl
new file mode 100644 (file)
index 0000000..f382714
--- /dev/null
@@ -0,0 +1,50 @@
+<?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>
index 01c19fe92672f341e41ab18c39cf556e206fc513..787225ec37cc7608fc14682a64bde0273b813a35 100644 (file)
                                                <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>
diff --git a/web/admin/financial/receipt_item/admin_receipt_item_edit.xhtml b/web/admin/financial/receipt_item/admin_receipt_item_edit.xhtml
new file mode 100644 (file)
index 0000000..ab1855d
--- /dev/null
@@ -0,0 +1,87 @@
+<?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>
index d0680bb1b50876e486a661a124ed403fb048c86b..546c4669565cb44f1d837d9e4222cb791834b0e9 100644 (file)
 
                                <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>