Search in sources :

Example 1 with Account

use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.

the class CUAccountMaintainableImpl method saveBusinessObject.

@Override
public void saveBusinessObject() {
    boolean isClosingAccount = isClosingAccount();
    Account account = (Account) getBusinessObject();
    AccountExtendedAttribute aea = (AccountExtendedAttribute) (account.getExtension());
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    HashMap<String, String> keys = new HashMap<String, String>();
    keys.put("programCode", aea.getProgramCode());
    keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
    SubFundProgram sfp = (SubFundProgram) bos.findByPrimaryKey(SubFundProgram.class, keys);
    aea.setSubFundProgram(sfp);
    aea.setSubFundGroupCode(account.getSubFundGroupCode());
    keys = new HashMap<String, String>();
    keys.put("appropriationAccountNumber", aea.getAppropriationAccountNumber());
    keys.put(SUB_FUND_GROUP_CODE, aea.getSubFundGroupCode());
    AppropriationAccount aan = (AppropriationAccount) bos.findByPrimaryKey(AppropriationAccount.class, keys);
    aea.setAppropriationAccount(aan);
    if (account.isClosed() && aea.getAccountClosedDate() == null) {
        aea.setAccountClosedDate(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate());
    } else if (!account.isClosed() && aea.getAccountClosedDate() != null) {
        aea.setAccountClosedDate(null);
    }
    super.saveBusinessObject();
    // trickle down Account Reversion inactivation
    if (isClosingAccount) {
        SpringContext.getBean(AccountReversionTrickleDownInactivationService.class).trickleDownInactivateAccountReversions((Account) getBusinessObject(), getDocumentNumber());
    }
    // content and will display any future notes on account edits as well
    try {
        Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
        Account xmlaccount = (Account) ((MaintenanceDocument) document).getNewMaintainableObject().getBusinessObject();
        if (ObjectUtils.isNull(xmlaccount.getObjectId()) && (KFSConstants.MAINTENANCE_NEW_ACTION.equals(getMaintenanceAction()) || KFSConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction()))) {
            ((MaintenanceDocument) document).getNewMaintainableObject().setBusinessObject(account);
            SpringContext.getBean(DocumentService.class).saveDocument(document);
        }
    } catch (Exception e) {
        LOG.error("Account doc not saved successfully " + e.getMessage());
    }
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) HashMap(java.util.HashMap) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) AccountReversionTrickleDownInactivationService(edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document) DocumentService(org.kuali.kfs.krad.service.DocumentService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) SubFundProgram(edu.cornell.kfs.coa.businessobject.SubFundProgram)

Example 2 with Account

use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.

the class CUAccountMaintainableImpl method getSections.

/**
 * Overridden to force the old maintenance object to include the relevant ICR account sections
 * if the new object has them. This is necessary to work around a section size mismatch issue
 * on certain ACCT maintenance documents.
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument, Maintainable)
 */
