Search in sources :

Example 1 with AccountGlobalDetail

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

the class FinancialSystemSearchableAttribute method extractDocumentAttributes.

@Override
public List<DocumentAttribute> extractDocumentAttributes(ExtensionDefinition extensionDefinition, DocumentWithContent documentWithContent) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractDocumentAttributes( " + extensionDefinition + ", " + documentWithContent + " )");
    }
    List<DocumentAttribute> searchAttrValues = super.extractDocumentAttributes(extensionDefinition, documentWithContent);
    String docId = documentWithContent.getDocument().getDocumentId();
    DocumentService docService = SpringContext.getBean(DocumentService.class);
    Document doc = null;
    try {
        doc = docService.getByDocumentHeaderIdSessionless(docId);
    } catch (WorkflowException we) {
    }
    if (doc != null) {
        if (doc instanceof AmountTotaling && ((AmountTotaling) doc).getTotalDollarAmount() != null) {
            DocumentAttributeDecimal.Builder searchableAttributeValue = DocumentAttributeDecimal.Builder.create(KFSPropertyConstants.FINANCIAL_DOCUMENT_TOTAL_AMOUNT);
            searchableAttributeValue.setValue(((AmountTotaling) doc).getTotalDollarAmount().bigDecimalValue());
            searchAttrValues.add(searchableAttributeValue.build());
        }
        if (doc instanceof AccountingDocument) {
            AccountingDocument accountingDoc = (AccountingDocument) doc;
            searchAttrValues.addAll(harvestAccountingDocumentSearchableAttributes(accountingDoc));
        }
        boolean indexedLedgerDoc = false;
        if (doc instanceof LaborLedgerPostingDocumentForSearching) {
            LaborLedgerPostingDocumentForSearching LLPostingDoc = (LaborLedgerPostingDocumentForSearching) doc;
            searchAttrValues.addAll(harvestLLPDocumentSearchableAttributes(LLPostingDoc));
            indexedLedgerDoc = true;
        }
        if (doc instanceof GeneralLedgerPostingDocument && !indexedLedgerDoc) {
            GeneralLedgerPostingDocument GLPostingDoc = (GeneralLedgerPostingDocument) doc;
            searchAttrValues.addAll(harvestGLPDocumentSearchableAttributes(GLPostingDoc));
        }
        DocumentHeader docHeader = doc.getDocumentHeader();
        if (ObjectUtils.isNotNull(docHeader) && ObjectUtils.isNotNull(docHeader.getWorkflowDocument()) && CUKFSConstants.GACC_DOCUMENT_TYPE.equalsIgnoreCase(docHeader.getWorkflowDocument().getDocumentTypeName())) {
            for (AccountGlobalDetail detail : ((AccountGlobal) ((AccountGlobalMaintainableImpl) ((FinancialSystemMaintenanceDocument) doc).getNewMaintainableObject()).getBusinessObject()).getAccountGlobalDetails()) {
                if (!StringUtils.isBlank(detail.getAccountNumber())) {
                    DocumentAttributeString.Builder searchableAttributeValue = DocumentAttributeString.Builder.create(KFSPropertyConstants.ACCOUNT_NUMBER);
                    searchableAttributeValue.setValue(detail.getAccountNumber());
                    searchAttrValues.add(searchableAttributeValue.build());
                }
            }
        }
    }
    return searchAttrValues;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DocumentAttributeDecimal(org.kuali.rice.kew.api.document.attribute.DocumentAttributeDecimal) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) Document(org.kuali.kfs.krad.document.Document) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentService(org.kuali.kfs.krad.service.DocumentService) LaborLedgerPostingDocumentForSearching(org.kuali.kfs.integration.ld.LaborLedgerPostingDocumentForSearching) FinancialSystemMaintenanceDocument(org.kuali.kfs.sys.document.FinancialSystemMaintenanceDocument) GeneralLedgerPostingDocument(org.kuali.kfs.sys.document.GeneralLedgerPostingDocument) AccountGlobal(org.kuali.kfs.coa.businessobject.AccountGlobal) DocumentAttribute(org.kuali.rice.kew.api.document.attribute.DocumentAttribute) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DocumentAttributeString(org.kuali.rice.kew.api.document.attribute.DocumentAttributeString) AmountTotaling(org.kuali.kfs.sys.document.AmountTotaling)

Example 2 with AccountGlobalDetail

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillNotBe100PercentAfterUpdateTwoSameAccounts_Pass.

