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.exceptions.receipt.ReceiptAlreadyAddedException;
import org.mxchange.jfinancials.model.receipt.BillableReceipt;
import org.mxchange.jfinancials.model.receipt.FinancialAdminReceiptSessionBeanRemote;
import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
* EJB for general financial receipt purposes
*/
@EJB (lookup = "java:global/jfinancials-ejb/adminFinancialReceipt!org.mxchange.jfinancials.model.receipt.FinancialAdminReceiptSessionBeanRemote")
- private FinancialAdminReceiptSessionBeanRemote adminFinancialBean;
+ private FinancialAdminReceiptSessionBeanRemote adminReceiptBean;
/**
* Bar-code number
// All is set, then try to call EJB
try {
// Add it
- updatedReceipt = this.adminFinancialBean.addReceipt(receipt);
+ updatedReceipt = this.adminReceiptBean.addReceipt(receipt);
} catch (final ReceiptAlreadyAddedException ex) {
// Throw it again
throw new FaceletException(ex);
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.exceptions.receipt.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.juserlogincore.events.login.ObservableUserLoggedInEvent;
/**
- * An administrative financial receipt bean (controller)
+ * A general financial receipt bean (controller)
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
// Is cache there?
if (!this.receiptCache.iterator().hasNext()) {
// Get whole list
- final List<BillableReceipt> list = this.receiptBean.allReceipts();
+ final List<BillableReceipt> receipts = this.receiptBean.allReceipts();
// Add all
- for (final Iterator<BillableReceipt> iterator = list.iterator(); iterator.hasNext();) {
- // Get next element
- final BillableReceipt next = iterator.next();
-
+ for (final BillableReceipt receipt : receipts) {
// Add it to cache
- this.receiptCache.put(next.getReceiptId(), next);
+ this.receiptCache.put(receipt.getReceiptId(), receipt);
}
}
--- /dev/null
+/*
+ * 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_item;
+
+import java.text.MessageFormat;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ReceiptItemAddedEvent;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
+import org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem;
+import org.mxchange.jfinancials.model.receipt.item.FinancialReceiptItem;
+import org.mxchange.jfinancials.model.receipt_item.FinancialAdminReceiptItemSessionBeanRemote;
+
+/**
+ * An administrative backing bean for receipt items
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminReceiptItemController")
+@RequestScoped
+public class FinancialAdminReceiptItemWebRequestBean extends BaseFinancialsBean implements FinancialAdminReceiptItemWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 595_754_280_374_172L;
+
+ /**
+ * Event being fired when administrator has added a new receipt item
+ */
+ @Inject
+ @Any
+ private Event<ObservableReceiptItemAddedEvent> adminAddedReceiptItemEvent;
+
+ /**
+ * EJB for general financial receipt item purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/adminFinancialReceiptItem!org.mxchange.jfinancials.model.receipt.item.FinancialAdminReceiptItemSessionBeanRemote")
+ private FinancialAdminReceiptItemSessionBeanRemote adminReceiptItemBean;
+
+ /**
+ * General receipt item controller
+ */
+ @Inject
+ private FinancialsReceiptItemWebRequestController receiptItemController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialAdminReceiptItemWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Adds the completed receipt item to database by calling an EJB business
+ * method. If not all required fields are set, a proper exception is being
+ * thrown.
+ * <p>
+ * @return Link outcome
+ */
+ public String addReceiptItem () {
+ // Are all required fields set?
+
+ // Prepare receipt item instance
+ final BillableReceiptItem receiptItem = this.createReceiptItemInstance();
+
+ // Is the receipt already there?
+ if (this.receiptItemController.isReceiptItemAdded(receiptItem)) {
+ // Receipt has already been added
+ throw new FaceletException(MessageFormat.format("Receipt for itemReceipt.receiptId={0},itemProduct.productId={1},itemProductQuantity={2} has already been added.", receiptItem.getItemReceipt().getReceiptId(), receiptItem.getItemProduct().getProductId(), receiptItem.getItemProductQuantity())); //NOI18N
+ }
+
+ // Init variable
+ final BillableReceiptItem updatedReceiptItem;
+
+ // All is set, then try to call EJB
+ try {
+ // Add it
+ updatedReceiptItem = this.adminReceiptItemBean.addReceiptItem(receiptItem);
+ } catch (final ReceiptItemAlreadyAddedException ex) {
+ // Throw it again
+ throw new FaceletException(ex);
+ }
+
+ // Fire event with updated instance
+ this.adminAddedReceiptItemEvent.fire(new ReceiptItemAddedEvent(updatedReceiptItem));
+
+ // Clear bean
+ this.clear();
+
+ // Return redirect outcome
+ return "add_receipt_item?faces-redirect=true"; //NOI18N
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all fields
+ }
+
+ /**
+ * Creates a new instance from all available data of this bean.
+ * <p>
+ * @return Receipt item instance
+ */
+ private BillableReceiptItem createReceiptItemInstance () {
+ // Create new instance with minimum required data
+ final BillableReceiptItem receiptItem = new FinancialReceiptItem();
+
+ // Set optional data
+
+ // Return prepared instance
+ return receiptItem;
+ }
+
+}
--- /dev/null
+/*
+ * 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_item;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative receipt item beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialAdminReceiptItemWebRequestController extends Serializable {
+
+}
--- /dev/null
+/*
+ * 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_item;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.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.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.events.receipt_item.added.ObservableReceiptItemAddedEvent;
+import org.mxchange.jfinancials.events.receipt_item.added.ReceiptItemAddedEvent;
+import org.mxchange.jfinancials.exceptions.receipt_item.ReceiptItemAlreadyAddedException;
+import org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem;
+import org.mxchange.jfinancials.model.receipt.item.FinancialReceiptItem;
+import org.mxchange.jfinancials.model.receipt_item.FinancialReceiptItemSessionBeanRemote;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+
+/**
+ * A general financial receipt item bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("receiptItemController")
+@RequestScoped
+public class FinancialsReceiptItemWebRequestBean extends BaseFinancialsBean implements FinancialsReceiptItemWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 56_189_028_928_372L;
+
+ /**
+ * Event being fired when user has added a new receipt
+ */
+ @Inject
+ @Any
+ private Event<ObservableReceiptItemAddedEvent> addedReceiptItemEvent;
+
+ /**
+ * All receipt items list
+ */
+ private final List<BillableReceiptItem> allReceiptItems;
+
+ /**
+ * Filtered receipt items list
+ */
+ private List<BillableReceiptItem> filteredReceiptItems;
+
+ /**
+ * EJB for general financial receipt purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/financialReceiptItem!org.mxchange.jfinancials.model.receipt.item.FinancialReceiptItemSessionBeanRemote")
+ private FinancialReceiptItemSessionBeanRemote receiptItemBean;
+
+ /**
+ * A list of all branch offices (globally)
+ */
+ @Inject
+ @NamedCache (cacheName = "receiptItemCache")
+ private Cache<Long, BillableReceiptItem> receiptItemCache;
+
+ /**
+ * User instance
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * User's receipt items
+ */
+ private final List<BillableReceiptItem> userReceiptItems;
+
+ /**
+ * Constructor
+ */
+ @SuppressWarnings ("CollectionWithoutInitialCapacity")
+ public FinancialsReceiptItemWebRequestBean () {
+ // Call super constructor
+ super();
+
+ // Init lists
+ this.allReceiptItems = new LinkedList<>();
+ this.userReceiptItems = new LinkedList<>();
+ }
+
+ /**
+ * Adds the completed receipt item to database by calling an EJB business method.
+ * If not all required fields are set, a proper exception is being thrown.
+ * <p>
+ * @return Link outcome
+ */
+ public String addReceiptItem () {
+ // Are all required fields set?
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ }
+
+ // Prepare receipt instance
+ final BillableReceiptItem receiptItem = this.createReceiptInstance();
+
+ // Is the receipt already there?
+ if (this.isReceiptItemAdded(receiptItem)) {
+ // Receipt has already been added
+ throw new FaceletException(MessageFormat.format("Receipt for itemReceipt.receiptId={0},itemProduct.productId={1},itemProductQuantity={2} has already been added.", receiptItem.getItemReceipt().getReceiptId(), receiptItem.getItemProduct().getProductId(), receiptItem.getItemProductQuantity())); //NOI18N
+ }
+
+ // Init variable
+ final BillableReceiptItem updatedReceiptItem;
+
+ // All is set, then try to call EJB
+ try {
+ // Add it
+ updatedReceiptItem = this.receiptItemBean.addReceiptItem(receiptItem);
+ } catch (final ReceiptItemAlreadyAddedException ex) {
+ // Throw it again
+ throw new FaceletException(ex);
+ }
+
+ // Fire event with updated instance
+ this.addedReceiptItemEvent.fire(new ReceiptItemAddedEvent(updatedReceiptItem));
+
+ // Clear bean
+ this.clear();
+
+ // Return redirect outcome
+ return "add_receipt_item?faces-redirect=true"; //NOI18N
+ }
+
+ /**
+ * Observes events being fired when a new receipt item has been added
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAddedReceiptItemEvent (@Observes final ObservableReceiptItemAddedEvent event) {
+ // Validate parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ }
+
+ // Add to cache and general list
+ this.receiptItemCache.put(event.getReceiptItem().getItemId(), event.getReceiptItem());
+ this.allReceiptItems.add(event.getReceiptItem());
+
+ // Is same user?
+ if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceiptItem().getItemReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
+ // Same user, then add it
+ this.userReceiptItems.add(event.getReceiptItem());
+ }
+ }
+
+ /**
+ * 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 BillableReceiptItem receiptItem : this.allReceiptItems) {
+ // Is same user?
+ if (Objects.equals(receiptItem.getItemReceipt().getReceiptUser(), event.getLoggedInUser())) {
+ // Yes, then add it
+ this.userReceiptItems.add(receiptItem);
+ }
+ }
+ }
+
+ /**
+ * Returns all receipt items
+ * <p>
+ * @return All receipt items
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<BillableReceiptItem> allReceiptItems () {
+ return this.allReceiptItems;
+ }
+
+ /**
+ * Getter for filtered receipt items
+ * <p>
+ * @return Filtered receipts
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<BillableReceiptItem> getFilteredReceiptItems () {
+ return this.filteredReceiptItems;
+ }
+
+ /**
+ * Setter for filtered receipt items
+ * <p>
+ * @param filteredReceiptItems Filtered receipt items
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredReceipts (final List<BillableReceiptItem> filteredReceiptItems) {
+ this.filteredReceiptItems = filteredReceiptItems;
+ }
+
+ @PostConstruct
+ public void initCache () {
+ // Is cache there?
+ if (!this.receiptItemCache.iterator().hasNext()) {
+ // Get whole list
+ final List<BillableReceiptItem> receiptItems = this.receiptItemBean.allReceiptItems();
+
+ // Add all
+ for (final BillableReceiptItem receiptItem : receiptItems) {
+ // Add it to cache
+ this.receiptItemCache.put(receiptItem.getItemId(), receiptItem);
+ }
+ }
+
+ // Is the list empty, but filled cache?
+ if (this.allReceiptItems.isEmpty() && this.receiptItemCache.iterator().hasNext()) {
+ // Get iterator
+ final Iterator<Cache.Entry<Long, BillableReceiptItem>> iterator = this.receiptItemCache.iterator();
+
+ // Build up list
+ while (iterator.hasNext()) {
+ // GEt next element
+ final Cache.Entry<Long, BillableReceiptItem> next = iterator.next();
+
+ // Add to list
+ this.allReceiptItems.add(next.getValue());
+ }
+
+ // Sort list
+ this.allReceiptItems.sort(new Comparator<BillableReceiptItem>() {
+ @Override
+ public int compare (final BillableReceiptItem o1, final BillableReceiptItem o2) {
+ return o1.getItemId() > o2.getItemId() ? 1 : o1.getItemId() < o2.getItemId() ? -1 : 0;
+ }
+ }
+ );
+ }
+ }
+
+ @Override
+ public boolean isReceiptItemAdded (final BillableReceiptItem receiptItem) {
+ // Always trust the cache
+ return this.allReceiptItems.contains(receiptItem);
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all fields
+ }
+
+ /**
+ * Returns a fully created receipt item instance (except primary key, of course)
+ * <p>
+ * @return Receipt item instance
+ */
+ private BillableReceiptItem createReceiptInstance () {
+ // Init receipt instance
+ final BillableReceiptItem receiptItem = new FinancialReceiptItem();
+
+ // Set optional fields
+
+ // Return it
+ return receiptItem;
+ }
+}
--- /dev/null
+/*
+ * 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_item;
+
+import java.io.Serializable;
+import org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem;
+
+/**
+ * An administrative interface for financial receipt item beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsReceiptItemWebRequestController extends Serializable {
+
+ /**
+ * Checks if receipt item has already been added to database
+ * <p>
+ * @param receiptItem Prepared receipt item instance
+ * <p>
+ * @return Whether the receipt item has already been added
+ */
+ boolean isReceiptItemAdded (final BillableReceiptItem receiptItem);
+
+}
#@TODO Please fix German umlauts!
ADMIN_ASSIGNED_RECEIPT_SELLER=Zugewiesener Verkaeufer:
DEPARTMENT_NAME_SALES=Verkauf
+#@TODO Please fix German umlauts!
+ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS=Eintraege auflisten
+#@TODO Please fix German umlauts!
+ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS_TITLE=Listet alle Eintraege aller Kassenbons auf.
+ADMIN_LINK_SHOW_RECEIPT_TITLE=Zeigt Daten des Kassenbons an.
+ADMIN_LINK_SHOW_RECEIPT_ITEM_TITLE=Zeigt Daten eines Eintrages eines Kassenbons an.
ADMIN_LINK_SHOW_RECEIPT_OWNER_USER_TITLE=Shows assigned user of receipt.
ADMIN_ASSIGNED_RECEIPT_SELLER=Assigned seller:
DEPARTMENT_NAME_SALES=Sales
+ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS=List receipt items
+ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS_TITLE=Lists all receipt items.
+ADMIN_LINK_SHOW_RECEIPT_TITLE=Shows receipt data.
+ADMIN_LINK_SHOW_RECEIPT_ITEM_TITLE=Shows receipt item data.
<from-outcome>admin_list_receipts</from-outcome>
<to-view-id>/admin/financials/receipts/admin_receipt_list.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>admin_list_receipt_items</from-outcome>
+ <to-view-id>/admin/financials/receipt_items/admin_receipt_item_list.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/user/login_index.xhtml</from-view-id>
</attribute>
<attribute>
<name>renderShowLink</name>
- <description>Whether this tag is used to show mobile data (default true).</description>
+ <description>Whether this tag is used to show receipt data (default true).</description>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ </attribute>
+ <attribute>
+ <name>rendered</name>
+ <description>Whether this tag is being rendered by JSF engine (default: true).</description>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ </attribute>
+ </tag>
+ <tag>
+ <tag-name>outputReceiptItemAdminMiniLinks</tag-name>
+ <description>This tag renders a full h:panelGroup for administrative "mini-links" for receipt item data.</description>
+ <source>resources/tags/admin/links/mini/financial/receipt_item/admin_receipt_item_links.tpl</source>
+ <attribute>
+ <name>receiptItem</name>
+ <description>The receipt item instance that provides the data for this tag.</description>
+ <required>true</required>
+ <type>org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem</type>
+ </attribute>
+ <attribute>
+ <name>renderShowLink</name>
+ <description>Whether this tag is used to show receipt item data (default true).</description>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
--- /dev/null
+<?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">
+
+ <!--
+ @TODO: title="#{project.ADMIN_FINANCIAL_RECEIPT_ITEM_BASIC_LEGEND_TITLE}"
+ -->
+ <p:fieldset legend="#{project.ADMIN_FINANCIAL_RECEIPT_ITEM_BASIC_LEGEND}">
+ <p:panelGrid layout="grid" columns="2" columnClasses="ui-grid-col-4, ui-grid-col-8" styleClass="table table-full ui-noborder">
+ <p:outputLabel for="itemProduct" value="#{msg.ADMIN_SELECT_BRANCH_OFFICE}" />
+ <p:selectOneMenu
+ id="itemProduct"
+ value="#{adminReceiptItemController.receiptBranchOffice}"
+ filter="true"
+ filterMatchMode="contains"
+ required="true"
+ requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_COMPANY_REQUIRED}"
+ >
+ <f:converter converterId="ProductConverter" />
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+ <f:selectItems value="#{productController.allProducts()}" var="product" itemValue="#{product}" itemLabel="#{product}" />
+ </p:selectOneMenu>
+
+ <p:outputLabel for="receiptIssued" value="#{project.ENTER_FINANCIAL_RECEIPT_ITEM_ISSUE_DATE}" />
+ <p:calendar
+ id="receiptIssued"
+ value="#{adminReceiptItemController.receiptIssued}"
+ required="true"
+ requiredMessage="#{project.ADMIN_FINANCIAL_RECEIPT_ITEM_ISSUE_DATE_REQUIRED}"
+ pattern="#{msg.DATE_PATTERN}"
+ navigator="true"
+ maskAutoClear="true"
+ styleClass="input"
+ title="#{project.ADMIN_RECEIPT_ITEM_DATE_OF_ISSUE_TITLE}"
+ />
+
+ <p:outputLabel for="receiptPaymentType" value="#{msg.ADMIN_SELECT_PAYMENT_TYPE}" />
+ <p:selectOneMenu
+ id="receiptPaymentType"
+ value="#{adminReceiptItemController.receiptPaymentType}"
+ filter="true"
+ filterMatchMode="contains"
+ required="true"
+ requiredMessage="#{project.FIELD_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:outputLabel for="receiptSellerEmployee" value="#{msg.ADMIN_SELECT_SELLER_EMPLOYEE}" />
+ <p:selectOneMenu
+ id="receiptSellerEmployee"
+ value="#{adminReceiptItemController.receiptSellerEmployee}"
+ filter="true"
+ filterMatchMode="contains"
+ >
+ <f:converter converterId="CompanyEmployeeConverter" />
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{employeeController.allCompanyEmployees()}" var="companyEmployee" itemValue="#{companyEmployee}" itemLabel="#{companyEmployee.employeeNumber} #{beanHelper.renderContact(companyEmployee.employeePersonalData)}" itemDescription="#{companyEmployee.employeeCompany.companyName}, #{beanHelper.renderBranchOffice(companyEmployee.employeeBranchOffice)}" />
+ </p:selectOneMenu>
+
+ <p:outputLabel for="receiptUser" value="#{project.ADMIN_SELECT_FINANCIAL_RECEIPT_ITEM_USER_OWNER}" />
+ <p:selectOneMenu
+ id="receiptUser"
+ value="#{adminReceiptItemController.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:panelGrid>
+ </p:fieldset>
+
+ <p:fieldset legend="#{project.ADMIN_FINANCIAL_RECEIPT_ITEM_OTHER_LEGEND}">
+ <!--
+ @TODO: title="#{project.ADMIN_FINANCIAL_RECEIPT_ITEM_OTHER_LEGEND_TITLE}">
+ -->
+ <p:panelGrid layout="grid" columns="2" columnClasses="ui-grid-col-4, ui-grid-col-8" styleClass="table table-full ui-noborder">
+ <p:outputLabel for="receiptNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_ITEM_NUMBER}" />
+ <p:inputText styleClass="input" id="receiptNumber" size="10" maxlength="20" value="#{adminReceiptItemController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_ITEM_NUMBER_INVALID}">
+ <f:validateLongRange minimum="1" maximum="9999999999" />
+ </p:inputText>
+
+ <p:outputLabel for="receiptRegisterNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_ITEM_REGISTER_NUMBER}" />
+ <p:inputText styleClass="input" id="receiptRegisterNumber" size="3" maxlength="10" value="#{adminReceiptItemController.receiptRegisterNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_ITEM_REGISTER_NUMBER_INVALID}">
+ <f:validateLongRange minimum="1" maximum="999" />
+ </p:inputText>
+
+ <p:outputLabel for="receiptBarCodeNumber" value="#{project.ENTER_FINANCIAL_RECEIPT_ITEM_BARCODE_NUMBER}" />
+ <p:inputText styleClass="input" id="receiptBarCodeNumber" size="24" maxlength="24" value="#{adminReceiptItemController.receiptBarCodeNumber}" />
+ </p:panelGrid>
+ </p:fieldset>
+</ui:composition>
<p:submenu label="#{project.ADMIN_MENU_FINANCIAL_RECEIPTS_TITLE}">
<p:menuitem title="#{project.ADMIN_LINK_LIST_FINANCIAL_RECEIPTS_TITLE}" outcome="admin_list_receipts" value="#{project.ADMIN_LINK_LIST_FINANCIAL_RECEIPTS}" />
+ <p:menuitem title="#{project.ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS_TITLE}" outcome="admin_list_receipt_items" value="#{project.ADMIN_LINK_LIST_FINANCIAL_RECEIPT_ITEMS}" />
</p:submenu>
</ui:composition>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition template="/WEB-INF/templates/admin/admin_base.tpl"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:widgets="http://mxchange.org/jsf/core/widgets"
+ xmlns:pl="http://mxchange.org/jsf/jfinancials/links"
+ xmlns:links="http://mxchange.org/jsf/core/links"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ xmlns:p="http://primefaces.org/ui">
+
+ <ui:define name="document_admin_title">
+ <h:outputText value="#{project.PAGE_TITLE_ADMIN_FINANCIALS_RECEIPT_ITEM_LIST}" />
+ </ui:define>
+
+ <ui:define name="content_header">
+ <h:outputText value="#{project.CONTENT_TITLE_ADMIN_FINANCIALS_RECEIPT_ITEM_LIST}" />
+ </ui:define>
+
+ <ui:define name="content">
+ <h:form id="form-list-financial-receipt-item">
+ <p:dataTable
+ id="table-list-financial-receipt-item"
+ var="receiptItem"
+ value="#{receiptItemController.allReceiptItems()}"
+ filteredValue="#{receiptItemController.filteredReceiptItems}"
+ tableStyleClass="table table-full"
+ rows="10"
+ paginator="true"
+ paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
+ reflow="true"
+ resizableColumns="true"
+ rowsPerPageTemplate="5,10,20,50,100"
+ sortMode="multiple"
+ summary="#{project.TABLE_SUMMARY_ADMIN_LIST_FINANCIAL_RECEIPT_ITEMSS}"
+ emptyMessage="#{project.ADMIN_EMPTY_LIST_FINANCIAL_RECEIPT_ITEM}"
+ widgetVar="receiptItemList"
+ >
+ <f:facet name="header">
+ <p:panelGrid columns="2" columnClasses="ui-grid-col-10, ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
+ <h:outputText value="#{project.ADMIN_LIST_FINANCIAL_RECEIPT_ITEMS_HEADER}" />
+
+ <h:panelGroup>
+ <p:commandButton id="toggler" type="button" value="#{msg.SELECT_SHOWN_COLUMNS}" styleClass="column-selector" />
+ <p:columnToggler datasource="table-list-financial-receipt-item" trigger="toggler" />
+ </h:panelGroup>
+ </p:panelGrid >
+ </f:facet>
+
+ <p:column headerText="#{msg.ADMIN_ID_NUMBER}" sortBy="#{receiptItem.itemId}" filterBy="#{receiptItem.itemId}">
+ <p:link outcome="admin_show_receipt_item" title="#{project.ADMIN_LINK_SHOW_RECEIPT_ITEM_TITLE}" value="#{receiptItem.itemId}">
+ <f:param name="receiptId" value="#{receiptItem.itemId}" />
+ </p:link>
+ </p:column>
+
+ <p:column headerText="#{msg.ADMIN_ASSIGNED_BRANCH_OFFICE}" sortBy="#{receiptItem.itemBranchOffice}" filterBy="#{receiptItem.itemBranchOffice}" filterMatchMode="in">
+ <f:facet name="filter">
+ <p:selectCheckboxMenu
+ filter="true"
+ filterMatchMode="contains"
+ label="#{msg.LABEL_BRANCH_OFFICES}"
+ onchange="PF('receiptItemList').filter()"
+ updateLabel="true"
+ title="#{msg.FILTER_BY_MULTIPLE_BRANCH_OFFICES_TITLE}"
+ >
+ <f:converter converterId="BranchOfficeConverter" />
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}" />
+ </p:selectCheckboxMenu>
+ </f:facet>
+
+ <p:link outcome="admin_show_branch_office" title="#{msg.ADMIN_LINK_SHOW_BRANCH_OFFICE_TITLE}" value="#{receiptItem.itemBranchOffice.branchId}">
+ <f:param name="branchId" value="#{receiptItem.itemBranchOffice.branchId}" />
+ </p:link>
+ </p:column>
+
+ <p:column headerText="#{project.ADMIN_ASSIGNED_RECEIPT_SELLER}" sortBy="#{receiptItem.itemUser.userName}" filterBy="#{receiptItem.itemUser}" filterMatchMode="in">
+ <f:facet name="filter">
+ <p:selectCheckboxMenu
+ filter="true"
+ filterMatchMode="contains"
+ label="#{msg.LABEL_RECEIPT_SELLERS}"
+ onchange="PF('receiptItemList').filter()"
+ updateLabel="true"
+ title="#{project.FILTER_BY_MULTIPLE_RECEIPT_SELLERS_TITLE}"
+ >
+ <f:converter converterId="CompanyEmployeeConverter" />
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{employeeController.allCompanyEmployees()}" var="employee" itemValue="#{employee}" itemLabel="#{beanHelper.renderEmployee(employee)}" />
+ </p:selectCheckboxMenu>
+ </f:facet>
+
+ <p:link outcome="admin_show_user" title="#{msg.ADMIN_LINK_SHOW_RECEIPT_OWNER_RECEIPT_SELLER_TITLE}" value="#{receiptItem.itemUser.userId}" rendered="#{not empty receiptItem.itemUser}">
+ <f:param name="userId" value="#{receiptItem.itemUser.userId}" />
+ </p:link>
+
+ <p:link outcome="admin_assign_receipt_user" title="#{msg.ADMIN_LINK_ASSIGN_RECEIPT_OWNER_RECEIPT_SELLER_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receiptItem.itemUser}">
+ <f:param name="receiptId" value="#{receiptItem.itemId}" />
+ </p:link>
+ </p:column>
+
+ <p:column headerText="#{msg.ADMIN_ASSIGNED_USER}" sortBy="#{receiptItem.itemUser.userName}" filterBy="#{receiptItem.itemUser}" filterMatchMode="in">
+ <f:facet name="filter">
+ <p:selectCheckboxMenu
+ filter="true"
+ filterMatchMode="contains"
+ label="#{msg.LABEL_USERS}"
+ onchange="PF('receiptItemList').filter()"
+ updateLabel="true"
+ title="#{msg.FILTER_BY_MULTIPLE_USERS_TITLE}"
+ >
+ <f:converter converterId="UserConverter" />
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{userController.allUsers()}" var="user" itemValue="#{user}" itemLabel="#{user.userName}" />
+ </p:selectCheckboxMenu>
+ </f:facet>
+
+ <p:link outcome="admin_show_user" title="#{msg.ADMIN_LINK_SHOW_RECEIPT_OWNER_USER_TITLE}" value="#{receiptItem.itemUser.userId}" rendered="#{not empty receiptItem.itemUser}">
+ <f:param name="userId" value="#{receiptItem.itemUser.userId}" />
+ </p:link>
+
+ <p:link outcome="admin_assign_receipt_user" title="#{msg.ADMIN_LINK_ASSIGN_RECEIPT_OWNER_USER_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receiptItem.itemUser}">
+ <f:param name="receiptId" value="#{receiptItem.itemId}" />
+ </p:link>
+ </p:column>
+
+ <p:column headerText="#{msg.ADMIN_DATE_OF_ISSUE}" sortBy="#{receiptItem.itemIssued}" filterBy="#{receiptItem.itemIssued}">
+ <h:outputText id="receiptIssued" value="#{receiptItem.itemIssued.time}">
+ <f:convertDateTime for="receiptIssued" type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column headerText="#{msg.ADMIN_PAYMENT_TYPE}" sortBy="#{receiptItem.itemPaymentType}" filterBy="#{receiptItem.itemPaymentType}">
+ <f:facet name="filter">
+ <p:selectOneMenu
+ filter="true"
+ filterMatchMode="contains"
+ label="#{msg.LABEL_PAYMENT_TYPES}"
+ onchange="PF('receiptItemList').filter()"
+ title="#{msg.FILTER_BY_MULTIPLE_PAYMENT_TYPES_TITLE}"
+ >
+ <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>
+ </f:facet>
+
+ <h:outputText value="#{msg[receiptItem.itemPaymentType.i18nKey]}" />
+ </p:column>
+
+ <p:column headerText="#{msg.ADMIN_ACTION_LINKS}" sortable="false">
+ <pl:outputReceiptItemAdminMiniLinks receiptItem="#{receiptItem}" />
+ </p:column>
+ </p:dataTable>
+ </h:form>
+
+ <h:form>
+ <p:panelGrid layout="grid" columns="1" styleClass="table table-full">
+ <h:panelGroup styleClass="table-header" layout="block">
+ <h4>
+ <h:outputText value="#{project.ADMIN_ADD_FINANCIAL_RECEIPT_ITEM_TITLE}" />
+ </h4>
+ </h:panelGroup>
+
+ <ui:include src="/WEB-INF/templates/admin/financial/receipt_item/admin_form_financial_receipt_item.tpl" />
+
+ <p:panelGrid columns="2" styleClass="table-footer" layout="grid">
+ <p:commandButton
+ styleClass="reset"
+ type="reset"
+ value="#{msg.BUTTON_RESET_FORM}"
+ />
+
+ <p:commandButton
+ styleClass="submit"
+ type="submit"
+ value="#{project.BUTTON_ADMIN_ADD_FINANCIAL_RECEIPT_TEM}"
+ action="#{adminReceiptItemController.addReceiptItem()}"
+ update=":master:form-list-financial-receipt-item:table-list-financial-receipt-item"
+ />
+ </p:panelGrid>
+ </p:panelGrid>
+ </h:form>
+ </ui:define>
+</ui:composition>
</f:facet>
<p:column headerText="#{msg.ADMIN_ID_NUMBER}" sortBy="#{receipt.receiptId}" filterBy="#{receipt.receiptId}">
- <p:link outcome="admin_show_receipt" title="#{msg.ADMIN_LINK_SHOW_RECEIPT_TITLE}" value="#{receipt.receiptId}">
+ <p:link outcome="admin_show_receipt" title="#{project.ADMIN_LINK_SHOW_RECEIPT_TITLE}" value="#{receipt.receiptId}">
<f:param name="receiptId" value="#{receipt.receiptId}" />
</p:link>
</p:column>