001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.financial.bo;
017:
018: import java.util.Map;
019:
020: import org.kuali.core.util.KualiDecimal;
021: import org.kuali.core.util.KualiInteger;
022: import org.kuali.kfs.bo.AccountingLine;
023:
024: /**
025: * This class is a utility class to consolidate budget adjustment accounting line code
026: */
027: public class BudgetAdjustmentAccountingLineUtil {
028: /**
029: * Initialize attributes
030: *
031: * @param accountingLine
032: */
033: public static void init(
034: BudgetAdjustmentAccountingLine accountingLine) {
035: accountingLine
036: .setCurrentBudgetAdjustmentAmount(KualiDecimal.ZERO);
037: accountingLine.setBaseBudgetAdjustmentAmount(KualiInteger.ZERO);
038: accountingLine
039: .setFinancialDocumentMonth1LineAmount(KualiDecimal.ZERO);
040: accountingLine
041: .setFinancialDocumentMonth2LineAmount(KualiDecimal.ZERO);
042: accountingLine
043: .setFinancialDocumentMonth3LineAmount(KualiDecimal.ZERO);
044: accountingLine
045: .setFinancialDocumentMonth4LineAmount(KualiDecimal.ZERO);
046: accountingLine
047: .setFinancialDocumentMonth5LineAmount(KualiDecimal.ZERO);
048: accountingLine
049: .setFinancialDocumentMonth6LineAmount(KualiDecimal.ZERO);
050: accountingLine
051: .setFinancialDocumentMonth7LineAmount(KualiDecimal.ZERO);
052: accountingLine
053: .setFinancialDocumentMonth8LineAmount(KualiDecimal.ZERO);
054: accountingLine
055: .setFinancialDocumentMonth9LineAmount(KualiDecimal.ZERO);
056: accountingLine
057: .setFinancialDocumentMonth10LineAmount(KualiDecimal.ZERO);
058: accountingLine
059: .setFinancialDocumentMonth11LineAmount(KualiDecimal.ZERO);
060: accountingLine
061: .setFinancialDocumentMonth12LineAmount(KualiDecimal.ZERO);
062: accountingLine.setFringeBenefitIndicator(false);
063: }
064:
065: /**
066: * Adds {@link BudgetAdjustmentAccountingLine} attributes to map
067: *
068: * @param simpleValues map used to add values to
069: * @param accountingLine accounting line that provides attributes to add to map
070: * @return
071: */
072: public static Map appendToValuesMap(Map simpleValues,
073: BudgetAdjustmentAccountingLine accountingLine) {
074: simpleValues.put("currentBudgetAdjustmentAmount",
075: accountingLine.getCurrentBudgetAdjustmentAmount());
076: simpleValues.put("baseBudgetAdjustmentAmount", accountingLine
077: .getBaseBudgetAdjustmentAmount());
078: simpleValues.put("financialDocumentMonth1LineAmount",
079: accountingLine.getFinancialDocumentMonth1LineAmount());
080: simpleValues.put("financialDocumentMonth2LineAmount",
081: accountingLine.getFinancialDocumentMonth2LineAmount());
082: simpleValues.put("financialDocumentMonth3LineAmount",
083: accountingLine.getFinancialDocumentMonth3LineAmount());
084: simpleValues.put("financialDocumentMonth4LineAmount",
085: accountingLine.getFinancialDocumentMonth4LineAmount());
086: simpleValues.put("financialDocumentMonth5LineAmount",
087: accountingLine.getFinancialDocumentMonth5LineAmount());
088: simpleValues.put("financialDocumentMonth6LineAmount",
089: accountingLine.getFinancialDocumentMonth6LineAmount());
090: simpleValues.put("financialDocumentMonth7LineAmount",
091: accountingLine.getFinancialDocumentMonth7LineAmount());
092: simpleValues.put("financialDocumentMonth8LineAmount",
093: accountingLine.getFinancialDocumentMonth8LineAmount());
094: simpleValues.put("financialDocumentMonth9LineAmount",
095: accountingLine.getFinancialDocumentMonth9LineAmount());
096: simpleValues.put("financialDocumentMonth10LineAmount",
097: accountingLine.getFinancialDocumentMonth10LineAmount());
098: simpleValues.put("financialDocumentMonth11LineAmount",
099: accountingLine.getFinancialDocumentMonth11LineAmount());
100: simpleValues.put("financialDocumentMonth12LineAmount",
101: accountingLine.getFinancialDocumentMonth12LineAmount());
102:
103: return simpleValues;
104: }
105:
106: /**
107: * Copies {@link BudgetAdjustmentAccountingLine} values
108: *
109: * @param toLine the line to copy values to
110: * @param fromLine the line to take the values to use in writing to the toLine
111: */
112: public static void copyFrom(BudgetAdjustmentAccountingLine toLine,
113: AccountingLine other) {
114: if (BudgetAdjustmentAccountingLine.class.isAssignableFrom(other
115: .getClass())) {
116: BudgetAdjustmentAccountingLine fromLine = (BudgetAdjustmentAccountingLine) other;
117: if (toLine != fromLine) {
118: toLine.setCurrentBudgetAdjustmentAmount(fromLine
119: .getCurrentBudgetAdjustmentAmount());
120: toLine.setBaseBudgetAdjustmentAmount(fromLine
121: .getBaseBudgetAdjustmentAmount());
122: toLine.setFinancialDocumentMonth1LineAmount(fromLine
123: .getFinancialDocumentMonth1LineAmount());
124: toLine.setFinancialDocumentMonth2LineAmount(fromLine
125: .getFinancialDocumentMonth2LineAmount());
126: toLine.setFinancialDocumentMonth3LineAmount(fromLine
127: .getFinancialDocumentMonth3LineAmount());
128: toLine.setFinancialDocumentMonth4LineAmount(fromLine
129: .getFinancialDocumentMonth4LineAmount());
130: toLine.setFinancialDocumentMonth5LineAmount(fromLine
131: .getFinancialDocumentMonth5LineAmount());
132: toLine.setFinancialDocumentMonth6LineAmount(fromLine
133: .getFinancialDocumentMonth6LineAmount());
134: toLine.setFinancialDocumentMonth7LineAmount(fromLine
135: .getFinancialDocumentMonth7LineAmount());
136: toLine.setFinancialDocumentMonth8LineAmount(fromLine
137: .getFinancialDocumentMonth8LineAmount());
138: toLine.setFinancialDocumentMonth9LineAmount(fromLine
139: .getFinancialDocumentMonth9LineAmount());
140: toLine.setFinancialDocumentMonth10LineAmount(fromLine
141: .getFinancialDocumentMonth10LineAmount());
142: toLine.setFinancialDocumentMonth11LineAmount(fromLine
143: .getFinancialDocumentMonth11LineAmount());
144: toLine.setFinancialDocumentMonth12LineAmount(fromLine
145: .getFinancialDocumentMonth12LineAmount());
146: toLine.setFringeBenefitIndicator(fromLine
147: .isFringeBenefitIndicator());
148: }
149: }
150: }
151:
152: /**
153: * Calculates monthlyLines total amount@param accountingLine
154: *
155: * @return KualiDecimal sum of all monthly line amounts
156: */
157: public static KualiDecimal getMonthlyLinesTotal(
158: BudgetAdjustmentAccountingLine accountingLine) {
159: KualiDecimal total = KualiDecimal.ZERO;
160: if (accountingLine.getFinancialDocumentMonth1LineAmount() != null) {
161: total = total.add(accountingLine
162: .getFinancialDocumentMonth1LineAmount());
163: }
164: if (accountingLine.getFinancialDocumentMonth2LineAmount() != null) {
165: total = total.add(accountingLine
166: .getFinancialDocumentMonth2LineAmount());
167: }
168: if (accountingLine.getFinancialDocumentMonth3LineAmount() != null) {
169: total = total.add(accountingLine
170: .getFinancialDocumentMonth3LineAmount());
171: }
172: if (accountingLine.getFinancialDocumentMonth4LineAmount() != null) {
173: total = total.add(accountingLine
174: .getFinancialDocumentMonth4LineAmount());
175: }
176: if (accountingLine.getFinancialDocumentMonth5LineAmount() != null) {
177: total = total.add(accountingLine
178: .getFinancialDocumentMonth5LineAmount());
179: }
180: if (accountingLine.getFinancialDocumentMonth6LineAmount() != null) {
181: total = total.add(accountingLine
182: .getFinancialDocumentMonth6LineAmount());
183: }
184: if (accountingLine.getFinancialDocumentMonth7LineAmount() != null) {
185: total = total.add(accountingLine
186: .getFinancialDocumentMonth7LineAmount());
187: }
188: if (accountingLine.getFinancialDocumentMonth8LineAmount() != null) {
189: total = total.add(accountingLine
190: .getFinancialDocumentMonth8LineAmount());
191: }
192: if (accountingLine.getFinancialDocumentMonth9LineAmount() != null) {
193: total = total.add(accountingLine
194: .getFinancialDocumentMonth9LineAmount());
195: }
196: if (accountingLine.getFinancialDocumentMonth10LineAmount() != null) {
197: total = total.add(accountingLine
198: .getFinancialDocumentMonth10LineAmount());
199: }
200: if (accountingLine.getFinancialDocumentMonth11LineAmount() != null) {
201: total = total.add(accountingLine
202: .getFinancialDocumentMonth11LineAmount());
203: }
204: if (accountingLine.getFinancialDocumentMonth12LineAmount() != null) {
205: total = total.add(accountingLine
206: .getFinancialDocumentMonth12LineAmount());
207: }
208: return total;
209: }
210:
211: }
|