Search in sources :

Example 1 with AccountReversion

use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.

the class AccountReversionMaintainableImpl method setBusinessObject.

/**
 * pre-populate the static list of details with each category
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#setBusinessObject(org.kuali.kfs.kns.bo.BusinessObject)
 */
public void setBusinessObject(PersistableBusinessObject businessObject) {
    AccountReversionService accountReversionService = SpringContext.getBean(AccountReversionService.class);
    AccountReversion accountReversion = (AccountReversion) businessObject;
    List<AccountReversionDetail> details = accountReversion.getAccountReversionDetails();
    if (details == null) {
        details = new ArrayList<AccountReversionDetail>();
        accountReversion.setAccountReversionDetails(details);
    }
    if (details.size() == 0) {
        Collection<ReversionCategory> categories = accountReversionService.getCategoryList();
        for (ReversionCategory category : categories) {
            if (category.isActive()) {
                AccountReversionDetail detail = new AccountReversionDetail();
                detail.setAccountReversionCategoryCode(category.getReversionCategoryCode());
                detail.setReversionCategory(category);
                details.add(detail);
            }
        }
        Collections.sort(details, new categoryComparator());
    }
    super.setBusinessObject(businessObject);
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) AccountReversionDetail(edu.cornell.kfs.coa.businessobject.AccountReversionDetail) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Example 2 with AccountReversion

use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.

the class AccountReversionServiceImplTest method testGetByPrimaryId.

public void testGetByPrimaryId() {
    // Grab data from bo service
    AccountReversion accountReversionBaseData = AccountReversionFixture.ACCOUNT_REVERSION_GOOD.createAccountReversion(businessObjectService);
    // Grab data via service
    AccountReversion accountReversion = accountReversionService.getByPrimaryId(2014, "IT", "G254700");
    // compare that the data is the same
    assertEquals(accountReversionBaseData.getBudgetReversionChartOfAccountsCode(), accountReversion.getBudgetReversionChartOfAccountsCode());
    assertEquals(accountReversionBaseData.getBudgetReversionAccountNumber(), accountReversion.getBudgetReversionAccountNumber());
    assertEquals(accountReversionBaseData.getCashReversionFinancialChartOfAccountsCode(), accountReversion.getCashReversionFinancialChartOfAccountsCode());
    assertEquals(accountReversionBaseData.getCashReversionChartCashObjectCode(), accountReversion.getCashReversionChartCashObjectCode());
    assertEquals(accountReversionBaseData.getCashReversionAccountNumber(), accountReversion.getCashReversionAccountNumber());
    assertEquals(accountReversionBaseData.isCarryForwardByObjectCodeIndicator(), accountReversion.isCarryForwardByObjectCodeIndicator());
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion)

Example 3 with AccountReversion

use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.

the class AccountReversionImportServiceImpl method importAccountReversions.

/* (non-Javadoc)
	 * @see edu.cornell.kfs.coa.service.AccountReversionImportService#importAccountReversions()
	 */
public void importAccountReversions(File f) {
    // KFSPTS-2174 : Repurposed this batch job to append the loaded values to the existing table, rather than delete all current values and reload the tables from scratch
    // arid.destroyAccountReversionsAndDetails();
    int count = 0;
    String objectCode = parameterService.getParameterValueAsString("KFS-COA", "Reversion", "CASH_REVERSION_OBJECT_CODE");
    Integer fiscalYear = Integer.parseInt(parameterService.getParameterValueAsString("KFS-COA", "Reversion", "ACCOUNT_REVERSION_FISCAL_YEAR"));
    try {
        CSVReader reader = new CSVReader(new FileReader(f));
        List<String[]> lines = reader.readAll();
        Object[] array = lines.toArray();
        LOG.info("Read: " + lines.toArray().length + " records");
        for (int i = 0; i < array.length; i++) {
            String[] line = (String[]) array[i];
            String fromChart = line[0];
            String fromAcct = line[1];
            String toChart = line[2];
            String toAcct = line[3];
            LOG.info("Creating Reversion for: from account: " + fromAcct + ": to account " + toAcct);
            if (StringUtils.isNotBlank(fromChart) && StringUtils.isNotBlank(fromAcct) && StringUtils.isNotBlank(toChart) && StringUtils.isNotBlank(toAcct)) {
                AccountReversion exists = null;
                Map<String, String> pks = new HashMap<String, String>();
                pks.put("UNIV_FISCAL_YR", String.valueOf(fiscalYear));
                pks.put("FIN_COA_CD", fromChart);
                pks.put("ACCT_NBR", fromAcct);
                exists = (AccountReversion) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(AccountReversion.class, pks);
                if (ObjectUtils.isNotNull(exists)) {
                    LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
                    continue;
                }
                // Validate from account; cannot add account reversion if account does not exist
                Account fromAcctExists = null;
                fromAcctExists = SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
                if (ObjectUtils.isNull(fromAcctExists)) {
                    LOG.info("From account (" + fromAcct + ") does not exist.");
                    LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
                    continue;
                }
                // Validate to account; cannot add account reversion if account does not exist
                Account toAcctExists = null;
                toAcctExists = SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
                if (ObjectUtils.isNull(toAcctExists)) {
                    LOG.info("To account (" + toAcct + ") does not exist.");
                    LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
                    continue;
                }
                AccountReversion accountReversion = new AccountReversion();
                accountReversion.setUniversityFiscalYear(fiscalYear);
                accountReversion.setChartOfAccountsCode(fromChart);
                accountReversion.setAccountNumber(fromAcct);
                accountReversion.setBudgetReversionChartOfAccountsCode(toChart);
                accountReversion.setBudgetReversionAccountNumber(toAcct);
                accountReversion.setCashReversionFinancialChartOfAccountsCode(toChart);
                accountReversion.setCashReversionAccountNumber(toAcct);
                accountReversion.setCarryForwardByObjectCodeIndicator(false);
                accountReversion.setActive(true);
                AccountReversionDetail accountReversionDetail = new AccountReversionDetail();
                accountReversionDetail.setUniversityFiscalYear(fiscalYear);
                accountReversionDetail.setChartOfAccountsCode(fromChart);
                accountReversionDetail.setAccountNumber(fromAcct);
                accountReversionDetail.setAccountReversionCategoryCode("A1");
                accountReversionDetail.setAccountReversionCode("CA");
                accountReversionDetail.setAccountReversionObjectCode(objectCode);
                accountReversionDetail.setActive(true);
                accountReversion.addAccountReversionDetail(accountReversionDetail);
                boService.save(accountReversion);
                count++;
            }
        }
        reader.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        LOG.info("Wrote: " + count + " records");
    }
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) CSVReader(au.com.bytecode.opencsv.CSVReader) HashMap(java.util.HashMap) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) AccountReversionDetail(edu.cornell.kfs.coa.businessobject.AccountReversionDetail) FileReader(java.io.FileReader)

