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