View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.gl.businessobject;
17  
18  import java.util.LinkedHashMap;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.ole.sys.OLEConstants;
22  import org.kuali.rice.core.api.util.type.KualiDecimal;
23  import org.kuali.rice.krad.bo.TransientBusinessObjectBase;
24  
25  /**
26   * An OriginEntryInformation wrapper which helpfully summarizes data for the pending entry report
27   */
28  public class PendingEntrySummary extends TransientBusinessObjectBase {
29      private OriginEntryInformation originEntry;
30      private boolean suppress;
31      
32      /**
33       * @return the document number of the wrapped entry
34       */
35      public String getDocumentNumber() {
36          return (!suppress) ? getConstantDocumentNumber() : "";
37      }
38      
39      /**
40       * @return the document number of the wrapped entry - even if suppressed
41       */
42      public String getConstantDocumentNumber() {
43          return StringUtils.join(new String[] { originEntry.getFinancialSystemOriginationCode(),originEntry.getDocumentNumber()}, '-');
44      }
45      
46      /**
47       * @return the document type code of the wrapped entry
48       */
49      public String getDocumentTypeCode() {
50          return (!suppress) ? getConstantDocumentTypeCode() : "";
51      }
52      
53      /**
54       * @return the document type code, even if suppressed
55       */
56      public String getConstantDocumentTypeCode() {
57          return originEntry.getFinancialDocumentTypeCode();
58      }
59      
60      /**
61       * @return the balance type code of the wrapped entry
62       */
63      public String getBalanceTypeCode() {
64          return (!suppress) ? getConstantBalanceTypeCode() : "";
65      }
66      
67      /**
68       * @return the balance type code, even if suppressed
69       */
70      public String getConstantBalanceTypeCode() {
71          return originEntry.getFinancialBalanceTypeCode();
72      }
73      
74      /**
75       * @return the chart of accounts code of the wrapped entry
76       */
77      public String getChartOfAccountsCode() {
78          return originEntry.getChartOfAccountsCode();
79      }
80      
81      /**
82       * @return the account number of the wrapped entry
83       */
84      public String getAccountNumber() {
85          return originEntry.getAccountNumber();
86      }
87      
88      /**
89       * @return the financial object code of the wrapped entry
90       */
91      public String getFinancialObjectCode() {
92          return originEntry.getFinancialObjectCode();
93      }
94      
95      /**
96       * @return the amount of the wrapped entry, or null if the entry does not represent a credit
97       */
98      public KualiDecimal getCreditAmount() {
99          if (!StringUtils.isBlank(originEntry.getTransactionDebitCreditCode())) {
100             if (originEntry.getTransactionDebitCreditCode().equals(OLEConstants.GL_CREDIT_CODE)) {
101                 return originEntry.getTransactionLedgerEntryAmount(); 
102             }
103         }
104         return null;
105     }
106 
107     /**
108      * @return the amount of the wrapped entry, or null if the entry does not represent a debit
109      */
110     public KualiDecimal getDebitAmount() {
111         if (!StringUtils.isBlank(originEntry.getTransactionDebitCreditCode())) { 
112             if (originEntry.getTransactionDebitCreditCode().equals(OLEConstants.GL_DEBIT_CODE)) {
113                 return originEntry.getTransactionLedgerEntryAmount();
114             }
115         }
116         return null;
117     }
118 
119     /**
120      * @return the amount for the wrapped entry, or null if the entry represents either a debit or a credt
121      */
122     public KualiDecimal getBudgetAmount() {
123         return (originEntry.getTransactionDebitCreditCode() == null || originEntry.getTransactionDebitCreditCode().equals(OLEConstants.GL_BUDGET_CODE) || originEntry.getTransactionDebitCreditCode().equals(OLEConstants.EMPTY_STRING)) ? originEntry.getTransactionLedgerEntryAmount() : null;
124     }
125 
126     /**
127      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
128      */
129     
130     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
131         LinkedHashMap<String, String> pkHashMap = new LinkedHashMap<String, String>();
132         pkHashMap.put("documentTypeCode", this.getDocumentTypeCode());
133         pkHashMap.put("documentNumber", this.getDocumentNumber());
134         pkHashMap.put("chartOfAccountsCode", this.getChartOfAccountsCode());
135         pkHashMap.put("accountNumber", this.getAccountNumber());
136         pkHashMap.put("balanceTypeCode", this.getBalanceTypeCode());
137         pkHashMap.put("financialObjectCode", this.getFinancialObjectCode());
138         return pkHashMap;
139     }
140     
141     /**
142      * @param originEntry sets the origin entry
143      */
144     public void setOriginEntry(OriginEntryInformation originEntry) {
145         this.originEntry = originEntry;
146         this.suppress = false;
147     }
148 
149     /**
150      * Sets the suppress attribute value.
151      * @param suppress The suppress to set.
152      */
153     public void suppressCommonFields(boolean suppress) {
154         this.suppress = suppress;
155     }
156 
157     /**
158      * @return a String representation of suppressable fields
159      */
160     public String getSuppressableFieldsAsKey() {
161         return StringUtils.join(new String[] {originEntry.getFinancialDocumentTypeCode(),originEntry.getFinancialSystemOriginationCode(),originEntry.getDocumentNumber(),originEntry.getFinancialBalanceTypeCode()}, ':');
162     }
163 }