View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.sys.fixture;
20  
21  import java.sql.Date;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.kfs.coa.businessobject.Account;
25  import org.kuali.rice.krad.service.BusinessObjectService;
26  
27  public enum AccountFixture {
28      ACTIVE_ACCOUNT(null, null, false, null, null, "2101-09-30"), CLOSED_ACCOUNT(null, null, true, null, null, null), EXPIRIED_ACCOUNT("BL", "1031467", false, "BL", "2331489", "2001-09-30"), EXPIRIED_ACCOUNT_NO_CONTINUATION("BL", "1031467", false, null, null, "2001-09-30"), EXPIRIED_ACCOUNT_EXPIRIED_AND_OPEN_CONTINUATION("BL", "fixture1", false, "BL", "4631644", "2001-09-30"), EXPIRIED_ACCOUNT_EXPIRIED_AND_CLOSED_CONTINUATION("BL", "fixture1", false, "BL", "4031425", "2001-09-30"), ACCOUNT_PRESENCE_ACCOUNT("BL", "4031416", false, null, null, null), ACCOUNT_NON_PRESENCE_ACCOUNT("BA", "6044900", false, null, null, null), ACCOUNT_PRESENCE_ACCOUNT_WITH_EXPIRED("BL", "4831483", false, null, null, "2001-09-30"), ACCOUNT_PRESENCE_ACCOUNT_BUT_CLOSED("BL", "4831483", false, null, null, null), ;
29  
30      public final String accountNumber;
31      public final String chartOfAccountsCode;
32      public final boolean closed;
33      private final String accountExpirationDate;
34      public final String continuationFinChrtOfAcctCd;
35      public final String continuationAccountNumber;
36  
37      private AccountFixture(String chartOfAccountsCode, String accountNumber, boolean closed, String continuationFinChrtOfAcctCd, String continuationAccountNumber, String accountExpirationDate) {
38          this.accountNumber = accountNumber;
39          this.chartOfAccountsCode = chartOfAccountsCode;
40          this.closed = closed;
41          this.accountExpirationDate = accountExpirationDate;
42          this.continuationFinChrtOfAcctCd = continuationFinChrtOfAcctCd;
43          this.continuationAccountNumber = continuationAccountNumber;
44      }
45  
46      public Account createAccount() {
47          Account account = new Account();
48          account.setAccountNumber(this.accountNumber);
49          account.setChartOfAccountsCode(this.chartOfAccountsCode);
50          account.setActive(!this.closed);
51          account.setContinuationAccountNumber(this.continuationAccountNumber);
52          account.setContinuationFinChrtOfAcctCd(this.continuationFinChrtOfAcctCd);
53          if (StringUtils.isNotBlank(this.accountExpirationDate)) {
54              account.setAccountExpirationDate(getAccountExpirationDate());
55          }
56  
57          return account;
58      }
59  
60      public Account createAccount(BusinessObjectService businessObjectService) {
61          return (Account) businessObjectService.retrieve(this.createAccount());
62      }
63  
64      public Date getAccountExpirationDate() {
65          return Date.valueOf(this.accountExpirationDate);
66      }
67  
68  }