Search in sources :

Example 1 with FavoriteAccount

use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileLookupableHelperServiceImpl method getSearchResultsWithAcctCriteria.

private List<PersistableBusinessObject> getSearchResultsWithAcctCriteria(List<PersistableBusinessObject> searchResults, Map<String, String> newFieldValues) {
    List<PersistableBusinessObject> returnResults = new ArrayList<PersistableBusinessObject>();
    for (String profileId : getSelectedUsers(searchResults)) {
        newFieldValues.put("userProfileId", profileId);
        List<PersistableBusinessObject> searchResults1 = (List) getLookupService().findCollectionBySearch(FavoriteAccount.class, newFieldValues);
        for (PersistableBusinessObject pbo : searchResults1) {
            FavoriteAccount account = (FavoriteAccount) pbo;
            returnResults.add(buildUserProfile(account.getUserProcurementProfile(), account));
        }
    }
    sortList(returnResults);
    return returnResults;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with FavoriteAccount

use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountValuesFinder method getKeyValues.

public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    List<FavoriteAccount> favoriteAccounts = getUserFavoriteAccounts();
    keyValues.add(new ConcreteKeyValue("", ""));
    if (CollectionUtils.isNotEmpty(favoriteAccounts)) {
        Collections.sort(favoriteAccounts, new Comparator() {

            public int compare(Object o1, Object o2) {
                FavoriteAccount accountFirst = (FavoriteAccount) o1;
                FavoriteAccount accountSecond = (FavoriteAccount) o2;
                if (accountFirst.getPrimaryInd() && !accountSecond.getPrimaryInd()) {
                    return -1;
                } else if (!accountFirst.getPrimaryInd() && accountSecond.getPrimaryInd()) {
                    return 1;
                }
                if (StringUtils.equals(accountFirst.getDescription(), accountSecond.getDescription())) {
                    return accountFirst.getAccountNumber().compareTo(accountSecond.getAccountNumber());
                } else if (StringUtils.isBlank(accountFirst.getDescription())) {
                    // Be aware case comparison.
                    return -1;
                } else if (StringUtils.isBlank(accountSecond.getDescription())) {
                    return 1;
                } else {
                    return accountFirst.getDescription().compareTo(accountSecond.getDescription());
                }
            }
        });
        for (FavoriteAccount account : favoriteAccounts) {
            keyValues.add(new ConcreteKeyValue(account.getAccountLineIdentifier().toString(), getAccountingLineDescription(account)));
        }
    }
    return keyValues;
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) KeyValue(org.kuali.rice.core.api.util.KeyValue) ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator)

Example 3 with FavoriteAccount

use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method populatePrimaryFavoriteAccount.

// KFSPTS_985, KFSUPGRADE-75
protected void populatePrimaryFavoriteAccount(List<PurApAccountingLine> sourceAccountinglines, Class<? extends PurApAccountingLine> accountingLineClass) {
    UserFavoriteAccountService userFavoriteAccountService = SpringContext.getBean(UserFavoriteAccountService.class);
    FavoriteAccount account = userFavoriteAccountService.getFavoriteAccount(GlobalVariables.getUserSession().getPrincipalId());
    if (ObjectUtils.isNotNull(account)) {
        sourceAccountinglines.add(userFavoriteAccountService.getPopulatedNewAccount(account, accountingLineClass));
    }
}
Also used : UserFavoriteAccountService(edu.cornell.kfs.sys.service.UserFavoriteAccountService) FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount)

Example 4 with FavoriteAccount

use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.

the class CuUserFavoriteAccountServiceImplTest method validateAccount.

private void validateAccount(String accountType, Class accountClass) {
    final FavoriteAccount favoriteAccount = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount();
    final GeneralLedgerPendingEntrySourceDetail acct = userFavoriteAccountService.getPopulatedNewAccount(favoriteAccount, accountClass);
    Assert.assertNotNull("Account should be populated", acct);
    Assert.assertTrue("Account should be " + accountType + " Account", accountClass.isInstance(acct));
    Assert.assertEquals("Account Number should be populated", favoriteAccount.getAccountNumber(), acct.getAccountNumber());
    Assert.assertEquals("Object Code should be populated", favoriteAccount.getFinancialObjectCode(), acct.getFinancialObjectCode());
    if (acct instanceof IWantAccount) {
        final KualiDecimal accountLinePercent = ((IWantAccount) acct).getAmountOrPercent();
        Assert.assertEquals("Incorrect percentage (comparison against 100% should have been zero)", 0, accountLinePercent.compareTo(new KualiDecimal(100)));
        Assert.assertEquals("Amount-or-Percent indicator should be Percent", CUPurapConstants.PERCENT, ((IWantAccount) acct).getUseAmountOrPercent());
    } else {
        final BigDecimal accountLinePercent = ((PurApAccountingLineBase) acct).getAccountLinePercent();
        Assert.assertEquals("Incorrect percentage (comparison against 100% should have been zero)", 0, accountLinePercent.compareTo(new BigDecimal(100)));
    }
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) GeneralLedgerPendingEntrySourceDetail(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail) IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) PurApAccountingLineBase(org.kuali.kfs.module.purap.businessobject.PurApAccountingLineBase) BigDecimal(java.math.BigDecimal)

Example 5 with FavoriteAccount

use of edu.cornell.kfs.sys.businessobject.FavoriteAccount in project cu-kfs by CU-CommunityApps.

the class CuUserProcurementProfileValidationServiceImplTest method createFavoriteAccount.

private FavoriteAccount createFavoriteAccount(String chartOfAccountsCode, String accountNumber, String financialObjectCode, boolean primaryInd) {
    FavoriteAccount favoriteAccount = new FavoriteAccount();
    favoriteAccount.setAccountNumber(accountNumber);
    favoriteAccount.setChartOfAccountsCode(chartOfAccountsCode);
    favoriteAccount.setFinancialObjectCode(financialObjectCode);
    favoriteAccount.setPrimaryInd(primaryInd);
    return favoriteAccount;
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount)

Aggregations

FavoriteAccount (edu.cornell.kfs.sys.businessobject.FavoriteAccount)14 ArrayList (java.util.ArrayList)5 UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)4 HashMap (java.util.HashMap)3 List (java.util.List)3 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)2 Test (org.junit.Test)2 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)2 CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)1 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)1 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)1 UserFavoriteAccountService (edu.cornell.kfs.sys.service.UserFavoriteAccountService)1 UserProcurementProfileValidationServiceImpl (edu.cornell.kfs.sys.service.impl.UserProcurementProfileValidationServiceImpl)1 BigDecimal (java.math.BigDecimal)1 Comparator (java.util.Comparator)1 BeforeClass (org.junit.BeforeClass)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)1 PurApAccountingLineBase (org.kuali.kfs.module.purap.businessobject.PurApAccountingLineBase)1 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)1