001/**
002 * Copyright 2005-2015 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 */
016package org.kuali.rice.krad.labs.transaction;
017
018import org.apache.commons.lang.RandomStringUtils;
019import org.kuali.rice.krad.web.form.UifFormBase;
020
021import java.util.ArrayList;
022import java.util.List;
023
024import java.math.BigDecimal;
025import java.text.NumberFormat;
026import java.util.*;
027
028/**
029 * KSA Transaction test form for lab
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033
034public class TransactionForm extends UifFormBase {
035
036    private static final long serialVersionUID = -9062785501387603918L;
037    private String testField;
038    private String accountId;
039
040    private String statusMessage;
041
042/*    private List<Memo> memos;
043    private Tree<Memo, String> memoTree = new Tree<Memo, String>();*/
044
045    private List<TransactionModel> rollupTransactions;
046    private List<TransactionModel> allTransactions;
047
048    private TransactionModel currentTransaction;
049    private List<TransactionModel> currrentTransactionAllocations = new ArrayList<TransactionModel>();
050
051    private List<TransactionModel> deferments;
052
053    private Boolean    showInternal = Boolean.FALSE;
054    private Date       startingDate;
055    private BigDecimal startingBalance = BigDecimal.ZERO;
056    private Date       endingDate;
057    private BigDecimal endingBalance = BigDecimal.ZERO;
058
059    private BigDecimal chargeTotal;
060    private BigDecimal paymentTotal;
061    private BigDecimal defermentTotal;
062    private BigDecimal allocatedTotal;
063    private BigDecimal unallocatedTotal;
064
065    private String newTag;
066/*    private List<Tag> filterTags;*/
067
068    private String zeroBalanceDate;
069    private Set<Date> zeroBalanceDates;
070    private String studentLookupByName;
071
072    private String selectedPersonName;
073/*    private List<Account> accountBrowseList;
074    private List<Charge> chargeList;
075    private List<Payment> paymentList;
076    private Charge charge;
077    private Payment payment;*/
078    private List<Currency> currencies;
079    private Currency currency;
080    private String code;
081    private String currencyName;
082  private String currencyDescription;
083
084/*    private List<Activity> activities;*/
085
086    public TransactionForm(){
087        this.accountId = RandomStringUtils.randomAlphanumeric(4);
088        rollupTransactions = new ArrayList<TransactionModel>();
089        for (int i = 0; i < 10; i++){
090            rollupTransactions.add(new TransactionModel(5));
091        }
092    }
093
094    public String getTestField() {
095        return testField;
096    }
097
098    public void setTestField(String testField) {
099        this.testField = testField;
100    }
101
102    public String getAccountId() {
103        return accountId;
104    }
105
106    public void setAccountId(String accountId) {
107        this.accountId = accountId;
108    }
109
110    /**
111     * Get the student name
112     * Possible uses is a query match for transactions
113     * The value can be a partial matching name
114     *
115     * @return
116     */
117    public String getStudentLookupByName() {
118        return studentLookupByName;
119    }
120
121    /**
122     * Set the student lookup name
123     * Possible uses is a query match for transactions
124     * The value can be a partial matching name
125     *
126     * @param studentLookupByName
127     */
128    public void setStudentLookupByName(String studentLookupByName) {
129        this.studentLookupByName = studentLookupByName;
130    }
131
132    /**
133     * Get the selected person name
134     *
135     * @return
136     */
137    public String getSelectedPersonName() {
138        return selectedPersonName;
139    }
140
141    /**
142     * Set the selected person name
143     *
144     * @param selectedPersonName
145     */
146    public void setSelectedPersonName(String selectedPersonName) {
147        this.selectedPersonName = selectedPersonName;
148    }
149/*
150    *//**
151     * Get the accountBrowseList
152     * Encapsulates Person and Address model
153     *
154     * @return
155     *//*
156    public List<Account> getAccountBrowseList() {
157        return accountBrowseList;
158    }
159
160    *//**
161     * Set the accountBrowseList
162     * Encapsulates Person and Address model
163     *
164     * @param accountBrowseList
165     *//*
166    public void setAccountBrowseList(List<Account> accountBrowseList) {
167        this.accountBrowseList = accountBrowseList;
168    }
169
170    *//**
171     * Get the list of Charges found via a selected Account
172     *
173     * @return
174     *//*
175    public List<Charge> getChargeList() {
176        return chargeList;
177    }
178
179    *//**
180     * Set the list of Charges found via a selected Account
181     *
182     * @param chargeList
183     *//*
184    public void setChargeList(List<Charge> chargeList) {
185        this.chargeList = chargeList;
186    }
187
188    *//**
189     * Get the list of Payments found via a selected Account
190     *
191     * @return
192     *//*
193    public List<Payment> getPaymentList() {
194        return paymentList;
195    }
196
197    *//**
198     * Set the list of Payments found via a selected Account
199     *
200     * @param paymentList
201     *//*
202    public void setPaymentList(List<Payment> paymentList) {
203        this.paymentList = paymentList;
204    }*/
205/*
206    *//**
207     * Get a charge object
208     *
209     * @return
210     *//*
211    public Charge getCharge() {
212        return charge;
213    }
214
215    *//**
216     * Set a charge object
217     *
218     * @param charge
219     *//*
220    public void setCharge(Charge charge) {
221        this.charge = charge;
222    }
223
224    *//**
225     * Get a Payment object
226     *
227     * @return
228     *//*
229    public Payment getPayment() {
230        return payment;
231    }
232
233    *//**
234     * Set a Payment object
235     *
236     * @param payment
237     *//*
238    public void setPayment(Payment payment) {
239        this.payment = payment;
240    }*/
241
242    // Currency get/Set methods
243
244    /**
245     * Get the list of Currency objects
246     *
247     * @return
248     */
249    public List<Currency> getCurrencies() {
250        return currencies;
251    }
252
253    /**
254     * Set the list of Currency objects
255     *
256     * @param currencies
257     */
258    public void setCurrencies(List<Currency> currencies) {
259        this.currencies = currencies;
260    }
261
262    /**
263     * Get the Currency model object
264     *
265     * @return
266     */
267    public Currency getCurrency() {
268        return currency;
269    }
270
271    /**
272     * Set teh Currency model object
273     *
274     * @param currency
275     */
276    public void setCurrency(Currency currency) {
277        this.currency = currency;
278    }
279
280    /**
281     * Get the ISO symbol
282     *
283     * @return
284     */
285    public String getCode() {
286        return code;
287    }
288
289    /**
290     * Set the ISO symbol
291     *
292     * @param code
293     */
294    public void setCode(String code) {
295        this.code = code;
296    }
297
298    /**
299     * Get the currencyName
300     *
301     * @return
302     */
303    public String getCurrencyName() {
304        return currencyName;
305    }
306
307    /**
308     * Set the Name
309     *
310     * @param currencyName
311     */
312    public void setCurrencyName(String currencyName) {
313        this.currencyName = currencyName;
314    }
315
316    /**
317     * Get the currency description
318     *
319     * @return
320     */
321    public String getCurrencyDescription() {
322        return currencyDescription;
323    }
324
325    /**
326     * Set  the currency description
327     *
328     * @param currencyDescription
329     */
330    public void setCurrencyDescription(String currencyDescription) {
331        this.currencyDescription = currencyDescription;
332    }
333
334/*    *//**
335     * Get a list of activities
336     *
337     * @return
338     *//*
339    public List<Activity> getActivities() {
340        return activities;
341    }
342/*
343    public void setActivities(List<Activity> activities) {
344        this.activities = activities;
345    }*/
346
347/*    public Account getAccount() {
348        return account;
349    }
350
351    public void setAccount(Account account) {
352        this.account = account;
353    }*/
354
355/*
356    public void setAlertObjects(List<Alert> alerts) {
357        List<InformationModel> models = new ArrayList<InformationModel>(alerts.size());
358        for(Alert alert : alerts){
359            models.add(new InformationModel(alert));
360        }
361        setAlerts(models);
362    }
363*/
364
365
366/*    public void setFlagObjects(List<Flag> flags) {
367        List<InformationModel> models = new ArrayList<InformationModel>(flags.size());
368        for(Flag flag : flags){
369            models.add(new InformationModel(flag));
370        }
371        setFlags(models);
372    }*/
373
374    public List<TransactionModel> getRollupTransactions() {
375        return rollupTransactions;
376    }
377
378    public void setRollupTransactions(List<TransactionModel> rollupTransactions) {
379        this.rollupTransactions = rollupTransactions;
380    }
381
382    public List<TransactionModel> getAllTransactions() {
383        return allTransactions;
384    }
385
386    public void setAllTransactions(List<TransactionModel> allTransactions) {
387        this.allTransactions = allTransactions;
388    }
389
390/*    public List<Memo> getMemos() {
391        return memos;
392    }*/
393
394/*    public void setMemos(List<Memo> memos) {
395        this.memos = memos;
396    }*/
397
398    public BigDecimal getStartingBalance() {
399        if (this.startingBalance == null) {
400            this.startingBalance = BigDecimal.ZERO;
401        }
402        return startingBalance;
403    }
404
405    public String getFormattedStartingBalance() {
406        NumberFormat percentFormat = NumberFormat.getCurrencyInstance();
407        return percentFormat.format(this.getStartingBalance());
408    }
409
410    public void setStartingBalance(BigDecimal startingBalance) {
411        this.startingBalance = startingBalance;
412    }
413
414    public BigDecimal getEndingBalance() {
415        if (this.endingBalance == null) {
416            this.endingBalance = BigDecimal.ZERO;
417        }
418        return endingBalance;
419    }
420
421    public void setEndingBalance(BigDecimal endingBalance) {
422        this.endingBalance = endingBalance;
423    }
424
425/*    private static int getItemsPerPage() {
426        return Integer.valueOf(ContextUtils.getBean(ConfigService.class).getParameter(Constants.QUICKVIEW_INFORMATION_COUNT));
427    }*/
428
429    public Date getStartingDate() {
430        return startingDate;
431    }
432
433    public void setStartingDate(Date startingDate) {
434        this.startingDate = startingDate;
435    }
436
437    public Date getEndingDate() {
438        return endingDate;
439    }
440
441    public void setEndingDate(Date endingDate) {
442        this.endingDate = endingDate;
443    }
444
445    public String getStatusMessage() {
446        return statusMessage;
447    }
448
449    public void setStatusMessage(String statusMessage) {
450        this.statusMessage = statusMessage;
451    }
452
453    public List<TransactionModel> getDeferments() {
454        if(deferments == null){
455            return new ArrayList<TransactionModel>();
456        }
457        return deferments;
458    }
459
460    public void setDeferments(List<TransactionModel> deferments) {
461        this.deferments = deferments;
462    }
463
464    public BigDecimal getChargeTotal() {
465        if(this.chargeTotal == null){
466            this.chargeTotal = BigDecimal.ZERO;
467        }
468        return chargeTotal;
469    }
470
471    public void setChargeTotal(BigDecimal chargeTotal) {
472        this.chargeTotal = chargeTotal;
473    }
474
475    public void addChargeTotal(BigDecimal chargeTotal){
476        this.chargeTotal = this.getChargeTotal().add(chargeTotal);
477    }
478
479    public BigDecimal getPaymentTotal() {
480        if(this.paymentTotal == null){
481            this.paymentTotal = BigDecimal.ZERO;
482        }
483        return paymentTotal;
484    }
485
486    public void setPaymentTotal(BigDecimal paymentTotal) {
487        this.paymentTotal = paymentTotal;
488    }
489
490    public void addPaymentTotal(BigDecimal paymentTotal){
491        this.paymentTotal = this.getPaymentTotal().add(paymentTotal);
492    }
493
494    public BigDecimal getDefermentTotal() {
495        if(defermentTotal == null){
496            defermentTotal = BigDecimal.ZERO;
497        }
498        return defermentTotal;
499    }
500
501    public void setDefermentTotal(BigDecimal defermentTotal) {
502        this.defermentTotal = defermentTotal;
503    }
504
505    public void addDefermentTotal(BigDecimal defermentTotal){
506        this.defermentTotal = this.getDefermentTotal().add(defermentTotal);
507    }
508
509    public BigDecimal getAllocatedTotal() {
510        if(allocatedTotal == null){
511            allocatedTotal = BigDecimal.ZERO;
512        }
513        return allocatedTotal;
514    }
515
516    public void setAllocatedTotal(BigDecimal allocatedTotal) {
517        this.allocatedTotal = allocatedTotal;
518    }
519
520    public void addAllocatedTotal(BigDecimal allocatedTotal){
521        this.allocatedTotal = this.getAllocatedTotal().add(allocatedTotal);
522    }
523
524    public void subtractAllocatedTotal(BigDecimal allocatedTotal){
525        this.allocatedTotal = this.getAllocatedTotal().subtract(allocatedTotal);
526    }
527
528    public BigDecimal getUnallocatedTotal() {
529        if(unallocatedTotal == null){
530            unallocatedTotal = BigDecimal.ZERO;
531        }
532        return unallocatedTotal;
533    }
534
535    public void setUnallocatedTotal(BigDecimal unallocatedTotal) {
536        this.unallocatedTotal = unallocatedTotal;
537    }
538
539    public void addUnallocatedTotal(BigDecimal unallocatedTotal){
540        this.unallocatedTotal = this.getUnallocatedTotal().add(unallocatedTotal);
541    }
542
543    public void subtractUnallocatedTotal(BigDecimal unallocatedTotal){
544        this.unallocatedTotal = this.getUnallocatedTotal().subtract(unallocatedTotal);
545    }
546
547    public String getNewTag() {
548        return newTag;
549    }
550
551    public void setNewTag(String newTag) {
552        this.newTag = newTag;
553    }
554
555/*    public List<Tag> getFilterTags() {
556        return filterTags;
557    }
558
559    public void setFilterTags(List<Tag> filterTags) {
560        this.filterTags = filterTags;
561    }*/
562
563    public TransactionModel getCurrentTransaction() {
564        return currentTransaction;
565    }
566
567    public void setCurrentTransaction(TransactionModel currentTransaction) {
568        this.currentTransaction = currentTransaction;
569    }
570
571    public List<TransactionModel> getCurrrentTransactionAllocations() {
572        return currrentTransactionAllocations;
573    }
574
575    public void setCurrrentTransactionAllocations(List<TransactionModel> currrentTransactionAllocations) {
576        this.currrentTransactionAllocations = currrentTransactionAllocations;
577    }
578
579    public Boolean getShowInternal() {
580        return showInternal;
581    }
582
583    public void setShowInternal(Boolean showInternal) {
584        this.showInternal = showInternal;
585    }
586
587
588/*    public static String getInformationTooltip(String name, List<InformationModel> items) {
589
590        int itemsPerPage = 10;
591
592        String html = "<b>" + name + " (";
593
594        if (items == null || items.size() == 0) {
595            html += "0/0)</b><br/><p>No " + name + "</p>";
596            return html;
597        }
598
599        int size = items.size();
600
601        if (size > itemsPerPage) {
602            html += itemsPerPage + "/" + size + ")</b><br/>";
603        } else {
604            html += size + "/" + size + ")</b><br/>";
605        }
606
607        html += "<p>";
608        for (int i = 0; i < items.size() && i < itemsPerPage; i++) {
609            html += items.get(i).getDisplayValue() + "<br/>";
610        }
611        html += "</p>";
612
613        return html;
614    }*/
615
616
617    public Set<Date> getZeroBalanceDates() {
618        if(zeroBalanceDates == null) {
619            zeroBalanceDates = new HashSet<Date>();
620        }
621        return zeroBalanceDates;
622    }
623
624    public void setZeroBalanceDates(Set<Date> zeroBalanceDates) {
625        this.zeroBalanceDates = zeroBalanceDates;
626    }
627
628/*    public KeyValuesFinder getZeroBalanceDateFinder() {
629        // Don't cache the values finder or else new entries will not show when added
630
631        TransactionZeroBalanceKeyValues keyValues = new TransactionZeroBalanceKeyValues();
632        keyValues.setBlankOption(true);
633        keyValues.setValues(new ArrayList<Date>(this.getZeroBalanceDates()));
634        return keyValues;
635    }*/
636
637
638    public String getZeroBalanceDate() {
639        return zeroBalanceDate;
640    }
641
642    public void setZeroBalanceDate(String zeroBalanceDate) {
643        this.zeroBalanceDate = zeroBalanceDate;
644    }
645}