Search in sources :

Example 6 with FavoriteAccount

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

the class UserProcurementProfileLookupableHelperServiceImpl method getSearchResultsNoAcctCriteria.

private List<PersistableBusinessObject> getSearchResultsNoAcctCriteria(List<PersistableBusinessObject> searchResults) {
    List<PersistableBusinessObject> returnResults = new ArrayList<PersistableBusinessObject>();
    for (PersistableBusinessObject pbo : searchResults) {
        UserProcurementProfile userProfile = (UserProcurementProfile) pbo;
        if (CollectionUtils.isEmpty(userProfile.getFavoriteAccounts())) {
            userProfile.setResultAccount(new FavoriteAccount());
            returnResults.add(userProfile);
        } else {
            for (FavoriteAccount account : userProfile.getFavoriteAccounts()) {
                returnResults.add(buildUserProfile(userProfile, 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) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 7 with FavoriteAccount

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

the class FavoriteAccountValuesFinder method getUserFavoriteAccounts.

/*
     * get user favoriteacounts with primary account sorted first
     */
private List<FavoriteAccount> getUserFavoriteAccounts() {
    Map<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put("principalId", GlobalVariables.getUserSession().getPrincipalId());
    List<UserProcurementProfile> userProfiles = (List<UserProcurementProfile>) SpringContext.getBean(BusinessObjectService.class).findMatching(UserProcurementProfile.class, fieldValues);
    if (CollectionUtils.isNotEmpty(userProfiles)) {
        UserProcurementProfile userProfile = userProfiles.get(0);
        fieldValues = new HashMap<String, Object>();
        fieldValues.put("userProfileId", userProfile.getUserProfileId());
        // retrieve from db for sorting purpose.
        return (List<FavoriteAccount>) SpringContext.getBean(BusinessObjectService.class).findMatchingOrderBy(FavoriteAccount.class, fieldValues, "primaryInd", false);
    }
    return null;
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 8 with FavoriteAccount

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

the class FavoriteAccountLineBuilderTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    userProcurementProfileValidationService = new UserProcurementProfileValidationServiceImpl();
    userFavoriteAccountService = new ExtendedTestUserFavoriteAccountService();
    reqsAccounts = new ArrayList<PurApAccountingLine>();
    poAccounts = new ArrayList<PurApAccountingLine>();
    reqsItem = new RequisitionItem();
    poItem = new PurchaseOrderItem();
    reqsDoc = getMockedDocument(CuRequisitionDocument.class);
    poDoc = getMockedDocument(PurchaseOrderDocument.class);
    iwntDoc = getMockedDocument(IWantDocument.class);
    iwntDoc.setAccounts(new ArrayList<IWantAccount>());
    // Favorite Account with only some fields populated.
    testFavoriteAccount = new FavoriteAccount();
    testFavoriteAccount.setAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    testFavoriteAccount.setUserProfileId(TEST_USER_PROFILE_ID);
    testFavoriteAccount.setChartOfAccountsCode(TEST_CHART_CODE);
    testFavoriteAccount.setAccountNumber(TEST_ACCOUNT_NUMBER);
    testFavoriteAccount.setFinancialObjectCode(TEST_OBJECT_CODE);
    // Favorite Account with all fields populated (except reference objects or object ID or version number).
    testAltFavoriteAccount = new FavoriteAccount();
    testAltFavoriteAccount.setAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
    testAltFavoriteAccount.setUserProfileId(TEST_ALT_USER_PROFILE_ID);
    testAltFavoriteAccount.setChartOfAccountsCode(TEST_ALT_CHART_CODE);
    testAltFavoriteAccount.setAccountNumber(TEST_ALT_ACCOUNT_NUMBER);
    testAltFavoriteAccount.setSubAccountNumber(TEST_ALT_SUB_ACCOUNT_NUMBER);
    testAltFavoriteAccount.setFinancialObjectCode(TEST_ALT_OBJECT_CODE);
    testAltFavoriteAccount.setFinancialSubObjectCode(TEST_ALT_SUB_OBJECT_CODE);
    testAltFavoriteAccount.setProjectCode(TEST_ALT_PROJECT_CODE);
    testAltFavoriteAccount.setOrganizationReferenceId(TEST_ALT_ORG_REF_ID);
    GlobalVariables.setMessageMap(new MessageMap());
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) UserProcurementProfileValidationServiceImpl(edu.cornell.kfs.sys.service.impl.UserProcurementProfileValidationServiceImpl) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) BeforeClass(org.junit.BeforeClass)

Example 9 with FavoriteAccount

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

the class CuUserFavoriteAccountServiceImplTest method testPrimaryFavoriteAccount.

@Test
public void testPrimaryFavoriteAccount() {
    final String principalId = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount().getUserProcurementProfile().getPrincipalId();
    FavoriteAccount favoriteAccount = userFavoriteAccountService.getFavoriteAccount(principalId);
    Assert.assertTrue("Favorite Account should exist", favoriteAccount != null);
    Assert.assertTrue("should be Primary favorite account", favoriteAccount.getPrimaryInd());
    favoriteAccount = userFavoriteAccountService.getFavoriteAccount("2");
    Assert.assertTrue("Favorite Account should not exist", favoriteAccount == null);
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) Test(org.junit.Test)

Example 10 with FavoriteAccount

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

the class CuUserFavoriteAccountServiceImplTest method testSelectedFavoriteAccount.

@Test
public void testSelectedFavoriteAccount() {
    FavoriteAccount favoriteAccount1 = FavoriteAccountFixture.FAVORITE_ACCOUNT_1.createFavoriteAccount();
    FavoriteAccount favoriteAccount2 = userFavoriteAccountService.getSelectedFavoriteAccount(favoriteAccount1.getAccountLineIdentifier());
    Assert.assertTrue("Favorite Account should exist", favoriteAccount2 != null);
    Assert.assertTrue("should have the same PK", favoriteAccount1.getAccountLineIdentifier().equals(favoriteAccount2.getAccountLineIdentifier()));
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) Test(org.junit.Test)

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