]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Don't cherr-pick:
authorRoland Häder <roland@mxchange.org>
Mon, 4 Sep 2017 22:25:13 +0000 (00:25 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 4 Sep 2017 22:25:13 +0000 (00:25 +0200)
- used more 'final' where possible to not have unwanted side effects when
  someone accidently assigns a new value somewhere
- reciepts are now linked against branch offices because you do not buy stuff
  at headquarters, mostly

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/financial/income/FinancialsIncomeWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/receipt/FinancialsReceiptWebRequestBean.java
web/user/financials/login_financials_add_receipt.xhtml

index 61f2bc1db80c3244b5c2f0d3e7ec6c610bdff5ba..c7a8210bcc5ff14b8ecce31f641534ecb817b298 100644 (file)
@@ -107,11 +107,11 @@ public class FinancialsIncomeWebRequestBean extends BaseFinancialsController imp
                }
 
                // Now that all required data has been entered, prepare new income instance
-               BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
+               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
-               BillableIncome updatedIncome = this.financialBean.addIncome(income);
+               final BillableIncome updatedIncome = this.financialBean.addIncome(income);
 
                // All fine
                return "add_user_fiancial_income"; //NOI18N
@@ -119,11 +119,8 @@ public class FinancialsIncomeWebRequestBean extends BaseFinancialsController imp
 
        @Override
        public List<FinancialInterval> allIncomeIntervals () {
-               // Init array
-               List<FinancialInterval> incomeIntervals = Arrays.asList(FinancialInterval.values());
-
-               // Return it
-               return incomeIntervals;
+               // Return list from enum values
+               return Arrays.asList(FinancialInterval.values());
        }
 
        @Override
index 2eca75a016988a2b7e299897271b6d30eddb1b31..98818d0cc6362b34f34d2cfe3ed292d1f3d866e2 100644 (file)
@@ -27,7 +27,7 @@ import javax.enterprise.event.Observes;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
 import org.mxchange.jfinancials.beans.BaseFinancialsController;
 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException;
