001/*
002 * Created on Apr 14, 2005
003 *
004 */
005package org.kuali.ole.module.purap.exception;
006
007import org.kuali.ole.coa.businessobject.Account;
008
009import java.io.Serializable;
010import java.util.ArrayList;
011import java.util.Iterator;
012import java.util.List;
013
014
015/**
016 * @author tdurkin
017 */
018public class PaymentRequestInitializationValidationErrors implements Serializable {
019
020    //    public List errorMessages = new ArrayList();
021    private List expiredAccounts = new ArrayList();
022    private List closedAccounts = new ArrayList();
023    private Integer purchaseOrderNumberToUse;
024    public boolean canAutoClosePO = false;
025
026    private List<PREQCreationFailure> PREQCreationFailures = new ArrayList<PREQCreationFailure>();
027
028    public void addPREQCreationFailure(String rejectReasonCode,
029                                       String extraDescription) {
030
031        PREQCreationFailure rejectReason = new PREQCreationFailure();
032        rejectReason.setRejectReasonCode(rejectReasonCode);
033        rejectReason.setExtraDescription(extraDescription);
034        PREQCreationFailures.add(rejectReason);
035    }
036
037    public PREQCreationFailure[] getPREQCreationFailures() {
038        if (PREQCreationFailures.size() > 0) {
039            PREQCreationFailure[] rejectReasons = new PREQCreationFailure[this.PREQCreationFailures.size()];
040            return this.PREQCreationFailures.toArray(rejectReasons);
041        } else {
042            return null;
043        }
044    }
045
046    public void addExpiredAccount(Account expiredAccount) {
047        expiredAccounts.add(new AccountContinuation(expiredAccount));
048    }
049
050    public void addClosedAccount(Account closedAccount) {
051        closedAccounts.add(new AccountContinuation(closedAccount));
052    }
053
054    public void addExpiredAccount(AccountContinuation expiredAccount) {
055        expiredAccounts.add(expiredAccount);
056    }
057
058    public void addClosedAccount(AccountContinuation closedAccount) {
059        closedAccounts.add(closedAccount);
060    }
061
062    public boolean isClosedAccountsValid() {
063        return this.isListMembersValid(closedAccounts);
064    }
065
066    public boolean isExpiredAccountsValid() {
067        return this.isListMembersValid(expiredAccounts);
068    }
069
070    public boolean isListMembersValid(List l) {
071        for (Iterator i = l.iterator(); i.hasNext(); ) {
072            AccountContinuation acctCont = (AccountContinuation) i.next();
073            if (acctCont.getReplacementAccountValid() == null || acctCont.getReplacementAccountValid().equals(Boolean.FALSE)) {
074                return false;
075            }
076        }
077        return true;
078    }
079
080    public Integer getPurchaseOrderNumberToUse() {
081        return purchaseOrderNumberToUse;
082    }
083
084    public void setPurchaseOrderNumberToUse(Integer purchaseOrderNumberToUse) {
085        this.purchaseOrderNumberToUse = purchaseOrderNumberToUse;
086    }
087
088    public boolean isCanAutoClosePO() {
089        return canAutoClosePO;
090    }
091
092    public void setCanAutoClosePO(boolean canAutoClosePO) {
093        this.canAutoClosePO = canAutoClosePO;
094    }
095
096    public class AccountContinuation implements Serializable {
097
098        private String accountFinancialChartOfAccountsCode;
099        private String accountAccountNumber;
100        private String replacementFinancialChartOfAccountsCode;
101        private String replacementAccountNumber;
102        private Boolean replacementAccountValid;
103
104        public AccountContinuation(Account account) {
105            this.accountFinancialChartOfAccountsCode = account.getChartOfAccountsCode();
106            this.accountAccountNumber = account.getAccountNumber();
107            this.replacementFinancialChartOfAccountsCode = account.getContinuationFinChrtOfAcctCd();
108            this.replacementAccountNumber = account.getContinuationAccountNumber();
109        }
110
111        public void setAccountFinancialChartOfAccountsCode(String accountFinancialChartOfAccountsCode) {
112            this.accountFinancialChartOfAccountsCode = accountFinancialChartOfAccountsCode;
113        }
114
115        public String getAccountFinancialChartOfAccountsCode() {
116            return accountFinancialChartOfAccountsCode;
117        }
118
119        public void setAccountAccountNumber(String accountAccountNumber) {
120            this.accountAccountNumber = accountAccountNumber;
121        }
122
123        public String getAccountAccountNumber() {
124            return accountAccountNumber;
125        }
126
127        public void setReplacementFinancialChartOfAccountsCode(String continuationFinancialChartOfAccountsCode) {
128            this.replacementFinancialChartOfAccountsCode = continuationFinancialChartOfAccountsCode;
129        }
130
131        public String getReplacementFinancialChartOfAccountsCode() {
132            return replacementFinancialChartOfAccountsCode;
133        }
134
135        public void setReplacementAccountNumber(String continuationAccountNumber) {
136            this.replacementAccountNumber = continuationAccountNumber;
137        }
138
139        public String getReplacementAccountNumber() {
140            return replacementAccountNumber;
141        }
142
143        public Boolean getReplacementAccountValid() {
144            return replacementAccountValid;
145        }
146
147        public void setReplacementAccountValid(Boolean replacementAccountValid) {
148            this.replacementAccountValid = replacementAccountValid;
149        }
150    }
151
152    public final class PREQCreationFailure {
153
154        private String rejectReasonCode;
155        private String extraDescription;
156
157        public String getExtraDescription() {
158            return extraDescription;
159        }
160
161        public void setExtraDescription(String extraDescription) {
162            this.extraDescription = extraDescription;
163        }
164
165        public String getRejectReasonCode() {
166            return rejectReasonCode;
167        }
168
169        public void setRejectReasonCode(String rejectReasonCode) {
170            this.rejectReasonCode = rejectReasonCode;
171        }
172
173    }
174}