@SuppressWarnings("rawtypes")
@Override
public List getSections(org.kuali.kfs.kns.document.MaintenanceDocument document, Maintainable oldMaintainable) {
    // The special handling only applies to the old maintainable.
    if (this == document.getOldMaintainableObject()) {
        Account oldAccount = (Account) getDataObject();
        Account newAccount = (Account) document.getNewMaintainableObject().getDataObject();
        if (oldAccount.getIndirectCostRecoveryAccounts().size() < newAccount.getIndirectCostRecoveryAccounts().size()) {
            // If necessary, add ICR accounts on the old account to match the quantity on the new account.
            List sections;
            List<IndirectCostRecoveryAccount> oldIcrAccounts = oldAccount.getIndirectCostRecoveryAccounts();
            oldAccount.setIndirectCostRecoveryAccounts(new ArrayList<IndirectCostRecoveryAccount>());
            for (IndirectCostRecoveryAccount oldIcrAccount : oldIcrAccounts) {
                oldAccount.getIndirectCostRecoveryAccounts().add((IndirectCostRecoveryAccount) ObjectUtils.deepCopy(oldIcrAccount));
            }
            for (int i = newAccount.getIndirectCostRecoveryAccounts().size() - oldAccount.getIndirectCostRecoveryAccounts().size() - 1; i >= 0; i--) {
                oldAccount.getIndirectCostRecoveryAccounts().add(new IndirectCostRecoveryAccount());
            }
            // Generate the sections using the temporarily-overridden list.
            sections = super.getSections(document, oldMaintainable);
            oldAccount.setIndirectCostRecoveryAccounts(oldIcrAccounts);
            return sections;
        }
    }
    return super.getSections(document, oldMaintainable);
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with Account

use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.

the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.

// KFSUPGRADE-765 :  Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
    String maintAction = super.getMaintenanceAction();
    boolean retval = false;
    if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
            // We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
            // "new" subAccount for data comparisons
            A21SubAccount newSubAccount = subAccount.getA21SubAccount();
            // "existing" data that would have pre-populated
            Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
            if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
                List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
                List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
                if (CollectionUtils.isEmpty(subAcctIcr)) {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = false;
                    } else {
                        retval = true;
                    }
                } else {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = true;
                    } else {
                        /*
                        	 * the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
                        	 */
                        int activeAcctIcrCount = 0;
                        for (IndirectCostRecoveryAccount acct : acctIcr) {
                            if (acct.isActive()) {
                                activeAcctIcrCount++;
                            }
                        }
                        if (subAcctIcr.size() == activeAcctIcrCount) {
                            retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
                        } else {
                            retval = true;
                        }
                    }
                }
            }
        }
    } else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        // "new" subAccount for data comparisons
        A21SubAccount newSubAccount = subAccount.getA21SubAccount();
        if (ObjectUtils.isNotNull(newSubAccount)) {
            try {
                MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
                A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
                retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
            } catch (Exception e) {
                LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
            }
        }
    }
    return retval;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 4 with Account

use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.

the class CuScrubberValidatorImpl method checkAccountFringeIndicator.

/**
 * Overridden to clear out the sub-account number on fringe transactions
 * if the transaction had its account number modified.
 *
 * @see org.kuali.kfs.module.ld.batch.service.impl.ScrubberValidatorImpl#checkAccountFringeIndicator(
 * org.kuali.kfs.module.ld.businessobject.LaborOriginEntry, org.kuali.kfs.module.ld.businessobject.LaborOriginEntry,
 * org.kuali.kfs.coa.businessobject.Account, org.kuali.kfs.sys.businessobject.UniversityDate,
 * org.kuali.kfs.module.ld.batch.service.LaborAccountingCycleCachingService)
 */
