001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.pdp.web.struts;
017
018 import java.util.ArrayList;
019 import java.util.List;
020 import java.util.Map;
021
022 import javax.servlet.http.HttpServletRequest;
023
024 import org.apache.struts.action.ActionMapping;
025 import org.kuali.kfs.pdp.PdpPropertyConstants;
026 import org.kuali.kfs.pdp.businessobject.CustomerProfile;
027 import org.kuali.kfs.pdp.businessobject.DisbursementNumberFormatter;
028 import org.kuali.kfs.pdp.businessobject.DisbursementNumberRange;
029 import org.kuali.kfs.pdp.businessobject.FormatProcessSummary;
030 import org.kuali.kfs.sys.KFSPropertyConstants;
031 import org.kuali.rice.kns.util.KNSConstants;
032 import org.kuali.rice.kns.util.KualiInteger;
033 import org.kuali.rice.kns.web.format.CurrencyFormatter;
034 import org.kuali.rice.kns.web.format.Formatter;
035 import org.kuali.rice.kns.web.struts.form.KualiForm;
036
037 /**
038 * Struts Action Form for Format Checks/ACH
039 */
040 public class FormatForm extends KualiForm {
041
042 private String campus;
043 private String paymentDate;
044 private String paymentTypes;
045
046 private FormatProcessSummary formatProcessSummary;
047
048 private List<CustomerProfile> customers;
049 private List<DisbursementNumberRange> ranges;
050
051 /**
052 * Constructs a FormatForm.
053 */
054 public FormatForm() {
055 super();
056 customers = new ArrayList<CustomerProfile>();
057 ranges = new ArrayList<DisbursementNumberRange>();
058
059 this.setFormatterType("range.lastAssignedDisbNbr", DisbursementNumberFormatter.class);
060 }
061
062 /**
063 * This method gets campus
064 *
065 * @return campus
066 */
067 public String getCampus() {
068 return campus;
069 }
070
071 /**
072 * This method sets campus
073 *
074 * @param campus
075 */
076 public void setCampus(String campus) {
077 this.campus = campus;
078 }
079
080 /**
081 * This method gets payment types
082 *
083 * @return paymentTypes
084 */
085 public String getPaymentTypes() {
086 return paymentTypes;
087 }
088
089 /**
090 * This method sets paymentTypes
091 *
092 * @param paymentTypes
093 */
094 public void setPaymentTypes(String paymentTypes) {
095 this.paymentTypes = paymentTypes;
096 }
097
098 /**
099 * This method gets customers
100 *
101 * @return customers
102 */
103 public List<CustomerProfile> getCustomers() {
104 return customers;
105 }
106
107 /**
108 * This method sets customers
109 *
110 * @param customers
111 */
112 public void setCustomers(List<CustomerProfile> customers) {
113 this.customers = customers;
114 }
115
116 /**
117 * This method retrieves a specific customer profile from the list, by index
118 *
119 * @param index the index of the customers to retrieve the customer profile from
120 * @return a CustomerProfile
121 */
122 public CustomerProfile getCustomer(int index) {
123 if (index >= customers.size()) {
124 for (int i = customers.size(); i <= index; i++) {
125 customers.add(new CustomerProfile());
126 }
127 }
128 return (CustomerProfile) customers.get(index);
129 }
130
131 /**
132 * This method sets a customer profile.
133 *
134 * @param key the index of the value
135 * @param value the new value
136 */
137 public void setCustomer(int key, CustomerProfile value) {
138 customers.set(key, value);
139 }
140
141
142 /**
143 * This method gets the ranges.
144 *
145 * @return ranges list
146 */
147 public List<DisbursementNumberRange> getRanges() {
148 return ranges;
149 }
150
151 /**
152 * This method sets ranges list.
153 *
154 * @param ranges
155 */
156 public void setRanges(List<DisbursementNumberRange> ranges) {
157 this.ranges = ranges;
158 }
159
160 /**
161 * This method retrieves a specific disbursement number range from the list, by index
162 *
163 * @param index the index of the ranges to retrieve the disbursement number range from
164 * @return a DisbursementNumberRange
165 */
166 public DisbursementNumberRange getRange(int index) {
167 if (index >= ranges.size()) {
168 for (int i = ranges.size(); i <= index; i++) {
169 ranges.add(new DisbursementNumberRange());
170 }
171 }
172 return (DisbursementNumberRange) ranges.get(index);
173 }
174
175 /**
176 * This method gets the currency formated value of the total amount.
177 *
178 * @return the currency formated value of the total amount
179 */
180 public String getCurrencyFormattedTotalAmount() {
181 return (String) new CurrencyFormatter().format(formatProcessSummary.getTotalAmount());
182 }
183
184 /**
185 * This method gets the payment date.
186 *
187 * @return paymentDate
188 */
189 public String getPaymentDate() {
190 return paymentDate;
191 }
192
193 /**
194 * This method sets the payment date.
195 *
196 * @param paymentDate
197 */
198 public void setPaymentDate(String paymentDate) {
199 this.paymentDate = paymentDate;
200 }
201
202 /**
203 * This method gets the format process summary.
204 *
205 * @return formatProcessSummary
206 */
207 public FormatProcessSummary getFormatProcessSummary() {
208 return formatProcessSummary;
209 }
210
211 /**
212 * This method sets the format process summary.
213 *
214 * @param formatProcessSummary
215 */
216 public void setFormatProcessSummary(FormatProcessSummary formatProcessSummary) {
217 this.formatProcessSummary = formatProcessSummary;
218 }
219
220 /**
221 * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
222 */
223 @Override
224 public void reset(ActionMapping arg0, HttpServletRequest arg1) {
225 super.reset(arg0, arg1);
226
227 for (CustomerProfile customer : customers) {
228 customer.setSelectedForFormat(false);
229 }
230 }
231 }