Search in sources :

Example 1 with AccountExtendedAttribute

use of edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute 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 AccountExtendedAttribute

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

the class AccountExtensionRule method checkSubFundProgram.

protected boolean checkSubFundProgram(MaintenanceDocument document) {
    boolean success = true;
    String subFundGroupCode = newAccount.getSubFundGroupCode();
    String subFundProg = ((AccountExtendedAttribute) newAccount.getExtension()).getProgramCode();
    // String subFundProgramCode = ((AccountExtendedAttribute)newAccount.getExtension()).getSubFundProgram().getProgramCode();
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    if (!StringUtils.isBlank(subFundProg)) {
        Map fieldValues = new HashMap();
        fieldValues.put("subFundGroupCode", subFundGroupCode);
        fieldValues.put("programCode", subFundProg);
        Collection<SubFundProgram> retVals = bos.findMatching(SubFundProgram.class, fieldValues);
        if (retVals.isEmpty()) {
            success = false;
            putFieldError("extension.programCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { subFundProg, subFundGroupCode });
        } else {
            for (SubFundProgram sfp : retVals) {
                if (!sfp.isActive()) {
                    putFieldError("extension.programCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.programCode"));
                    success = false;
                }
            }
        }
    } else {
        // BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
        Map fieldValues = new HashMap();
        fieldValues.put("subFundGroupCode", subFundGroupCode);
        Collection<SubFundProgram> retVals = bos.findMatching(SubFundProgram.class, fieldValues);
        if (!retVals.isEmpty()) {
            success = false;
            putFieldError("extension.programCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_PROGRAM_CODE_CANNOT_BE_BLANK_FOR_GROUP_CODE, new String[] { subFundGroupCode });
        }
    }
    return success;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) HashMap(java.util.HashMap) SubFundProgram(edu.cornell.kfs.coa.businessobject.SubFundProgram) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 3 with AccountExtendedAttribute

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

the class AccountGlobalRule method checkAccountExtensionProgramCd.

private boolean checkAccountExtensionProgramCd(Account account, String subFundGroupCode, String subFundProg) {
    boolean success = true;
    if (StringUtils.isBlank(subFundGroupCode)) {
        if (StringUtils.isNotBlank(subFundProg)) {
            SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, account.getSubFundGroupCode(), CUKFSPropertyConstants.PROGRAM_CODE, subFundProg);
            if (subFundProgram == null) {
                success = false;
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { subFundProg, account.getSubFundGroupCode(), account.getAccountNumber() });
            } else {
                if (!subFundProgram.isActive()) {
                    putFieldError(CUKFSPropertyConstants.PROGRAM_CODE, KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, CUKFSPropertyConstants.PROGRAM_CODE));
                    success = false;
                }
            }
        }
    } else {
        AccountExtendedAttribute accountExtension = (AccountExtendedAttribute) account.getExtension();
        if (StringUtils.isBlank(subFundProg)) {
            if (StringUtils.isBlank(accountExtension.getProgramCode())) {
                SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, subFundGroupCode, CUKFSPropertyConstants.PROGRAM_CODE, accountExtension.getProgramCode());
                if (subFundProgram != null) {
                    success = false;
                    GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_CANNOT_BE_BLANK_FOR_GROUP_CODE, new String[] { subFundGroupCode, account.getAccountNumber() });
                }
            } else {
                SubFundProgram subFundProgram = getMatchedRecord(SubFundProgram.class, subFundGroupCode, CUKFSPropertyConstants.PROGRAM_CODE, accountExtension.getProgramCode());
                if (subFundProgram == null) {
                    success = false;
                    GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ACCT_PROGRAM_CODE_NOT_GROUP_CODE, new String[] { accountExtension.getProgramCode(), subFundGroupCode, account.getAccountNumber() });
                }
            }
        }
    }
    return success;
}
Also used : AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) Account(org.kuali.kfs.coa.businessobject.Account) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubFundProgram(edu.cornell.kfs.coa.businessobject.SubFundProgram) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)

Example 4 with AccountExtendedAttribute

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

the class AccountGlobalRule method checkAccountExtensionApprAcct.

private boolean checkAccountExtensionApprAcct(Account account, String subFundGroupCode, String appropriationAccountNumber) {
    boolean success = true;
    if (StringUtils.isBlank(subFundGroupCode)) {
        if (StringUtils.isNotBlank(appropriationAccountNumber)) {
            AppropriationAccount appropriationAcct = getMatchedRecord(AppropriationAccount.class, account.getSubFundGroupCode(), CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, appropriationAccountNumber);
            if (appropriationAcct == null) {
                success = false;
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, account.getSubFundGroupCode(), account.getAccountNumber() });
            } else {
                if (!appropriationAcct.isActive()) {
                    putFieldError(CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(AccountGlobal.class, CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER));
                    success = false;
                }
            }
        }
    } else {
        AccountExtendedAttribute accountExtension = (AccountExtendedAttribute) account.getExtension();
        if (StringUtils.isBlank(appropriationAccountNumber)) {
            if (StringUtils.isNotBlank(accountExtension.getAppropriationAccountNumber())) {
                AppropriationAccount appropriationAcct = getMatchedRecord(AppropriationAccount.class, subFundGroupCode, CUKFSPropertyConstants.APPROPRIATION_ACCT_NUMBER, accountExtension.getAppropriationAccountNumber());
                if (appropriationAcct == null) {
                    success = false;
                    GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { accountExtension.getAppropriationAccountNumber(), subFundGroupCode, account.getAccountNumber() });
                }
            }
        }
    }
    return success;
}
Also used : AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) AccountGlobal(org.kuali.kfs.coa.businessobject.AccountGlobal)

Example 5 with AccountExtendedAttribute

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

the class AccountExtensionRule method checkMajorReportingCategoryCode.

protected boolean checkMajorReportingCategoryCode(MaintenanceDocument document) {
    boolean success = true;
    String majorReportingCategoryCode = ((AccountExtendedAttribute) newAccount.getExtension()).getMajorReportingCategoryCode();
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    // MajorReportingCategory code is not a required field, if no value is entered no validation is performed
    if (!StringUtils.isBlank(majorReportingCategoryCode)) {
        Map fieldValues = new HashMap();
        fieldValues.put("majorReportingCategoryCode", majorReportingCategoryCode);
        Collection<MajorReportingCategory> retVals = bos.findMatching(MajorReportingCategory.class, fieldValues);
        if (retVals.isEmpty()) {
            putFieldError("extension.majorReportingCategoryCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_MJR_RPT_CAT_CODE_NOT_EXIST, new String[] { majorReportingCategoryCode });
            success = false;
        } else {
            for (MajorReportingCategory sfp : retVals) {
                if (!sfp.isActive()) {
                    putFieldError("extension.majorReportingCategoryCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.majorReportingCategoryCode"));
                    success = false;
                }
            }
        }
    }
    return success;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) MajorReportingCategory(edu.cornell.kfs.coa.businessobject.MajorReportingCategory) HashMap(java.util.HashMap) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Aggregations

AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)6 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)6 Account (org.kuali.kfs.coa.businessobject.Account)5 HashMap (java.util.HashMap)4 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)4 SubFundProgram (edu.cornell.kfs.coa.businessobject.SubFundProgram)3 Map (java.util.Map)3 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)2 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)1 MajorReportingCategory (edu.cornell.kfs.coa.businessobject.MajorReportingCategory)1 AccountReversionTrickleDownInactivationService (edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService)1 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 Document (org.kuali.kfs.krad.document.Document)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1