@Override
protected Message checkAccountFringeIndicator(LaborOriginEntry laborOriginEntry, LaborOriginEntry laborWorkingEntry, Account account, UniversityDate universityRunDate, LaborAccountingCycleCachingService laborAccountingCycleCachingService) {
    LaborObject laborObject = laborAccountingCycleCachingService.getLaborObject(laborOriginEntry.getUniversityFiscalYear(), laborOriginEntry.getChartOfAccountsCode(), laborOriginEntry.getFinancialObjectCode());
    boolean isFringeTransaction = laborObject != null && org.apache.commons.lang.StringUtils.equals(LaborConstants.BenefitExpenseTransfer.LABOR_LEDGER_BENEFIT_CODE, laborObject.getFinancialObjectFringeOrSalaryCode());
    if (isFringeTransaction && !account.isAccountsFringesBnftIndicator()) {
        Account altAccount = accountService.getByPrimaryId(laborOriginEntry.getAccount().getReportsToChartOfAccountsCode(), laborOriginEntry.getAccount().getReportsToAccountNumber());
        if (ObjectUtils.isNotNull(altAccount)) {
            laborWorkingEntry.setAccount(altAccount);
            laborWorkingEntry.setAccountNumber(altAccount.getAccountNumber());
            laborWorkingEntry.setChartOfAccountsCode(altAccount.getChartOfAccountsCode());
            Message err = handleExpiredClosedAccount(altAccount, laborOriginEntry, laborWorkingEntry, universityRunDate);
            if (err == null) {
                err = MessageBuilder.buildMessageWithPlaceHolder(LaborKeyConstants.MESSAGE_FRINGES_MOVED_TO, Message.TYPE_WARNING, new Object[] { altAccount.getAccountNumber() });
            }
            clearSubAccountOnModifiedFringeTransaction(laborOriginEntry, laborWorkingEntry, laborAccountingCycleCachingService, err);
            return err;
        }
        boolean suspenseAccountLogicInd = parameterService.getParameterValueAsBoolean(LaborScrubberStep.class, LaborConstants.Scrubber.SUSPENSE_ACCOUNT_LOGIC_PARAMETER);
        if (suspenseAccountLogicInd) {
            return useSuspenseAccount(laborWorkingEntry);
        }
        return MessageBuilder.buildMessage(LaborKeyConstants.ERROR_NON_FRINGE_ACCOUNT_ALTERNATIVE_NOT_FOUND, Message.TYPE_FATAL);
    }
    return handleExpiredClosedAccount(account, laborOriginEntry, laborWorkingEntry, universityRunDate);
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) Message(org.kuali.kfs.sys.Message) LaborObject(org.kuali.kfs.module.ld.businessobject.LaborObject) LaborObject(org.kuali.kfs.module.ld.businessobject.LaborObject)

Example 5 with Account

use of org.kuali.kfs.coa.businessobject.Account in project cu-kfs by CU-CommunityApps.

the class TransactionRowBuilder method checkForEntityAndAccountAndOrgExistence.

/**
 * Helper method for checking if entity, account, and org objects exist
 * for the current tax source row. Certain statistics will be updated
 * accordingly if one or more of these objects cannot not be found.
 * The initiator's principal name will also be returned, if found.
 *
 * @param initiatorPrincipalId The document initiator's principal ID; may be blank.
 * @param chartCode The chart code; may be blank.
 * @param accountNumber The account number; may be blank.
 * @param summary The object encapsulating the tax-type-specific summary info.
 * @return The initiator's principal name, or null if a principal name could not be found.
 */
String checkForEntityAndAccountAndOrgExistence(String initiatorPrincipalId, String chartCode, String accountNumber, T summary) {
    Account account;
    EntityNamePrincipalName entityName;
    // Check for null entity name info.
    entityName = (StringUtils.isNotBlank(initiatorPrincipalId)) ? identityService.getDefaultNamesForPrincipalId(initiatorPrincipalId) : null;
    if (entityName == null) {
        numNoEntityName++;
    }
    // Check for null account or null org.
    account = (StringUtils.isNotBlank(chartCode) && StringUtils.isNotBlank(accountNumber)) ? accountService.getByPrimaryIdWithCaching(chartCode, accountNumber) : null;
    if (account != null) {
        if (organizationService.getByPrimaryIdWithCaching(chartCode, account.getOrganizationCode()) == null) {
            numNoOrg++;
        }
    } else {
        numNoAccount++;
    }
    // Return the initiator's principal name, if found.
    return (entityName != null) ? entityName.getPrincipalName() : null;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) EntityNamePrincipalName(org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName)

Aggregations

Account (org.kuali.kfs.coa.businessobject.Account)38 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)14 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)11 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)9 HashMap (java.util.HashMap)6 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)6 ArrayList (java.util.ArrayList)5 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)5 List (java.util.List)4 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)4 Message (org.kuali.kfs.sys.Message)4 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)3 AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)2 SubFundProgram (edu.cornell.kfs.coa.businessobject.SubFundProgram)2 Date (java.sql.Date)2 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)2 AccountService (org.kuali.kfs.coa.service.AccountService)2 SubAccountService (org.kuali.kfs.coa.service.SubAccountService)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 DocumentService (org.kuali.kfs.krad.service.DocumentService)2