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;
}
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;
}
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));
}
}
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)));
}
}
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;
}
Aggregations