Search in sources :

Example 1 with PurchasingFavoriteAccountLineBuilderForDistribution

use of edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method addFavoriteAccount.

/*
     * KFSPTS-985 : add favorite account.
     * This is a copy from requisitionaction.  to be shared by both req & po
     */
public ActionForward addFavoriteAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase poForm = (PurchasingFormBase) form;
    PurchasingDocumentBase document = (PurchasingDocumentBase) poForm.getDocument();
    int itemIdx = getSelectedLine(request);
    final int DISTRIBUTION_INDEX = -2;
    PurchasingFavoriteAccountLineBuilderBase<? extends PurApAccountingLine> favoriteAccountBuilder;
    // Initialize the correct builder based on whether the Favorite Account is for an item in the list or for account distribution.
    if (itemIdx >= 0) {
        PurchasingItemBase item = (PurchasingItemBase) document.getItem(itemIdx);
        favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForLineItem<PurApAccountingLine>(item, itemIdx, poForm.setupNewPurchasingAccountingLine());
    } else if (itemIdx == DISTRIBUTION_INDEX) {
        favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForDistribution<PurApAccountingLine>(document, poForm.getAccountDistributionsourceAccountingLines(), poForm.setupNewAccountDistributionAccountingLine());
    } else {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    // Add a new Favorite-Account-derived accounting line to the list, with errors inserted into the message map as appropriate.
    favoriteAccountBuilder.addNewFavoriteAccountLineToListIfPossible();
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingFavoriteAccountLineBuilderForDistribution(edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingItemBase(org.kuali.kfs.module.purap.businessobject.PurchasingItemBase) PurchasingDocumentBase(org.kuali.kfs.module.purap.document.PurchasingDocumentBase)

Aggregations

PurchasingFavoriteAccountLineBuilderForDistribution (edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution)1 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)1 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)1 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)1