@@ -42,7 +42,7 @@ import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@Named ("financialReceiptController")
+@Named ("receiptController")
 @RequestScoped
 public class FinancialsReceiptWebRequestBean extends BaseFinancialsController implements FinancialsReceiptWebRequestController {
 
@@ -65,7 +65,7 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsController im
        /**
         * Recipient issuing company (for example where the user went shopping to)
         */
-       private BusinessBasicData receiptCompany;
+       private BranchOffice receiptBranchOffice;
 
        /**
         * Date/time the receipt has been issued
@@ -110,7 +110,7 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsController im
                // Pre-check if receipt number is set
                if (this.getReceiptNumber() == null || this.getReceiptNumber() == 0) {
                        // Generate one randomly
-                       Long randomNumber = Math.round(Math.random() * 1_000_000);
+                       final Long randomNumber = Math.round(Math.random() * 1_000_000);
 
                        // And set it here
                        this.setReceiptNumber(randomNumber);
@@ -120,15 +120,15 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsController im
                if (!this.userLoginController.isUserLoggedIn()) {
                        // Not logged-in
                        throw new IllegalStateException("User is not logged-in"); //NOI18N
-               } else if (this.getReceiptCompany() == null) {
+               } else if (this.getReceiptBranchOffice() == null) {
                        // Is not set
-                       throw new NullPointerException("this.receiptCompany is not set."); //NOI18N
-               } else if (this.getReceiptCompany().getCompanyDataId() == null) {
+                       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.receiptCompany.businessContactId is not set."); //NOI18N
-               } else if (this.getReceiptCompany().getCompanyDataId() < 1) {
+                       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.receiptCompany.businessContactId={0} is not valid.", this.getReceiptCompany().getCompanyDataId())); //NOI18N
+                       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
@@ -138,15 +138,15 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsController im
                }
 
                // Prepare receipt instance
-               BillableReceipt receipt = new FinancialReceipt(this.getPaymentType(), this.getReceiptCompany(), this.userLoginController.getLoggedInUser(), this.getReceiptIssued());
+               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 receiptCompany={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptCompany().getCompanyDataId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
+                       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
-               BillableReceipt updatedReceipt;
+               final BillableReceipt updatedReceipt;
 
                // All is set, then try to call EJB
                try {
@@ -215,21 +215,21 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsController im
        }
 
        /**
-        * Getter for receipt issuing company
+        * Getter for receipt issuing branch office
         * <p>
-        * @return Receipt issuing company
+        * @return Receipt issuing branch office
         */
-       public BusinessBasicData getReceiptCompany () {
-               return this.receiptCompany;
+       public BranchOffice getReceiptBranchOffice () {
+               return this.receiptBranchOffice;
        }
 
        /**
-        * Setter for receipt issuing company
+        * Setter for receipt issuing branch office
         * <p>
-        * @param receiptCompany Receipt issuing company
+        * @param receiptBranchOffice Receipt issuing branch office
         */
-       public void setReceiptCompany (final BusinessBasicData receiptCompany) {
-               this.receiptCompany = receiptCompany;
+       public void setReceiptBranchOffice (final BranchOffice receiptBranchOffice) {
+               this.receiptBranchOffice = receiptBranchOffice;
        }
 
        /**
index 24d14ab521ced2435e441031dc08bb8fae21e8e9..0137fca1dec8d4de097dd0a122fecf568b7238cf 100644 (file)
 
                                <h:panelGroup styleClass="table-row" layout="block">
                                        <div class="table-left-medium">
-                                               <h:outputLabel for="receiptCompany" value="#{msg.LOGIN_FINANCIAL_SELECT_RECEIPT_COMPANY}" />
+                                               <h:outputLabel for="receiptBranchOffice" value="#{msg.LOGIN_FINANCIAL_SELECT_RECEIPT_BRANCH_OFFICE}" />
                                        </div>
 
                                        <div class="table-right-medium">
-                                               <h:selectOneMenu styleClass="select" id="receiptCompany" value="#{financialReceiptController.receiptCompany}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_RECEIPT_COMPANY_REQUIRED}" converter="BusinessContactConverter">
+                                               <h:selectOneMenu styleClass="select" id="receiptBranchOffice" value="#{receiptController.receiptBranchOffice}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_RECEIPT_BRANCH_OFFICE_REQUIRED}" converter="BasicCompanyDataConverter">
                                                        <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                                       <f:selectItems value="#{companyDataController.allCompanyBasicData()}" var="receiptCompany" itemValue="#{receiptCompany}" itemLabel="#{receiptCompany.companyName}" />
+                                                       <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="receiptBranchOffice" itemValue="#{receiptBranchOffice}" itemLabel="#{receiptBranchOffice.companyName}" />
                                                </h:selectOneMenu>
                                        </div>
                                </h:panelGroup>
@@ -40,7 +40,7 @@
                                        </div>
 
                                        <div class="table-right-medium">
-                                               <p:calendar id="receiptIssued" title="#{msg.LOGIN_FINANCIAL_ENTER_RECEIPT_ISSUED_TITLE}" locale="#{localizationController.locale.displayCountry}" value="#{financialReceiptController.receiptIssued}" />
+                                               <p:calendar id="receiptIssued" title="#{msg.LOGIN_FINANCIAL_ENTER_RECEIPT_ISSUED_TITLE}" locale="#{localizationController.locale.displayCountry}" value="#{receiptController.receiptIssued}" />
                                        </div>
                                </h:panelGroup>
 
@@ -50,7 +50,7 @@
                                        </div>
 
                                        <div class="table-right-medium">
-                                               <h:inputText styleClass="input" id="receiptNumber" size="2" maxlength="10" value="#{financialReceiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
+                                               <h:inputText styleClass="input" id="receiptNumber" size="2" maxlength="10" value="#{receiptController.receiptNumber}" validatorMessage="#{msg.ENTERED_RECEIPT_NUMBER_INVALID}">
                                                        <f:validateLongRange minimum="1" maximum="20" />
                                                </h:inputText>
                                        </div>
@@ -67,9 +67,9 @@
                                        </div>
 
                                        <div class="table-right-medium">
-                                               <h:selectOneMenu styleClass="select" id="paymentType" value="#{financialReceiptController.paymentType}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_REQUIRED}">
+                                               <h:selectOneMenu styleClass="select" id="paymentType" value="#{receiptController.paymentType}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_REQUIRED}">
                                                        <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
-                                                       <f:selectItems value="#{financialReceiptController.allPaymentTypes()}" var="paymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType]}" />
+                                                       <f:selectItems value="#{receiptController.allPaymentTypes()}" var="paymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType]}" />
                                                </h:selectOneMenu>
                                        </div>
                                </h:panelGroup>
@@ -77,7 +77,7 @@
                                <div class="table-footer">
                                        <h:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
 
-                                       <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialReceiptController.addReceipt()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
+                                       <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{receiptController.addReceipt()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
                                </div>
                        </h:panelGroup>
                </h:form>