Example 4 with AccountReversion

use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.

the class AccountReversionTrickleDownInactivationServiceImpl method generateTrickleDownMaintenanceLocks.

/**
 * Will generate Maintenance Locks for all (active or not) AccountReversions in the system related to the inactivated account using the AccountReversion
 * maintainable registered for the AccountReversion maintenance document
 *
 * @see edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService#generateTrickleDownMaintenanceLocks(org.kuali.kfs.coa.businessobject.Account, java.lang.String)
 */
public List<MaintenanceLock> generateTrickleDownMaintenanceLocks(Account inactivatedAccount, String documentNumber) {
    List<MaintenanceLock> maintenanceLocks = new ArrayList<MaintenanceLock>();
    Maintainable accountReversionMaintainable;
    try {
        accountReversionMaintainable = (Maintainable) maintenanceDocumentDictionaryService.getMaintainableClass(AccountReversion.class.getName()).newInstance();
        accountReversionMaintainable.setBoClass(AccountReversion.class);
        accountReversionMaintainable.setDocumentNumber(documentNumber);
    } catch (Exception e) {
        LOG.error("Unable to instantiate Account Reversion Maintainable", e);
        throw new RuntimeException("Unable to instantiate Account Reversion Maintainable", e);
    }
    List<AccountReversion> accountReversionRules = new ArrayList<AccountReversion>();
    List<AccountReversion> matchingAccountReversionRules = accountReversionService.getAccountReversionsByChartAndAccount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
    if (ObjectUtils.isNotNull(matchingAccountReversionRules) && CollectionUtils.isNotEmpty(matchingAccountReversionRules)) {
        accountReversionRules.addAll(matchingAccountReversionRules);
    }
    List<AccountReversion> cashAccountReversionRules = accountReversionService.getAccountReversionsByCashReversionAcount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
    if (ObjectUtils.isNotNull(cashAccountReversionRules) && cashAccountReversionRules.size() > 0) {
        accountReversionRules.addAll(cashAccountReversionRules);
    }
    List<AccountReversion> budgetAccountReversionRules = accountReversionService.getAccountReversionsByBudgetReversionAcount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
    if (ObjectUtils.isNotNull(budgetAccountReversionRules) && budgetAccountReversionRules.size() > 0) {
        accountReversionRules.addAll(budgetAccountReversionRules);
    }
    if (ObjectUtils.isNotNull(accountReversionRules) && !accountReversionRules.isEmpty()) {
        for (AccountReversion accountReversion : accountReversionRules) {
            accountReversionMaintainable.setBusinessObject(accountReversion);
            maintenanceLocks.addAll(accountReversionMaintainable.generateMaintenanceLocks());
        }
    }
    return maintenanceLocks;
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) ArrayList(java.util.ArrayList) MaintenanceLock(org.kuali.kfs.krad.maintenance.MaintenanceLock) Maintainable(org.kuali.kfs.kns.maintenance.Maintainable)

Example 5 with AccountReversion

use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.

the class AccountReversionDaoOjb method getByPrimaryId.

/**
 * @see org.kuali.kfs.coa.dataaccess.OrganizationReversionDao#getByPrimaryId(java.lang.Integer, java.lang.String,
 *      java.lang.String)
 */
public AccountReversion getByPrimaryId(Integer universityFiscalYear, String financialChartOfAccountsCode, String accountNumber) {
    LOG.debug("getByPrimaryId() started");
    Criteria criteria = new Criteria();
    criteria.addEqualTo("universityFiscalYear", universityFiscalYear);
    criteria.addEqualTo("chartOfAccountsCode", financialChartOfAccountsCode);
    criteria.addEqualTo("accountNumber", accountNumber);
    return (AccountReversion) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(AccountReversion.class, criteria));
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria)

Aggregations

AccountReversion (edu.cornell.kfs.coa.businessobject.AccountReversion)12 HashMap (java.util.HashMap)4 AccountReversionDetail (edu.cornell.kfs.coa.businessobject.AccountReversionDetail)3 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)3 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)2 ArrayList (java.util.ArrayList)2 Maintainable (org.kuali.kfs.kns.maintenance.Maintainable)2 MaintenanceLock (org.kuali.kfs.krad.maintenance.MaintenanceLock)2 CSVReader (au.com.bytecode.opencsv.CSVReader)1 FileReader (java.io.FileReader)1 Map (java.util.Map)1 Criteria (org.apache.ojb.broker.query.Criteria)1 QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)1 Account (org.kuali.kfs.coa.businessobject.Account)1 Note (org.kuali.kfs.krad.bo.Note)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1