@Test
public void testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillNotBe100PercentAfterUpdateTwoSameAccounts_Pass() {
    LOG.debug("enter testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdateTwoSameAccounts_Pass");
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_1111111_2222222_98_2_ACTIVE_3333333_100_INACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_3333333_100_ACTIVE_1111111_98_INACTIVE_98_INACTIVE.getAccountGlobalDetail();
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = accountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    List<IndirectCostRecoveryAccount> existing = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccounts(existing);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existing, accountGlobalDetail, accountGlobal);
    assertTrue("Updated Account Global ICR account distribution should have been 100%", result);
}
Also used : IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Example 3 with AccountGlobalDetail

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail.

@Test
public void testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail() {
    LOG.info("enter testAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail");
    CuAccountGlobal accountGlobal = (CuAccountGlobal) AccountGlobalFixture.ACCT_GLOBAL_1111111_98_ACTIVE.getAccountGlobal();
    AccountGlobalDetail accountGlobalDetail = AccountGlobalDetailFixture.ACCOUNT_GLOBAL_DETAIL_3333333_100_ACTIVE_1111111_98_INACTIVE_2222222_2_INACTIVE.getAccountGlobalDetail();
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = accountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    List<IndirectCostRecoveryAccount> existing = accountGlobalDetail.getAccount().getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccounts(existing);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existing, accountGlobalDetail, accountGlobal);
    assertFalse("Updated Account Global ICR account distribution should NOT have been 100%", result);
}
Also used : IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) CuAccountGlobal(edu.cornell.kfs.coa.businessobject.CuAccountGlobal) Test(org.junit.Test)

Example 4 with AccountGlobalDetail

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

the class AccountGlobalRule method checkOrganizationValidity.

/**
 * Validate that the object code on the form (if entered) is valid for all charts used in the detail sections.
 *
 * @param acctGlobal
 * @return
 */
protected boolean checkOrganizationValidity(AccountGlobal acctGlobal) {
    boolean result = true;
    // check that an org has been entered
    if (StringUtils.isNotBlank(acctGlobal.getOrganizationCode())) {
        // get all distinct charts
        HashSet<String> charts = new HashSet<String>(10);
        for (AccountGlobalDetail acct : acctGlobal.getAccountGlobalDetails()) {
            charts.add(acct.getChartOfAccountsCode());
        }
        OrganizationService orgService = SpringContext.getBean(OrganizationService.class);
        // test for an invalid organization
        for (String chartCode : charts) {
            if (StringUtils.isNotBlank(chartCode)) {
                if (null == orgService.getByPrimaryIdWithCaching(chartCode, acctGlobal.getOrganizationCode())) {
                    result = false;
                    putFieldError("organizationCode", KFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCOUNT_INVALID_ORG, new String[] { chartCode, acctGlobal.getOrganizationCode() });
                    break;
                }
            }
        }
    }
    return result;
}
Also used : OrganizationService(org.kuali.kfs.coa.service.OrganizationService) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) HashSet(java.util.HashSet)

Example 5 with AccountGlobalDetail

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

the class AccountGlobalRule method checkICRCollectionExistsWhenUpdatingToCGSubFund.

protected boolean checkICRCollectionExistsWhenUpdatingToCGSubFund(CuAccountGlobal newAccount, String subFundGroupCode) {
    boolean success = true;
    if (newAccount.getActiveIndirectCostRecoveryAccounts().isEmpty()) {
        if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && !newAccount.getAccountGlobalDetails().isEmpty()) {
            for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
                List<IndirectCostRecoveryAccount> activeICRList = getActiveUpdatedIcrAccounts(newAccount, accountGlobalDetail);
                if (activeICRList.isEmpty()) {
                    success &= false;
                    putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_ICR_EMPTY_FOR_CG_ACCOUNT, new String[] { subFundGroupCode, accountGlobalDetail.getAccountNumber() });
                }
            }
        }
    }
    return success;
}
Also used : IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail)

Aggregations

AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)25 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)8 CuAccountGlobal (edu.cornell.kfs.coa.businessobject.CuAccountGlobal)6 Test (org.junit.Test)5 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)4 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)3 HashMap (java.util.HashMap)3 Date (java.sql.Date)2 ArrayList (java.util.ArrayList)2 Account (org.kuali.kfs.coa.businessobject.Account)2 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 GlobalObjectWithIndirectCostRecoveryAccounts (edu.cornell.kfs.coa.businessobject.GlobalObjectWithIndirectCostRecoveryAccounts)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 AccountDelegate (org.kuali.kfs.coa.businessobject.AccountDelegate)1 AccountDelegateGlobalDetail (org.kuali.kfs.coa.businessobject.AccountDelegateGlobalDetail)1 IndirectCostRecoveryRateDetail (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)1 OrganizationService (org.kuali.kfs.coa.service.OrganizationService)1