Search in sources :

Example 1 with RequisitionAccount

use of org.kuali.kfs.module.purap.businessobject.RequisitionAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method testLineBuilderFailureForNonexistentLine.

/*
     * Test that line creation will fail if no favorite account exists for the given ID.
     */
@Test
public void testLineBuilderFailureForNonexistentLine() throws Exception {
    Integer badId = Integer.valueOf(-1);
    reqsItem.setFavoriteAccountLineIdentifier(badId);
    poDoc.setFavoriteAccountLineIdentifier(badId);
    iwntDoc.setFavoriteAccountLineIdentifier(badId);
    PurchasingFavoriteAccountLineBuilderForLineItem<RequisitionAccount> reqsBuilder = createBuilderForLineItem(reqsItem, 0, new RequisitionAccount());
    PurchasingFavoriteAccountLineBuilderForDistribution<PurchaseOrderAccount> poBuilder = createBuilderForDistribution(poDoc, poAccounts, new PurchaseOrderAccount());
    PurApFavoriteAccountLineBuilderForIWantDocument iwntBuilder = createBuilderForIWant(iwntDoc);
    assertUnsuccessfulAccountLineCreation(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(iwntBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(iwntBuilder);
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) Test(org.junit.Test)

Example 2 with RequisitionAccount

use of org.kuali.kfs.module.purap.businessobject.RequisitionAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method testCreateAndAddMultipleAccountLines.

/*
     * Test creating and adding multiple accounting lines for distinct favorite accounts.
     */
@Test
public void testCreateAndAddMultipleAccountLines() throws Exception {
    reqsItem.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    poDoc.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    iwntDoc.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    PurchasingFavoriteAccountLineBuilderForLineItem<RequisitionAccount> reqsBuilder = createBuilderForLineItem(reqsItem, 0, new RequisitionAccount());
    PurchasingFavoriteAccountLineBuilderForDistribution<PurchaseOrderAccount> poBuilder = createBuilderForDistribution(poDoc, poAccounts, new PurchaseOrderAccount());
    PurApFavoriteAccountLineBuilderForIWantDocument iwntBuilder = createBuilderForIWant(iwntDoc);
    // Initial addition should succeed.
    assertAccountLineAdditionToList(reqsBuilder, testFavoriteAccount, RequisitionAccount.class);
    assertAccountLineAdditionToList(poBuilder, testFavoriteAccount, PurchaseOrderAccount.class);
    assertAccountLineAdditionToList(iwntBuilder, testFavoriteAccount, IWantAccount.class);
    // Subsequent addition for a different favorite account should also succeed.
    reqsItem.setFavoriteAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
    poDoc.setFavoriteAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
    iwntDoc.setFavoriteAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
    assertAccountLineAdditionToList(reqsBuilder, testAltFavoriteAccount, RequisitionAccount.class);
    assertAccountLineAdditionToList(poBuilder, testAltFavoriteAccount, PurchaseOrderAccount.class);
    assertAccountLineAdditionToList(iwntBuilder, testAltFavoriteAccount, IWantAccount.class);
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) Test(org.junit.Test)

Example 3 with RequisitionAccount

use of org.kuali.kfs.module.purap.businessobject.RequisitionAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method testLineBuilderFailureForNullLineID.

/*
     * Test that a null line ID will cause line creation to fail.
     */
@Test
public void testLineBuilderFailureForNullLineID() throws Exception {
    reqsItem.setFavoriteAccountLineIdentifier(null);
    poDoc.setFavoriteAccountLineIdentifier(null);
    iwntDoc.setFavoriteAccountLineIdentifier(null);
    PurchasingFavoriteAccountLineBuilderForLineItem<RequisitionAccount> reqsBuilder = createBuilderForLineItem(reqsItem, 0, new RequisitionAccount());
    PurchasingFavoriteAccountLineBuilderForDistribution<PurchaseOrderAccount> poBuilder = createBuilderForDistribution(poDoc, poAccounts, new PurchaseOrderAccount());
    PurApFavoriteAccountLineBuilderForIWantDocument iwntBuilder = createBuilderForIWant(iwntDoc);
    assertUnsuccessfulAccountLineCreation(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineCreation(iwntBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(reqsBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(poBuilder);
    clearMessageMapErrors();
    assertUnsuccessfulAccountLineAdditionToList(iwntBuilder);
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) Test(org.junit.Test)

Example 4 with RequisitionAccount

use of org.kuali.kfs.module.purap.businessobject.RequisitionAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method assertAccountingLineHasCorrectConfiguration.

/*
     * Convenience method for validating that the generated accounting line has the correct data and is of the correct type.
     */
private void assertAccountingLineHasCorrectConfiguration(FavoriteAccount expectedAccount, Class<? extends GeneralLedgerPendingEntrySourceDetail> expectedLineClass, GeneralLedgerPendingEntrySourceDetail acctLine) throws Exception {
    if (!expectedLineClass.isAssignableFrom(acctLine.getClass())) {
        fail("Expected line type is " + expectedLineClass.getName() + " but the generated line is of type " + acctLine.getClass().getName() + " which is not an instance of the expected one");
    }
    assertEquals("Generated line has wrong chart code", expectedAccount.getChartOfAccountsCode(), acctLine.getChartOfAccountsCode());
    assertEquals("Generated line has wrong account number", expectedAccount.getAccountNumber(), acctLine.getAccountNumber());
    assertEquals("Generated line has wrong sub-account number", expectedAccount.getSubAccountNumber(), acctLine.getSubAccountNumber());
    assertEquals("Generated line has wrong object code", expectedAccount.getFinancialObjectCode(), acctLine.getFinancialObjectCode());
    assertEquals("Generated line has wrong sub-object code", expectedAccount.getFinancialSubObjectCode(), acctLine.getFinancialSubObjectCode());
    assertEquals("Generated line has wrong project code", expectedAccount.getProjectCode(), acctLine.getProjectCode());
    assertEquals("Generated line has wrong org ref ID", expectedAccount.getOrganizationReferenceId(), acctLine.getOrganizationReferenceId());
    // Validate pre-initialized percentage. The retrieval means will vary depending on line type and whether we need hacks to avoid Spring calls.
    if (acctLine instanceof RequisitionAccount) {
        assertEquals("Generated line has wrong percentage (comparison against 100% should have been zero)", 0, getRequisitionAccountLinePercent(((RequisitionAccount) acctLine)).compareTo(new BigDecimal(100)));
    } else if (acctLine instanceof PurApAccountingLine) {
        assertEquals("Generated line has wrong percentage (comparison against 100% should have been zero)", 0, ((PurApAccountingLine) acctLine).getAccountLinePercent().compareTo(new BigDecimal(100)));
    } else if (acctLine instanceof IWantAccount) {
        assertEquals("Generated line has wrong amount-or-percent indicator", CUPurapConstants.PERCENT, ((IWantAccount) acctLine).getUseAmountOrPercent());
        assertEquals("Generated line has wrong percentage (comparison against 100% should have been zero)", 0, ((IWantAccount) acctLine).getAmountOrPercent().compareTo(new KualiDecimal(100)));
    }
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) BigDecimal(java.math.BigDecimal)

Example 5 with RequisitionAccount

use of org.kuali.kfs.module.purap.businessobject.RequisitionAccount in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountLineBuilderTest method testCreateAndAddFavoriteAccountLinesForDistribution.

/*
     * Test creating favorite accounting lines for use with the account distribution section.
     */
@Test
public void testCreateAndAddFavoriteAccountLinesForDistribution() throws Exception {
    reqsDoc.setFavoriteAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
    poDoc.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
    PurchasingFavoriteAccountLineBuilderForDistribution<RequisitionAccount> reqsBuilder = createBuilderForDistribution(reqsDoc, reqsAccounts, new RequisitionAccount());
    PurchasingFavoriteAccountLineBuilderForDistribution<PurchaseOrderAccount> poBuilder = createBuilderForDistribution(poDoc, poAccounts, new PurchaseOrderAccount());
    assertAccountLineCreation(reqsBuilder, testAltFavoriteAccount, RequisitionAccount.class);
    assertAccountLineCreation(poBuilder, testFavoriteAccount, PurchaseOrderAccount.class);
    assertAccountLineAdditionToList(reqsBuilder, testAltFavoriteAccount, RequisitionAccount.class);
    assertAccountLineAdditionToList(poBuilder, testFavoriteAccount, PurchaseOrderAccount.class);
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) PurchaseOrderAccount(org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount) Test(org.junit.Test)

Aggregations

RequisitionAccount (org.kuali.kfs.module.purap.businessobject.RequisitionAccount)9 PurchaseOrderAccount (org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount)7 Test (org.junit.Test)6 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)4 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 PersistenceService (org.kuali.kfs.krad.service.PersistenceService)1 PaymentRequestAccount (org.kuali.kfs.module.purap.businessobject.PaymentRequestAccount)1 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)1 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)1 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)1 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1 FinancialSystemUserService (org.kuali.kfs.sys.service.FinancialSystemUserService)1