]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 12:15:06 +0000 (14:15 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 12:15:06 +0000 (14:15 +0200)
- added general backing bean for receipts which has an exposed (interface)
  method isReceiptAdded() which will check if receipt is already added
- added missing i18n strings
- added template for login (user) area for adding new receipts
- fixed mess of choosing wrong language bundle
- changed template towards p:panelGrid which is responsive and the correct
  way in modern JSF (no need for table-XXX<left|right>YYY)
- fixed wrong usage of controllers: admin versus general

Signed-off-by: Roland Häder <roland@mxchange.org>
16 files changed:
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java [deleted file]
src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java [deleted file]
src/java/org/mxchange/localization/project_de_DE.properties
src/java/org/mxchange/localization/project_en_US.properties
web/WEB-INF/templates/admin/financial/receipt/admin_form_financial_receipt.tpl
web/WEB-INF/templates/user/financial/receipt/login_form_financial_receipt.tpl [new file with mode: 0644]
web/admin/financials/receipts/admin_receipt_list.xhtml
web/user/financials/login_financials_add_receipt.xhtml

diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java
deleted file mode 100644 (file)
index c2edf3f..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * 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.income;
-
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.model.income.BillableIncome;
-import org.mxchange.jfinancials.model.income.FinancialIncome;
-import org.mxchange.jfinancials.model.income.FinancialIncomeSessionBeanRemote;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative financial income bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("financialIncomeController")
-@RequestScoped
-public class FinancialsIncomeWebRequestBean extends BaseFinancialsController implements FinancialsIncomeWebRequestController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_189_028_928_371L;
-
-       /**
-        * EJB for general financial income purposes
-        */
-       @EJB (lookup = "java:global/jfinancials-ejb/financialIncome!org.mxchange.jfinancials.model.income.FinancialIncomeSessionBeanRemote")
-       private FinancialIncomeSessionBeanRemote financialBean;
-
-       /**
-        * Income interval
-        */
-       private FinancialInterval incomeInterval;
-
-       /**
-        * Income single amount
-        */
-       private Float incomeSingleAmount;
-
-       /**
-        * Income (type) title
-        */
-       private String incomeTitle;
-
-       /**
-        * User instance
-        */
-       @Inject
-       private FinancialsUserLoginWebSessionController userLoginController;
-
-       /**
-        * Constructor
-        */
-       public FinancialsIncomeWebRequestBean () {
-               // Call super constructor
-               super();
-       }
-
-       /**
-        * Adds income data by calling proper business method of the EJB.
-        * <p>
-        * @return Redirect outcome
-        */
-       public String addIncome () {
-               // Is all data valid?
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged-in
-                       throw new IllegalStateException("User is not logged-in"); //NOI18N
-               } else if (null == this.getIncomeInterval()) {
-                       // Throw NPE
-                       throw new NullPointerException("incomeInterval is null"); //NOI18N
-               } else if (null == this.getIncomeSingleAmount()) {
-                       // Throw again
-                       throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
-               } else if (this.getIncomeSingleAmount() < 0) {
-                       // Not allowed value
-                       throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
-               } else if (null == this.getIncomeTitle()) {
-                       // Throw again
-                       throw new NullPointerException("incomeTitle is null"); //NOI18N
-               } else if (this.getIncomeTitle().isEmpty()) {
-                       // Should not be empty
-                       throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
-               }
-
-               // Now that all required data has been entered, prepare new income instance
-               final BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
-
-               // Handle it over to the EJB
-               // @TODO Use updated income instance, e.g. fire event
-               final BillableIncome updatedIncome = this.financialBean.addIncome(income);
-
-               // All fine
-               return "add_user_fiancial_income"; //NOI18N
-       }
-
-       @Override
-       public List<FinancialInterval> allIncomeIntervals () {
-               // Return list from enum values
-               return Arrays.asList(FinancialInterval.values());
-       }
-
-       @Override
-       public FinancialInterval getIncomeInterval () {
-               return this.incomeInterval;
-       }
-
-       @Override
-       public void setIncomeInterval (final FinancialInterval incomeInterval) {
-               this.incomeInterval = incomeInterval;
-       }
-
-       @Override
-       public Float getIncomeSingleAmount () {
-               return this.incomeSingleAmount;
-       }
-
-       @Override
-       public void setIncomeSingleAmount (final Float incomeSingleAmount) {
-               this.incomeSingleAmount = incomeSingleAmount;
-       }
-
-       @Override
-       public String getIncomeTitle () {
-               return this.incomeTitle;
-       }
-
-       @Override
-       public void setIncomeTitle (final String incomeTitle) {
-               this.incomeTitle = incomeTitle;
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestController.java
deleted file mode 100644 (file)
index e25f954..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * 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.income;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative interface for financial income beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsIncomeWebRequestController extends Serializable {
-
-       /**
-        * Getter for income single amount
-        * <p>
-        * @return Income single amount
-        */
-       Float getIncomeSingleAmount ();
-
-       /**
-        * Setter for income single amount
-        * <p>
-        * @param incomeSingleAmount Income single amount
-        */
-       void setIncomeSingleAmount (final Float incomeSingleAmount);
-
-       /**
-        * Getter for income (type) title
-        * <p>
-        * @return Income title
-        */
-       String getIncomeTitle ();
-
-       /**
-        * Setter for income (type) title
-        * <p>
-        * @param incomeTitle Income title
-        */
-       void setIncomeTitle (final String incomeTitle);
-
-       /**
-        * Getter for income interval
-        * <p>
-        * @return Income interval
-        */
-       FinancialInterval getIncomeInterval ();
-
-       /**
-        * Setter for income (type) interval
-        * <p>
-        * @param incomeInterval Income interval
-        */
-       void setIncomeInterval (final FinancialInterval incomeInterval);
-
-       /**
-        * Returns a list of all all income intervals
-        * <p>
-        * @return Income intervals
-        */
-       List<FinancialInterval> allIncomeIntervals ();
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestBean.java
new file mode 100644 (file)
index 0000000..20c6795
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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.income;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+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.model.income.BillableIncome;
+import org.mxchange.jfinancials.model.income.FinancialIncome;
+import org.mxchange.jfinancials.model.income.FinancialIncomeSessionBeanRemote;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative financial income bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("financialIncomeController")
+@RequestScoped
+public class FinancialsIncomeWebRequestBean extends BaseFinancialsBean implements FinancialsIncomeWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_189_028_928_371L;
+
+       /**
+        * EJB for general financial income purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/financialIncome!org.mxchange.jfinancials.model.income.FinancialIncomeSessionBeanRemote")
+       private FinancialIncomeSessionBeanRemote financialBean;
+
+       /**
+        * Income interval
+        */
+       private FinancialInterval incomeInterval;
+
+       /**
+        * Income single amount
+        */
+       private Float incomeSingleAmount;
+
+       /**
+        * Income (type) title
+        */
+       private String incomeTitle;
+
+       /**
+        * User instance
+        */
+       @Inject
+       private FinancialsUserLoginWebSessionController userLoginController;
+
+       /**
+        * Constructor
+        */
+       public FinancialsIncomeWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Adds income data by calling proper business method of the EJB.
+        * <p>
+        * @return Redirect outcome
+        */
+       public String addIncome () {
+               // Is all data valid?
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged-in
+                       throw new IllegalStateException("User is not logged-in"); //NOI18N
+               } else if (null == this.getIncomeInterval()) {
+                       // Throw NPE
+                       throw new NullPointerException("incomeInterval is null"); //NOI18N
+               } else if (null == this.getIncomeSingleAmount()) {
+                       // Throw again
+                       throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
+               } else if (this.getIncomeSingleAmount() < 0) {
+                       // Not allowed value
+                       throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
+               } else if (null == this.getIncomeTitle()) {
+                       // Throw again
+                       throw new NullPointerException("incomeTitle is null"); //NOI18N
+               } else if (this.getIncomeTitle().isEmpty()) {
+                       // Should not be empty
+                       throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
+               }
+
+               // Now that all required data has been entered, prepare new income instance
+               final BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
+
+               // Handle it over to the EJB
+               // @TODO Use updated income instance, e.g. fire event
+               final BillableIncome updatedIncome = this.financialBean.addIncome(income);
+
+               // All fine
+               return "add_user_fiancial_income"; //NOI18N
+       }
+
+       @Override
+       public List<FinancialInterval> allIncomeIntervals () {
+               // Return list from enum values
+               return Arrays.asList(FinancialInterval.values());
+       }
+
+       @Override
+       public FinancialInterval getIncomeInterval () {
+               return this.incomeInterval;
+       }
+
+       @Override
+       public void setIncomeInterval (final FinancialInterval incomeInterval) {
+               this.incomeInterval = incomeInterval;
+       }
+
+       @Override
+       public Float getIncomeSingleAmount () {
+               return this.incomeSingleAmount;
+       }
+
+       @Override
+       public void setIncomeSingleAmount (final Float incomeSingleAmount) {
+               this.incomeSingleAmount = incomeSingleAmount;
+       }
+
+       @Override
+       public String getIncomeTitle () {
+               return this.incomeTitle;
+       }
+
+       @Override
+       public void setIncomeTitle (final String incomeTitle) {
+               this.incomeTitle = incomeTitle;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/income/FinancialsIncomeWebRequestController.java
new file mode 100644 (file)
index 0000000..e885949
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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.income;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative interface for financial income beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsIncomeWebRequestController extends Serializable {
+
+       /**
+        * Getter for income single amount
+        * <p>
+        * @return Income single amount
+        */
+       Float getIncomeSingleAmount ();
+
+       /**
+        * Setter for income single amount
+        * <p>
+        * @param incomeSingleAmount Income single amount
+        */
+       void setIncomeSingleAmount (final Float incomeSingleAmount);
+
+       /**
+        * Getter for income (type) title
+        * <p>
+        * @return Income title
+        */
+       String getIncomeTitle ();
+
+       /**
+        * Setter for income (type) title
+        * <p>
+        * @param incomeTitle Income title
+        */
+       void setIncomeTitle (final String incomeTitle);
+
+       /**
+        * Getter for income interval
+        * <p>
+        * @return Income interval
+        */
+       FinancialInterval getIncomeInterval ();
+
+       /**
+        * Setter for income (type) interval
+        * <p>
+        * @param incomeInterval Income interval
+        */
+       void setIncomeInterval (final FinancialInterval incomeInterval);
+
+       /**
+        * Returns a list of all all income intervals
+        * <p>
+        * @return Income intervals
+        */
+       List<FinancialInterval> allIncomeIntervals ();
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestBean.java
new file mode 100644 (file)
index 0000000..00af46b
--- /dev/null
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
+import org.mxchange.jfinancials.events.receipt.added.ReceiptAddedEvent;
+import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.receipt.FinancialAdminReceiptSessionBeanRemote;
+import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
+import org.mxchange.jproduct.model.payment.PaymentType;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An administrative backing bean for receipts
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminReceiptController")
+@RequestScoped
+public class FinancialAdminReceiptWebRequestBean extends BaseFinancialsBean implements FinancialAdminReceiptWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 595_754_280_374_171L;
+
+       /**
+        * Event being fired when administrator has added a new receipt
+        */
+       @Inject
+       @Any
+       private Event<ObservableReceiptAddedEvent> adminAddedReceiptEvent;
+
+       /**
+        * EJB for general financial receipt purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/adminFinancialReceipt!org.mxchange.jfinancials.model.receipt.FinancialAdminReceiptSessionBeanRemote")
+       private FinancialAdminReceiptSessionBeanRemote adminFinancialBean;
+
+       /**
+        * Bar-code number
+        */
+       private Long receiptBarCodeNumber;
+
+       /**
+        * Recipient issuing company (for example where the user went shopping to)
+        */
+       private BranchOffice receiptBranchOffice;
+
+       /**
+        * General receipt controller
+        */
+       @Inject
+       private FinancialsReceiptWebRequestController receiptController;
+
+       /**
+        * Date/time the receipt has been issued
+        */
+       private Date receiptIssued;
+
+       /**
+        * Receipt number (only numbers)
+        */
+       private Long receiptNumber;
+
+       /**
+        * Payment type being used for this receipt
+        */
+       private PaymentType receiptPaymentType;
+
+       /**
+        * Register number
+        */
+       private Long receiptRegisterNumber;
+
+       /**
+        * Selling employee
+        */
+       private Employee receiptSellerEmployee;
+
+       /**
+        * User who "owns" this receipt
+        */
+       private User receiptUser;
+
+       /**
+        * Default constructor
+        */
+       public FinancialAdminReceiptWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Adds the completed receipt to database by calling an EJB business method.
+        * If not all required fields are set, a proper exception is being thrown.
+        * <p>
+        * @return Link outcome
+        */
+       public String addReceipt () {
+               // Are all required fields set?
+               if (this.getReceiptBranchOffice() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptBranchOffice is not set."); //NOI18N
+               } else if (this.getReceiptBranchOffice().getBranchId() == null) {
+                       // It must be an already peristed instance
+                       throw new NullPointerException("this.receiptBranchOffice.businessContactId is not set."); //NOI18N
+               } else if (this.getReceiptBranchOffice().getBranchId() < 1) {
+                       // It must be an already peristed instance
+                       throw new IllegalArgumentException(MessageFormat.format("this.receiptBranchOffice.businessContactId={0} is not valid.", this.getReceiptBranchOffice().getBranchId())); //NOI18N
+               } else if (this.getReceiptPaymentType() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptPaymentType is not set."); //NOI18N
+               } else if (this.getReceiptIssued() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptIssued is not set."); //NOI18N
+               }
+
+               // Prepare receipt instance
+               final BillableReceipt receipt = this.createReceiptInstance();
+
+               // Is the receipt already there?
+               if (this.receiptController.isReceiptAdded(receipt)) {
+                       // Receipt has already been added
+                       throw new FaceletException(MessageFormat.format("Receipt for receiptBranchOffice={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptBranchOffice().getBranchId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
+               }
+
+               // Init variable
+               final BillableReceipt updatedReceipt;
+
+               // All is set, then try to call EJB
+               try {
+                       // Add it
+                       updatedReceipt = this.adminFinancialBean.addReceipt(receipt);
+               } catch (final ReceiptAlreadyAddedException ex) {
+                       // Throw it again
+                       throw new FaceletException(ex);
+               }
+
+               // Fire event with updated instance
+               this.adminAddedReceiptEvent.fire(new ReceiptAddedEvent(updatedReceipt));
+
+               // Return redirect outcome
+               return "add_receipt_item?faces-redirect=true"; //NOI18N
+       }
+
+       /**
+        * Getter for receipt's bar-code number
+        * <p>
+        * @return Receipt's bar-code number
+        */
+       public Long getReceiptBarCodeNumber () {
+               return this.receiptBarCodeNumber;
+       }
+
+       /**
+        * Setter for receipt's bar-code number
+        * <p>
+        * @param receiptBarCodeNumber Receipt's bar-code number
+        */
+       public void setReceiptBarCodeNumber (final Long receiptBarCodeNumber) {
+               this.receiptBarCodeNumber = receiptBarCodeNumber;
+       }
+
+       /**
+        * Getter for receipt issuing branch office
+        * <p>
+        * @return Receipt issuing branch office
+        */
+       public BranchOffice getReceiptBranchOffice () {
+               return this.receiptBranchOffice;
+       }
+
+       /**
+        * Setter for receipt issuing branch office
+        * <p>
+        * @param receiptBranchOffice Receipt issuing branch office
+        */
+       public void setReceiptBranchOffice (final BranchOffice receiptBranchOffice) {
+               this.receiptBranchOffice = receiptBranchOffice;
+       }
+
+       /**
+        * Getter for receipt issue date and time
+        * <p>
+        * @return Receipt issue date and time
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getReceiptIssued () {
+               return this.receiptIssued;
+       }
+
+       /**
+        * Setter for receipt issue date and time
+        * <p>
+        * @param receiptIssued Receipt issue date and time
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setReceiptIssued (final Date receiptIssued) {
+               this.receiptIssued = receiptIssued;
+       }
+
+       /**
+        * Getter for receipt number
+        * <p>
+        * @return Receipt number
+        */
+       public Long getReceiptNumber () {
+               return this.receiptNumber;
+       }
+
+       /**
+        * Setter for receipt number
+        * <p>
+        * @param receiptNumber Receipt number
+        */
+       public void setReceiptNumber (final Long receiptNumber) {
+               this.receiptNumber = receiptNumber;
+       }
+
+       /**
+        * Getter for payment type
+        * <p>
+        * @return Payment type
+        */
+       public PaymentType getReceiptPaymentType () {
+               return this.receiptPaymentType;
+       }
+
+       /**
+        * Setter for payment type
+        * <p>
+        * @param receiptPaymentType Payment type
+        */
+       public void setReceiptPaymentType (final PaymentType receiptPaymentType) {
+               this.receiptPaymentType = receiptPaymentType;
+       }
+
+       /**
+        * Getter for receipt register's number
+        * <p>
+        * @return Receipt register's number
+        */
+       public Long getReceiptRegisterNumber () {
+               return this.receiptRegisterNumber;
+       }
+
+       /**
+        * Setter for receipt register's number
+        * <p>
+        * @param receiptRegisterNumber Receipt register's number
+        */
+       public void setReceiptRegisterNumber (final Long receiptRegisterNumber) {
+               this.receiptRegisterNumber = receiptRegisterNumber;
+       }
+
+       /**
+        * Getter for receipt seller employee
+        * <p>
+        * @return Receipt seller employee
+        */
+       public Employee getReceiptSellerEmployee () {
+               return this.receiptSellerEmployee;
+       }
+
+       /**
+        * Setter for receipt seller employee
+        * <p>
+        * @param receiptSellerEmployee Receipt seller employee
+        */
+       public void setReceiptSellerEmployee (final Employee receiptSellerEmployee) {
+               this.receiptSellerEmployee = receiptSellerEmployee;
+       }
+
+       /**
+        * Getter for user instance
+        * <p>
+        * @return User instance
+        */
+       public User getReceiptUser () {
+               return this.receiptUser;
+       }
+
+       /**
+        * Setter for user instance
+        * <p>
+        * @param receiptUser User instance
+        */
+       public void setReceiptUser (final User receiptUser) {
+               this.receiptUser = receiptUser;
+       }
+
+       /**
+        * Creates a new instance from all available data of this bean.
+        * <p>
+        * @return Receipt instance
+        */
+       private BillableReceipt createReceiptInstance () {
+               // Create new instance with minimum required data
+               final BillableReceipt receipt = new FinancialReceipt(this.getReceiptPaymentType(), this.getReceiptBranchOffice(), this.getReceiptIssued());
+
+               // Set optional data
+               receipt.setReceiptUser(this.getReceiptUser());
+               receipt.setReceiptNumber(this.getReceiptNumber());
+               receipt.setReceiptBarCodeNumber(this.getReceiptBarCodeNumber());
+               receipt.setReceiptRegisterNumber(this.getReceiptRegisterNumber());
+               receipt.setReceiptSellerEmployee(this.getReceiptSellerEmployee());
+
+               // Return prepared instance
+               return receipt;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestController.java
new file mode 100644 (file)
index 0000000..6ae4ff0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative receipt beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialAdminReceiptWebRequestController extends Serializable {
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestBean.java
new file mode 100644 (file)
index 0000000..46a90a6
--- /dev/null
@@ -0,0 +1,496 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
+import org.mxchange.jfinancials.events.receipt.added.ReceiptAddedEvent;
+import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
+import org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote;
+import org.mxchange.jproduct.model.payment.PaymentType;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+
+/**
+ * An administrative financial receipt bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("receiptController")
+@RequestScoped
+public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implements FinancialsReceiptWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 56_189_028_928_371L;
+
+       /**
+        * Event being fired when user has added a new receipt
+        */
+       @Inject
+       @Any
+       private Event<ObservableReceiptAddedEvent> addedReceiptEvent;
+
+       /**
+        * All receipts list
+        */
+       private final List<BillableReceipt> allReceipts;
+
+       /**
+        * Filtered receipts list
+        */
+       private List<BillableReceipt> filteredReceipts;
+
+       /**
+        * Bar-code number
+        */
+       private Long receiptBarCodeNumber;
+
+       /**
+        * EJB for general financial receipt purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/financialReceipt!org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote")
+       private FinancialReceiptSessionBeanRemote receiptBean;
+
+       /**
+        * Recipient issuing company (for example where the user went shopping to)
+        */
+       private BranchOffice receiptBranchOffice;
+
+       /**
+        * A list of all branch offices (globally)
+        */
+       @Inject
+       @NamedCache (cacheName = "receiptCache")
+       private Cache<Long, BillableReceipt> receiptCache;
+
+       /**
+        * Date/time the receipt has been issued
+        */
+       private Date receiptIssued;
+
+       /**
+        * Receipt number (only numbers)
+        */
+       private Long receiptNumber;
+
+       /**
+        * Payment type being used for this receipt
+        */
+       private PaymentType receiptPaymentType;
+
+       /**
+        * Register number
+        */
+       private Long receiptRegisterNumber;
+
+       /**
+        * Selling employee
+        */
+       private Employee receiptSellerEmployee;
+
+       /**
+        * User instance
+        */
+       @Inject
+       private FinancialsUserLoginWebSessionController userLoginController;
+
+       /**
+        * User's receipts
+        */
+       private final List<BillableReceipt> userReceipts;
+
+       /**
+        * Constructor
+        */
+       @SuppressWarnings ("CollectionWithoutInitialCapacity")
+       public FinancialsReceiptWebRequestBean () {
+               // Call super constructor
+               super();
+
+               // Init lists
+               this.allReceipts = new LinkedList<>();
+               this.userReceipts = new LinkedList<>();
+       }
+
+       /**
+        * Adds the completed receipt to database by calling an EJB business method.
+        * If not all required fields are set, a proper exception is being thrown.
+        * <p>
+        * @return Link outcome
+        */
+       public String addReceipt () {
+               // Are all required fields set?
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged-in
+                       throw new IllegalStateException("User is not logged-in"); //NOI18N
+               } else if (this.getReceiptBranchOffice() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptBranchOffice is not set."); //NOI18N
+               } else if (this.getReceiptBranchOffice().getBranchId() == null) {
+                       // It must be an already peristed instance
+                       throw new NullPointerException("this.receiptBranchOffice.businessContactId is not set."); //NOI18N
+               } else if (this.getReceiptBranchOffice().getBranchId() < 1) {
+                       // It must be an already peristed instance
+                       throw new IllegalArgumentException(MessageFormat.format("this.receiptBranchOffice.businessContactId={0} is not valid.", this.getReceiptBranchOffice().getBranchId())); //NOI18N
+               } else if (this.getReceiptPaymentType() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptPaymentType is not set."); //NOI18N
+               } else if (this.getReceiptIssued() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.receiptIssued is not set."); //NOI18N
+               }
+
+               // Prepare receipt instance
+               final BillableReceipt receipt = this.createReceiptInstance();
+
+               // Is the receipt already there?
+               if (this.isReceiptAdded(receipt)) {
+                       // Receipt has already been added
+                       throw new FaceletException(MessageFormat.format("Receipt for receiptBranchOffice={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptBranchOffice().getBranchId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
+               }
+
+               // Init variable
+               final BillableReceipt updatedReceipt;
+
+               // All is set, then try to call EJB
+               try {
+                       // Add it
+                       updatedReceipt = this.receiptBean.addReceipt(receipt);
+               } catch (final ReceiptAlreadyAddedException ex) {
+                       // Throw it again
+                       throw new FaceletException(ex);
+               }
+
+               // Fire event with updated instance
+               this.addedReceiptEvent.fire(new ReceiptAddedEvent(updatedReceipt));
+
+               // Return redirect outcome
+               return "add_receipt_item?faces-redirect=true"; //NOI18N
+       }
+
+       /**
+        * Observes events being fired when a new receipt has been added
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAddedReceiptEvent (@Observes final ObservableReceiptAddedEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getReceipt() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.receipt is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("event.receipt.receiptId is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("event.receipt.receiptId={0} is invalid", event.getReceipt().getReceiptId())); //NOI18N
+               }
+
+               // Add to cache and general list
+               this.receiptCache.put(event.getReceipt().getReceiptId(), event.getReceipt());
+               this.allReceipts.add(event.getReceipt());
+
+               // Is same user?
+               if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
+                       // Same user, then add it
+                       this.userReceipts.add(event.getReceipt());
+               }
+       }
+
+       /**
+        * Event observer for logged-in user
+        * <p>
+        * @param event Event instance
+        */
+       public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLoggedInUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.loggedInUser is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+               }
+
+               // Fill cache with all found user's receipts
+               for (final BillableReceipt receipt : this.allReceipts) {
+                       // Is same user?
+                       if (Objects.equals(receipt.getReceiptUser(), event.getLoggedInUser())) {
+                               // Yes, then add it
+                               this.userReceipts.add(receipt);
+                       }
+               }
+       }
+
+       /**
+        * Returns all receipts
+        * <p>
+        * @return All receipts
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<BillableReceipt> allReceipts () {
+               return this.allReceipts;
+       }
+
+       /**
+        * Getter for filtered receipts
+        * <p>
+        * @return Filtered receipts
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<BillableReceipt> getFilteredReceipts () {
+               return this.filteredReceipts;
+       }
+
+       /**
+        * Setter for filtered receipts
+        * <p>
+        * @param filteredReceipts Filtered receipts
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredReceipts (final List<BillableReceipt> filteredReceipts) {
+               this.filteredReceipts = filteredReceipts;
+       }
+
+       /**
+        * Getter for receipt's bar-code number
+        * <p>
+        * @return Receipt's bar-code number
+        */
+       public Long getReceiptBarCodeNumber () {
+               return this.receiptBarCodeNumber;
+       }
+
+       /**
+        * Setter for receipt's bar-code number
+        * <p>
+        * @param receiptBarCodeNumber Receipt's bar-code number
+        */
+       public void setReceiptBarCodeNumber (final Long receiptBarCodeNumber) {
+               this.receiptBarCodeNumber = receiptBarCodeNumber;
+       }
+
+       /**
+        * Getter for receipt issuing branch office
+        * <p>
+        * @return Receipt issuing branch office
+        */
+       public BranchOffice getReceiptBranchOffice () {
+               return this.receiptBranchOffice;
+       }
+
+       /**
+        * Setter for receipt issuing branch office
+        * <p>
+        * @param receiptBranchOffice Receipt issuing branch office
+        */
+       public void setReceiptBranchOffice (final BranchOffice receiptBranchOffice) {
+               this.receiptBranchOffice = receiptBranchOffice;
+       }
+
+       /**
+        * Getter for receipt issue date and time
+        * <p>
+        * @return Receipt issue date and time
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getReceiptIssued () {
+               return this.receiptIssued;
+       }
+
+       /**
+        * Setter for receipt issue date and time
+        * <p>
+        * @param receiptIssued Receipt issue date and time
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setReceiptIssued (final Date receiptIssued) {
+               this.receiptIssued = receiptIssued;
+       }
+
+       /**
+        * Getter for receipt number
+        * <p>
+        * @return Receipt number
+        */
+       public Long getReceiptNumber () {
+               return this.receiptNumber;
+       }
+
+       /**
+        * Setter for receipt number
+        * <p>
+        * @param receiptNumber Receipt number
+        */
+       public void setReceiptNumber (final Long receiptNumber) {
+               this.receiptNumber = receiptNumber;
+       }
+
+       /**
+        * Getter for payment type
+        * <p>
+        * @return Payment type
+        */
+       public PaymentType getReceiptPaymentType () {
+               return this.receiptPaymentType;
+       }
+
+       /**
+        * Setter for payment type
+        * <p>
+        * @param receiptPaymentType Payment type
+        */
+       public void setReceiptPaymentType (final PaymentType receiptPaymentType) {
+               this.receiptPaymentType = receiptPaymentType;
+       }
+
+       /**
+        * Getter for receipt register's number
+        * <p>
+        * @return Receipt register's number
+        */
+       public Long getReceiptRegisterNumber () {
+               return this.receiptRegisterNumber;
+       }
+
+       /**
+        * Setter for receipt register's number
+        * <p>
+        * @param receiptRegisterNumber Receipt register's number
+        */
+       public void setReceiptRegisterNumber (final Long receiptRegisterNumber) {
+               this.receiptRegisterNumber = receiptRegisterNumber;
+       }
+
+       /**
+        * Getter for receipt seller employee
+        * <p>
+        * @return Receipt seller employee
+        */
+       public Employee getReceiptSellerEmployee () {
+               return this.receiptSellerEmployee;
+       }
+
+       /**
+        * Setter for receipt seller employee
+        * <p>
+        * @param receiptSellerEmployee Receipt seller employee
+        */
+       public void setReceiptSellerEmployee (final Employee receiptSellerEmployee) {
+               this.receiptSellerEmployee = receiptSellerEmployee;
+       }
+
+       @PostConstruct
+       public void initCache () {
+               // Is cache there?
+               if (!this.receiptCache.iterator().hasNext()) {
+                       // Get whole list
+                       final List<BillableReceipt> list = this.receiptBean.allReceipts();
+
+                       // Add all
+                       for (final Iterator<BillableReceipt> iterator = list.iterator(); iterator.hasNext();) {
+                               // Get next element
+                               final BillableReceipt next = iterator.next();
+
+                               // Add it to cache
+                               this.receiptCache.put(next.getReceiptId(), next);
+                       }
+               }
+
+               // Is the list empty, but filled cache?
+               if (this.allReceipts.isEmpty() && this.receiptCache.iterator().hasNext()) {
+                       // Get iterator
+                       final Iterator<Cache.Entry<Long, BillableReceipt>> iterator = this.receiptCache.iterator();
+
+                       // Build up list
+                       while (iterator.hasNext()) {
+                               // GEt next element
+                               final Cache.Entry<Long, BillableReceipt> next = iterator.next();
+
+                               // Add to list
+                               this.allReceipts.add(next.getValue());
+                       }
+
+                       // Sort list
+                       this.allReceipts.sort(new Comparator<BillableReceipt>() {
+                               @Override
+                               public int compare (final BillableReceipt o1, final BillableReceipt o2) {
+                                       return o1.getReceiptId() > o2.getReceiptId() ? 1 : o1.getReceiptId() < o2.getReceiptId() ? -1 : 0;
+                               }
+                       }
+                       );
+               }
+       }
+
+       @Override
+       public boolean isReceiptAdded (final BillableReceipt receipt) {
+               // Always trust the cache
+               return this.allReceipts.contains(receipt);
+       }
+
+       /**
+        * Returns a fully created receipt instance (except primary key, of course)
+        * <p>
+        * @return Receipt instance
+        */
+       private BillableReceipt createReceiptInstance () {
+               // Init receipt instance
+               final BillableReceipt receipt = new FinancialReceipt(this.getReceiptPaymentType(), this.getReceiptBranchOffice(), this.userLoginController.getLoggedInUser(), this.getReceiptIssued());
+
+               // Set optional fields
+               receipt.setReceiptNumber(this.getReceiptNumber());
+               receipt.setReceiptBarCodeNumber(this.getReceiptBarCodeNumber());
+               receipt.setReceiptRegisterNumber(this.getReceiptRegisterNumber());
+               receipt.setReceiptSellerEmployee(this.getReceiptSellerEmployee());
+
+               // Return it
+               return receipt;
+       }
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestController.java
new file mode 100644 (file)
index 0000000..a79d554
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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;
+
+import java.io.Serializable;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+
+/**
+ * An administrative interface for financial receipt beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsReceiptWebRequestController extends Serializable {
+
+       /**
+        * Checks if receipt has already been added to database
+        * <p>
+        * @param receipt Prepared receipt instance
+        * <p>
+        * @return Whether the receipt has already been added
+        */
+       boolean isReceiptAdded (final BillableReceipt receipt);
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java
deleted file mode 100644 (file)
index 3e9c128..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * 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;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.List;
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
-import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
-import org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote;
-import org.mxchange.jproduct.model.payment.PaymentType;
-import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
-
-/**
- * An administrative financial receipt bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("receiptController")
-@RequestScoped
-public class FinancialsReceiptWebRequestBean extends BaseFinancialsController implements FinancialsReceiptWebRequestController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 56_189_028_928_371L;
-
-       /**
-        * EJB for general financial receipt purposes
-        */
-       @EJB (lookup = "java:global/jfinancials-ejb/financialReceipt!org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote")
-       private FinancialReceiptSessionBeanRemote financialBean;
-
-       /**
-        * Payment type being used for this receipt
-        */
-       private PaymentType paymentType;
-
-       /**
-        * Recipient issuing company (for example where the user went shopping to)
-        */
-       private BranchOffice receiptBranchOffice;
-
-       /**
-        * Date/time the receipt has been issued
-        */
-       private Calendar receiptIssued;
-
-       /**
-        * Receipt number (only numbers)
-        */
-       private Long receiptNumber;
-
-       /**
-        * Cached receipts
-        */
-       private final List<BillableReceipt> receipts;
-
-       /**
-        * User instance
-        */
-       @Inject
-       private FinancialsUserLoginWebSessionController userLoginController;
-
-       /**
-        * Constructor
-        */
-       @SuppressWarnings ("CollectionWithoutInitialCapacity")
-       public FinancialsReceiptWebRequestBean () {
-               // Call super constructor
-               super();
-
-               // Init cache
-               this.receipts = new ArrayList<>();
-       }
-
-       /**
-        * Adds the completed receipt to database by calling an EJB business method.
-        * If not all required fields are set, a proper exception is being thrown.
-        * <p>
-        * @return Link outcome
-        */
-       public String addReceipt () {
-               // Pre-check if receipt number is set
-               if (this.getReceiptNumber() == null || this.getReceiptNumber() == 0) {
-                       // Generate one randomly
-                       final Long randomNumber = Math.round(Math.random() * 1_000_000);
-
-                       // And set it here
-                       this.setReceiptNumber(randomNumber);
-               }
-
-               // Are all required fields set?
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged-in
-                       throw new IllegalStateException("User is not logged-in"); //NOI18N
-               } else if (this.getReceiptBranchOffice() == null) {
-                       // Is not set
-                       throw new NullPointerException("this.receiptBranchOffice is not set."); //NOI18N
-               } else if (this.getReceiptBranchOffice().getBranchId() == null) {
-                       // It must be an already peristed instance
-                       throw new NullPointerException("this.receiptBranchOffice.businessContactId is not set."); //NOI18N
-               } else if (this.getReceiptBranchOffice().getBranchId() < 1) {
-                       // It must be an already peristed instance
-                       throw new IllegalArgumentException(MessageFormat.format("this.receiptBranchOffice.businessContactId={0} is not valid.", this.getReceiptBranchOffice().getBranchId())); //NOI18N
-               } else if (this.getPaymentType() == null) {
-                       // Is not set
-                       throw new NullPointerException("this.paymentType is not set."); //NOI18N
-               } else if (this.getReceiptIssued() == null) {
-                       // Is not set
-                       throw new NullPointerException("this.receiptIssued is not set."); //NOI18N
-               }
-
-               // Prepare receipt instance
-               final BillableReceipt receipt = new FinancialReceipt(this.getPaymentType(), this.getReceiptBranchOffice(), this.userLoginController.getLoggedInUser(), this.getReceiptIssued());
-
-               if (this.isReceiptAdded(receipt)) {
-                       // Receipt has already been added
-                       throw new FaceletException(MessageFormat.format("Receipt for receiptBranchOffice={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptBranchOffice().getBranchId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
-               }
-
-               // Init variable
-               final BillableReceipt updatedReceipt;
-
-               // All is set, then try to call EJB
-               try {
-                       // Add it
-                       updatedReceipt = this.financialBean.addReceipt(receipt);
-               } catch (final ReceiptAlreadyAddedException ex) {
-                       // Throw it again
-                       throw new FaceletException(ex);
-               }
-
-               // @TODO Maybe fire event here?
-               // Return redirect outcome
-               return "add_receipt_item?faces-redirect=true"; //NOI18N
-       }
-
-       /**
-        * Event observer for logged-in user
-        * <p>
-        * @param event Event instance
-        */
-       public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getLoggedInUser() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.loggedInUser is null"); //NOI18N
-               } else if (event.getLoggedInUser().getUserId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
-               } else if (event.getLoggedInUser().getUserId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
-               }
-
-               // Fill cache with all found user's receipts
-               this.receipts.addAll(this.financialBean.allUsersReceipts(this.userLoginController.getLoggedInUser()));
-       }
-
-       /**
-        * Returns a list of all payment types
-        * <p>
-        * @return A list of all payment types
-        */
-       public List<PaymentType> allPaymentTypes () {
-               return Arrays.asList(PaymentType.values());
-       }
-
-       /**
-        * Getter for payment type
-        * <p>
-        * @return Payment type
-        */
-       public PaymentType getPaymentType () {
-               return this.paymentType;
-       }
-
-       /**
-        * Setter for payment type
-        * <p>
-        * @param paymentType Payment type
-        */
-       public void setPaymentType (final PaymentType paymentType) {
-               this.paymentType = paymentType;
-       }
-
-       /**
-        * Getter for receipt issuing branch office
-        * <p>
-        * @return Receipt issuing branch office
-        */
-       public BranchOffice getReceiptBranchOffice () {
-               return this.receiptBranchOffice;
-       }
-
-       /**
-        * Setter for receipt issuing branch office
-        * <p>
-        * @param receiptBranchOffice Receipt issuing branch office
-        */
-       public void setReceiptBranchOffice (final BranchOffice receiptBranchOffice) {
-               this.receiptBranchOffice = receiptBranchOffice;
-       }
-
-       /**
-        * Getter for receipt issue date and time
-        * <p>
-        * @return Receipt issue date and time
-        */
-       @SuppressWarnings ("ReturnOfDateField")
-       public Calendar getReceiptIssued () {
-               return this.receiptIssued;
-       }
-
-       /**
-        * Setter for receipt issue date and time
-        * <p>
-        * @param receiptIssued Receipt issue date and time
-        */
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setReceiptIssued (final Calendar receiptIssued) {
-               this.receiptIssued = receiptIssued;
-       }
-
-       /**
-        * Getter for receipt number
-        * <p>
-        * @return Receipt number
-        */
-       public Long getReceiptNumber () {
-               return this.receiptNumber;
-       }
-
-       /**
-        * Setter for receipt number
-        * <p>
-        * @param receiptNumber Receipt number
-        */
-       public void setReceiptNumber (final Long receiptNumber) {
-               this.receiptNumber = receiptNumber;
-       }
-
-       /**
-        * Checks if receipt has already been added to database
-        * <p>
-        * @param receipt Prepared receipt instance
-        * <p>
-        * @return Whether the receipt has already been added
-        */
-       private boolean isReceiptAdded (final BillableReceipt receipt) {
-               // Always trust the cache
-               return this.receipts.contains(receipt);
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestController.java
deleted file mode 100644 (file)
index e5c331c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * 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;
-
-import java.io.Serializable;
-
-/**
- * An administrative interface for financial receipt beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsReceiptWebRequestController extends Serializable {
-
-}
index d79d2a29a09f80d78834f3dfed5d93682aee687e..dd5c15906db15ffb8dfc79fe5f1d9cb7c72bca38 100644 (file)
@@ -48,5 +48,16 @@ ADMIN_ADD_FINANCIAL_RECEIPT_TITLE=Neuen Kassenbon hinzufuegen
 BUTTON_ADMIN_ADD_FINANCIAL_RECEIPT=Kassenbon hinzufuegen
 ADMIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED=Bitte geben Sie das Ausstellungsdatum des Kassenbons ein.
 ADMIN_MENU_FINANCIAL_RECEIPTS_TITLE=Kassenbons
-LINK_ADMIN_LIST_FINANCIAL_RECEIPTS_TITLE=Lists all registered receipts.
-LINK_ADMIN_LIST_FINANCIAL_RECEIPTS=Kassenbons auflisten
+LINK_ADMIN_LIST_FINANCIAL_RECEIPTS_TITLE=Listet alle registrierten Kassenbos/Rechnungen auf..
+LINK_ADMIN_LIST_FINANCIAL_RECEIPTS=Kassenbons/Rechnungen auflisten
+ADMIN_LIST_FINANCIAL_RECEIPTS_HEADER=Alle Kassenbons/Rechnungen auflisten
+ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND=Grunddaten des Kassenbons
+ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND_TITLE=Geben Sie hier die Grunddaten des neuen Kassenbons einn.
+ENTER_FINANCIAL_RECEIPT_ISSUE_DATE=Ausstellungsdatum des Kassenbons eingeben:
+ENTER_FINANCIAL_RECEIPT_NUMBER=Rechnungsnummer eingeben:
+ENTERED_RECEIPT_NUMBER_INVALID=Die eingegebene Bonnummer/Rechnungsnummer ist kleiner 1 oder groesser 9999999999.
+ADMIN_SELECT_FINANCIAL_RECEIPT_USER_OWNER=Kassenbon einem Benutzer zuweisen:
+ENTER_FINANCIAL_RECEIPT_REGISTER_NUMBER=Kassennummer eingeben:
+ENTER_FINANCIAL_RECEIPT_BARCODE_NUMBER=Barcode-Nummer eingeben:
+ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND=Sonstige Daten des Kassenbons eingeben:
+ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND_TITLE=Geben Sie hier weitere Daten an, die Sie auf dem Kassenbon finden koennen.
index 3f05e7236f52db6a9592f2c955c6ef1d6eee01c0..839e42227e5b9367d481696bc966a5f8f08ce8f2 100644 (file)
@@ -36,5 +36,16 @@ ADMIN_ADD_FINANCIAL_RECEIPT_TITLE=Add new receipt
 BUTTON_ADMIN_ADD_FINANCIAL_RECEIPT=Add receipt
 ADMIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED=Please enter date of issue of receipt.
 ADMIN_MENU_FINANCIAL_RECEIPTS_TITLE=Receipts
-LINK_ADMIN_LIST_FINANCIAL_RECEIPTS_TITLE=Listet alle registrierten Kassenbons auf.
+LINK_ADMIN_LIST_FINANCIAL_RECEIPTS_TITLE=Lists all registered receipts.
 LINK_ADMIN_LIST_FINANCIAL_RECEIPTS=List receipts
+ADMIN_LIST_FINANCIAL_RECEIPTS_HEADER=List all receipts
+ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND=Basic data of receipt:
+ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND_TITLE=Enter here basic data of the new receipt.
+ENTER_FINANCIAL_RECEIPT_ISSUE_DATE=Enter date of issue of receipt:
+ENTER_FINANCIAL_RECEIPT_NUMBER=Enter receipt number:
+ENTERED_RECEIPT_NUMBER_INVALID=Your entered receipt number is smaller than 1 or larger than 9999999999.
+ADMIN_SELECT_FINANCIAL_RECEIPT_USER_OWNER=Assign receipt to user:
+ENTER_FINANCIAL_RECEIPT_REGISTER_NUMBER=Enter cash register number:
+ENTER_FINANCIAL_RECEIPT_BARCODE_NUMBER=Enter bar code number:
+ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND=Enter other data of receipt:
+ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND_TITLE=Enter other additional data you can find on the receipt.
index 58b9c114307b3ef10618c64b313e31b893ea201f..a9bb9e50beca831a5369da8b4c02acce1b6a0223 100644 (file)
        xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
 
-       <h:panelGroup styleClass="para" layout="block">
-               <fieldset class="fieldset">
-                       <legend title="#{project.ADMIN_FINANCIAL_RECEIPT_LEGEND_TITLE}">
-                               <h:outputText value="#{project.ADMIN_FINANCIAL_RECEIPT_LEGEND}" />
-                       </legend>
+       <fieldset class="fieldset">
+               <legend title="#{project.ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND_TITLE}">
+                       <h:outputText value="#{project.ADMIN_FINANCIAL_RECEIPT_BASIC_LEGEND}" />
+               </legend>
 
-                       <h:panelGroup styleClass="table-row" layout="block">
-                               <div class="table-left-medium">
-                                       <p:outputLabel for="branchOffice" value="#{project.ADMIN_SELECT_FINANCIAL_RECEIPT_BRANCH_OFFICE}" />
-                               </div>
+               <h:panelGrid columns="3" styleClass="table table-full">
+                       <p:outputLabel for="branchOffice" value="#{msg.ADMIN_SELECT_BRANCH_OFFICE}" />
+                       <p:selectOneMenu
+                               id="branchOffice"
+                               value="#{adminReceiptController.receiptBranchOffice}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               required="true"
+                               requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_COMPANY_REQUIRED}"
+                               >
+                               <f:converter converterId="BranchOfficeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+                               <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{branchOffice.branchCompany.companyName} #{branchOffice.branchStreet} #{branchOffice.branchHouseNumber}, #{branchOffice.branchCity}" />
+                       </p:selectOneMenu>
+                       <p:message for="branchOffice" />
 
-                               <div class="table-right-medium">
-                                       <p:selectOneMenu
-                                               id="branchOffice"
-                                               value="#{adminReceiptController.receiptBranchOffice}"
-                                               filter="true"
-                                               filterMatchMode="contains"
-                                               required="true"
-                                               requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_COMPANY_REQUIRED}"
-                                               >
-                                               <f:converter converterId="BranchOfficeConverter" />
-                                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" itemDisabled="true" />
-                                               <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{branchOffice.branchCompany.companyName} #{branchOffice.branchStreet} #{branchOffice.branchHouseNumber}, #{branchOffice.branchZipCode} #{branchOffice.branchCity}" />
-                                       </p:selectOneMenu>
-                               </div>
-                       </h:panelGroup>
+                       <p:outputLabel for="receiptIssued" value="#{project.ENTER_FINANCIAL_RECEIPT_ISSUE_DATE}" />
+                       <p:calendar
+                               id="receiptIssued"
+                               value="#{adminReceiptController.receiptIssued}"
+                               required="true"
+                               requiredMessage="#{project.ADMIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED}"
+                               pattern="#{msg.DATE_PATTERN}"
+                               navigator="true"
+                               maskAutoClear="true"
+                               styleClass="input"
+                               title="#{project.ADMIN_RECEIPT_DATE_OF_ISSUE_TITLE}"
+                               />
+                       <p:message for="receiptIssued" />
 
-                       <h:panelGroup styleClass="error-container" layout="block">
-                               <p:message for="branchOffice" />
-                       </h:panelGroup>
+                       <p:outputLabel for="receiptPaymentType" value="#{msg.ADMIN_SELECT_PAYMENT_TYPE}" />
+                       <p:selectOneMenu
+                               id="receiptPaymentType"
+                               value="#{adminReceiptController.receiptPaymentType}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               required="true"
+                               requiredMessage="#{project.FIELD_FINANCIAL_RECEIPT_PAYMENT_TYPE_REQUIRED}"
+                               >
+                               <f:converter converterId="PaymentTypeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+                               <f:selectItems value="#{dataController.paymentTypes}" var="receiptPaymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType.i18nKey]}" />
+                       </p:selectOneMenu>
+                       <p:message for="receiptPaymentType" />
 
-                       <h:panelGroup styleClass="table-row" layout="block">
-                               <div class="table-left-medium">
-                                       <p:outputLabel for="receiptIssued" value="#{msg.ENTER_FINANCIAL_RECEIPT_ISSUE_DATE}" />
-                               </div>
+                       <p:outputLabel for="receiptSellerEmployee" value="#{msg.ADMIN_SELECT_SELLER_EMPLOYEE}" />
+                       <p:selectOneMenu
+                               id="receiptSellerEmployee"
+                               value="#{adminReceiptController.receiptSellerEmployee}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               >
+                               <f:converter converterId="CompanyEmployeeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+                               <f:selectItems value="#{companyEmployeeController.allCompanyEmployees()}" var="companyEmployee" itemValue="#{companyEmployee}" itemLabel="#{companyEmployee.employeeNumber} #{beanHelper.renderContact(companyEmployee.employeePersonalData)}" itemDescription="#{companyEmployee.employeeCompany.companyName}, #{beanHelper.renderBranchOffice(companyEmployee.employeeBranchOffice)}" />
+                       </p:selectOneMenu>
+                       <p:message for="receiptSellerEmployee" />
 
-                               <div class="table-right-medium">
-                                       <p:calendar
-                                               id="receiptIssued"
-                                               value="#{adminReceiptController.receiptIssued}"
-                                               required="true"
-                                               requiredMessage="#{msg.ADMIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED}"
-                                               pattern="#{msg.DATE_PATTERN}"
-                                               navigator="true"
-                                               maskAutoClear="true"
-                                               title="#{msg.ADMIN_RECEIPT_DATE_OF_ISSUE_TITLE}"
-                                               />
-                               </div>
-                       </h:panelGroup>
+                       <p:outputLabel for="receiptUser" value="#{project.ADMIN_SELECT_FINANCIAL_RECEIPT_USER_OWNER}" />
+                       <p:selectOneMenu
+                               id="receiptUser"
+                               value="#{adminReceiptController.receiptUser}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               >
+                               <f:converter converterId="UserConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+                               <f:selectItems value="#{userController.allUsers()}" var="receiptUser" itemValue="#{receiptUser}" itemLabel="#{receiptUser.userContact.contactFirstName} #{receiptUser.userContact.contactFamilyName} (#{receiptUser.userName})" />
+                       </p:selectOneMenu>
+                       <p:message for="receiptUser" />
+               </h:panelGrid>
+       </fieldset>
 
-                       <h:panelGroup styleClass="error-container" layout="block">
-                               <p:message for="receiptIssued" />
-                       </h:panelGroup>
+       <fieldset class="fieldset">
+               <legend title="#{project.ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND_TITLE}">
+                       <h:outputText value="#{project.ADMIN_FINANCIAL_RECEIPT_OTHER_LEGEND}" />
+               </legend>
 
-                       <h:panelGroup styleClass="table-row" layout="block">
-                               <div class="table-left-medium">
-                                       <p:outputLabel for="receiptNumber" value="#{project.LOGIN_FINANCIAL_RECEIPT_NUMBER}" />
-                               </div>
+               <h:panelGrid columns="3" styleClass="table table-full">
+                       <p:outputLabel for="receiptNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptNumber" size="10" maxlength="20" value="#{adminReceiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
+                               <f:validateLongRange minimum="1" maximum="9999999999" />
+                       </p:inputText>
+                       <p:message for="receiptNumber" />
 
-                               <div class="table-right-medium">
-                                       <p:inputText styleClass="input" id="receiptNumber" size="2" maxlength="10" value="#{adminReceiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
-                                               <f:validateLongRange minimum="1" maximum="20" />
-                                       </p:inputText>
-                               </div>
-                       </h:panelGroup>
+                       <p:outputLabel for="receiptRegisterNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_REGISTER_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptRegisterNumber" size="3" maxlength="10" value="#{adminReceiptController.receiptRegisterNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_REGISTER_NUMBER_INVALID}">
+                               <f:validateLongRange minimum="1" maximum="999" />
+                       </p:inputText>
+                       <p:message for="receiptRegisterNumber" />
 
-                       <h:panelGroup styleClass="error-container" layout="block">
-                               <p:message for="receiptNumber" />
-                       </h:panelGroup>
-
-                       <h:panelGroup styleClass="table-row" layout="block">
-                               <div class="table-left-medium">
-                                       <p:outputLabel for="receiptPaymentType" value="#{project.LOGIN_FINANCIAL_RECEIPT_PAYMENT_TYPE}" />
-                               </div>
-
-                               <div class="table-right-medium">
-                                       <p:selectOneMenu
-                                               id="receiptPaymentType"
-                                               value="#{adminReceiptController.receiptPaymentType}"
-                                               filter="true"
-                                               filterMatchMode="contains"
-                                               required="true"
-                                               requiredMessage="#{project.FIELD_FINANCIAL_RECEIPT_PAYMENT_TYPE_REQUIRED}"
-                                               >
-                                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                               <f:selectItems value="#{receiptController.allPaymentTypes()}" var="receiptPaymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType.i18nKey]}" />
-                                       </p:selectOneMenu>
-                               </div>
-                       </h:panelGroup>
-
-                       <h:panelGroup styleClass="error-container" layout="block">
-                               <p:message for="receiptPaymentType" />
-                       </h:panelGroup>
-               </fieldset>
-
-               <div class="table-footer">
-                       <p:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-
-                       <p:commandButton styleClass="submit" id="submit_add_receipt" type="submit" action="#{receiptController.addReceipt()}" value="#{project.BUTTON_LOGIN_FINANCIAL_ADD_INCOME}" />
-               </div>
-       </h:panelGroup>
+                       <p:outputLabel for="receiptBarCodeNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_BARCODE_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptBarCodeNumber" size="24" maxlength="24" value="#{adminReceiptController.receiptBarCodeNumber}" />
+                       <p:message for="receiptBarCodeNumber" />
+               </h:panelGrid>
+       </fieldset>
 </ui:composition>
diff --git a/web/WEB-INF/templates/user/financial/receipt/login_form_financial_receipt.tpl b/web/WEB-INF/templates/user/financial/receipt/login_form_financial_receipt.tpl
new file mode 100644 (file)
index 0000000..848a92b
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:widgets="http://mxchange.org/jsf/core/widgets"
+       xmlns:f="http://xmlns.jcp.org/jsf/core"
+       xmlns:h="http://xmlns.jcp.org/jsf/html"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:p="http://primefaces.org/ui">
+
+       <fieldset class="fieldset">
+               <legend title="#{project.LOGIN_FINANCIAL_RECEIPT_BASIC_LEGEND_TITLE}">
+                       <h:outputText value="#{project.LOGIN_FINANCIAL_RECEIPT_BASIC_LEGEND}" />
+               </legend>
+
+               <h:panelGrid columns="3" styleClass="table table-full">
+                       <p:outputLabel for="branchOffice" value="#{project.LOGIN_SELECT_BRANCH_OFFICE}" />
+                       <p:selectOneMenu
+                               id="branchOffice"
+                               value="#{receiptController.receiptBranchOffice}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               required="true"
+                               requiredMessage="#{msg.LOGIN_BRANCH_OFFICE_COMPANY_REQUIRED}"
+                               >
+                               <f:converter converterId="BranchOfficeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+                               <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{branchOffice.branchCompany.companyName} #{branchOffice.branchStreet} #{branchOffice.branchHouseNumber}, #{branchOffice.branchCity}" />
+                       </p:selectOneMenu>
+                       <p:message for="branchOffice" />
+
+                       <p:outputLabel for="receiptIssued" value="#{project.ENTER_FINANCIAL_RECEIPT_ISSUE_DATE}" />
+                       <p:calendar
+                               id="receiptIssued"
+                               value="#{receiptController.receiptIssued}"
+                               required="true"
+                               requiredMessage="#{project.LOGIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED}"
+                               pattern="#{msg.DATE_PATTERN}"
+                               navigator="true"
+                               maskAutoClear="true"
+                               styleClass="input"
+                               title="#{project.LOGIN_RECEIPT_DATE_OF_ISSUE_TITLE}"
+                               />
+                       <p:message for="receiptIssued" />
+
+                       <p:outputLabel for="receiptPaymentType" value="#{project.LOGIN_SELECT_PAYMENT_TYPE}" />
+                       <p:selectOneMenu
+                               id="receiptPaymentType"
+                               value="#{receiptController.receiptPaymentType}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               required="true"
+                               requiredMessage="#{project.FIELD_FINANCIAL_RECEIPT_PAYMENT_TYPE_REQUIRED}"
+                               >
+                               <f:converter converterId="PaymentTypeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+                               <f:selectItems value="#{dataController.paymentTypes}" var="receiptPaymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType.i18nKey]}" />
+                       </p:selectOneMenu>
+                       <p:message for="receiptPaymentType" />
+
+                       <p:outputLabel for="receiptSellerEmployee" value="#{msg.LOGIN_SELECT_SELLER_EMPLOYEE}" />
+                       <p:selectOneMenu
+                               id="receiptSellerEmployee"
+                               value="#{receiptController.receiptSellerEmployee}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               >
+                               <f:converter converterId="CompanyEmployeeConverter" />
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+                               <f:selectItems value="#{companyEmployeeController.allCompanyEmployees()}" var="companyHeadQuarters" itemValue="#{companyEmployee}" itemLabel="#{companyEmployee.foo}" />
+                       </p:selectOneMenu>
+                       <p:message for="receiptSellerEmployee" />
+               </h:panelGrid>
+       </fieldset>
+
+       <fieldset class="fieldset">
+               <legend title="#{project.LOGIN_FINANCIAL_RECEIPT_OTHER_LEGEND_TITLE}">
+                       <h:outputText value="#{project.LOGIN_FINANCIAL_RECEIPT_OTHER_LEGEND}" />
+               </legend>
+
+               <h:panelGrid columns="3" styleClass="table table-full">
+                       <p:outputLabel for="receiptNumber" value="#{project.FINANCIAL_RECEIPT_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptNumber" size="10" maxlength="20" value="#{receiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
+                               <f:validateLongRange minimum="1" maximum="9999999999" />
+                       </p:inputText>
+                       <p:message for="receiptNumber" />
+
+                       <p:outputLabel for="receiptRegisterNumber" value="#{project.FINANCIAL_RECEIPT_REGISTER_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptRegisterNumber" size="3" maxlength="10" value="#{receiptController.receiptRegisterNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_REGISTER_NUMBER_INVALID}">
+                               <f:validateLongRange minimum="1" maximum="999" />
+                       </p:inputText>
+                       <p:message for="receiptRegisterNumber" />
+
+                       <p:outputLabel for="receiptBarCodeNumber" value="#{project.FINANCIAL_RECEIPT_BARCODE_NUMBER}" />
+                       <p:inputText styleClass="input" id="receiptBarCodeNumber" size="24" maxlength="24" value="#{receiptController.receiptBarCodeNumber}" />
+                       <p:message for="receiptBarCodeNumber" />
+               </h:panelGrid>
+       </fieldset>
+</ui:composition>
index ad042f811a7a322a966c8bbbbb825955c0f593a5..e24fff891bb65ce956ab13313d102c0a3882b4c4 100644 (file)
@@ -19,9 +19,9 @@
                        <p:dataTable
                                id="table-list-financial-receipt"
                                var="receipt"
-                               value="#{adminReceiptController.allFinancialReceipts()}"
+                               value="#{receiptController.allReceipts()}"
                                widgetVar="receiptTable"
-                               filteredValue="#{adminReceiptController.filteredFinancialReceipts}"
+                               filteredValue="#{receiptController.filteredReceipts}"
                                tableStyleClass="table table-full"
                                rows="10"
                                paginator="true"
@@ -31,7 +31,7 @@
                                rowsPerPageTemplate="5,10,20,50,100"
                                sortMode="multiple"
                                summary="#{project.TABLE_SUMMARY_ADMIN_LIST_FINANCIAL_RECEIPTS}"
-                               emptyMessage="#{msg.ADMIN_FINANCIAL_RECEIPT_LIST_EMPTY}">
+                               emptyMessage="#{project.ADMIN_FINANCIAL_RECEIPT_LIST_EMPTY}">
 
                                <f:facet name="header">
                                        <h:outputText value="#{project.ADMIN_LIST_FINANCIAL_RECEIPTS_HEADER}" />
                        </p:dataTable>
                </h:form>
 
-               <h:form id="form_add_financial_receipt">
-                       <h:panelGroup styleClass="table table-medium" layout="block">
-                               <div class="table-header">
+               <h:form id="form_admin_add_financial_receipt">
+                       <h:panelGrid columns="1" headerClass="table-header" footerClass="table-footer" styleClass="table table-full">
+                               <f:facet name="header">
                                        <h:outputText value="#{project.ADMIN_ADD_FINANCIAL_RECEIPT_TITLE}" />
-                               </div>
+                               </f:facet>
 
-                               <ui:include src="/WEB-INF/templates/admin/financial/receipt/admin_form_financial_receipt.tpl" />
+                               <p:column>
+                                       <ui:include src="/WEB-INF/templates/admin/financial/receipt/admin_form_financial_receipt.tpl" />
+                               </p:column>
 
-                               <div class="table-footer">
+                               <f:facet name="footer">
                                        <p:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
                                        <p:commandButton styleClass="submit" type="submit" id="button_add_financial_receipt" value="#{project.BUTTON_ADMIN_ADD_FINANCIAL_RECEIPT}" action="#{adminReceiptController.addReceipt()}" />
-                               </div>
-                       </h:panelGroup>
-
-                       <h:panelGroup styleClass="para notice" layout="block">
-                               <h:outputText value="#{project.ADMIN_ADD_FINANCIAL_RECEIPT_NOTICES}" />
-                               <ul>
-                                       <li><h:outputText value="#{project.ADMIN_ADD_FINANCIAL_RECEIPT_PATTERN}" /></li>
-                               </ul>
-                       </h:panelGroup>
+                               </f:facet>
+                       </h:panelGrid>
                </h:form>
        </ui:define>
 </ui:composition>
index 1dc91df5592f816c04515cace622caa18fdf1d46..fe029289a46084e3ca1da9d8c261ae614fff2c3f 100644 (file)
        </ui:define>
 
        <ui:define name="content">
-               <h:form id="form_add_financials_receipt">
-                       <h:panelGroup styleClass="table table-medium" layout="block">
-                               <div class="table-header">
-                                       <h:outputText value="#{project.LOGIN_FINANCIAL_ADD_RECEIPT_FORM_TITLE}" />
-                               </div>
+               <h:form id="form_add_financial_receipt">
+                       <h:panelGrid columns="1" headerClass="table-header" footerClass="table-footer" styleClass="table table-full">
+                               <f:facet name="header">
+                                       <h:outputText value="#{project.LOGIN_ADD_FINANCIAL_RECEIPT_TITLE}" />
+                               </f:facet>
 
-                               <h:panelGroup styleClass="table-row" layout="block">
-                                       <div class="table-left-medium">
-                                               <p:outputLabel for="receiptBranchOffice" value="#{project.LOGIN_FINANCIAL_SELECT_RECEIPT_BRANCH_OFFICE}" />
-                                       </div>
+                               <p:column>
+                                       <ui:include src="/WEB-INF/templates/user/financial/receipt/login_form_financial_receipt.tpl" />
+                               </p:column>
 
-                                       <div class="table-right-medium">
-                                               <p:selectOneMenu
-                                                       id="receiptBranchOffice"
-                                                       value="#{receiptController.receiptBranchOffice}"
-                                                       filter="true"
-                                                       filterMatchMode="contains"
-                                                       required="true"
-                                                       requiredMessage="#{project.FIELD_FINANCIAL_RECEIPT_BRANCH_OFFICE_REQUIRED}"
-                                                       >
-                                                       <f:converter converterId="BasicCompanyDataConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                                       <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{branchOffice.branchCompany.companyName}" />
-                                               </p:selectOneMenu>
-                                       </div>
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="table-row" layout="block">
-                                       <div class="table-left-medium">
-                                               <p:outputLabel for="receiptIssued" value="#{project.ENTER_FINANCIAL_RECEIPT_ISSUE_DATE}" />
-                                       </div>
-
-                                       <div class="table-right-medium">
-                                               <p:calendar
-                                                       id="receiptIssued"
-                                                       value="#{adminReceiptController.receiptIssued}"
-                                                       required="true"
-                                                       requiredMessage="#{msg.LOGIN_FINANCIAL_RECEIPT_ISSUE_DATE_REQUIRED}"
-                                                       pattern="#{msg.DATE_PATTERN}"
-                                                       navigator="true"
-                                                       maskAutoClear="true"
-                                                       title="#{msg.LOGIN_FINANCIAL_ENTER_RECEIPT_ISSUE_DATE_TITLE}"
-                                                       />
-                                       </div>
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="error-container" layout="block">
-                                       <p:message for="receiptIssued" />
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="table-row" layout="block">
-                                       <div class="table-left-medium">
-                                               <p:outputLabel for="receiptNumber" value="#{project.LOGIN_FINANCIAL_RECEIPT_NUMBER}" />
-                                       </div>
-
-                                       <div class="table-right-medium">
-                                               <p:inputText styleClass="input" id="receiptNumber" size="2" maxlength="10" value="#{receiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
-                                                       <f:validateLongRange minimum="1" maximum="20" />
-                                               </p:inputText>
-                                       </div>
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="error-container" layout="block">
-                                       <p:message for="receiptNumber" />
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="table-row" layout="block">
-                                       <h:outputText value="#{project.LOGIN_FINANCIAL_COMPANY_NOT_FOUND} " />
-                                       <p:link title="#{project.LINK_LOGIN_FINANCIAL_ADD_COMPANY_TITLE}" outcome="login_add_receipt_company" value="#{project.LINK_LOGIN_FINANCIAL_ADD_COMPANY}" />
-                               </h:panelGroup>
-
-                               <h:panelGroup styleClass="table-row" layout="block">
-                                       <div class="table-left-medium">
-                                               <p:outputLabel for="paymentType" value="#{project.LOGIN_FINANCIAL_INCOME_INTERVAL}" />
-                                       </div>
-
-                                       <div class="table-right-medium">
-                                               <p:selectOneMenu
-                                                       id="paymentType"
-                                                       value="#{receiptController.paymentType}"
-                                                       required="true"
-                                                       requiredMessage="#{project.FIELD_FINANCIAL_RECEIPT_PAYMENT_TYPE_REQUIRED}"
-                                                       >
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                                       <f:selectItems value="#{receiptController.allPaymentTypes()}" var="paymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType]}" />
-                                               </p:selectOneMenu>
-                                       </div>
-                               </h:panelGroup>
-
-                               <div class="table-footer">
+                               <f:facet name="footer">
                                        <p:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-
-                                       <p:commandButton styleClass="submit" id="submit_add_receipt" type="submit" action="#{receiptController.addReceipt()}" value="#{project.BUTTON_LOGIN_FINANCIAL_ADD_RECEIPT}" />
-                               </div>
-                       </h:panelGroup>
+                                       <p:commandButton styleClass="submit" type="submit" id="button_add_financial_receipt" value="#{project.BUTTON_LOGIN_ADD_FINANCIAL_RECEIPT}" action="#{receiptController.addReceipt()}" />
+                               </f:facet>
+                       </h:panelGrid>
                </h:form>
        </ui:define>
 </ui:composition>