001: /*
002: * Copyright 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: /*
017: * Created on Aug 17, 2004
018: *
019: */
020: package org.kuali.module.pdp.service;
021:
022: import java.io.Serializable;
023: import java.math.BigDecimal;
024:
025: import org.apache.commons.lang.builder.EqualsBuilder;
026: import org.apache.commons.lang.builder.HashCodeBuilder;
027: import org.apache.commons.lang.builder.ToStringBuilder;
028: import org.kuali.module.pdp.bo.CustomerProfile;
029: import org.kuali.module.pdp.bo.DisbursementType;
030:
031: /**
032: * @author jsissom
033: */
034: public class FormatResult implements Serializable, Comparable {
035: private Integer procId;
036: private boolean pymtAttachment;
037: private boolean pymtSpecialHandling;
038: private boolean processImmediate;
039: private CustomerProfile cust;
040: private int payments;
041: private BigDecimal amount;
042: private DisbursementType disbursementType;
043: private int beginDisbursementNbr;
044: private int endDisbursementNbr;
045: private String sortGroup = null;
046:
047: public FormatResult() {
048: super ();
049: amount = new BigDecimal(0);
050: payments = 0;
051: }
052:
053: public FormatResult(Integer p, CustomerProfile c) {
054: procId = p;
055: cust = c;
056: amount = new BigDecimal(0);
057: payments = 0;
058: }
059:
060: public String getSortGroupId() {
061: if (sortGroup == null) {
062: if (isProcessImmediate()) {
063: return "B";
064: } else if (isPymtSpecialHandling()) {
065: return "C";
066: } else if (isPymtAttachment()) {
067: return "D";
068: } else {
069: return "E";
070: }
071: } else {
072: return sortGroup;
073: }
074: }
075:
076: public String getSortGroupName() {
077: String sortGroup = getSortGroupId();
078: if ("B".equals(sortGroup)) {
079: return "Immediate";
080: } else if ("C".equals(sortGroup)) {
081: return "Special Handling";
082: } else if ("D".equals(sortGroup)) {
083: return "Attachment";
084: } else {
085: return "Other";
086: }
087: }
088:
089: public String getSortGroupOverride() {
090: return sortGroup;
091: }
092:
093: public void setSortGroupOverride(String sortGroup) {
094: this .sortGroup = sortGroup;
095: }
096:
097: public boolean isProcessImmediate() {
098: return processImmediate;
099: }
100:
101: public void setProcessImmediate(boolean processImmediate) {
102: this .processImmediate = processImmediate;
103: }
104:
105: public boolean isPymtAttachment() {
106: return pymtAttachment;
107: }
108:
109: public void setPymtAttachment(boolean pymtAttachment) {
110: this .pymtAttachment = pymtAttachment;
111: }
112:
113: public boolean isPymtSpecialHandling() {
114: return pymtSpecialHandling;
115: }
116:
117: public void setPymtSpecialHandling(boolean pymtSpecialHandling) {
118: this .pymtSpecialHandling = pymtSpecialHandling;
119: }
120:
121: public int getBeginDisbursementNbr() {
122: return beginDisbursementNbr;
123: }
124:
125: public void setBeginDisbursementNbr(int beginDisbursementNbr) {
126: this .beginDisbursementNbr = beginDisbursementNbr;
127: }
128:
129: public DisbursementType getDisbursementType() {
130: return disbursementType;
131: }
132:
133: public void setDisbursementType(DisbursementType disbursementType) {
134: this .disbursementType = disbursementType;
135: }
136:
137: public int getEndDisbursementNbr() {
138: return endDisbursementNbr;
139: }
140:
141: public void setEndDisbursementNbr(int endDisbursementNbr) {
142: this .endDisbursementNbr = endDisbursementNbr;
143: }
144:
145: public BigDecimal getAmount() {
146: return amount;
147: }
148:
149: public void setAmount(BigDecimal amount) {
150: this .amount = amount;
151: }
152:
153: public CustomerProfile getCust() {
154: return cust;
155: }
156:
157: public void setCust(CustomerProfile cust) {
158: this .cust = cust;
159: }
160:
161: public int getPayments() {
162: return payments;
163: }
164:
165: public void setPayments(int payments) {
166: this .payments = payments;
167: }
168:
169: public Integer getProcId() {
170: return procId;
171: }
172:
173: public void setProcId(Integer procId) {
174: this .procId = procId;
175: }
176:
177: public String getSortString() {
178: StringBuffer sb = new StringBuffer();
179: if (getDisbursementType() != null) {
180: if ("CHCK".equals(getDisbursementType().getCode())) {
181: sb.append("B");
182: } else {
183: sb.append("A");
184: }
185: } else {
186: sb.append("A");
187: }
188: sb.append(getSortGroupId());
189: sb.append(cust.getChartCode());
190: sb.append(cust.getOrgCode());
191: sb.append(cust.getSubUnitCode());
192: return sb.toString();
193: }
194:
195: public int compareTo(Object a) {
196: FormatResult f = (FormatResult) a;
197:
198: return this .getSortString().compareTo(f.getSortString());
199: }
200:
201: public boolean equals(Object obj) {
202: if (!(obj instanceof FormatResult)) {
203: return false;
204: }
205: FormatResult o = (FormatResult) obj;
206: return new EqualsBuilder().append(procId, o.getProcId())
207: .append(getSortGroupId(), o.getSortGroupId()).append(
208: cust, o.getCust()).isEquals();
209: }
210:
211: public int hashCode() {
212: return new HashCodeBuilder(7, 3).append(procId).append(
213: getSortGroupId()).append(cust).toHashCode();
214: }
215:
216: public String toString() {
217: return new ToStringBuilder(this ).append("procId", procId)
218: .append("sortGroupId", getSortGroupId()).append("cust",
219: cust).toString();
220: }
221: }
|